Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

When build fails with errors that do not match known problem matchers, print it to output channel #732

Closed
bruceauyeung opened this issue Jan 17, 2017 · 7 comments

Comments

@bruceauyeung
Copy link

bruceauyeung commented Jan 17, 2017

for example, i have a struct

type ServiceCheck struct {
	Service       string
	CheckIfActive bool
}

but i try to construct an instance like this:

dockerCheck := preflight.ServiceCheck{Service: "docker", checkIfActive: true}

checkIfActive is incorrect , it should be CheckIfActive , but vscode-go doesn't detect this.

vscode-go version:0.6.52
vscode version:1.8.1
os: Ubuntu 16.04.1 LTS KDE 64bit
i have update all dependencies of vscode-go by running:

gocode: go get -u -v github.com/nsf/gocode
godef: go get -u -v github.com/rogpeppe/godef
gogetdoc: go get -u -v github.com/zmb3/gogetdoc
golint: go get -u -v github.com/golang/lint/golint
go-outline: go get -u -v github.com/lukehoban/go-outline
goreturns: go get -u -v sourcegraph.com/sqs/goreturns
gorename: go get -u -v golang.org/x/tools/cmd/gorename
gopkgs: go get -u -v github.com/tpng/gopkgs
go-symbols: go get -u -v github.com/newhook/go-symbols
guru: go get -u -v golang.org/x/tools/cmd/guru
gotests: go get -u -v github.com/cweill/gotests/...

my user settings.json:

{
    "editor.fontSize": 16,
    "editor.fontFamily":"YaHei Consolas Hybrid",
    "http.proxy": "http://10.114.12.39:9090",
    "http.proxyStrictSSL": false,
    "go.buildOnSave": true,
    "go.lintOnSave": true,
    "go.vetOnSave": true,
    "go.buildTags": "",
    "go.buildFlags": [],
    "go.lintTool": "gometalinter",
    "go.lintFlags": ["--enable=misspell","--disable=gotype"],
    "go.vetFlags": [],
    "go.coverOnSave": false,
    "go.useCodeSnippetsOnFunctionSuggest": false,
    "go.formatOnSave": true, 
    "go.formatTool": "goreturns",
    "go.formatFlags": [],
    "go.gocodeAutoBuild": false
}
@ramya-rao-a
Copy link
Contributor

I am able to see the errors. See below where I have a struct "ABC" and I have wrongly spelt "Hello" as "hello"

screen shot 2017-01-17 at 10 44 19 am

screen shot 2017-01-17 at 10 45 28 am

However, I only see the error, when I make a change in the file and save which triggers the build.
If you open a file from another package, make a change, save (that triggers build on that package), then you lose the errors that were generated on the original file.

Can you confirm that you see the same as well?

If yes, then the way to fix this would to be to trigger save on when the active editor changes.
There was some discussion on this (or similar to this) in #118

@bruceauyeung
Copy link
Author

@ramya-rao-a no, the problem here is different from yours. even i change a file and then save it, vscode-go doesn't notify me the error

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jan 18, 2017

Do you see any errors when you run go build from the command line on the package which uses the struct?
Do you see any errors in the output panel when you make a change and save the file that uses the struct?

@bruceauyeung
Copy link
Author

hi @ramya-rao-a , i just created a brand new project and i can see the same with you.

Finished running tool: /usr/local/go/bin/go tool vet /root/test111/src/github.com/bruceauyeung/test111/main.go

Finished running tool: /usr/local/go/bin/go build -o /tmp/go-code-check -tags "" .
/root/test111/src/github.com/bruceauyeung/test111/main.go:4: unknown Test field 'hello' in struct literal

