File tree Expand file tree Collapse file tree 4 files changed +31
-12
lines changed Expand file tree Collapse file tree 4 files changed +31
-12
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ issues:
24
24
# gosec
25
25
- " ^G101: Potential hardcoded credentials"
26
26
- " ^G108: Profiling endpoint is automatically exposed on /debug/pprof"
27
+ - " ^G115: integer overflow conversion u?int(8|32|64)? -> u?int(8|32|64)?"
27
28
- " ^G204: Subprocess launched with (variable|a potential tainted input or cmd arguments)"
28
29
- " ^G301: Expect directory permissions to be 0750 or less"
29
30
- " ^G302: Expect file permissions to be 0600 or less"
@@ -47,6 +48,7 @@ issues:
47
48
- " ^var-naming: (method|range var) \\ w*(Api|Http|Id|Rpc|Url)[^\\ s]* should be \\ w*(API|HTTP|ID|RPC|URL)"
48
49
- " ^var-naming: don't use underscores in Go names"
49
50
- " ^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)"
50
52
51
53
exclude-use-default : false
52
54
exclude-rules :
Original file line number Diff line number Diff line change @@ -16,12 +16,21 @@ import (
16
16
"github.com/filecoin-project/go-jsonrpc"
17
17
)
18
18
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
+
19
27
func goCmd () string {
20
28
var exeSuffix string
21
29
if runtime .GOOS == "windows" {
22
30
exeSuffix = ".exe"
23
31
}
24
- path := filepath .Join (runtime .GOROOT (), "bin" , "go" + exeSuffix )
32
+ root , _ := goRoot ()
33
+ path := filepath .Join (root , "bin" , "go" + exeSuffix )
25
34
if _ , err := os .Stat (path ); err == nil {
26
35
return path
27
36
}
Original file line number Diff line number Diff line change @@ -60,17 +60,16 @@ func encodeRLP(val interface{}) ([]byte, error) {
60
60
} else if len (data ) <= 55 {
61
61
prefix := byte (0x80 + len (data ))
62
62
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
73
63
}
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
74
73
case []interface {}:
75
74
encodedList , err := encodeRLPListItems (data )
76
75
if err != nil {
Original file line number Diff line number Diff line change @@ -9,12 +9,21 @@ import (
9
9
"testing"
10
10
)
11
11
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
+
12
20
func goCmd () string {
13
21
var exeSuffix string
14
22
if runtime .GOOS == "windows" {
15
23
exeSuffix = ".exe"
16
24
}
17
- path := filepath .Join (runtime .GOROOT (), "bin" , "go" + exeSuffix )
25
+ root , _ := goRoot ()
26
+ path := filepath .Join (root , "bin" , "go" + exeSuffix )
18
27
if _ , err := os .Stat (path ); err == nil {
19
28
return path
20
29
}
You can’t perform that action at this time.
0 commit comments