-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathdefault_on_source_struct_target_pointer.yml
74 lines (62 loc) · 2.36 KB
/
default_on_source_struct_target_pointer.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
74
input:
input.go: |
package execution
// goverter:converter
type Converter interface {
// goverter:default NewOutputWithDefaults
// goverter:useZeroValueOnPointerInconsistency
Convert(source *Input) (Output, error)
}
// goverter:converter
type Update interface {
// goverter:default NewOutputWithDefaults
// goverter:default:update
// goverter:useZeroValueOnPointerInconsistency
Update(source *Input) (Output, error)
}
// goverter:converter
type UpdateUpdate interface {
// goverter:default NewOutputWithDefaults
// goverter:default:update
// goverter:update:ignoreZeroValueField
// goverter:useZeroValueOnPointerInconsistency
Update(source *Input) (Output, error)
}
type Input struct { Name string }
type Output struct { Name string }
func NewOutputWithDefaults() Output {
return Output{ Name: "string" }
}
success:
- generated/generated.go: |
// Code generated by github.com/jmattheis/goverter, DO NOT EDIT.
package generated
import execution "github.com/jmattheis/goverter/execution"
type ConverterImpl struct{}
func (c *ConverterImpl) Convert(source *execution.Input) (execution.Output, error) {
executionOutput := execution.NewOutputWithDefaults()
if source != nil {
var executionOutput2 execution.Output
executionOutput2.Name = (*source).Name
executionOutput = executionOutput2
}
return executionOutput, nil
}
type UpdateImpl struct{}
func (c *UpdateImpl) Update(source *execution.Input) (execution.Output, error) {
executionOutput := execution.NewOutputWithDefaults()
if source != nil {
executionOutput.Name = (*source).Name
}
return executionOutput, nil
}
type UpdateUpdateImpl struct{}
func (c *UpdateUpdateImpl) Update(source *execution.Input) (execution.Output, error) {
executionOutput := execution.NewOutputWithDefaults()
if source != nil {
if (*source).Name != "" {
executionOutput.Name = (*source).Name
}
}
return executionOutput, nil
}