Is it a documented feature that passing nil to C.GoString() returns ""? The only clues I've found is this message from Release notes
for 2012-02-07* cgo: accept null pointers in gccgo flavour of C.GoString (thanks Rémy Oudompheng),
And also this code from the standard library that is using this feature (net/cgo_unix.go):
func cgoLookupIPCNAME(name string) (addrs []IPAddr, cname string, err error, completed bool) {
// ...
if res != nil {
cname = C.GoString(res.ai_canonname)
if cname == "" {
cname = name
}
if len(cname) > 0 && cname[len(cname)-1] != '.' {
cname += "."
}
}
// ...
}