Skip to content

Go Companion extension ignoring go.testEnvFile settings #3782

Open
@m1yon

Description

@m1yon

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

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.24.4 darwin/arm64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • golang.org/x/tools/gopls v0.18.1
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.100.2
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.47.3
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
    • Tools Configuration

Environment

GOBIN: undefined
toolsGopath:
gopath: /Users/michael/go/1.24.0
GOROOT: /Users/michael/go/1.24.0/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.4.darwin-arm64
PATH: /Users/michael/go/1.24.0/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.4.darwin-arm64/bin:/Users/michael/.atuin/bin:/Library/TeX/texbin:/Users/michael/.deno/bin:/Users/michael/.goenv/versions/1.24.0/bin:/Users/michael/.goenv/bin:/opt/homebrew/opt/postgresql@15/bin:/Users/michael/.bun/bin:/Users/michael/.docker/bin:/Users/michael/Library/pnpm:/opt/homebrew/bin:/Users/michael/.volta/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/MacGPG2/bin:/Library/TeX/texbin:/Users/michael/.orbstack/bin:/Users/michael/.local/bin:/Users/michael/Library/Application Support/JetBrains/Toolbox/scripts:/Users/michael/.goenv/shims:/Users/michael/go/1.24.0/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin
PATH (vscode launched with): /Users/michael/.atuin/bin:/Library/TeX/texbin:/Users/michael/.deno/bin:/Users/michael/.goenv/versions/1.24.0/bin:/Users/michael/.goenv/bin:/opt/homebrew/opt/postgresql@15/bin:/Users/michael/.bun/bin:/Users/michael/.docker/bin:/Users/michael/Library/pnpm:/opt/homebrew/bin:/Users/michael/.volta/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/MacGPG2/bin:/Library/TeX/texbin:/Users/michael/.orbstack/bin:/Users/michael/.local/bin:/Users/michael/Library/Application Support/JetBrains/Toolbox/scripts:/Users/michael/.goenv/shims:/Users/michael/go/1.24.0/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin

Tools

go:	/Users/michael/.goenv/shims/go: go version go1.24.4 darwin/arm64

gopls:	/Users/michael/go/1.24.0/bin/gopls	(version: v0.18.1 built with go: go1.24.0)
gotests:	not installed
impl:	not installed
goplay:	not installed
dlv:	/Users/michael/go/1.24.0/bin/dlv	(version: v1.24.2 built with go: go1.24.0)
golangci-lint:	/Users/michael/go/1.24.0/bin/golangci-lint	(version: v1.64.8 built with go: go1.24.1)

Go env

Workspace Folder (pearsuite-api-svc): /Users/michael/GitHub/pearsuite-api-svc

AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/michael/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/michael/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/s3/g9qwc9dj4v37m42th1g5s3bh0000gn/T/go-build1254379804=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/michael/GitHub/pearsuite-api-svc/go.mod'
GOMODCACHE='/Users/michael/go/1.24.0/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/michael/go/1.24.0'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/michael/go/1.24.0/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.4.darwin-arm64'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/Users/michael/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/michael/go/1.24.0/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.4.darwin-arm64/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.4'
GOWORK=''
PKG_CONFIG='pkg-config'

Share the Go related settings you have added/edited

  "[go]": {
    "editor.codeActionsOnSave": {
      "source.organizeImports": "explicit"
    },
    "editor.formatOnSave": true,
    "editor.insertSpaces": false
  },
  "go.alternateTools": {
    "go": "/Users/michael/.goenv/shims/go"
  },
  "go.lintFlags": ["--fast"],
  "go.lintTool": "golangci-lint",
  "go.lintOnSave": "package",
  "go.toolsManagement.autoUpdate": true,
  "go.inlayHints.parameterNames": true,
  "go.testExplorer.packageDisplayMode": "nested",
  "go.testExplorer.showDynamicSubtestsInEditor": true,
  "exp-vscode-go.testExplorer.enable": true

Describe the bug

When using the Go Companion extension, env variables aren't being loaded from the env file specified with the go.testEnvFile setting. If I disable the extension, things work as usual.

Steps to reproduce the behavior:

  1. Add "go.testEnvFile": "${workspaceFolder}/.env" to your vscode settings
  2. Create a .env file in the root of your workspace with a dummy env variable
  3. Create a test that references the dummy env variable you created
  4. Run the "Test: Run All Tests" command
  5. See that the dummy env variable does not exist

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Go CompanionIssues relating to the Go Companion extensionHelpWantedIssues that are not prioritized by the maintainers. Help is requested from community contributors.

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions