Skip to content

Built-in govet and golint can't parse quicktemplate output, standalone versions can #316

@aaron42net

Description

@aaron42net

When using a template code generator called quicktemplate (https://github.com/valyala/quicktemplate), golangci-lint's govet and golint linters can't parse the generated output, though go vet and golint work fine.

I've created a tiny git repo that illustrates the interaction. See: https://github.com/aaron42net/glci-demo

Here's the result of running the steps in the README:

$ golint ./...
templates/partials/partials/foo.qtpl:3:1: exported function StreamFoo should have comment or be unexported
templates/partials/partials/foo.qtpl:5:1: exported function Foo should have comment or be unexported
templates/partials/partials/foo.qtpl:5:1: exported function WriteFoo should have comment or be unexported
templates/partials/partials/foo.qtpl:7:1: comment on exported function Bar should be of the form "Bar ..."
$ go vet ./...
# github.com/aaron42net/glci-demo/templates/partials
templates/partials/partials/foo.qtpl:11: Printf format %s has arg 345 of wrong type int
$ golangci-lint run --no-config --disable-all -E golint -E govet
WARN [runner] Can't run linter golint: no AST for file /home/aaron/go/src/github.com/aaron42net/glci-demo/templates/partials/foo.qtpl.go in cache: {m:map[/home/aaron/go/src/github.com/aaron42net/glci-demo/templates/partials/partials/foo.qtpl:0xc423aa6d20 /home/aaron/go/src/github.com/aaron42net/glci-demo/main.go:0xc423aa6d50 /home/aaron/go/src/github.com/aaron42net/glci-demo/templates/templates.go:0xc423aa6d80] s:[0xc423aa6d50 0xc423aa6d80 0xc423aa6d20] log:{rd:0xc420040360 tags:[loader astcache] origLog:0xc423aa4800}} 
WARN [runner] Can't run linter govet: can't eval symlinks for path /home/aaron/go/src/github.com/aaron42net/glci-demo/templates/partials/partials/foo.qtpl: lstat /home/aaron/go/src/github.com/aaron42net/glci-demo/templates/partials/partials: no such file or directory 

Let me know if you need more info. Thanks!
-- Aaron

Please include the following information:

  1. Version of golangci-lint: golangci-lint --version (or git commit if you don't use binary distribution)

Git commit is current master: ef7864383087163c1330f90342b6a5887e847c37

  1. Config file: cat .golangci.yml

Running with no config: golangci-lint -v run --no-config --disable-all -E golint -E govet

  1. Go environment: go version && go env
go version go1.10.3 linux/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/aaron/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/aaron/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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-build641986617=/tmp/go-build -gno-record-gcc-switches"
  1. Verbose output of running: golangci-lint run -v
$ golangci-lint -v run --no-config --disable-all -E golint -E govet
INFO Gocritic enabled checks: [appendAssign assignOp caseOrder dupArg dupBranchBody dupCase flagDeref ifElseChain regexpMust singleCaseSwitch sloppyLen switchTrue typeSwitchVar underef unlambda unslice defaultCaseOrder] 
INFO [lintersdb] Active 2 linters: [golint govet] 
INFO [loader] Go packages loading at mode load types and syntax took 408.066946ms 
INFO [runner] worker.18 took 4.697µs              
INFO [runner] worker.19 took 7.245µs              
INFO [runner] worker.20 took 1.773µs              
INFO [runner] worker.14 took 5.8µs                
INFO [runner] worker.7 took 4.574µs               
INFO [runner] worker.6 took 2.218µs               
INFO [runner] worker.23 took 1.413µs              
INFO [runner] worker.11 took 2.332µs              
INFO [runner] worker.22 took 1.37µs               
INFO [runner] worker.12 took 2.107µs              
INFO [runner] worker.9 took 1.687µs               
INFO [runner] worker.8 took 4.44µs                
INFO [runner] worker.2 took 2.307µs               
INFO [runner] worker.24 took 4.328µs              
INFO [runner] worker.3 took 1.825µs               
INFO [runner] worker.21 took 1.92µs               
INFO [runner] worker.15 took 2.345µs              
INFO [runner] worker.17 took 1.535µs              
INFO [runner] worker.13 took 1.835µs              
INFO [runner] worker.1 took 1.837µs               
INFO [runner] worker.4 took 1.417µs               
INFO [runner] worker.16 took 1.923µs              
INFO [runner] worker.10 took 706.908µs with stages: golint: 685.518µs 
WARN [runner] Can't run linter golint: no AST for file /home/aaron/go/src/github.com/aaron42net/glci-demo/templates/partials/foo.qtpl.go in cache: {m:map[/home/aaron/go/src/github.com/aaron42net/glci-demo/main.go:0xc4239756e0 /home/aaron/go/src/github.com/aaron42net/glci-demo/templates/templates.go:0xc423975710 /home/aaron/go/src/github.com/aaron42net/glci-demo/templates/partials/partials/foo.qtpl:0xc423975740] s:[0xc4239756e0 0xc423975710 0xc423975740] log:{rd:0xc420040360 tags:[loader astcache] origLog:0xc423978be0}} 
INFO [runner] worker.5 took 3.173777ms with stages: govet: 3.151315ms 
WARN [runner] Can't run linter govet: can't eval symlinks for path /home/aaron/go/src/github.com/aaron42net/glci-demo/templates/partials/partials/foo.qtpl: lstat /home/aaron/go/src/github.com/aaron42net/glci-demo/templates/partials/partials: no such file or directory 
INFO [runner] Workers idle times: #1: 2.818577ms, #2: 2.909626ms, #3: 2.890309ms, #4: 2.812481ms, #6: 3.016928ms, #7: 3.02526ms, #8: 2.938023ms, #9: 2.945976ms, #10: 2.464579ms, #11: 2.982397ms, #12: 2.95158ms, #13: 2.824411ms, #14: 3.03542ms, #15: 2.856895ms, #16: 2.806677ms, #17: 2.850766ms, #18: 3.098844ms, #19: 3.068532ms, #20: 3.057092ms, #21: 2.883212ms, #22: 2.956468ms, #23: 2.989744ms, #24: 2.899334ms 
INFO [runner] processing took 7.524µs with stages: max_same_issues: 1.68µs, path_prettifier: 785ns, skip_dirs: 620ns, skip_files: 545ns, nolint: 540ns, max_from_linter: 537ns, cgo: 397ns, exclude: 390ns, source_code: 390ns, path_shortener: 390ns, autogenerated_exclude: 318ns, diff: 312ns, uniq_by_line: 310ns, max_per_file_from_linter: 310ns 
INFO Memory: 5 samples, avg is 25.4MB, max is 55.3MB 
INFO Execution took 478.054182ms                  

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cgoRelated to CGO or line directivesbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions