Standard library / fmt

fmt.Fprintln()

Writes to the supplied io.Writer rather than stdout. Space-separated default formatting plus a newline. Returns byte count and write error. Expected stdout: '"id 9\\n" 5 <nil>\n'.

Formal Syntax & Structure

go syntaxgo
func Fprintln(w io.Writer, a ...any) (n int, err error)

Parameters & Attributes

NameTypeDescription
wio.WriterDestination implementing io.Writer.
a...anyValues consumed by formatting; may be empty.

Return Value

(n int, err error)

Number of bytes written and write error.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt")
func main() {  var b bytes.Buffer  n, e := fmt.Fprintln(&b, "id", 9)  fmt.Printf("%q %d %v\n", b.String(), n, e)}
Go Reference