Merge e7086fbd9dc8308826d71f5084ec1046ad2794e2 into 0f09c3a9b4626d9fe9979cf4d0521d6ae32ab646

This commit is contained in:
Name 2026-10-28 17:03:37 +00:00 committed by GitHub
commit 0bacb93b6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 14 additions and 14 deletions

View File

@ -713,7 +713,7 @@ func TestBindingFormMultipartForMapFail(t *testing.T) {
func TestBindingProtoBuf(t *testing.T) {
test := &protoexample.Test{
Label: proto.String("yes"),
Label: new("yes"),
}
data, _ := proto.Marshal(test)
@ -725,7 +725,7 @@ func TestBindingProtoBuf(t *testing.T) {
func TestBindingProtoBufFail(t *testing.T) {
test := &protoexample.Test{
Label: proto.String("yes"),
Label: new("yes"),
}
data, _ := proto.Marshal(test)

View File

@ -51,7 +51,7 @@ func (v *defaultValidator) ValidateStruct(obj any) error {
value := reflect.ValueOf(obj)
switch value.Kind() {
case reflect.Ptr:
case reflect.Pointer:
if value.Elem().Kind() != reflect.Struct {
return v.ValidateStruct(value.Elem().Interface())
}

View File

@ -13,7 +13,7 @@ import (
func BenchmarkSliceValidationError(b *testing.B) {
const size int = 100
e := make(SliceValidationError, size)
for j := 0; j < size; j++ {
for j := range size {
e[j] = errors.New(strconv.Itoa(j))
}

View File

@ -47,7 +47,7 @@ func mapFormByTag(ptr any, form map[string][]string, tag string) error {
// Check if ptr is a map
ptrVal := reflect.ValueOf(ptr)
var pointed any
if ptrVal.Kind() == reflect.Ptr {
if ptrVal.Kind() == reflect.Pointer {
ptrVal = ptrVal.Elem()
pointed = ptrVal.Interface()
}
@ -88,7 +88,7 @@ func mapping(value reflect.Value, field reflect.StructField, setter setter, tag
vKind := value.Kind()
if vKind == reflect.Ptr {
if vKind == reflect.Pointer {
var isNew bool
vPtr := value
if value.IsNil() {
@ -376,7 +376,7 @@ func setWithProperType(val string, value reflect.Value, field reflect.StructFiel
return json.API.Unmarshal(bytesconv.StringToBytes(val), value.Addr().Interface())
case reflect.Map:
return json.API.Unmarshal(bytesconv.StringToBytes(val), value.Addr().Interface())
case reflect.Ptr:
case reflect.Pointer:
if !value.Elem().IsValid() {
value.Set(reflect.New(value.Type().Elem()))
}

View File

@ -34,7 +34,7 @@ func (r *multipartRequest) TrySet(value reflect.Value, field reflect.StructField
func setByMultipartFormFile(value reflect.Value, field reflect.StructField, files []*multipart.FileHeader) (isSet bool, err error) {
switch value.Kind() {
case reflect.Ptr:
case reflect.Pointer:
switch value.Interface().(type) {
case *multipart.FileHeader:
value.Set(reflect.ValueOf(files[0]))

View File

@ -35,7 +35,7 @@ func decodePlain(data []byte, obj any) error {
v := reflect.ValueOf(obj)
for v.Kind() == reflect.Ptr {
for v.Kind() == reflect.Pointer {
if v.IsNil() {
return nil
}

View File

@ -715,13 +715,13 @@ func TestCopyConcurrentWithSet(t *testing.T) {
wg.Add(2)
go func() {
defer wg.Done()
for i := 0; i < 100; i++ {
for i := range 100 {
c.Set(i, i)
}
}()
go func() {
defer wg.Done()
for i := 0; i < 100; i++ {
for range 100 {
cp := c.Copy()
for k, v := range cp.Keys {
if k != v {

View File

@ -160,7 +160,7 @@ func readNthLine(file string, n int) (string, error) {
defer f.Close()
scanner := bufio.NewScanner(f)
for i := 0; i < n; i++ {
for range n {
if !scanner.Scan() {
return "", nil
}

View File

@ -41,7 +41,7 @@ func waitForServerReady(url string, maxAttempts int) error {
Timeout: 100 * time.Millisecond,
}
for i := 0; i < maxAttempts; i++ {
for i := range maxAttempts {
resp, err := client.Get(url)
if err == nil {
resp.Body.Close()

View File

@ -29,7 +29,7 @@ const localhostIPv6 = "::1"
// It panics if val is a pointer; pass the struct value directly (e.g., gin.Bind(Struct{}) not gin.Bind(&Struct{})).
func Bind(val any) HandlerFunc {
value := reflect.ValueOf(val)
if value.Kind() == reflect.Ptr {
if value.Kind() == reflect.Pointer {
panic(`Bind struct can not be a pointer. Example:
Use: gin.Bind(Struct{}) instead of gin.Bind(&Struct{})
`)