就像dyoo所说的,
nil如果您的struct属性是指针,则可以使用。如果您想将它们保留为字符串,可以与进行比较
""。这是一个示例:
package mainimport "fmt"type MyStruct struct { Property string}func main() { s1 := MyStruct{ Property: "hey", } s2 := MyStruct{} if s1.Property != "" { fmt.Println("s1.Property has been set") } if s2.Property == "" { fmt.Println("s2.Property has not been set") }}http://play.golang.org/p/YStKFuekeZ



