4 ms·
I think one of the string format examples missing the type formatter: fmt.Println("it's a", i) Should be something like: fmt.Println("it's a %T", i) See htt
by NKCSS 13y ago
I think one of the string format examples missing the type formatter:
fmt.Println("it's a", i)
Should be something like:
fmt.Println("it's a %T", i)
See http://golang.org/pkg/fmt/ http://golang.org/pkg/fmt/ for more options.
[update]
Forgot they allowed to send pull requests; done :)
- ivanvanderbyl 13y agoI just tried it, both seem correct as fmt.PrintLn takes multiple inputs
- enneff 13y agoPrintln does not take format strings. You're thinking of Printf.
- NKCSS 13y agoYup, forgot to edit that :-/
- JulianMorrison 13y agoAre you mixing up Println and Printf?
- mseepgood 13y agoNo, it's correct. It's meant to print "it's a 84".
- NKCSS 13y agoWould't you expect either "it's 84" or "it's a(n) int|decimal|other_type"? I figured they ment to do the latter, since the next print function outputs: "it's a string".
- mseepgood 13y agoSince c is a chan int it can only be an int, no other type. You could directly write fmt.Println("it's an int").
- cthackers 13y agoThat should be Printf. With Println you get "it's a %T 43". With Printf you get "it's a int"