Quantcast
Channel: User Schwern - Stack Overflow
Viewing all articles
Browse latest Browse all 581

Answer by Schwern for How to initalize sql.NullString member in struct type?

$
0
0
type MyNullString struct {    sql.NullString    json.Marshaler    json.Unmarshaler}

That says you have a type MyNullString which is a struct with sql.NullString, json.Marshaler, and json.Unmarshaler embedded members. The struct does not inherit its embedded structs' fields, they might not even be structs. It takes values of that type.

Since the member names were not given, the member names are the names of the type it takes without a namespace.

a := A{  B: MyNullString{    NullString: sql.NullString{String: "Foo", Valid: true},    Marshaler: SomethingThatImplementsMarshal(),    Unmarshaler: SomethingThatImplementsUnmarshal(),  }}

Note: it might make more sense to simply use MyNullString directly rather than define a new struct with just one member.


Viewing all articles
Browse latest Browse all 581

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>