Skip to content

Commit 85aeba9

Browse files
chore(internal): use explicit returns in more places
1 parent 6c2484b commit 85aeba9

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

internal/apiform/encoder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,5 +469,5 @@ func WriteExtras(writer *multipart.Writer, extras map[string]any) (err error) {
469469
break
470470
}
471471
}
472-
return
472+
return err
473473
}

internal/apiform/tag.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func parseFormStructTag(field reflect.StructField) (tag parsedStructTag, ok bool
2424
raw, ok = field.Tag.Lookup(jsonStructTag)
2525
}
2626
if !ok {
27-
return
27+
return tag, ok
2828
}
2929
parts := strings.Split(raw, ",")
3030
if len(parts) == 0 {
@@ -45,7 +45,7 @@ func parseFormStructTag(field reflect.StructField) (tag parsedStructTag, ok bool
4545
}
4646

4747
parseApiStructTag(field, &tag)
48-
return
48+
return tag, ok
4949
}
5050

5151
func parseApiStructTag(field reflect.StructField, tag *parsedStructTag) {
@@ -68,5 +68,5 @@ func parseApiStructTag(field reflect.StructField, tag *parsedStructTag) {
6868

6969
func parseFormatStructTag(field reflect.StructField) (format string, ok bool) {
7070
format, ok = field.Tag.Lookup(formatStructTag)
71-
return
71+
return format, ok
7272
}

internal/apijson/encoder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ func (e *encoder) newStructTypeEncoder(t reflect.Type) encoderFunc {
286286
return nil, err
287287
}
288288
}
289-
return
289+
return json, err
290290
}
291291
}
292292

internal/apijson/json_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ type MarshallingUnionStruct struct {
268268
func (r *MarshallingUnionStruct) UnmarshalJSON(data []byte) (err error) {
269269
*r = MarshallingUnionStruct{}
270270
err = UnmarshalRoot(data, &r.Union)
271-
return
271+
return err
272272
}
273273

274274
func (r MarshallingUnionStruct) MarshalJSON() (data []byte, err error) {

internal/apijson/tag.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type parsedStructTag struct {
2020
func parseJSONStructTag(field reflect.StructField) (tag parsedStructTag, ok bool) {
2121
raw, ok := field.Tag.Lookup(jsonStructTag)
2222
if !ok {
23-
return
23+
return tag, ok
2424
}
2525
parts := strings.Split(raw, ",")
2626
if len(parts) == 0 {
@@ -42,7 +42,7 @@ func parseJSONStructTag(field reflect.StructField) (tag parsedStructTag, ok bool
4242

4343
// the `api` struct tag is only used alongside `json` for custom behaviour
4444
parseApiStructTag(field, &tag)
45-
return
45+
return tag, ok
4646
}
4747

4848
func parseApiStructTag(field reflect.StructField, tag *parsedStructTag) {
@@ -65,5 +65,5 @@ func parseApiStructTag(field reflect.StructField, tag *parsedStructTag) {
6565

6666
func parseFormatStructTag(field reflect.StructField) (format string, ok bool) {
6767
format, ok = field.Tag.Lookup(formatStructTag)
68-
return
68+
return format, ok
6969
}

internal/apiquery/encoder.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (e *encoder) newTypeEncoder(t reflect.Type) encoderFunc {
103103
encoder := e.typeEncoder(t.Elem())
104104
return func(key string, value reflect.Value) (pairs []Pair, err error) {
105105
if !value.IsValid() || value.IsNil() {
106-
return
106+
return pairs, err
107107
}
108108
return encoder(key, value.Elem())
109109
}
@@ -205,7 +205,7 @@ func (e *encoder) newStructTypeEncoder(t reflect.Type) encoderFunc {
205205
}
206206
pairs = append(pairs, subpairs...)
207207
}
208-
return
208+
return pairs, err
209209
}
210210
}
211211

@@ -256,7 +256,7 @@ func (e *encoder) newMapEncoder(t reflect.Type) encoderFunc {
256256
}
257257
pairs = append(pairs, subpairs...)
258258
}
259-
return
259+
return pairs, err
260260
}
261261
}
262262

@@ -300,7 +300,7 @@ func (e *encoder) newArrayTypeEncoder(t reflect.Type) encoderFunc {
300300
}
301301
pairs = append(pairs, subpairs...)
302302
}
303-
return
303+
return pairs, err
304304
}
305305
case ArrayQueryFormatIndices:
306306
panic("The array indices format is not supported yet")
@@ -315,7 +315,7 @@ func (e *encoder) newArrayTypeEncoder(t reflect.Type) encoderFunc {
315315
}
316316
pairs = append(pairs, subpairs...)
317317
}
318-
return
318+
return pairs, err
319319
}
320320
default:
321321
panic(fmt.Sprintf("Unknown ArrayFormat value: %d", e.settings.ArrayFormat))

internal/apiquery/tag.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type parsedStructTag struct {
1818
func parseQueryStructTag(field reflect.StructField) (tag parsedStructTag, ok bool) {
1919
raw, ok := field.Tag.Lookup(queryStructTag)
2020
if !ok {
21-
return
21+
return tag, ok
2222
}
2323
parts := strings.Split(raw, ",")
2424
if len(parts) == 0 {
@@ -35,10 +35,10 @@ func parseQueryStructTag(field reflect.StructField) (tag parsedStructTag, ok boo
3535
tag.inline = true
3636
}
3737
}
38-
return
38+
return tag, ok
3939
}
4040

4141
func parseFormatStructTag(field reflect.StructField) (format string, ok bool) {
4242
format, ok = field.Tag.Lookup(formatStructTag)
43-
return
43+
return format, ok
4444
}

0 commit comments

Comments
 (0)