fmt is outputting an error because you passed it an integer type when you 
asked it to format a boolean type. I think you wanted %T, not %t

https://play.golang.org/p/Uvws_k2peX

On Wednesday, 22 March 2017 12:23:04 UTC+11, WinD zz wrote:
>
>
> func main() {
>       const abc = 111
>       fmt.Printf("%t\n", abc)
>       fmt.Println(math.Pi * abc)
>       fmt.Printf("%t", math.Pi)
> }
>
> result:
> %!t(int=111)
> 25.132741228718345
> %!t(float64=3.141592653589793)
>
> func main() {
>       const abc int = 111
>       fmt.Printf("%t\n", abc)
>       fmt.Println(math.Pi * abc)
>       fmt.Printf("%t", math.Pi)
> }
>
> result:
> constant 3.14159 truncated to integer
>
> Why when i typed abc int ,the compiler will error.
> But,first example tell me on runtime the abc type is int.
>
> this is why?
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to