This question already has an answer here:
- nested struct initialization literals 2 answers
I am trying to run this code:
type NullInt64 struct {
sql.NullInt64
}
func ToNullInt64(s string) NullInt64 {
i, err := strconv.Atoi(s)
return NullInt64{Int64: int64(i), Valid: err == nil}
}
but I get this error:
..\sql\sql.go:27: unknown NullInt64 field 'Int64' in struct literal
..\sql\sql.go:27: unknown NullInt64 field 'Valid' in struct literal
</div>