-
-
Notifications
You must be signed in to change notification settings - Fork 50
/
enum_unknown_ignore.yml
73 lines (64 loc) · 1.86 KB
/
enum_unknown_ignore.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
input:
input.go: |
package example
import (
input "github.com/jmattheis/goverter/execution/input"
output "github.com/jmattheis/goverter/execution/output"
)
// goverter:converter
// goverter:enum:unknown @ignore
type Converter interface {
Convert(input.Color) output.Color
Convert2(output.Color) input.Color
}
input/enum.go: |
package input
type Color int
const (
Green Color = iota
Blue
Red
)
output/enum.go: |
package output
type Color string
const (
Green Color = "green"
Blue Color = "blue"
Red Color = "red"
)
success:
- generated/generated.go: |
// Code generated by github.com/jmattheis/goverter, DO NOT EDIT.
package generated
import (
input "github.com/jmattheis/goverter/execution/input"
output "github.com/jmattheis/goverter/execution/output"
)
type ConverterImpl struct{}
func (c *ConverterImpl) Convert(source input.Color) output.Color {
var outputColor output.Color
switch source {
case input.Blue:
outputColor = output.Blue
case input.Green:
outputColor = output.Green
case input.Red:
outputColor = output.Red
default: // ignored
}
return outputColor
}
func (c *ConverterImpl) Convert2(source output.Color) input.Color {
var inputColor input.Color
switch source {
case output.Blue:
inputColor = input.Blue
case output.Green:
inputColor = input.Green
case output.Red:
inputColor = input.Red
default: // ignored
}
return inputColor
}