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

Unable to detect exported codes, such as function and struct. #2827

Closed
4 tasks done
nixijnat opened this issue May 6, 2022 · 3 comments
Closed
4 tasks done

Unable to detect exported codes, such as function and struct. #2827

nixijnat opened this issue May 6, 2022 · 3 comments
Labels
question Further information is requested

Comments

@nixijnat
Copy link

nixijnat commented May 6, 2022

Welcome

  • 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).
  • Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)

Description of the problem

Example code (test.go):

package test

type ExportType struct{}

func ExportFunc() {}

lint by revive:

revive test.go

then, the output is:

test.go:3:6: exported type ExportType should have comment or be unexported
test.go:5:1: exported function ExportFunc should have comment or be unexported

but lint by golangci-lint :

golangci-lint run --disable-all -E revive test.go 

there is no output.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.45.2 built from 8bdc4d3f on 2022-03-24T11:51:26Z

Configuration file

$ cat .golangci.yml
# no config file

Go environment

$ go version && go env
go version go1.16.13 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/opt/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/opt/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.com.cn,direct"
GOROOT="/opt/go"
GOSUMDB=""
GOTMPDIR=""
GOTOOLDIR="/opt/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.13"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/root/projects/doc/go.mod"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3365228336=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v --disable-all -E revive test.go 
INFO [config_reader] Config search paths: [./ /root/tmp /root /] 
INFO [lintersdb] Active 1 linters: [revive]       
INFO [loader] Go packages loading at mode 7 (compiled_files|files|name) took 9.300011ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 70.743µs 
INFO [linters context/goanalysis] analyzers took 453.922µs with top 10 stages: the_only_name: 453.922µs 
INFO [runner] Issues before processing: 2, after processing: 0 
INFO [runner] Processors filtering stat (out/in): exclude: 2/2, exclude-rules: 0/2, filename_unadjuster: 2/2, autogenerated_exclude: 2/2, identifier_marker: 2/2, skip_files: 2/2, skip_dirs: 2/2, cgo: 2/2, path_prettifier: 2/2 
INFO [runner] processing took 154.216µs with stages: exclude-rules: 63.419µs, identifier_marker: 55.073µs, autogenerated_exclude: 13.636µs, path_prettifier: 11.752µs, skip_dirs: 4.769µs, cgo: 1.083µs, nolint: 883ns, filename_unadjuster: 561ns, exclude: 521ns, max_same_issues: 502ns, uniq_by_line: 291ns, source_code: 261ns, severity-rules: 241ns, max_per_file_from_linter: 231ns, sort_results: 230ns, max_from_linter: 200ns, diff: 161ns, skip_files: 160ns, path_shortener: 141ns, path_prefixer: 101ns 
INFO [runner] linters took 6.402571ms with stages: revive: 6.171216ms 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 2 samples, avg is 46.1MB, max is 46.1MB 
INFO Execution took 19.814943ms   

Code example or link to a public repository

package test

type ExportType struct{}

func ExportFunc() {}
@nixijnat nixijnat added the bug Something isn't working label May 6, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented May 6, 2022

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

@bombsimon
Copy link
Member

You need to set --exclude-use-default=false. All the rules that are excluded by default should be listed when you run golangci-lint run --help.

See #456 and the more general one #2239.

@nixijnat
Copy link
Author

nixijnat commented May 6, 2022

You need to set --exclude-use-default=false. All the rules that are excluded by default should be listed when you run golangci-lint run --help.

See #456 and the more general one #2239.

Thank you very much

@ldez ldez added question Further information is requested and removed bug Something isn't working labels May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants