-
Notifications
You must be signed in to change notification settings - Fork 3
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
WIP: PoC expose a fluent api to generate code #36
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Joffref <[email protected]>
love it |
Signed-off-by: Joffref <[email protected]>
Signed-off-by: Joffref <[email protected]>
return c | ||
} | ||
|
||
func (c *Code) WithNamedImports(namedImports map[string]string) *Code { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
func (c *Code) Generate() error { | ||
var buf bytes.Buffer | ||
if len(c.headerComments) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if len(c.headerComments) > 0 { |
return fmt.Errorf("package name is required") | ||
} | ||
|
||
if len(c.imports) > 0 || len(c.namedImports) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gofmt should automatically remove useless closes like
import (
)
if len(c.imports) > 0 || len(c.namedImports) > 0 { |
same for the rest \n
outside function bodies
Signed-off-by: Joffref <[email protected]>
No description provided.