chore: fix warnings (#3989)

This commit is contained in:
Kevin Wan
2024-03-08 22:35:17 +08:00
committed by GitHub
parent 69bb746a1d
commit 159ecb7386
32 changed files with 64 additions and 61 deletions

View File

@@ -12,7 +12,7 @@ const (
)
// Marshal marshals the given val and returns the map that contains the fields.
// optional=another is not implemented, and it's hard to implement and not common used.
// optional=another is not implemented, and it's hard to implement and not commonly used.
func Marshal(val any) (map[string]map[string]any, error) {
ret := make(map[string]map[string]any)
tp := reflect.TypeOf(val)

View File

@@ -39,7 +39,7 @@ var (
)
type (
// Unmarshaler is used to unmarshal with given tag key.
// Unmarshaler is used to unmarshal with the given tag key.
Unmarshaler struct {
key string
opts unmarshalOptions
@@ -69,7 +69,7 @@ func NewUnmarshaler(key string, opts ...UnmarshalOption) *Unmarshaler {
return &unmarshaler
}
// UnmarshalKey unmarshals m into v with tag key.
// UnmarshalKey unmarshals m into v with the tag key.
func UnmarshalKey(m map[string]any, v any) error {
return keyUnmarshaler.Unmarshal(m, v)
}
@@ -629,7 +629,7 @@ func (u *Unmarshaler) processFieldPrimitiveWithJSONNumber(fieldType reflect.Type
return err
}
// if value is a pointer, we need to check overflow with the pointer's value.
// if the value is a pointer, we need to check overflow with the pointer's value.
derefedValue := value
for derefedValue.Type().Kind() == reflect.Ptr {
derefedValue = derefedValue.Elem()

View File

@@ -5866,7 +5866,7 @@ type mockValuerWithParent struct {
ok bool
}
func (m mockValuerWithParent) Value(key string) (any, bool) {
func (m mockValuerWithParent) Value(_ string) (any, bool) {
return m.value, m.ok
}

View File

@@ -416,7 +416,7 @@ func parseOption(fieldOpts *fieldOptions, fieldName, option string) error {
}
// parseOptions parses the given options in tag.
// for example: `json:"name,options=foo|bar"` or `json:"name,options=[foo,bar]"`
// for example, `json:"name,options=foo|bar"` or `json:"name,options=[foo,bar]"`
func parseOptions(val string) []string {
if len(val) == 0 {
return nil

View File

@@ -26,9 +26,9 @@ type (
parent valuerWithParent
}
// mapValuer is a type for map to meet the Valuer interface.
// mapValuer is a type for the map to meet the Valuer interface.
mapValuer map[string]any
// simpleValuer is a type to get value from current node.
// simpleValuer is a type to get value from the current node.
simpleValuer node
// recursiveValuer is a type to get the value recursively from current and parent nodes.
recursiveValuer node