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

Error in local generation #14

Open
ebonetti opened this issue Apr 3, 2018 · 2 comments
Open

Error in local generation #14

ebonetti opened this issue Apr 3, 2018 · 2 comments

Comments

@ebonetti
Copy link

ebonetti commented Apr 3, 2018

Hi taylorchu :)
while generating a local code the command gorewrite returns the error:

2018/04/03 19:42:47 GOPACKAGE cannot be empty

You can checkout the test setup in the attachment.

On the other side generating a separate package doesn't give such error.

Keep up the great work,
Enrico Bonetti Vieno

P.S.: I do like a lot the elegance of your program - big fun here 👍 - in my opininion with some minor refinments and integrated in the toolchain could be a real substitute for the generics.

@taylorchu
Copy link
Owner

This tool is designed to run with go generate which fills the env variable GOPACKAGE.

Go generate sets several variables when it runs the generator:

$GOARCH
	The execution architecture (arm, amd64, etc.)
$GOOS
	The execution operating system (linux, windows, etc.)
$GOFILE
	The base name of the file.
$GOLINE
	The line number of the directive in the source file.
$GOPACKAGE
	The name of the package of the file containing the directive.
$DOLLAR
	A dollar sign.

@ebonetti
Copy link
Author

ebonetti commented Apr 5, 2018

Holy pretzel! Now I have some nice local code, knowing that beforehand I could just have used an environment variable:
GOPACKAGE=main gorewrite

  1. About that, if go-generate is a use requisite, why it's not documented in the README? 😏
  2. Moreover, this's such a common misuse, why not check it beforehand? So that the user can be warned and guided to the intended one

Keep it up, Enrico

P.S.: I just like a lot your tool and I want it to succeed ;)

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