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

Create generator and generate enum.go. #7

Merged
merged 2 commits into from
Jun 20, 2017
Merged

Create generator and generate enum.go. #7

merged 2 commits into from
Jun 20, 2017

Conversation

dmitshur
Copy link
Member

@dmitshur dmitshur commented Jun 20, 2017

This PR addresses the following TODO comment in enum.go:

// TODO: Generate the rest from schema according to this formula.

Generating all of enum.go has proven that this approach won't work. There are many name collisions, because different enum types share same enum value names.

# github.com/shurcooL/githubql
./enum.go:71: CreatedAt redeclared in this block
	previous declaration at ./enum.go:17
./enum.go:111: Open redeclared in this block
	previous declaration at ./enum.go:8
./enum.go:112: Closed redeclared in this block
	previous declaration at ./enum.go:9
./enum.go:120: CreatedAt redeclared in this block
	previous declaration at ./enum.go:71
./enum.go:121: UpdatedAt redeclared in this block
	previous declaration at ./enum.go:18
./enum.go:149: CreatedAt redeclared in this block
	previous declaration at ./enum.go:120
./enum.go:150: UpdatedAt redeclared in this block
	previous declaration at ./enum.go:121
./enum.go:152: Name redeclared in this block
	previous declaration at ./enum.go:19
./enum.go:170: Open redeclared in this block
	previous declaration at ./enum.go:111
./enum.go:171: Closed redeclared in this block
	previous declaration at ./enum.go:112
./enum.go:171: too many errors

The duplicate identifiers are manually commented out for now while I decide on which of multiple approaches to use to resolve the issue.

Generating all of enum.go has proven that this approach won't work.
There are many name collisions, because different enum types share same
enum value names.

	# github.com/shurcooL/githubql
	./enum.go:71: CreatedAt redeclared in this block
		previous declaration at ./enum.go:17
	./enum.go:111: Open redeclared in this block
		previous declaration at ./enum.go:8
	./enum.go:112: Closed redeclared in this block
		previous declaration at ./enum.go:9
	./enum.go:120: CreatedAt redeclared in this block
		previous declaration at ./enum.go:71
	./enum.go:121: UpdatedAt redeclared in this block
		previous declaration at ./enum.go:18
	./enum.go:149: CreatedAt redeclared in this block
		previous declaration at ./enum.go:120
	./enum.go:150: UpdatedAt redeclared in this block
		previous declaration at ./enum.go:121
	./enum.go:152: Name redeclared in this block
		previous declaration at ./enum.go:19
	./enum.go:170: Open redeclared in this block
		previous declaration at ./enum.go:111
	./enum.go:171: Closed redeclared in this block
		previous declaration at ./enum.go:112
	./enum.go:171: too many errors
The duplicate identifiers are manually commented out for now while I
decide on which of multiple approaches to use to resolve the issue.

Fixes build.
@dmitshur dmitshur merged commit e7e57eb into master Jun 20, 2017
@dmitshur dmitshur deleted the gen-enum branch June 20, 2017 17:34
dmitshur added a commit that referenced this pull request Jul 2, 2017
Go with solution 1, as described in #8. Solution 1 is the simplest,
most predictable, and least controversial option. Its only downfall
are the verbose enum value identifiers, but it suffers from least
other problems.

Since the API of the library is not frozen yet, if another solution
is found which is determined to be better overall, we can still
improve this.

Regenerate with:

	go generate ./...

Updates #8.
Follows #7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant