Skip to content

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

@nixijnat

Description

@nixijnat

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() {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions