-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from sublee/default-config-variables
Enable goverter:enum on goverter:variables mode
- Loading branch information
Showing
2 changed files
with
45 additions
and
4 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,44 @@ | ||
input: | ||
input.go: | | ||
package example | ||
type Enum1 int | ||
type Enum2 string | ||
const ( | ||
Enum1A Enum1 = iota | ||
Enum1B | ||
) | ||
const ( | ||
Enum2A Enum2 = "A" | ||
Enum2B Enum2 = "B" | ||
) | ||
// goverter:variables | ||
var ( | ||
// goverter:enum:unknown Enum2A | ||
// goverter:enum:map Enum1A Enum2A | ||
// goverter:enum:map Enum1B Enum2B | ||
Convert func(Enum1) Enum2 | ||
) | ||
success: | ||
- input.gen.go: | | ||
// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. | ||
package example | ||
func init() { | ||
Convert = func(source Enum1) Enum2 { | ||
var exampleEnum2 Enum2 | ||
switch source { | ||
case Enum1A: | ||
exampleEnum2 = Enum2A | ||
case Enum1B: | ||
exampleEnum2 = Enum2B | ||
default: | ||
exampleEnum2 = Enum2A | ||
} | ||
return exampleEnum2 | ||
} | ||
} |