Skip to content

Commit 2a2d530

Browse files
committed
fix: minor fix, format code
1 parent cefe822 commit 2a2d530

File tree

12 files changed

+43
-40
lines changed

12 files changed

+43
-40
lines changed

gofakes3.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"strings"
1616
"sync/atomic"
1717
"time"
18-
18+
1919
xml "github.com/Mikubill/gofakes3/xml"
2020
)
2121

xml/atom_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ func NewText(text string) Text {
5353
return Text{
5454
Body: text,
5555
}
56-
}
56+
}

xml/example_marshaling_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,4 @@ func Example_customMarshalXML() {
8181
// * Gophers: 3
8282
// * Zebras: 2
8383
// * Unknown: 3
84-
}
84+
}

xml/example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,4 @@ func ExampleUnmarshal() {
148148
// Email: [{home gre@example.com} {work gre@work.com}]
149149
// Groups: [Friends Squash]
150150
// Address: {Hanga Roa Easter Island}
151-
}
151+
}

xml/example_test_marshaling_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ func Example_textMarshalXML() {
7676
// * Small: 3
7777
// * Large: 2
7878
// * Unrecognized: 3
79-
}
79+
}

xml/marshal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,4 +1059,4 @@ func isEmptyValue(v reflect.Value) bool {
10591059
return v.IsNil()
10601060
}
10611061
return false
1062-
}
1062+
}

xml/marshal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2529,4 +2529,4 @@ func TestMarshalZeroValue(t *testing.T) {
25292529
if string(anotherXML) != proofXml {
25302530
t.Fatalf("unexpected unmarshal result, want %q but got %q", proofXml, anotherXML)
25312531
}
2532-
}
2532+
}

xml/read.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (d *Decoder) Decode(v interface{}) error {
145145
// but also wants to defer to Unmarshal for some elements.
146146
func (d *Decoder) DecodeElement(v interface{}, start *StartElement) error {
147147
val := reflect.ValueOf(v)
148-
if val.Kind() != reflect.Pointer {
148+
if val.Kind() != reflect.Ptr {
149149
return errors.New("non-pointer passed to Unmarshal")
150150
}
151151

@@ -768,4 +768,4 @@ func (d *Decoder) Skip() error {
768768
depth--
769769
}
770770
}
771-
}
771+
}

xml/read_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,4 +1125,4 @@ func TestCVE202228131(t *testing.T) {
11251125
} else if !errors.Is(err, errExeceededMaxUnmarshalDepth) {
11261126
t.Fatalf("Unmarshal unexpected error: got %q, want %q", err, errExeceededMaxUnmarshalDepth)
11271127
}
1128-
}
1128+
}

xml/typeinfo.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ func structFieldInfo(typ reflect.Type, f *reflect.StructField) (*fieldInfo, erro
115115

116116
// Split the tag from the xml namespace if necessary.
117117
tag := f.Tag.Get("xml")
118-
if ns, t, ok := strings.Cut(tag, " "); ok {
119-
finfo.xmlns, tag = ns, t
118+
if i := strings.Index(tag, " "); i >= 0 {
119+
finfo.xmlns, tag = tag[:i], tag[i+1:]
120120
}
121121

122122
// Parse flags.
@@ -229,7 +229,7 @@ func structFieldInfo(typ reflect.Type, f *reflect.StructField) (*fieldInfo, erro
229229
// in case it exists and has a valid xml field tag, otherwise
230230
// it returns nil.
231231
func lookupXMLName(typ reflect.Type) (xmlname *fieldInfo) {
232-
for typ.Kind() == reflect.Pointer {
232+
for typ.Kind() == reflect.Ptr {
233233
typ = typ.Elem()
234234
}
235235
if typ.Kind() != reflect.Struct {
@@ -371,4 +371,4 @@ func (finfo *fieldInfo) value(v reflect.Value, shouldInitNilPointers bool) refle
371371
v = v.Field(x)
372372
}
373373
return v
374-
}
374+
}

0 commit comments

Comments
 (0)