Finished running tool: /usr/local/go-ext-path/bin/gometalinter --enable=misspell --disable=gotype
/root/test111/src/github.com/bruceauyeung/test111/main.go:4: unknown field hello in struct literal (unconvert)
/root/test111/src/github.com/bruceauyeung/test111/main.go:4: error return value not checked (unknown field hello in struct literal) (errcheck)
/root/test111/src/github.com/bruceauyeung/test111/main.go:4: error return value not checked (t declared but not used) (errcheck)
/root/test111/src/github.com/bruceauyeung/test111/main.go:4: ineffectual assignment to t (ineffassign)
/root/test111/src/github.com/bruceauyeung/test111/main.go:4: t declared but not used (unconvert)
/root/test111/src/github.com/bruceauyeung/test111/main.go:4: unknown field hello in struct literal (interfacer)
/root/test111/src/github.com/bruceauyeung/test111/main.go:4: unknown field hello in struct literal (aligncheck)
/root/test111/src/github.com/bruceauyeung/test111/main.go:4: t declared but not used (aligncheck)
/root/test111/src/github.com/bruceauyeung/test111/main.go:7: exported type Test should have comment or be unexported (golint)
/root/test111/src/github.com/bruceauyeung/test111/main.go:4: unused global variable unknown field hello in struct literal (varcheck)
/root/test111/src/github.com/bruceauyeung/test111/main.go:4: unused struct field unknown field hello in struct literal (structcheck)
/root/test111/src/github.com/bruceauyeung/test111/main.go:4: unused global variable t declared but not used (varcheck)
/root/test111/src/github.com/bruceauyeung/test111/main.go:4: unused struct field t declared but not used (structcheck)

but with my k8s project, it didn't notice me that error

Finished running tool: /usr/local/go/bin/go tool vet /root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/reset.go

Finished running tool: /usr/local/go/bin/go build -o /tmp/go-code-check -tags "" .

Finished running tool: /usr/local/go-ext-path/bin/gometalinter --enable=misspell --disable=gotype
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/init.go:137: duplicate of join.go:94-102 (dupl)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/join.go:94: duplicate of init.go:137-145 (dupl)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/cmd.go:29: exported function NewKubeadmCommand should have comment or be unexported (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/init.go:129: exported type Init should have comment or be unexported (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/init.go:133: exported function NewInit should have comment or be unexported (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/init.go:180: if block ends with a return statement, so drop this else and outdent its block (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/init.go:196: exported method Init.Validate should have comment or be unexported (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/join.go:87: exported type Join should have comment or be unexported (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/join.go:91: exported function NewJoin should have comment or be unexported (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/join.go:126: exported method Join.Validate should have comment or be unexported (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/reset.go:61: exported type Reset should have comment or be unexported (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/reset.go:65: exported function NewReset should have comment or be unexported (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/token.go:39: exported function NewCmdToken should have comment or be unexported (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/token.go:53: if block ends with a return statement, so drop this else and outdent its block (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/token.go:102: exported function NewCmdTokenGenerate should have comment or be unexported (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/token.go:146: exported function RunGenerateToken should have comment or be unexported (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/token.go:181: var tokenId should be tokenID (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/token.go:213: func parameter tokenId should be tokenID (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/version.go:29: exported function NewCmdVersion should have comment or be unexported (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/version.go:41: exported function RunVersion should have comment or be unexported (golint)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/reset.go:106: Subprocess launching with variable.,HIGH,HIGH (gas)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/reset.go:114: Subprocess launching with partial path.,MEDIUM,HIGH (gas)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/reset.go:156: Subprocess launching with variable.,HIGH,HIGH (gas)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/reset.go:164: Subprocess launching with variable.,HIGH,HIGH (gas)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/reset.go:172: Subprocess launching with variable.,HIGH,HIGH (gas)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/init.go:201: cyclomatic complexity 15 of function (*Init).Run() is high (> 10) (gocyclo)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/init.go:133: cyclomatic complexity 12 of function NewInit() is high (> 10) (gocyclo)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/init.go:212: declaration of "err" shadows declaration at init.go:204 (vetshadow)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/init.go:218: declaration of "err" shadows declaration at init.go:204 (vetshadow)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/init.go:225: declaration of "err" shadows declaration at init.go:204 (vetshadow)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/init.go:242: declaration of "err" shadows declaration at init.go:204 (vetshadow)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/reset_test.go:159: should check returned error before deferring f.Close() (staticcheck)
/root/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/init.go:212: should omit comparison to bool constant, can be simplified to !valid (gosimple)

and i tried to go build that package but got error:

~/k8s-branch-check-docker-service-active-when-resetting-cluster/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd# go build -o /tmp/go-code-check -tags "" .
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
panic(0x7e18e0, 0xc4200100f0)
        /usr/local/go/src/runtime/panic.go:500 +0x1a1
main.vendoredImportPath(0xc420369200, 0xc42035bc21, 0x1c, 0x3, 0x0)
        /usr/local/go/src/cmd/go/pkg.go:463 +0x66c
main.loadImport(0xc42035bc21, 0x1c, 0xc420343100, 0x77, 0xc420369200, 0xc4204259e0, 0xc4204b0640, 0x4, 0x4, 0x1, ...)
        /usr/local/go/src/cmd/go/pkg.go:333 +0x9ea
main.(*Package).load(0xc420369200, 0xc4204259e0, 0xc420325880, 0x0, 0x0, 0x4)
        /usr/local/go/src/cmd/go/pkg.go:940 +0x12b6
main.loadImport(0xc4202c2da1, 0x16, 0xc4201ad170, 0x86, 0xc4202fa900, 0xc4204259e0, 0xc4202c4a80, 0x1, 0x1, 0x1, ...)
        /usr/local/go/src/cmd/go/pkg.go:374 +0x470
main.(*Package).load(0xc4202fa900, 0xc4204259e0, 0xc4201c6e00, 0x0, 0x0, 0x4)
        /usr/local/go/src/cmd/go/pkg.go:940 +0x12b6
main.loadImport(0xc42013d171, 0x20, 0xc4201bcbd0, 0x6d, 0xc4201be000, 0xc4204259e0, 0xc42013d530, 0x1, 0x1, 0x1, ...)
        /usr/local/go/src/cmd/go/pkg.go:374 +0x470
main.(*Package).load(0xc4201be000, 0xc4204259e0, 0xc4201b4700, 0x0, 0x0, 0xc)
        /usr/local/go/src/cmd/go/pkg.go:940 +0x12b6
main.loadImport(0xc4201bc748, 0x25, 0xc42001a004, 0x6d, 0x0, 0xc4204259e0, 0x0, 0x0, 0x0, 0x0, ...)
        /usr/local/go/src/cmd/go/pkg.go:374 +0x470
main.loadPackage(0x8488e5, 0x1, 0xc4204259e0, 0x0)
        /usr/local/go/src/cmd/go/pkg.go:1658 +0x28f
main.packagesAndErrors(0xc42014e340, 0x1, 0x1, 0xc42014e320, 0x20, 0x7f3a60)
        /usr/local/go/src/cmd/go/pkg.go:1703 +0x337
main.packagesForBuild(0xc42000c140, 0x1, 0x1, 0x893c68, 0xc42001c040, 0x0)
        /usr/local/go/src/cmd/go/pkg.go:1719 +0x75
main.runBuild(0xa27440, 0xc42000c140, 0x1, 0x1)
        /usr/local/go/src/cmd/go/build.go:440 +0xd4
main.main()
        /usr/local/go/src/cmd/go/main.go:181 +0x624

it looks like a golang error, but all my tests run on the same machine.

@ramya-rao-a
Copy link
Contributor

The Go extension depends on the output of go build to show you errors. But you seem to have problems running go build itself.

Without fixing the golang errors that you are seeing, I don't think there is anything the the Go extension can do, am sorry :(

One thing that can be done, is that we can show a message saying go build was not run successfully, please see the output pane and show the build errors in the output pane

@ramya-rao-a ramya-rao-a changed the title vscode-go doesn't detect an error when constructing an struct instance with wrong field name When build fails with errors that do not match known regex, print it to output channel Jan 18, 2017
@ramya-rao-a ramya-rao-a changed the title When build fails with errors that do not match known regex, print it to output channel When build fails with errors that do not match known problem matchers, print it to output channel Jan 18, 2017
@ramya-rao-a
Copy link
Contributor

The PR #735 will help with this

@ramya-rao-a
Copy link
Contributor

With the latest update (0.6.53), build errors such as the above will be displayed in the output window and will be mapped to the first line of the file i.e the first line of the file will get a red squiggly pointing to the error.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants