Skip to content
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

Panic: gci #1291

Closed
3 tasks
sergey-kurenkov opened this issue Aug 3, 2020 · 4 comments · Fixed by #1292
Closed
3 tasks

Panic: gci #1291

sergey-kurenkov opened this issue Aug 3, 2020 · 4 comments · Fixed by #1292
Assignees
Labels
bug Something isn't working

Comments

@sergey-kurenkov
Copy link

Thank you for creating the issue!

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).

Please include the following information:

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.30.0 built from 45b90f6 on 2020-08-03T03:10:34Z
Config file
$ cat .golangci.yml
linters:
  enable:
    - bodyclose
    - rowserrcheck
    - gosec
    - interfacer
    - unconvert
    - goconst
    - asciicheck
    - misspell
    - unparam
    - prealloc
    - gochecknoinits
    - nakedret
    - maligned
    - gochecknoglobals
    - gofmt
    - dogsled 
    - lll
    - goerr113
    - gomnd
    - gofumpt
    - nestif
    - noctx
    - nolintlint
    - whitespace
    - funlen
    - exportloopref
    - gocritic
    - stylecheck
    - gocognit
    - gocyclo
    - goprintffuncname
    - nolintlint
    - dupl
    - exhaustive
    - gci

run:
  timeout: 5m

issues:
  new-from-rev: b51c535224e29755c50b359328956a418e4d4a1c
  exclude:
    - "ST1006: receiver name should be a reflection of its identity"
    - "ST1003: should not use underscores in package name"

  exclude-rules:
    # Exclude some linters from running on tests files.
    - path: _test\.go
      linters:
        - funlen

linters-settings:
  lll:
    # max line length, lines longer will be reported. Default is 120.
    # '\t' is counted as 1 character by default, and can be changed with the tab-width option
    line-length: 120
    # tab width in spaces. Default to 1.
    tab-width: 2
  dupl:
    threshold: 100%
Go environment
$ go version && go env
$ go version && go env
go version go1.13.4 darwin/amd64
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/sergey.kurenkov/Library/Caches/go-build"
GOENV="/Users/sergey.kurenkov/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/sergey.kurenkov/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/8k/wmd646w54nb94_rfs6l1rn312bkjmr/T/go-build195806320=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/sergey.kurenkov/go/src/gitlab.mobbtech.com/marginal-portfolio/app /Users/sergey.kurenkov/go/src/gitlab.mobbtech.com/marginal-portfolio /Users/sergey.kurenkov/go/src/gitlab.mobbtech.com /Users/sergey.kurenkov/go/src /Users/sergey.kurenkov/go /Users/sergey.kurenkov /Users /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 44 linters: [asciicheck bodyclose deadcode dogsled dupl errcheck exhaustive exportloopref funlen gci gochecknoglobals gochecknoinits gocognit goconst gocritic gocyclo goerr113 gofmt gofumpt gomnd goprintffuncname gosec gosimple govet ineffassign interfacer lll maligned misspell nakedret nestif noctx nolintlint prealloc rowserrcheck staticcheck structcheck stylecheck typecheck unconvert unparam unused varcheck whitespace] 
INFO [loader] Go packages loading at mode 575 (deps|name|types_sizes|compiled_files|exports_file|files|imports) took 8.211366681s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 831.665441ms 
INFO [linters context/goanalysis] analyzers took 1h37m37.654536396s with top 10 stages: gofumpt: 7m22.965417776s, whitespace: 7m20.476889168s, dupl: 7m18.212155365s, gosec: 7m4.846878555s, buildir: 4m17.471566839s, ineffassign: 2m59.32456763s, buildssa: 2m42.321130329s, gofmt: 2m42.253938558s, gocritic: 2m25.990633162s, mnd: 2m20.023761981s 
WARN [linters context] Panic: gci: package "marginal_portfolio" (isInitialPkg: true, needAnalyzeSource: true): runtime error: index out of range [10] with length 10: goroutine 62266 [running]:
runtime/debug.Stack(0x1d0197e, 0x3c, 0xc0025b75e0)
	/opt/hostedtoolcache/go/1.14.6/x64/src/runtime/debug/stack.go:24 +0x9d
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1(0xc00556fe70)
	/home/runner/work/golangci-lint/golangci-lint/pkg/golinters/goanalysis/runner.go:508 +0x1b5
panic(0x1bda100, 0xc0113ff820)
	/opt/hostedtoolcache/go/1.14.6/x64/src/runtime/panic.go:969 +0x166
github.com/daixiang0/gci/pkg/gci.newPkg(0xc007147b00, 0xb, 0xb, 0x0, 0x0, 0x1)
	/home/runner/go/pkg/mod/github.com/daixiang0/[email protected]/pkg/gci/gci.go:72 +0x879
github.com/daixiang0/gci/pkg/gci.Run(0xc0016ba300, 0x74, 0xc0025b7bd0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/home/runner/go/pkg/mod/github.com/daixiang0/[email protected]/pkg/gci/gci.go:351 +0x30a
github.com/golangci/golangci-lint/pkg/golinters.NewGci.func1.1(0xc0a1f4d440, 0x2253f94ada, 0x2727340, 0xc056644208, 0x2)
	/home/runner/work/golangci-lint/golangci-lint/pkg/golinters/gci.go:46 +0x2f2
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc00556fe70)
	/home/runner/work/golangci-lint/golangci-lint/pkg/golinters/goanalysis/runner.go:590 +0xa25
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
	/home/runner/work/golangci-lint/golangci-lint/pkg/golinters/goanalysis/runner.go:512 +0x2a
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc001afa820, 0x1c4c352, 0x3, 0xc002200770)
	/home/runner/work/golangci-lint/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x50
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc00556fe70)
	/home/runner/work/golangci-lint/golangci-lint/pkg/golinters/goanalysis/runner.go:511 +0x91
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc0293b0930, 0xc00556fe70)
	/home/runner/work/golangci-lint/golangci-lint/pkg/golinters/goanalysis/runner.go:1059 +0x61
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze
	/home/runner/work/golangci-lint/golangci-lint/pkg/golinters/goanalysis/runner.go:1054 +0x306 
INFO [linters context/goanalysis] analyzers took 59.766308517s with top 10 stages: buildir: 32.959507463s, U1000: 26.806801054s 
WARN [runner] Can't run linter unused: buildir: analysis skipped: errors in package: [/Users/sergey.kurenkov/go/src/gitlab.mobbtech.com/marginal-portfolio/app/autogeneration/generated/golang/types/mgw/Testing/service/functions.go:357:42: field and method with the same name String /Users/sergey.kurenkov/go/src/gitlab.mobbtech.com/marginal-portfolio/app/autogeneration/generated/golang/types/mgw/Testing/service/types.go:28:2: 	other declaration of String] 
INFO [runner] processing took 7.657µs with stages: max_same_issues: 3.31µs, nolint: 741ns, skip_dirs: 392ns, max_from_linter: 361ns, cgo: 283ns, max_per_file_from_linter: 239ns, filename_unadjuster: 238ns, exclude-rules: 204ns, path_prettifier: 192ns, autogenerated_exclude: 175ns, source_code: 174ns, exclude: 168ns, identifier_marker: 166ns, diff: 163ns, path_shortener: 155ns, severity-rules: 155ns, skip_files: 154ns, uniq_by_line: 149ns, path_prefixer: 139ns, sort_results: 99ns 
INFO [runner] linters took 2m36.858266994s with stages: goanalysis_metalinter: 2m22.119860884s, unused: 14.738285369s 
ERRO Running error: buildir: analysis skipped: errors in package: [/Users/sergey.kurenkov/go/src/gitlab.mobbtech.com/marginal-portfolio/app/autogeneration/generated/golang/types/mgw/Testing/service/functions.go:357:42: field and method with the same name String /Users/sergey.kurenkov/go/src/gitlab.mobbtech.com/marginal-portfolio/app/autogeneration/generated/golang/types/mgw/Testing/service/types.go:28:2: 	other declaration of String] 
INFO Memory: 999 samples, avg is 3790.8MB, max is 6720.1MB 
INFO Execution took 2m46.241794489s               
@sergey-kurenkov sergey-kurenkov added the bug Something isn't working label Aug 3, 2020
@boring-cyborg
Copy link

boring-cyborg bot commented Aug 3, 2020

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@butuzov
Copy link
Member

butuzov commented Aug 3, 2020

@daixiang0 yo
There are some issues with traversing formatData (i+1).

https://github.com/daixiang0/gci/blob/master/pkg/gci/gci.go#L72

@SVilgelm
Copy link
Member

SVilgelm commented Aug 3, 2020

@daixiang0 Here is a snippet:

//args: -Egci
//config: linters-settings.gci.local-prefixes=github.com/golangci/golangci-lint
package gci

import (
	"fmt"

	"github.com/golangci/golangci-lint/pkg/config"

	"github.com/pkg/errors"
	// fmt
)

func GoimportsLocalTest() {
	fmt.Print("x")
	_ = config.Config{}
	_ = errors.New("")
}

it fails because of the comment on the last line in import section

@daixiang0
Copy link
Contributor

Sorry that I ignore this case, i will fix ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants