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

WIP: PoC expose a fluent api to generate code #36

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Joffref
Copy link
Owner

@Joffref Joffref commented Jan 8, 2024

No description provided.

@leorolland leorolland self-assigned this Jan 8, 2024
@leorolland
Copy link
Collaborator

love it

@Joffref Joffref requested a review from leorolland January 9, 2024 09:29
return c
}

func (c *Code) WithNamedImports(namedImports map[string]string) *Code {
Copy link
Collaborator

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if len(c.headerComments) > 0 {

return fmt.Errorf("package name is required")
}

if len(c.imports) > 0 || len(c.namedImports) > 0 {
Copy link
Collaborator

@leorolland leorolland Jan 15, 2024

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 (
)
Suggested change
if len(c.imports) > 0 || len(c.namedImports) > 0 {

same for the rest \n outside function bodies

Signed-off-by: Joffref <[email protected]>
@Joffref Joffref linked an issue Jan 22, 2024 that may be closed by this pull request
1 task
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

Successfully merging this pull request may close these issues.

[Enhancement]: Consume GenZ as code - Proposal WIP
2 participants