This small site is oriented to developers learning golang that want to see the unexpected, at least for a newcomer, behaviors in the language.
This examples expect that reader is familiar with the language, if you’re not familiar with it, you should complete the Go by Example tutorial.
Examples
The WIP list of examples is (with no specific order):
nil
errors that are non-nilerror
stime.RFC3339
constant is not a validRFC3339
timestampos.Stdout
changes afterinit()
in testable examplesWrite([]byte) (int, error)
should not retain the sliceif err := recover(); err != nil
does not recover from all panicsjson.Unmarhsal
merges structs and slices, but not map valuesdefer
does not wait for parallelized tests- Benchmarks with very long setup run faster in sub-benchmarks
clear()
built-in function removes map keys but keeps slice indexes- You can’t remove a
NaN
key from a map without clearing it - Generic type
T any
cannot benil
Grab some popcorn
Disclaimer
This examples are not trying to prove that golang is wrong, it’s just sharing stuff that someone who has just started learning the language doesn’t expect.
Outdated / fixed items
These items have been updated, fixed or changed in the language, but are kept here for historical reasons: