Standard library / fmt
fmt.Fprint()
Writes to the supplied io.Writer rather than stdout. Default formatting; spaces only between adjacent non-string operands. Returns byte count and write error. Expected stdout: '"id=9" 4 <nil>\n'.
Formal Syntax & Structure
go syntaxgo
func Fprint(w io.Writer, a ...any) (n int, err error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| w | io.Writer | Destination implementing io.Writer. |
| a | ...any | Values 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.Fprint(&b, "id=", 9) fmt.Printf("%q %d %v\n", b.String(), n, e)}