-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
goanalysis_metalinter: SA9002: runtime error: index out of range [2] with length 1 #1730
Closed
3 tasks done
Labels
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
Hello, It's an issue with https://github.com/dominikh/go-tools, you can open an issue in the repo. The issue is related to the rule SA9002 $ staticcheck --checks="SA9002" .
panic: runtime error: index out of range [2] with length 1
goroutine 360 [running]:
honnef.co/go/tools/staticcheck.CheckNonOctalFileMode.func1(0x9df540, 0xc0020e7180)
/home/ldez/sources/go/src/honnef.co/go/tools/staticcheck/lint.go:2928 +0x7b5
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder(0xc000ba2500, 0xc000318dd8, 0x1, 0x1, 0xc000064de8)
/home/ldez/sources/go/pkg/mod/golang.org/x/[email protected]/go/ast/inspector/inspector.go:77 +0xa2
honnef.co/go/tools/analysis/code.Preorder(...)
/home/ldez/sources/go/src/honnef.co/go/tools/analysis/code/visit.go:16
honnef.co/go/tools/staticcheck.CheckNonOctalFileMode(0xc001658f70, 0x20996c8c, 0xc4b100, 0xc001658ee8, 0x0)
/home/ldez/sources/go/src/honnef.co/go/tools/staticcheck/lint.go:2947 +0xcc
honnef.co/go/tools/lintcmd/runner.(*analyzerRunner).do(0xc001a7aa50, 0x9ea7e0, 0xc0004e5400, 0x0, 0x0)
/home/ldez/sources/go/src/honnef.co/go/tools/lintcmd/runner/runner.go:938 +0x61e
honnef.co/go/tools/lintcmd/runner.genericHandle(0x9ea7e0, 0xc0004e5400, 0x9ea7e0, 0xc0004d8000, 0xc000c6b4a0, 0xc0002ca0b8, 0xc000d17120)
/home/ldez/sources/go/src/honnef.co/go/tools/lintcmd/runner/runner.go:763 +0x18b
created by honnef.co/go/tools/lintcmd/runner.(*subrunner).runAnalyzers
/home/ldez/sources/go/src/honnef.co/go/tools/lintcmd/runner/runner.go:1004 +0x5ca As a workaround, you can do that: diff --git i/file.go w/file.go
index fe01944..d147db4 100644
--- i/file.go
+++ w/file.go
@@ -152,7 +152,8 @@ func (w *FileWriter) Rotate() (err error) {
func (w *FileWriter) rotate() (err error) {
var file *os.File
- file, err = os.OpenFile(w.fileargs(timeNow()))
+ args, flag, perm := w.fileargs(timeNow())
+ file, err = os.OpenFile(args, flag, perm)
if err != nil {
return err
}
@@ -216,7 +217,8 @@ func (w *FileWriter) rotate() (err error) {
}
func (w *FileWriter) create() (err error) {
- w.file, err = os.OpenFile(w.fileargs(timeNow()))
+ args, flag, perm := w.fileargs(timeNow())
+ w.file, err = os.OpenFile(args, flag, perm)
if err != nil {
return err
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for creating the issue!
Please include the following information:
Version of golangci-lint
Config file
Go environment
Verbose output of running
I'm trying to add
golangci-lint
to the open-source Go project phuslu/log but the linter returns a runtime error.The author of the project @phuslu was trying to run
golangci-lint
on GitHub Actions and the job failed as well, as shown by the job logs here.The text was updated successfully, but these errors were encountered: