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

proposal: encoding/asn1: add "enum" keyword for TagEnum #28873

Closed
barlevd opened this issue Nov 19, 2018 · 2 comments
Closed

proposal: encoding/asn1: add "enum" keyword for TagEnum #28873

barlevd opened this issue Nov 19, 2018 · 2 comments
Labels
FrozenDueToAge Proposal Proposal-Crypto Proposal related to crypto packages or other security issues
Milestone

Comments

@barlevd
Copy link

barlevd commented Nov 19, 2018

Adding an "enum" tag option helps keeping the code clean.

for example:

the following code:

type tEnum int

const (
	tZero tEnum = iota
	tOne
)

type enumTest struct {
	A tEnum `asn1:"enum"`
}

func sampleTest(t *testing.T) {

	myTest := enumTest{A: tOne}

	buf, err := Marshal(myTest)
}

as compared to

type tEnum int

const (
	tZero tEnum = iota
	tOne
)

type enumTest struct {
	A tEnum
}
type enumStruct struct {
	A Enumerated
}

func sampleTest(t *testing.T) {

	myTest := enumTest{A: tOne}

	enum := enumStruct{A: Enumerated(int(myTest.A))}
	buf, err := Marshal(enum)
}

note the enumStruct is completely redundant and is used solely for getting an enum tag in the buffer

Same goes for Unmarshal, you need an intermediate structure if you want to have you own enumerated types.

@gopherbot gopherbot added this to the Proposal milestone Nov 19, 2018
@bcmills
Copy link
Contributor

bcmills commented Nov 20, 2018

CC @FiloSottile @agl

@andybons andybons added the Proposal-Crypto Proposal related to crypto packages or other security issues label Dec 5, 2018
@ianlancetaylor ianlancetaylor added this to Incoming in Proposals (old) Feb 24, 2021
@rsc
Copy link
Contributor

rsc commented Feb 24, 2021

This is very old and I can't tell what is being proposed. If this is still an active concern, please file a new proposal. Thanks.

@rsc rsc closed this as completed Feb 24, 2021
@rsc rsc moved this from Incoming to Declined in Proposals (old) Feb 24, 2021
@golang golang locked and limited conversation to collaborators Feb 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Proposal Proposal-Crypto Proposal related to crypto packages or other security issues
Projects
No open projects
Development

No branches or pull requests

5 participants