Go Printing to Stdout and Stderr: Difference between revisions
Jump to navigation
Jump to search
(7 intermediate revisions by the same user not shown) | |||
Line 17: | Line 17: | ||
=<tt>fmt</tt> Functions= | =<tt>fmt</tt> Functions= | ||
{{Internal|Go_Package_fmt|The <tt>fmt</tt> Package}} | |||
==<tt>fmt.Printf()</tt>== | ==<tt>fmt.Printf()</tt>== | ||
{{External|https://golang.org/pkg/fmt/#Printf}} | {{External|https://golang.org/pkg/fmt/#Printf}} | ||
Line 26: | Line 26: | ||
fmt.Printf("something %s", "blue") | fmt.Printf("something %s", "blue") | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<code>Print()</code> expects a format specifier (or a format string) as the first argument, which contains conversion characters (ex. <code>%s</code>) | <code>Print()</code> expects a '''format specifier''' (or a '''format string''') as the first argument, which contains [[Go_Package_fmt#Conversion_Characters|conversion characters]] (ex. <code>%s</code>). {{Internal|Go_Package_fmt#Conversion_Characters|Format String | Conversion Characters}} | ||
{{Internal| |
Latest revision as of 22:00, 22 December 2023
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
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
).