Skip to content

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

Closed
@thep0y

Description

@thep0y

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions