Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/asn1: cannot marshal into slice of strings and pass stringtype parameter tags to members #18834

Open
jcmturner opened this Issue Jan 28, 2017 · 2 comments

Comments

Projects
None yet
4 participants
@jcmturner
Copy link

jcmturner commented Jan 28, 2017

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:

  1. Validation does not allow it and you get the error: explicit string type given to non-string member
  2. 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

jcmturner added a commit to jcmturner/asn1 that referenced this issue Jan 28, 2017

@jcmturner

This comment has been minimized.

Copy link
Author

jcmturner commented Jan 28, 2017

Possible update that appears to work: jcmturner/asn1@d10e504

I note that this problem may also affect slices of time.Time

@bradfitz bradfitz added this to the Unplanned milestone Mar 21, 2017

@mastahyeti

This comment has been minimized.

Copy link

mastahyeti commented May 12, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.