internal: fix staticcheck warnings (#20380)

This commit is contained in:
Guillaume Ballet 2019-11-29 11:40:02 +01:00 committed by Felix Lange
parent 1ff3d7c2d4
commit e0bf5f0ccb
3 changed files with 27 additions and 14 deletions

View File

@ -127,12 +127,12 @@ func (tt *TestCmd) matchExactOutput(want []byte) error {
// Find the mismatch position. // Find the mismatch position.
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
if want[i] != buf[i] { if want[i] != buf[i] {
return fmt.Errorf("Output mismatch at ◊:\n---------------- (stdout text)\n%s◊%s\n---------------- (expected text)\n%s", return fmt.Errorf("output mismatch at ◊:\n---------------- (stdout text)\n%s◊%s\n---------------- (expected text)\n%s",
buf[:i], buf[i:n], want) buf[:i], buf[i:n], want)
} }
} }
if n < len(want) { if n < len(want) {
return fmt.Errorf("Not enough output, got until ◊:\n---------------- (stdout text)\n%s\n---------------- (expected text)\n%s◊%s", return fmt.Errorf("not enough output, got until ◊:\n---------------- (stdout text)\n%s\n---------------- (expected text)\n%s◊%s",
buf, want[:n], want[n:]) buf, want[:n], want[n:])
} }
} }

View File

@ -486,7 +486,7 @@ func (s *PrivateAccountAPI) InitializeWallet(ctx context.Context, url string) (s
case *scwallet.Wallet: case *scwallet.Wallet:
return mnemonic, wallet.Initialize(seed) return mnemonic, wallet.Initialize(seed)
default: default:
return "", fmt.Errorf("Specified wallet does not support initialization") return "", fmt.Errorf("specified wallet does not support initialization")
} }
} }
@ -501,7 +501,7 @@ func (s *PrivateAccountAPI) Unpair(ctx context.Context, url string, pin string)
case *scwallet.Wallet: case *scwallet.Wallet:
return wallet.Unpair([]byte(pin)) return wallet.Unpair([]byte(pin))
default: default:
return fmt.Errorf("Specified wallet does not support pairing") return fmt.Errorf("specified wallet does not support pairing")
} }
} }
@ -1389,7 +1389,7 @@ func (args *SendTxArgs) setDefaults(ctx context.Context, b Backend) error {
args.Nonce = (*hexutil.Uint64)(&nonce) args.Nonce = (*hexutil.Uint64)(&nonce)
} }
if args.Data != nil && args.Input != nil && !bytes.Equal(*args.Data, *args.Input) { if args.Data != nil && args.Input != nil && !bytes.Equal(*args.Data, *args.Input) {
return errors.New(`Both "data" and "input" are set and not equal. Please use "input" to pass transaction call data.`) return errors.New(`both "data" and "input" are set and not equal. Please use "input" to pass transaction call data`)
} }
if args.To == nil { if args.To == nil {
// Contract creation // Contract creation
@ -1645,7 +1645,7 @@ func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, sendArgs SendTxAr
} }
} }
return common.Hash{}, fmt.Errorf("Transaction %#x not found", matchTx.Hash()) return common.Hash{}, fmt.Errorf("transaction %#x not found", matchTx.Hash())
} }
// PublicDebugAPI is the collection of Ethereum APIs exposed over the public // PublicDebugAPI is the collection of Ethereum APIs exposed over the public

View File

@ -1,8 +1,7 @@
// Code generated by go-bindata. DO NOT EDIT. // Package deps Code generated by go-bindata. (@generated) DO NOT EDIT.
// sources: // sources:
// bignumber.js // bignumber.js
// web3.js // web3.js
package deps package deps
import ( import (
@ -20,7 +19,7 @@ import (
func bindataRead(data []byte, name string) ([]byte, error) { func bindataRead(data []byte, name string) ([]byte, error) {
gz, err := gzip.NewReader(bytes.NewBuffer(data)) gz, err := gzip.NewReader(bytes.NewBuffer(data))
if err != nil { if err != nil {
return nil, fmt.Errorf("Read %q: %v", name, err) return nil, fmt.Errorf("read %q: %v", name, err)
} }
var buf bytes.Buffer var buf bytes.Buffer
@ -28,7 +27,7 @@ func bindataRead(data []byte, name string) ([]byte, error) {
clErr := gz.Close() clErr := gz.Close()
if err != nil { if err != nil {
return nil, fmt.Errorf("Read %q: %v", name, err) return nil, fmt.Errorf("read %q: %v", name, err)
} }
if clErr != nil { if clErr != nil {
return nil, err return nil, err
@ -49,21 +48,32 @@ type bindataFileInfo struct {
modTime time.Time modTime time.Time
} }
// Name return file name
func (fi bindataFileInfo) Name() string { func (fi bindataFileInfo) Name() string {
return fi.name return fi.name
} }
// Size return file size
func (fi bindataFileInfo) Size() int64 { func (fi bindataFileInfo) Size() int64 {
return fi.size return fi.size
} }
// Mode return file mode
func (fi bindataFileInfo) Mode() os.FileMode { func (fi bindataFileInfo) Mode() os.FileMode {
return fi.mode return fi.mode
} }
// ModTime return file modify time
func (fi bindataFileInfo) ModTime() time.Time { func (fi bindataFileInfo) ModTime() time.Time {
return fi.modTime return fi.modTime
} }
// IsDir return file whether a directory
func (fi bindataFileInfo) IsDir() bool { func (fi bindataFileInfo) IsDir() bool {
return false return fi.mode&os.ModeDir != 0
} }
// Sys return file is sys mode
func (fi bindataFileInfo) Sys() interface{} { func (fi bindataFileInfo) Sys() interface{} {
return nil return nil
} }
@ -161,7 +171,6 @@ func AssetNames() []string {
// _bindata is a table, holding each asset generator, mapped to its name. // _bindata is a table, holding each asset generator, mapped to its name.
var _bindata = map[string]func() (*asset, error){ var _bindata = map[string]func() (*asset, error){
"bignumber.js": bignumberJs, "bignumber.js": bignumberJs,
"web3.js": web3Js, "web3.js": web3Js,
} }
@ -228,7 +237,11 @@ func RestoreAsset(dir, name string) error {
if err != nil { if err != nil {
return err return err
} }
return os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
if err != nil {
return err
}
return nil
} }
// RestoreAssets restores an asset under the given directory recursively // RestoreAssets restores an asset under the given directory recursively