-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Showing
2 changed files
with
70 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
input: | ||
input.go: | | ||
package structs | ||
// goverter:converter | ||
// goverter:extend StringPToString | ||
// goverter:output ./generated.go | ||
// goverter:outputPackage github.com/jmattheis/goverter/execution:structs | ||
type Converter interface { | ||
ConvertPerson(source Input) Output | ||
} | ||
func StringPToString(value *string) string { | ||
if value == nil { | ||
return "" | ||
} | ||
return *value | ||
} | ||
type Input struct { | ||
Name *string | ||
} | ||
type Output struct { | ||
Name string | ||
} | ||
success: | ||
- generated.go: | | ||
// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. | ||
package structs | ||
type ConverterImpl struct{} | ||
func (c *ConverterImpl) ConvertPerson(source Input) Output { | ||
var structsOutput Output | ||
structsOutput.Name = StringPToString(source.Name) | ||
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,31 @@ | ||
input: | ||
input.go: | | ||
package pkg | ||
// goverter:converter | ||
// goverter:outputPackage github.com/jmattheis/goverter/execution/generated:myname | ||
type Converter2 interface { | ||
Convert(source Input) Output | ||
} | ||
type Input struct { | ||
ID int | ||
} | ||
type Output struct { | ||
ID int | ||
} | ||
success: | ||
- generated/generated.go: | | ||
// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. | ||
package myname | ||
import execution "github.com/jmattheis/goverter/execution" | ||
type Converter2Impl struct{} | ||
func (c *Converter2Impl) Convert(source execution.Input) execution.Output { | ||
var pkgOutput execution.Output | ||
pkgOutput.ID = source.ID | ||
return pkgOutput | ||
} |