-
Notifications
You must be signed in to change notification settings - Fork 178
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
chore: PoC - Define make command to call code generation logic #2706
Changes from all commits
56261da
5fb9add
db24b5d
13fb973
c978425
3efaf97
0fd7f7f
57d74f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package codespec | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/huandu/xstrings" | ||
) | ||
|
||
type SnakeCaseString string | ||
|
||
func (snake SnakeCaseString) SnakeCase() string { | ||
return string(snake) | ||
} | ||
|
||
func (snake SnakeCaseString) PascalCase() string { | ||
return xstrings.ToCamelCase(string(snake)) // in xstrings v1.15.0 we can switch to using ToPascalCase for same functionality | ||
} | ||
|
||
func (snake SnakeCaseString) LowerCaseNoUnderscore() string { | ||
return strings.ReplaceAll(string(snake), "_", "") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package test_name | ||
package testname | ||
|
||
import ( | ||
"context" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package test_name | ||
package testname | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's idiomatic Go to call the package same as last folder, here it is testdata but testname There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This actually a golden file to verify the output of generated code. In the test the resource name is defined as |
||
|
||
import ( | ||
"context" | ||
|
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.
knit: this is used by our mock library, but I guess you already have everything you need: https://pkg.go.dev/github.com/huandu/xstrings#ToSnakeCase
via https://vektra.github.io/mockery/latest/configuration/#functions
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.
nice, adjusted to use an xstring implementation directly