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

x/tools/gopls: cannot use func from same package #44831

Closed
holooooo opened this issue Mar 6, 2021 · 2 comments
Closed

x/tools/gopls: cannot use func from same package #44831

holooooo opened this issue Mar 6, 2021 · 2 comments

Comments

@holooooo
Copy link

@holooooo holooooo commented Mar 6, 2021

ATTENTION: Please answer these questions BEFORE submitting your issue. Thanks!

What did you do?

declare a function name listenWindows in package router
and try to run it

What did you expect to see?

listenWindows can be used in other file of router package

What did you see instead?

vscode alert undeclared name: listenWindows

use go run or go test also have same problem

when I change the file which contain listenWindows file name from router_windows.go to router_window.go, this problem is solved immediately.Once rename back, it alert again

I have try to remove ~/.cache, reinstall go, upgrade go from 1.15.7 to 1.15.8 or 1.16, run go clean -cache. it all useless

Build info

golang.org/x/tools/gopls v0.6.6
    golang.org/x/tools/gopls@v0.6.6 h1:GmCsAKZMEb1BD1BTWnQrMyx4FmNThlEsmuFiJbLBXio=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/go-cmp@v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.4.1 h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY=
    golang.org/x/sync@v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
    golang.org/x/sys@v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
    golang.org/x/tools@v0.1.1-0.20210222172741-77e031214674 h1:XzEjy9Ks1MwmcJOarbxTnL/AqHtzsRfRzAwfDhII2lE=
    golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
    honnef.co/go/tools@v0.1.1 h1:EVDuO03OCZwpV2t/tLLxPmPiomagMoBOgfPt0FM+4IY=
    mvdan.cc/gofumpt@v0.1.0 h1:hsVv+Y9UsZ/mFZTxJZuHVI6shSQCtzZ11h1JEFPAZLw=
    mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=
@gopherbot gopherbot added this to the Unreleased milestone Mar 6, 2021
@AlexRouSg
Copy link
Contributor

@AlexRouSg AlexRouSg commented Mar 6, 2021

Files that are named _windows.go will only be compiled and included if you are compiling for windows.

If a file's name, after stripping the extension and a possible _test suffix, matches any of the following patterns:

  • *_GOOS
  • *_GOARCH
  • *_GOOS_GOARCH

(example: source_windows_amd64.go) where GOOS and GOARCH represent any known operating system and architecture values respectively, then the file is considered to have an implicit build constraint requiring those terms (in addition to any explicit constraints in the file).

https://golang.org/cmd/go/#hdr-Build_constraints

@holooooo
Copy link
Author

@holooooo holooooo commented Mar 6, 2021

a this, i got it. thank you very much! @AlexRouSg

@holooooo holooooo closed this Mar 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants