Go Printing to Stdout and Stderr

From NovaOrdis Knowledge Base
Revision as of 22:00, 22 December 2023 by Ovidiu (talk | contribs) (→‎fmt Functions)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

Bootstrapping Functions

Both print() and println() are pre-declared functions, ready to use without any import.

TODO: https://golang.org/ref/spec#Bootstrapping

print()

println()

func main() {
  println("something")
}

fmt Functions

The fmt Package

fmt.Printf()

https://golang.org/pkg/fmt/#Printf
import "fmt"

// ...
fmt.Printf("something %s", "blue")

Print() expects a format specifier (or a format string) as the first argument, which contains conversion characters (ex. %s).

Format String | Conversion Characters