-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58ba62d
commit edc349e
Showing
15 changed files
with
280 additions
and
21 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
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
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
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,36 @@ | ||
input: | ||
input.go: | | ||
package structs | ||
// goverter:converter | ||
type Converter interface { | ||
// goverter:matchIgnoreCase | ||
Convert(source Input) Output | ||
} | ||
type Input struct { | ||
Name string | ||
UUID string | ||
OtherID int | ||
} | ||
type Output struct { | ||
Name string | ||
Uuid string | ||
OtherId int | ||
} | ||
success: | | ||
// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. | ||
package generated | ||
import execution "github.com/jmattheis/goverter/execution" | ||
type ConverterImpl struct{} | ||
func (c *ConverterImpl) Convert(source execution.Input) execution.Output { | ||
var structsOutput execution.Output | ||
structsOutput.Name = source.Name | ||
structsOutput.Uuid = source.UUID | ||
structsOutput.OtherId = source.OtherID | ||
return structsOutput | ||
} |
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,46 @@ | ||
input: | ||
input.go: | | ||
package structs | ||
// goverter:converter | ||
type Converter interface { | ||
// goverter:matchIgnoreCase | ||
// goverter:map AmbID AmbId | ||
// goverter:ignore Ambid2 | ||
Convert(source Input) Output | ||
} | ||
type Input struct { | ||
OtherID string | ||
OtherId int // should prefer exact match | ||
Uuid string | ||
AmbID float64 // explicit choice | ||
Ambid float64 | ||
AmbID2 string | ||
Ambid2 string | ||
} | ||
type Output struct { | ||
OtherId int | ||
Uuid string // should prefer exact match | ||
UUID string | ||
AmbId float64 | ||
AmbId2 string | ||
} | ||
success: | | ||
// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. | ||
package generated | ||
import execution "github.com/jmattheis/goverter/execution" | ||
type ConverterImpl struct{} | ||
func (c *ConverterImpl) Convert(source execution.Input) execution.Output { | ||
var structsOutput execution.Output | ||
structsOutput.OtherId = source.OtherId | ||
structsOutput.Uuid = source.Uuid | ||
structsOutput.UUID = source.Uuid | ||
structsOutput.AmbId = source.AmbID | ||
structsOutput.AmbId2 = source.AmbID2 | ||
return structsOutput | ||
} |
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,10 @@ | ||
input: | ||
input.go: | | ||
package structs | ||
// goverter:converter | ||
type Converter interface { | ||
// goverter:matchIgnoreCase a | ||
ConvertString(source string) string | ||
} | ||
error: '/ABSOLUTE/execution/input.go:4:1: type Converter: parsing method ConvertString: invalid goverter:matchIgnoreCase, parameters not supported' |
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,42 @@ | ||
input: | ||
input.go: | | ||
package structs | ||
// goverter:converter | ||
type Converter interface { | ||
// goverter:matchIgnoreCase | ||
Convert(source Input) Output | ||
} | ||
type Input struct { | ||
NESTED InputNested | ||
} | ||
type InputNested struct { | ||
Name string | ||
} | ||
type Output struct { | ||
Nested OutputNested | ||
} | ||
type OutputNested struct { | ||
Name int | ||
} | ||
error: |- | ||
Error while creating converter method: | ||
func (github.com/jmattheis/goverter/execution.Converter).Convert(source github.com/jmattheis/goverter/execution.Input) github.com/jmattheis/goverter/execution.Output | ||
| github.com/jmattheis/goverter/execution.Input | ||
| | ||
| | github.com/jmattheis/goverter/execution.InputNested | ||
| | | ||
| | | string | ||
| | | | ||
source.NESTED.Name | ||
target.Nested.Name | ||
| | | | ||
| | | int | ||
| | | ||
| | github.com/jmattheis/goverter/execution.OutputNested | ||
| | ||
| github.com/jmattheis/goverter/execution.Output | ||
TypeMismatch: Cannot convert string to int |
39 changes: 39 additions & 0 deletions
39
scenario/7_error_match_ignore_case_unresolved_ambiguity.yml
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,39 @@ | ||
input: | ||
input.go: | | ||
package structs | ||
// goverter:converter | ||
type Converter interface { | ||
// goverter:matchIgnoreCase | ||
Convert(source Input) Output | ||
} | ||
type Input struct { | ||
MyID string | ||
MyId string | ||
} | ||
type Output struct { | ||
Myid string | ||
} | ||
error: |- | ||
Error while creating converter method: | ||
func (github.com/jmattheis/goverter/execution.Converter).Convert(source github.com/jmattheis/goverter/execution.Input) github.com/jmattheis/goverter/execution.Output | ||
| github.com/jmattheis/goverter/execution.Input | ||
| | ||
| | ||
| | ||
source.??? | ||
target.Myid | ||
| | | ||
| | string | ||
| | ||
| github.com/jmattheis/goverter/execution.Output | ||
Cannot match the target field with the source entry: multiple matches found for "Myid". Possible matches: MyID, MyId. | ||
Explicitly define the mapping via goverter:map. Example: | ||
goverter:map MyID Myid | ||
See https://github.com/jmattheis/goverter#struct-field-mapping. |
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
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.