diff options
Diffstat (limited to 'lib/http')
| -rw-r--r-- | lib/http/form.go | 8 | ||||
| -rw-r--r-- | lib/http/range_example_test.go | 28 | ||||
| -rw-r--r-- | lib/http/range_position_test.go | 6 |
3 files changed, 19 insertions, 23 deletions
diff --git a/lib/http/form.go b/lib/http/form.go index e746b403..cfc77b1b 100644 --- a/lib/http/form.go +++ b/lib/http/form.go @@ -34,7 +34,7 @@ func MarshalForm(in any) (out url.Values, err error) { x int ) - if inKind == reflect.Ptr { + if inKind == reflect.Pointer { inType = inType.Elem() inKind = inType.Kind() } @@ -166,7 +166,7 @@ func UnmarshalForm(in url.Values, out any) (err error) { hasTag bool ) - if rkind != reflect.Ptr { + if rkind != reflect.Pointer { return fmt.Errorf("%s: expecting *T got %T", logp, out) } @@ -177,7 +177,7 @@ func UnmarshalForm(in url.Values, out any) (err error) { vout = vout.Elem() rtype = rtype.Elem() rkind = rtype.Kind() - if rkind == reflect.Ptr { + if rkind == reflect.Pointer { rtype = rtype.Elem() rkind = rtype.Kind() if rkind != reflect.Struct { @@ -232,7 +232,7 @@ func UnmarshalForm(in url.Values, out any) (err error) { rtype = fval.Type() rkind = fval.Kind() - if rkind == reflect.Ptr { + if rkind == reflect.Pointer { // F *T rtype = rtype.Elem() // T <= *T rkind = rtype.Kind() diff --git a/lib/http/range_example_test.go b/lib/http/range_example_test.go index 0f53b9b7..80c6e15f 100644 --- a/lib/http/range_example_test.go +++ b/lib/http/range_example_test.go @@ -106,27 +106,25 @@ func ExampleParseRange() { // bytes=0-9,10-19,-20 } -func ptrInt64(v int64) *int64 { return &v } - func ExampleRange_Add() { var listpos = []struct { start *int64 end *int64 }{ - {ptrInt64(0), ptrInt64(9)}, // OK. - {ptrInt64(0), ptrInt64(5)}, // Overlap with [0,9]. - {ptrInt64(9), ptrInt64(19)}, // Overlap with [0,9]. + {new(int64(0)), new(int64(9))}, // OK. + {new(int64(0)), new(int64(5))}, // Overlap with [0,9]. + {new(int64(9)), new(int64(19))}, // Overlap with [0,9]. - {ptrInt64(10), ptrInt64(19)}, // OK. - {ptrInt64(19), ptrInt64(20)}, // Overlap with [10,19]. - {ptrInt64(20), ptrInt64(19)}, // End less than start. + {new(int64(10)), new(int64(19))}, // OK. + {new(int64(19)), new(int64(20))}, // Overlap with [10,19]. + {new(int64(20)), new(int64(19))}, // End less than start. - {nil, ptrInt64(10)}, // OK. - {nil, ptrInt64(20)}, // Overlap with [nil,10]. + {nil, new(int64(10))}, // OK. + {nil, new(int64(20))}, // Overlap with [nil,10]. - {ptrInt64(20), nil}, // Overlap with [nil,10]. - {ptrInt64(30), ptrInt64(40)}, // Overlap with [20,nil]. - {ptrInt64(30), nil}, // Overlap with [20,nil]. + {new(int64(20)), nil}, // Overlap with [nil,10]. + {new(int64(30)), new(int64(40))}, // Overlap with [20,nil]. + {new(int64(30)), nil}, // Overlap with [20,nil]. } var r = libhttp.NewRange(``) @@ -153,7 +151,7 @@ func ExampleRange_Positions() { var r = libhttp.NewRange(``) fmt.Println(r.Positions()) // Empty positions. - r.Add(ptrInt64(10), ptrInt64(20)) + r.Add(new(int64(10)), new(int64(20))) fmt.Println(r.Positions()) // Output: // [] @@ -165,7 +163,7 @@ func ExampleRange_String() { fmt.Println(r.String()) // Empty range will return empty string. - r.Add(ptrInt64(0), ptrInt64(9)) + r.Add(new(int64(0)), new(int64(9))) fmt.Println(r.String()) // Output: // diff --git a/lib/http/range_position_test.go b/lib/http/range_position_test.go index 8fc2afd4..83f08358 100644 --- a/lib/http/range_position_test.go +++ b/lib/http/range_position_test.go @@ -54,14 +54,12 @@ func TestParseContentRange(t *testing.T) { } } -func ptrInt64(v int64) *int64 { return &v } - func TestRangePositionContentRange(t *testing.T) { var ( unit = AcceptRangesBytes pos = RangePosition{ - start: ptrInt64(10), - end: ptrInt64(20), + start: new(int64(10)), + end: new(int64(20)), } ) |
