Skip to content

Commit 5fe2690

Browse files
committed
chore: fix linter errors
1 parent 697fd3e commit 5fe2690

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
lines changed

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ issues:
2424
# gosec
2525
- "^G101: Potential hardcoded credentials"
2626
- "^G108: Profiling endpoint is automatically exposed on /debug/pprof"
27+
- "^G115: integer overflow conversion u?int(8|32|64)? -> u?int(8|32|64)?"
2728
- "^G204: Subprocess launched with (variable|a potential tainted input or cmd arguments)"
2829
- "^G301: Expect directory permissions to be 0750 or less"
2930
- "^G302: Expect file permissions to be 0600 or less"
@@ -47,6 +48,7 @@ issues:
4748
- "^var-naming: (method|range var) \\w*(Api|Http|Id|Rpc|Url)[^\\s]* should be \\w*(API|HTTP|ID|RPC|URL)"
4849
- "^var-naming: don't use underscores in Go names"
4950
- "^var-naming: don't use ALL_CAPS in Go names; use CamelCase"
51+
- "^redefines-builtin-id: redefinition of the built-in (function|type) (max|min|cap|recover|new|error)"
5052

5153
exclude-use-default: false
5254
exclude-rules:

api/api_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,21 @@ import (
1616
"github.com/filecoin-project/go-jsonrpc"
1717
)
1818

19+
func goRoot() (string, error) {
20+
out, err := exec.Command("go", "env", "GOROOT").Output()
21+
if err != nil {
22+
return "", err
23+
}
24+
return strings.TrimSpace(string(out)), nil
25+
}
26+
1927
func goCmd() string {
2028
var exeSuffix string
2129
if runtime.GOOS == "windows" {
2230
exeSuffix = ".exe"
2331
}
24-
path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix)
32+
root, _ := goRoot()
33+
path := filepath.Join(root, "bin", "go"+exeSuffix)
2534
if _, err := os.Stat(path); err == nil {
2635
return path
2736
}

chain/types/ethtypes/rlp.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,16 @@ func encodeRLP(val interface{}) ([]byte, error) {
6060
} else if len(data) <= 55 {
6161
prefix := byte(0x80 + len(data))
6262
return append([]byte{prefix}, data...), nil
63-
} else {
64-
lenInBytes, err := encodeLength(len(data))
65-
if err != nil {
66-
return nil, err
67-
}
68-
prefix := byte(0xb7 + len(lenInBytes))
69-
return append(
70-
[]byte{prefix},
71-
append(lenInBytes, data...)...,
72-
), nil
7363
}
64+
lenInBytes, err := encodeLength(len(data))
65+
if err != nil {
66+
return nil, err
67+
}
68+
prefix := byte(0xb7 + len(lenInBytes))
69+
return append(
70+
[]byte{prefix},
71+
append(lenInBytes, data...)...,
72+
), nil
7473
case []interface{}:
7574
encodedList, err := encodeRLPListItems(data)
7675
if err != nil {

node/config/dep_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,21 @@ import (
99
"testing"
1010
)
1111

12+
func goRoot() (string, error) {
13+
out, err := exec.Command("go", "env", "GOROOT").Output()
14+
if err != nil {
15+
return "", err
16+
}
17+
return strings.TrimSpace(string(out)), nil
18+
}
19+
1220
func goCmd() string {
1321
var exeSuffix string
1422
if runtime.GOOS == "windows" {
1523
exeSuffix = ".exe"
1624
}
17-
path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix)
25+
root, _ := goRoot()
26+
path := filepath.Join(root, "bin", "go"+exeSuffix)
1827
if _, err := os.Stat(path); err == nil {
1928
return path
2029
}

0 commit comments

Comments
 (0)