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

Error with go module and git submodules #414

Closed
pascencio opened this issue Jul 26, 2020 · 4 comments
Closed

Error with go module and git submodules #414

pascencio opened this issue Jul 26, 2020 · 4 comments
Labels
FrozenDueToAge upstream-tools Issues that are caused by problems in the tools that the extension depends on.

Comments

@pascencio
Copy link

Hi guys,

I have some troubles with the extension and git submodules.

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

  • Run go version to get version of Go
    • go1.14.5 linux/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
    • 1.48.0-insider
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.15.2
  • Run go env to get the go development environment details
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/patricio/.cache/go-build"
GOENV="/home/patricio/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/patricio/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build939111051=/tmp/go-build -gno-record-gcc-switches"

Share the Go related settings you have added/edited

{
    "go.autocompleteUnimportedPackages": true,
    "go.formatTool": "goimports",
    "go.buildOnSave": "workspace",
    "go.useLanguageServer": true
}

Describe the bug

Problem

I have a project with two components:

  1. Backend with golang using go modules.
  2. Frontend with vue

Both components are git submodules in a parent repository. When I open the project with both submodules I have the following issues:

  1. Module dependencies are not imported (autocompleteUnimportedPackages)
  2. Error with packages already imported

Opening directly submodule resolves the issue.

Behavior expected

I expect same behavior with git submodules and simple git project.

Steps to reproduce the behavior:

  1. Clone a project with git submodules (with golang modules inside).
  2. Init and update submodules.
  3. Open main.go file
  4. See errors in packages imported already declared in go.mod file.

Screenshots or recordings

Project opened with git submodules:

image

Project opened directly:

image

@hyangah
Copy link
Contributor

hyangah commented Jul 27, 2020

@pascencio It looks like this is another way of creating a repo setup that is currently not supported by gopls. See #275 - currently gopls (the default language server used by "go.useLanguageServer": true) requires the directory with go.mod to be the root workspace.

Currently suggested workaround is to add the sub directory that contains go.mod file as a workspace folder (https://code.visualstudio.com/docs/editor/multi-root-workspaces).

/cc @stamblerre

@hyangah hyangah added the upstream-tools Issues that are caused by problems in the tools that the extension depends on. label Jul 27, 2020
@pascencio
Copy link
Author

@hyangah I will try to use the workaround mentioned by you. Thanks!

@pascencio
Copy link
Author

@pascencio It looks like this is another way of creating a repo setup that is currently not supported by gopls. See #275 - currently gopls (the default language server used by "go.useLanguageServer": true) requires the directory with go.mod to be the root workspace.

Currently suggested workaround is to add the sub directory that contains go.mod file as a workspace folder (https://code.visualstudio.com/docs/editor/multi-root-workspaces).

/cc @stamblerre

@hyangah You workaround works perfectly.

This issue is related with the extension? or I must report this to the gopls team?

To me is enough with your answer, thanks again!

@stamblerre
Copy link
Contributor

This is a gopls issue that will be addressed in future versions. Glad you got it working!

@golang golang locked and limited conversation to collaborators Jul 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge upstream-tools Issues that are caused by problems in the tools that the extension depends on.
Projects
None yet
Development

No branches or pull requests

4 participants