4 ms·
Don't use println(), use fmt.Println() or other equivalent functions instead. Current implementations provide several built-in functions useful during bo
by drtse4 12y ago
Don't use println(), use fmt.Println() or other equivalent functions instead.
Current implementations provide several built-in functions
useful during bootstrapping. These functions are documented
for completeness but are not guaranteed to stay in the
language.
http://golang.org/ref/spec#Bootstrapping http://golang.org/ref/spec#Bootstrapping
And for beginners, it could be interesting to know that decoders also support simple maps in addition to tagged struct.
Nice series of articles.
- sagichmal 12y ago> Don't use println() println() is nice because it doesn't require an import. For "the smallest possible program" I think it's a good match. > decoders also support simple maps in addition to tagged > structs I think it's a mistake to teach Go programmers to decode into map[string]interface{}. It's pretty rare that you actually want to do that.
- Intermernet 12y agoYes, but as stated above "it is not guaranteed to stay in the language". The functions from "fmt" are guaranteed to stay in the language. May as well start learning the language with best practices, even if it does involve an extra line to 'import "fmt"'.
- sagichmal 12y agoI disagree. (shrug)
- AYBABTME 12y agoDon't decode into maps. If you don't want to create a struct, use an anonymous struct. The only case I can think of making sense is when you deal with JSON that can change shape under your feet (like when dealing with shitty APIs that sometimes returns {}, sometimes []).