Standard library / log

log.Logger.Printf()

Write a line using a format string. Expected stdout: 'count=2\n'.

Formal Syntax & Structure

go syntaxgo
func (l *Logger) Printf(format string, v ...any)

Parameters & Attributes

NameTypeDescription
formatstringPrintf-style format string.
v...anyValues to log or convert.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt"  "log")
func main() {  var b bytes.Buffer  l := log.New(&b, "", 0)  l.Printf("count=%d", 2)  fmt.Print(b.String())}
Go Reference