diff --git a/scenario/into_source_package.yml b/scenario/into_source_package.yml new file mode 100644 index 00000000..b40455e6 --- /dev/null +++ b/scenario/into_source_package.yml @@ -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 + } diff --git a/scenario/package_name.yaml b/scenario/package_name.yaml new file mode 100644 index 00000000..77c946a6 --- /dev/null +++ b/scenario/package_name.yaml @@ -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 + }