Go Package fmt: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 12: Line 12:


==<tt>fmt.Printf()</tt>==
==<tt>fmt.Printf()</tt>==
 
See: {{Internal|Go_Printing_to_Stdout_and_Stderr#fmt.Printf.28.29|<code>fmt.Printf()</code>}}
* <tt>[https://golang.org/pkg/fmt/#Printf fmt.Printf()]</tt>
 
Prints according to a format specifier. Format specifier documentation https://golang.org/pkg/fmt
 
===Pointers===
 
<pre>
fmt.Printf("%p\n", sPtr)
</pre>
 
"%p" prepend the "0x" prefix.
 
Pointers can be also represented using "%X" (base 16, upper case characters).
 
===Ints===
 
<pre>
fmt.Printf("%d\n",i)
</pre>
 
===Characters===
 
<pre>
fmt.Printf("%c\n",i)
</pre>
 
===Boolean Values===
 
<pre>
fmt.Printf("%t\n",b)
</pre>


==<tt>fmt.Scanf()</tt>==
==<tt>fmt.Scanf()</tt>==

Revision as of 00:47, 19 August 2023

External

Internal

Functions

fmt.Printf()

See:

fmt.Printf()

fmt.Scanf()

fmt.Scanln()

var line string
fmt.Scanln(&line)

fmt.Errorf()

Errorf formats according to a format specifier and returns the string as a value that satisfies error. For more on error handling see error handling.