move internal/reflectunsafe into internal/bind

bind
Trim21 2022-08-31 23:26:23 +08:00
parent ffc1c41d4a
commit 9887ac5979
No known key found for this signature in database
GPG Key ID: A3F35EA8C368A6CE
4 changed files with 21 additions and 21 deletions

View File

@ -6,7 +6,7 @@ import (
"reflect"
"sync"
"github.com/gofiber/fiber/v3/internal/reflectunsafe"
"github.com/gofiber/fiber/v3/internal/bind"
"github.com/gofiber/fiber/v3/utils"
)
@ -165,7 +165,7 @@ func (b *Bind) Validate() *Bind {
}
func (b *Bind) reqDecode(v any) error {
rv, typeID := reflectunsafe.ValueAndTypeID(v)
rv, typeID := bind.ValueAndTypeID(v)
if rv.Kind() != reflect.Pointer || rv.IsNil() {
return &InvalidBinderError{Type: reflect.TypeOf(v)}
}
@ -187,7 +187,7 @@ func (b *Bind) reqDecode(v any) error {
}
func (b *Bind) formDecode(v any) error {
rv, typeID := reflectunsafe.ValueAndTypeID(v)
rv, typeID := bind.ValueAndTypeID(v)
if rv.Kind() != reflect.Pointer || rv.IsNil() {
return &InvalidBinderError{Type: reflect.TypeOf(v)}
}
@ -209,7 +209,7 @@ func (b *Bind) formDecode(v any) error {
}
func (b *Bind) multipartDecode(v any) error {
rv, typeID := reflectunsafe.ValueAndTypeID(v)
rv, typeID := bind.ValueAndTypeID(v)
if rv.Kind() != reflect.Pointer || rv.IsNil() {
return &InvalidBinderError{Type: reflect.TypeOf(v)}
}

View File

@ -1,4 +1,4 @@
package reflectunsafe
package bind
import (
"reflect"

View File

@ -0,0 +1,16 @@
package bind_test
import (
"testing"
"github.com/gofiber/fiber/v3/internal/bind"
"github.com/stretchr/testify/require"
)
func TestTypeID(t *testing.T) {
_, intType := bind.ValueAndTypeID(int(1))
_, uintType := bind.ValueAndTypeID(uint(1))
_, shouldBeIntType := bind.ValueAndTypeID(int(1))
require.NotEqual(t, intType, uintType)
require.Equal(t, intType, shouldBeIntType)
}

View File

@ -1,16 +0,0 @@
package reflectunsafe_test
import (
"testing"
"github.com/gofiber/fiber/v3/internal/reflectunsafe"
"github.com/stretchr/testify/require"
)
func TestTypeID(t *testing.T) {
_, intType := reflectunsafe.ValueAndTypeID(int(1))
_, uintType := reflectunsafe.ValueAndTypeID(uint(1))
_, shouldBeIntType := reflectunsafe.ValueAndTypeID(int(1))
require.NotEqual(t, intType, uintType)
require.Equal(t, intType, shouldBeIntType)
}