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

Go generate #361

Merged
merged 5 commits into from
Jan 29, 2019
Merged

Go generate #361

merged 5 commits into from
Jan 29, 2019

Conversation

retgits
Copy link
Contributor

@retgits retgits commented Jan 20, 2019

as mentioned in #310

What problem does this solve?

Right now anyone creating a new module has to start from scratch, probably copy/pasting/chopping the guts from an existing module. This is tedious, error-prone, and not a great use of people's time.

How does it work?

The package generator contains generates for empty widgets (stubs). Each generator is named after the type of widget it generate, so textwidget.go will generate the skeleton for a new TextWidget using the textwidget.tpl template. Since you can't dynamically add any arguments to go generate, the TextWidget generator needs one environment variable, called WTF_WIDGET_NAME, which will be the name of the TextWidget it generates. If the variable hasn't been set, the generator will use NewTextWidget. As an example, on macOS the command can be run as WTF_WIDGET_NAME=MySuperAwesomeWidget go generate -run=text, which will generate a new module based on the TextWidget generator in the folder mysuperawesomewidget

@senorprogrammer
Copy link
Collaborator

This is awesome, and I would love to merge this in. Before that though, I'm getting the following error when I follow the directions above:

~/go/src/github.com/wtfutil/wtf retgits-go-generate 8s
❯ WTF_WIDGET_NAME=MySuperAwesomeWidget go generate text
can't load package: package text: no Go files in /usr/local/Cellar/go/1.11.1/libexec/src/text

Suggestions?

@retgits
Copy link
Contributor Author

retgits commented Jan 27, 2019

Totally my bad, sorry. The command should be WTF_WIDGET_NAME=MySuperAwesomeWidget go generate -run=text. I'll update the text so it reflects the correct command.

@senorprogrammer
Copy link
Collaborator

Thanks!

@retgits
Copy link
Contributor Author

retgits commented Jan 28, 2019

All updates should be in place now 😄

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.

2 participants