What is the best way to test for an empty string in Go?

Both styles are used within the Go’s standard libraries. if len(s) > 0 { … } can be found in the strconv package: http://golang.org/src/pkg/strconv/atoi.go if s != “” { … } can be found in the encoding/json package: http://golang.org/src/pkg/encoding/json/encode.go Both are idiomatic and are clear enough. It is more a matter of personal taste and … Read more

tech