Skip to content

Commit 3598f29

Browse files
authored
Change type definition blocks to single declarations. This helps copy/pasting Echo code in examples. (#2606)
1 parent 5f7bedf commit 3598f29

31 files changed

+1364
-1462
lines changed

bind.go

+13-15
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,21 @@ import (
1414
"strings"
1515
)
1616

17-
type (
18-
// Binder is the interface that wraps the Bind method.
19-
Binder interface {
20-
Bind(i interface{}, c Context) error
21-
}
17+
// Binder is the interface that wraps the Bind method.
18+
type Binder interface {
19+
Bind(i interface{}, c Context) error
20+
}
2221

23-
// DefaultBinder is the default implementation of the Binder interface.
24-
DefaultBinder struct{}
22+
// DefaultBinder is the default implementation of the Binder interface.
23+
type DefaultBinder struct{}
2524

26-
// BindUnmarshaler is the interface used to wrap the UnmarshalParam method.
27-
// Types that don't implement this, but do implement encoding.TextUnmarshaler
28-
// will use that interface instead.
29-
BindUnmarshaler interface {
30-
// UnmarshalParam decodes and assigns a value from an form or query param.
31-
UnmarshalParam(param string) error
32-
}
33-
)
25+
// BindUnmarshaler is the interface used to wrap the UnmarshalParam method.
26+
// Types that don't implement this, but do implement encoding.TextUnmarshaler
27+
// will use that interface instead.
28+
type BindUnmarshaler interface {
29+
// UnmarshalParam decodes and assigns a value from an form or query param.
30+
UnmarshalParam(param string) error
31+
}
3432

3533
// BindPathParams binds path params to bindable object
3634
func (b *DefaultBinder) BindPathParams(c Context, i interface{}) error {

bind_test.go

+85-85
Original file line numberDiff line numberDiff line change
@@ -22,91 +22,91 @@ import (
2222
"github.com/stretchr/testify/assert"
2323
)
2424

25-
type (
26-
bindTestStruct struct {
27-
I int
28-
PtrI *int
29-
I8 int8
30-
PtrI8 *int8
31-
I16 int16
32-
PtrI16 *int16
33-
I32 int32
34-
PtrI32 *int32
35-
I64 int64
36-
PtrI64 *int64
37-
UI uint
38-
PtrUI *uint
39-
UI8 uint8
40-
PtrUI8 *uint8
41-
UI16 uint16
42-
PtrUI16 *uint16
43-
UI32 uint32
44-
PtrUI32 *uint32
45-
UI64 uint64
46-
PtrUI64 *uint64
47-
B bool
48-
PtrB *bool
49-
F32 float32
50-
PtrF32 *float32
51-
F64 float64
52-
PtrF64 *float64
53-
S string
54-
PtrS *string
55-
cantSet string
56-
DoesntExist string
57-
GoT time.Time
58-
GoTptr *time.Time
59-
T Timestamp
60-
Tptr *Timestamp
61-
SA StringArray
62-
}
63-
bindTestStructWithTags struct {
64-
I int `json:"I" form:"I"`
65-
PtrI *int `json:"PtrI" form:"PtrI"`
66-
I8 int8 `json:"I8" form:"I8"`
67-
PtrI8 *int8 `json:"PtrI8" form:"PtrI8"`
68-
I16 int16 `json:"I16" form:"I16"`
69-
PtrI16 *int16 `json:"PtrI16" form:"PtrI16"`
70-
I32 int32 `json:"I32" form:"I32"`
71-
PtrI32 *int32 `json:"PtrI32" form:"PtrI32"`
72-
I64 int64 `json:"I64" form:"I64"`
73-
PtrI64 *int64 `json:"PtrI64" form:"PtrI64"`
74-
UI uint `json:"UI" form:"UI"`
75-
PtrUI *uint `json:"PtrUI" form:"PtrUI"`
76-
UI8 uint8 `json:"UI8" form:"UI8"`
77-
PtrUI8 *uint8 `json:"PtrUI8" form:"PtrUI8"`
78-
UI16 uint16 `json:"UI16" form:"UI16"`
79-
PtrUI16 *uint16 `json:"PtrUI16" form:"PtrUI16"`
80-
UI32 uint32 `json:"UI32" form:"UI32"`
81-
PtrUI32 *uint32 `json:"PtrUI32" form:"PtrUI32"`
82-
UI64 uint64 `json:"UI64" form:"UI64"`
83-
PtrUI64 *uint64 `json:"PtrUI64" form:"PtrUI64"`
84-
B bool `json:"B" form:"B"`
85-
PtrB *bool `json:"PtrB" form:"PtrB"`
86-
F32 float32 `json:"F32" form:"F32"`
87-
PtrF32 *float32 `json:"PtrF32" form:"PtrF32"`
88-
F64 float64 `json:"F64" form:"F64"`
89-
PtrF64 *float64 `json:"PtrF64" form:"PtrF64"`
90-
S string `json:"S" form:"S"`
91-
PtrS *string `json:"PtrS" form:"PtrS"`
92-
cantSet string
93-
DoesntExist string `json:"DoesntExist" form:"DoesntExist"`
94-
GoT time.Time `json:"GoT" form:"GoT"`
95-
GoTptr *time.Time `json:"GoTptr" form:"GoTptr"`
96-
T Timestamp `json:"T" form:"T"`
97-
Tptr *Timestamp `json:"Tptr" form:"Tptr"`
98-
SA StringArray `json:"SA" form:"SA"`
99-
}
100-
Timestamp time.Time
101-
TA []Timestamp
102-
StringArray []string
103-
Struct struct {
104-
Foo string
105-
}
106-
Bar struct {
107-
Baz int `json:"baz" query:"baz"`
108-
}
109-
)
25+
type bindTestStruct struct {
26+
I int
27+
PtrI *int
28+
I8 int8
29+
PtrI8 *int8
30+
I16 int16
31+
PtrI16 *int16
32+
I32 int32
33+
PtrI32 *int32
34+
I64 int64
35+
PtrI64 *int64
36+
UI uint
37+
PtrUI *uint
38+
UI8 uint8
39+
PtrUI8 *uint8
40+
UI16 uint16
41+
PtrUI16 *uint16
42+
UI32 uint32
43+
PtrUI32 *uint32
44+
UI64 uint64
45+
PtrUI64 *uint64
46+
B bool
47+
PtrB *bool
48+
F32 float32
49+
PtrF32 *float32
50+
F64 float64
51+
PtrF64 *float64
52+
S string
53+
PtrS *string
54+
cantSet string
55+
DoesntExist string
56+
GoT time.Time
57+
GoTptr *time.Time
58+
T Timestamp
59+
Tptr *Timestamp
60+
SA StringArray
61+
}
62+
63+
type bindTestStructWithTags struct {
64+
I int `json:"I" form:"I"`
65+
PtrI *int `json:"PtrI" form:"PtrI"`
66+
I8 int8 `json:"I8" form:"I8"`
67+
PtrI8 *int8 `json:"PtrI8" form:"PtrI8"`
68+
I16 int16 `json:"I16" form:"I16"`
69+
PtrI16 *int16 `json:"PtrI16" form:"PtrI16"`
70+
I32 int32 `json:"I32" form:"I32"`
71+
PtrI32 *int32 `json:"PtrI32" form:"PtrI32"`
72+
I64 int64 `json:"I64" form:"I64"`
73+
PtrI64 *int64 `json:"PtrI64" form:"PtrI64"`
74+
UI uint `json:"UI" form:"UI"`
75+
PtrUI *uint `json:"PtrUI" form:"PtrUI"`
76+
UI8 uint8 `json:"UI8" form:"UI8"`
77+
PtrUI8 *uint8 `json:"PtrUI8" form:"PtrUI8"`
78+
UI16 uint16 `json:"UI16" form:"UI16"`
79+
PtrUI16 *uint16 `json:"PtrUI16" form:"PtrUI16"`
80+
UI32 uint32 `json:"UI32" form:"UI32"`
81+
PtrUI32 *uint32 `json:"PtrUI32" form:"PtrUI32"`
82+
UI64 uint64 `json:"UI64" form:"UI64"`
83+
PtrUI64 *uint64 `json:"PtrUI64" form:"PtrUI64"`
84+
B bool `json:"B" form:"B"`
85+
PtrB *bool `json:"PtrB" form:"PtrB"`
86+
F32 float32 `json:"F32" form:"F32"`
87+
PtrF32 *float32 `json:"PtrF32" form:"PtrF32"`
88+
F64 float64 `json:"F64" form:"F64"`
89+
PtrF64 *float64 `json:"PtrF64" form:"PtrF64"`
90+
S string `json:"S" form:"S"`
91+
PtrS *string `json:"PtrS" form:"PtrS"`
92+
cantSet string
93+
DoesntExist string `json:"DoesntExist" form:"DoesntExist"`
94+
GoT time.Time `json:"GoT" form:"GoT"`
95+
GoTptr *time.Time `json:"GoTptr" form:"GoTptr"`
96+
T Timestamp `json:"T" form:"T"`
97+
Tptr *Timestamp `json:"Tptr" form:"Tptr"`
98+
SA StringArray `json:"SA" form:"SA"`
99+
}
100+
101+
type Timestamp time.Time
102+
type TA []Timestamp
103+
type StringArray []string
104+
type Struct struct {
105+
Foo string
106+
}
107+
type Bar struct {
108+
Baz int `json:"baz" query:"baz"`
109+
}
110110

111111
func (t *Timestamp) UnmarshalParam(src string) error {
112112
ts, err := time.Parse(time.RFC3339, src)

0 commit comments

Comments
 (0)