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

Giving multiple types that all appear in the same file causes duplication in the generated code #9

Open
benbarbour opened this issue Aug 13, 2015 · 2 comments

Comments

@benbarbour
Copy link

//go:generate jsonenums -type=A,B

package main

type A int
const (
   X A = iota
   Y
   Z
)

type B int 
const (
   M B = iota
   N
   O
)

After running "go generate" a_jsonenums.go contains the correct definitions for type A, but b_jsonenums.go has the definitions for both type A and type B.

What I would like best is a way to dump all of the generated json into just one fil like stringer's -o flag allows me to do.

@benbarbour
Copy link
Author

I should note that I worked around it for now by using a separate generation directive for each type instead of one with multiple types. I've got 10+ types though, so this makes 10 separate files. I'd love to automatically put them into "generated_json_funcs.go" to match my "generated_strings.go" file.

@aprice2704
Copy link

I just ran into this one as well. I would argue that the (desirable) -o option is not a fix but a workaround. For now I just have multiple go:generate lines. Sorry for no PR :(
Still a nifty tool Francesc -- thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants