I cam across some code today that suprised me with a 'print' that wasn't defined. After a little playing I determined that you can just use a print to get things dumped to the console
e.g.
print("Hello World")
So it seems to be some sort of builtin but I can't find any reference to it (and I thought the go rules were lowercase functions never imported anyway)
Is this well known and if so are there other convenience functions or am I just very, very confused?
One other point -- this print doesn't use the magic formatting tricks (%v) of fmt.Printf -- If you print maps or structs you seem to get their address.
print
and println
are defined here.
Their purpose is explained here.
You are right, and someone else has already complained about it. It's been added to the built-in documentation for the next Go release (go1.2).
func print(args ...Type)
The
func println(args ...Type)
The
println
built-in function formats its arguments in an implementation-specific way and writes the result to standard error. Spaces are always added between arguments and a newline is appended. Println is useful for bootstrapping and debugging; it is not guaranteed to stay in the language.
Thanks all for the quick response
What threw me off is the 'builtin' package doesn't define print (in the version I am using anyway)
It seems like a dangerous feature to depend in general so I'll pretend I never saw it and continue to fmt.Print....