encoding/asn1: cannot marshal into slice of strings and pass stringtype parameter tags to members
jcmturner opened this issue · comments
What version of Go are you using (go version
)?
go version go1.7.5 linux/amd64
What operating system and processor architecture are you using (go env
)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GORACE=""
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build372878858=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1
Issue
I need to be able to marshal into a slice of strings and to be able to specify the string types for the elements in this slice (is5, generalstring, etc)
https://play.golang.org/p/l5id74lMoI
Issue seems to be two fold:
- Validation does not allow it and you get the error: explicit string type given to non-string member
- Strings would all be marshaled as the default type - PrintableString
Suggestion
When struct tags for string types are defined against a slice this should be accepted if the slice is of strings
The struct tag for the string type should be passed down to the marshaling of the members of the slice
Possible update that appears to work: jcmturner/asn1@d10e504
I note that this problem may also affect slices of time.Time
I was complaining about this on the internet and @FiloSottile asked me to open an issue and CC him. It seems there's already an issue though. Here's where I ran into wanting to include a utf8
tag on a []string
.