I have a my-project multi-root workspace:
- my-project
- my-project-api-gateway
- another-root-folder-we-dont-care-about
Here's my launch.json configuration file for my-project-api-gateway
{
// See https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
// and variables here https://code.visualstudio.com/docs/editor/variables-reference
"version": "0.2.0",
"configurations": [
{
"name": "my-project-api-gateway",
"type": "go",
"request": "launch",
"mode": "debug",
"envFile": "${workspaceFolder}/.env", ----> Error loading .env file
"program": "${workspaceFolder}/src/main.go"
}
]
}
DEBUG Console Output
Starting: /Users/me/go/bin/dlv dap --check-go-version=false --listen=127.0.0.1:53890 --log-dest=3 from /Users/me/path/to/project/src
DAP server listening at: 127.0.0.1:53890
Type 'dlv help' for list of commands.
2022/07/20 10:30:52 Error loading .env file
Process 13526 has exited with status 1
Detaching
dlv dap (13508) exited with code: 0
Thanks for your help
dlv, go, gopls and vscode versions
❯ dlv version
Delve Debugger
Version: 1.8.2
❯ go version
go version go1.18 darwin/amd64
❯ gopls -v version
Build info
----------
golang.org/x/tools/gopls v0.9.1
❯ code -v
1.69.2
Extension Go for Visual Studio Code is v0.35.1
Go: Locate Configured Go Tools output:
Checking configured tools....
GOBIN: /Users/me/go/bin
toolsGopath:
gopath: /Users/me/dev/go
GOROOT: /usr/local/go
PATH: /usr/local/go/bin:/Users/me/.nvm/versions/node/v16.14.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Users/me/.cargo/bin:/Users/me/go/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/usr/local/cassandra/bin
PATH (vscode launched with): /Users/me/.nvm/versions/node/v16.14.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Users/me/.cargo/bin:/Users/me/go/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/usr/local/cassandra/bin
go: /usr/local/go/bin/go: go version go1.18 darwin/amd64
gotests: /Users/me/go/bin/gotests (version: v1.6.0 built with go: go1.18)
gomodifytags: /Users/me/go/bin/gomodifytags (version: v1.16.0 built with go: go1.18)
impl: /Users/me/go/bin/impl (version: v1.1.0 built with go: go1.18)
goplay: /Users/me/go/bin/goplay (version: v1.0.0 built with go: go1.18)
dlv: /Users/me/go/bin/dlv (version: v1.8.2 built with go: go1.18)
golangci-lint: /Users/me/go/bin/golangci-lint (version: v1.45.2 built with go: go1.18)
gopls: /Users/me/go/bin/gopls (version: v0.9.1 built with go: go1.18)
go env
Workspace Folder (my-project-api-gateway): /Users/me/dev/back/go/my-project/my-project-api-gateway
GO111MODULE=""
GOARCH="amd64"
GOBIN="/Users/me/go/bin"
GOCACHE="/Users/me/Library/Caches/go-build"
GOENV="/Users/me/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/me/dev/go/pkg/mod"
GONOPROXY="github.com/BigBoulard/*"
GONOSUMDB="github.com/BigBoulard/*"
GOOS="darwin"
GOPATH="/Users/me/dev/go"
GOPRIVATE="github.com/BigBoulard/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/me/dev/back/go/my-project/my-project-api-gateway/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/1g/fytltrn578gg3xgp3c_sglhw0000gq/T/go-build1439123167=/tmp/go-build -gno-record-gcc-switches -fno-common"