|
| 1 | +version_dependent: true |
| 2 | +input: |
| 3 | + input.go: | |
| 4 | + package alias |
| 5 | +
|
| 6 | + // goverter:converter |
| 7 | + // goverter:extend AnyAny |
| 8 | + type Converter interface { |
| 9 | + A(source map[string]InputAlias) map[string]OutputAlias |
| 10 | + B(source map[string]any) map[string]any |
| 11 | + C(source struct{A InputAlias}) struct{A OutputAlias} |
| 12 | + D(source []GenAlias[string]) []GenAlias[string] |
| 13 | + } |
| 14 | +
|
| 15 | + func AnyAny(a any) any { |
| 16 | + return a |
| 17 | + } |
| 18 | +
|
| 19 | + type GenAlias[T any] []T |
| 20 | + type InputAlias = string |
| 21 | + type OutputAlias = string |
| 22 | +success: |
| 23 | + - generated/generated.go: | |
| 24 | + // Code generated by github.com/jmattheis/goverter, DO NOT EDIT. |
| 25 | +
|
| 26 | + package generated |
| 27 | +
|
| 28 | + import execution "github.com/jmattheis/goverter/execution" |
| 29 | +
|
| 30 | + type ConverterImpl struct{} |
| 31 | +
|
| 32 | + func (c *ConverterImpl) A(source map[string]string) map[string]string { |
| 33 | + var mapStringString map[string]string |
| 34 | + if source != nil { |
| 35 | + mapStringString = make(map[string]string, len(source)) |
| 36 | + for key, value := range source { |
| 37 | + mapStringString[key] = value |
| 38 | + } |
| 39 | + } |
| 40 | + return mapStringString |
| 41 | + } |
| 42 | + func (c *ConverterImpl) B(source map[string]interface{}) map[string]interface{} { |
| 43 | + var mapStringUnknown map[string]interface{} |
| 44 | + if source != nil { |
| 45 | + mapStringUnknown = make(map[string]interface{}, len(source)) |
| 46 | + for key, value := range source { |
| 47 | + mapStringUnknown[key] = execution.AnyAny(value) |
| 48 | + } |
| 49 | + } |
| 50 | + return mapStringUnknown |
| 51 | + } |
| 52 | + func (c *ConverterImpl) C(source struct { |
| 53 | + A string |
| 54 | + }) struct { |
| 55 | + A string |
| 56 | + } { |
| 57 | + var unnamed struct { |
| 58 | + A string |
| 59 | + } |
| 60 | + unnamed.A = source.A |
| 61 | + return unnamed |
| 62 | + } |
| 63 | + func (c *ConverterImpl) D(source []execution.GenAlias[string]) []execution.GenAlias[string] { |
| 64 | + var aliasGenAliasList []execution.GenAlias[string] |
| 65 | + if source != nil { |
| 66 | + aliasGenAliasList = make([]execution.GenAlias[string], len(source)) |
| 67 | + for i := 0; i < len(source); i++ { |
| 68 | + aliasGenAliasList[i] = c.aliasGenAliasToAliasGenAlias(source[i]) |
| 69 | + } |
| 70 | + } |
| 71 | + return aliasGenAliasList |
| 72 | + } |
| 73 | + func (c *ConverterImpl) aliasGenAliasToAliasGenAlias(source execution.GenAlias[string]) execution.GenAlias[string] { |
| 74 | + var aliasGenAlias execution.GenAlias[string] |
| 75 | + if source != nil { |
| 76 | + aliasGenAlias = make(execution.GenAlias[string], len(source)) |
| 77 | + for i := 0; i < len(source); i++ { |
| 78 | + aliasGenAlias[i] = source[i] |
| 79 | + } |
| 80 | + } |
| 81 | + return aliasGenAlias |
| 82 | + } |
0 commit comments