I see a lot of code in Go to detect nil, like this:
if err != nil {
// handle the error
}
however, I have a struct like this:
type Config struct {
host string
port float64
}
and config is an instance of Config, when I do:
if config == nil {
}
there is compile error, saying: cannot convert nil to type Config
转载于:https://stackoverflow.com/questions/20240179/nil-detection-in-go