-
-
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.
fix: multiple input one output and package mismatches
- Loading branch information
Showing
4 changed files
with
93 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
input: | ||
model/model.go: | | ||
package model | ||
type Input struct { | ||
ID int | ||
} | ||
type Output struct { | ||
ID int | ||
} | ||
pkg1/input.go: | | ||
package pkg1 | ||
import model "github.com/jmattheis/goverter/execution/model" | ||
// goverter:converter | ||
// goverter:output ../generated/output.go | ||
type Converter interface { | ||
Convert(source model.Input) model.Output | ||
} | ||
pkg2/input.go: | | ||
package pkg2 | ||
import model "github.com/jmattheis/goverter/execution/model" | ||
// goverter:converter | ||
// goverter:output ../generated/output.go | ||
type Converter2 interface { | ||
Convert(source model.Input) model.Output | ||
} | ||
success: | ||
- generated/output.go: | | ||
// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. | ||
package generated | ||
import model "github.com/jmattheis/goverter/execution/model" | ||
type Converter2Impl struct{} | ||
func (c *Converter2Impl) Convert(source model.Input) model.Output { | ||
var modelOutput model.Output | ||
modelOutput.ID = source.ID | ||
return modelOutput | ||
} | ||
type ConverterImpl struct{} | ||
func (c *ConverterImpl) Convert(source model.Input) model.Output { | ||
var modelOutput model.Output | ||
modelOutput.ID = source.ID | ||
return modelOutput | ||
} |
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,35 @@ | ||
input: | ||
input.go: | | ||
package structs | ||
// goverter:converter | ||
// goverter:outputPackage pkg1 | ||
type Converter interface { | ||
Convert(source Input) Output | ||
} | ||
// goverter:converter | ||
// goverter:outputPackage pkg2 | ||
type Converter2 interface { | ||
Convert(source Input) Output | ||
} | ||
type Input struct { | ||
ID int | ||
} | ||
type Output struct { | ||
ID int | ||
} | ||
error: |- | ||
Error creating converters | ||
/ABSOLUTE/execution/input.go | ||
github.com/jmattheis/goverter/execution.Converter | ||
and | ||
/ABSOLUTE/execution/input.go | ||
github.com/jmattheis/goverter/execution.Converter2 | ||
Cannot use different packages | ||
pkg1 | ||
pkg2 | ||
in the same ouput file: | ||
/ABSOLUTE/execution/generated/generated.go |