Go 语言中检测空字符串的最优方法
以下两种风格在 Go 的标准库源码中皆可找到:
if len(s) > 0 { ... }
可以在 strconv
包里找到 —— http://golang.org/src/pkg/strconv/atoi.go
if s != "" { ... }
可以在 encoding/json
包里找到 —— http://golang.org/src/pkg/encoding/json/en...
以下两种风格在 Go 的标准库源码中皆可找到:
if len(s) > 0 { ... }
可以在 strconv
包里找到 —— http://golang.org/src/pkg/strconv/atoi.go
if s != "" { ... }
可以在 encoding/json
包里找到 —— http://golang.org/src/pkg/encoding/json/en...
推荐文章: