1/9
Go offers several formatting verbs that can be used with the ....... function.
Printf()
Prints the value in the default format
%v
Prints the value in Go-syntax format
%#v
Prints the type of the value
%T
Prints the % sign
%%
Verb %v:
Prints the value in the default format
Verb %#v:
Prints the value in Go-syntax format
Verb %T:
Prints the type of the value
Verb %%:
Prints the % sign
What is the output of this snippet?:
package main
import ("fmt")
func main() {
var i = 15.5
var txt = "Hello World!"
fmt.Printf("%v\n", i)
fmt.Printf("%#v\n", i)
fmt.Printf("%v%%\n", i)
fmt.Printf("%T\n", i)
fmt.Printf("%v\n", txt)
fmt.Printf("%#v\n", txt)
fmt.Printf("%T\n", txt)
}
15.5
15.5
15.5%
float64
Hello World!
"Hello World!"
string