mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
accounts/abi: fix some go-critic linter warnings (#23709)
This commit is contained in:
parent
2af78feca0
commit
46a16f9149
1 changed files with 10 additions and 15 deletions
|
|
@ -28,11 +28,13 @@ import (
|
||||||
// given type
|
// given type
|
||||||
// e.g. turn
|
// e.g. turn
|
||||||
// var fields []reflect.StructField
|
// var fields []reflect.StructField
|
||||||
// fields = append(fields, reflect.StructField{
|
//
|
||||||
// Name: "X",
|
// fields = append(fields, reflect.StructField{
|
||||||
// Type: reflect.TypeOf(new(big.Int)),
|
// Name: "X",
|
||||||
// Tag: reflect.StructTag("json:\"" + "x" + "\""),
|
// Type: reflect.TypeOf(new(big.Int)),
|
||||||
// }
|
// Tag: reflect.StructTag("json:\"" + "x" + "\""),
|
||||||
|
// }
|
||||||
|
//
|
||||||
// into
|
// into
|
||||||
// type TupleT struct { X *big.Int }
|
// type TupleT struct { X *big.Int }
|
||||||
func ConvertType(in interface{}, proto interface{}) interface{} {
|
func ConvertType(in interface{}, proto interface{}) interface{} {
|
||||||
|
|
@ -123,22 +125,15 @@ func set(dst, src reflect.Value) error {
|
||||||
func setSlice(dst, src reflect.Value) error {
|
func setSlice(dst, src reflect.Value) error {
|
||||||
slice := reflect.MakeSlice(dst.Type(), src.Len(), src.Len())
|
slice := reflect.MakeSlice(dst.Type(), src.Len(), src.Len())
|
||||||
for i := 0; i < src.Len(); i++ {
|
for i := 0; i < src.Len(); i++ {
|
||||||
if src.Index(i).Kind() == reflect.Struct {
|
if err := set(slice.Index(i), src.Index(i)); err != nil {
|
||||||
if err := set(slice.Index(i), src.Index(i)); err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// e.g. [][32]uint8 to []common.Hash
|
|
||||||
if err := set(slice.Index(i), src.Index(i)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if dst.CanSet() {
|
if dst.CanSet() {
|
||||||
dst.Set(slice)
|
dst.Set(slice)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errors.New("Cannot set slice, destination not settable")
|
return errors.New("cannot set slice, destination not settable")
|
||||||
}
|
}
|
||||||
|
|
||||||
func setArray(dst, src reflect.Value) error {
|
func setArray(dst, src reflect.Value) error {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue