-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix(#14): return short type name (in Name attr) * feat: add type Name and InternalName
- Loading branch information
1 parent
8b3796a
commit c99fca8
Showing
6 changed files
with
290 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package test | ||
|
||
{{ range .Attributes }} | ||
{{ if has "+getter" .Comments }}{{ $receiverName := substr 0 1 $.Type.InternalName | lower}} | ||
func ({{ $receiverName }} *{{ $.Type.InternalName }}) Get{{ camelcase .Name }}() {{ .Type.InternalName }} { | ||
return {{ $receiverName }}.{{.Name}} | ||
} | ||
{{ end }} | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package test | ||
|
||
//go:generate genz -type Car -template ../getters.tmpl -output car.gen.go | ||
type Car struct { | ||
|
||
//+getter | ||
model string | ||
|
||
//+getter | ||
wheels []Wheel | ||
|
||
motorReference string | ||
} | ||
|
||
type Wheel struct{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.