Skip to content

go mod: auto complete can't work on local package when I set "GO111MODULE": "on" #262

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

Closed
thep0y opened this issue Jun 27, 2020 · 3 comments

Comments

@thep0y
Copy link

thep0y commented Jun 27, 2020

Please direct general questions to:

Please review the documentation before filing an issue.
Helpful pages include:

Please answer these questions before submitting your issue. Thanks!

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go
    • go version go1.14.3 linux/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
    • 1.46.1
      • cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
      • x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.14.4
  • Run go env to get the go development environment details
GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/thepoy/.cache/go-build"
GOENV="/home/thepoy/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/thepoy/OneDrive/code/go:/home/thepoy/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/run/media/thepoy/软件/OneDrive - WULEL/code/go/src/web/alipay/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-build530815193=/tmp/go-build -gno-record-gcc-switches"

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

{
    "workbench.colorTheme": "Ayu Mirage",
    "editor.wordWrap": "on",
    "editor.minimap.renderCharacters": false,
    "editor.minimap.enabled": false,
    "terminal.external.osxExec": "iTerm.app",
    "go.docsTool": "gogetdoc",
    "go.testFlags": ["-v","-count=1"],
    "go.buildTags": "",
    "go.buildFlags": [],
    "go.lintFlags": [],
    "go.vetFlags": [],
    "go.coverOnSave": false,
    "go.useCodeSnippetsOnFunctionSuggest": false,
    "go.formatTool": "goimports",
    "go.gocodeAutoBuild": false,
    "go.goroot": "/usr/local/go",
    "go.gopath": "/home/thepoy/OneDrive/code/go",
    "go.toolsGopath": "/home/thepoy/OneDrive/code/go",
    "go.autocompleteUnimportedPackages": true,
    "go.formatOnSave": true,
    "window.zoomLevel": 0,
    "debug.console.fontSize": 16,
    "debug.console.lineHeight": 30,
    "editor.fontFamily": "'Source Code Variable'",
    "editor.fontSize": 15,
    "sync.gist": "9d9538d15672b223f067dada16bc329e",
    "sync.autoDownload": true,
    "sync.autoUpload": true,
    "sync.quietSync": true,
    "workbench.activityBar.visible": true,
    "files.autoSave": "onWindowChange",
    "go.useLanguageServer": true,
    "files.associations": {
        "*.go": "go"
    },
    "explorer.confirmDelete": false,
    "[go]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true
        },
    },
    "gopls": {
        "completeUnimported": true,
        "usePlaceholders": true,
        "completionDocumentation": true,
        "hoverKind": "SynopsisDocumentation"
    },
    "go.toolsEnvVars": {
        "GO111MODULE": "on",
    },
    "files.eol": "\n",
}

Describe the bug

Auto-import couldn't work when I set "GO111MODULE": "auto", and editor always reported many import-erros, but go run main.go could work normally, so I tried to change the value of "GO111MODULE" to "on", and the import-errors was resolved, but auto-complete can't work on local package now.

Steps to reproduce the behavior:

  1. Install go module and gopls
  2. set "go.useLanguageServer": true and "GO111MODULE": "on",
  3. Write a local package with a function, and import the package in other package, then auto-complete will not work.

Screenshots or recordings

20200627102430

@hyangah
Copy link
Contributor

hyangah commented Jun 27, 2020

@thep0y the go language server (gopls) is responsible for providing the info. Can you please follow the instruction in https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#vs-code to capture the trace?

Are the controller package and the web/BookStore/* packages in the same module (/run/media/thepoy/软件/OneDrive - WULEL/code/go/src/web/alipay/go.mod), and is the workspace root /run/media/thepoy/软件/OneDrive - WULEL/code/go/src/web/alipay/ ?

If not, please see golang/go#36899 whether gopls is currently supporting your project setup.

/cc @stamblerre

@thep0y
Copy link
Author

thep0y commented Jun 27, 2020

@thep0y the go language server (gopls) is responsible for providing the info. Can you please follow the instruction in https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#vs-code to capture the trace?

Are the controller package and the web/BookStore/* packages in the same module (/run/media/thepoy/软件/OneDrive - WULEL/code/go/src/web/alipay/go.mod), and is the workspace root /run/media/thepoy/软件/OneDrive - WULEL/code/go/src/web/alipay/ ?

If not, please see golang/go#36899 whether gopls is currently supporting your project setup.

/cc @stamblerre

Thank you for your reply. I worked in GOPATH previous to this, not in the module root.
I tried to open workspace at the module root just now, and the auto-complete is working normally.
Thank you!

@hyangah
Copy link
Contributor

hyangah commented Jun 27, 2020

Good to hear it's now working for you, @thep0y!

@hyangah hyangah closed this as completed Jun 27, 2020
@golang golang locked and limited conversation to collaborators Jun 27, 2021
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

3 participants