diff --git a/accounts/abi/method.go b/accounts/abi/method.go index b6e1eef3cf..f69e3ee9b5 100644 --- a/accounts/abi/method.go +++ b/accounts/abi/method.go @@ -127,12 +127,11 @@ func NewMethod(name string, rawName string, funType FunctionType, mutability str state = state + " " } identity := fmt.Sprintf("function %v", rawName) - switch funType { - case Fallback: + if funType == Fallback { identity = "fallback" - case Receive: + } else if funType == Receive { identity = "receive" - case Constructor: + } else if funType == Constructor { identity = "constructor" } str := fmt.Sprintf("%v(%v) %sreturns(%v)", identity, strings.Join(inputNames, ", "), state, strings.Join(outputNames, ", ")) diff --git a/accounts/abi/method_test.go b/accounts/abi/method_test.go index 9230e307aa..395a528965 100644 --- a/accounts/abi/method_test.go +++ b/accounts/abi/method_test.go @@ -84,12 +84,11 @@ func TestMethodString(t *testing.T) { for _, test := range table { var got string - switch test.method { - case "fallback": + if test.method == "fallback" { got = abi.Fallback.String() - case "receive": + } else if test.method == "receive" { got = abi.Receive.String() - default: + } else { got = abi.Methods[test.method].String() } if got != test.expectation { diff --git a/accounts/abi/unpack.go b/accounts/abi/unpack.go index 905b5ce629..68451483cd 100644 --- a/accounts/abi/unpack.go +++ b/accounts/abi/unpack.go @@ -160,14 +160,13 @@ func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error) // this value will become our slice or our array, depending on the type var refSlice reflect.Value - switch t.T { - case SliceTy: + if t.T == SliceTy { // declare our slice refSlice = reflect.MakeSlice(t.GetType(), size, size) - case ArrayTy: + } else if t.T == ArrayTy { // declare our array refSlice = reflect.New(t.GetType()).Elem() - default: + } else { return nil, errors.New("abi: invalid type in array/slice unpacking stage") }