Skip to content

code coverage: Apply Cover Profile runs without cwd #610

Closed
@galli-leo

Description

@galli-leo

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

  • Run go version to get version of Go
    • go version go1.15 darwin/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
    • 1.48.2
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.16.2 (though latest master also has this issue)
  • Run go env to get the go development environment details
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/leonardogalli/Library/Caches/go-build"
GOENV="/Users/leonardogalli/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/leonardogalli/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/leonardogalli/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/leonardogalli/Code/VIS/cdn/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/20/0vlkhfx51rv66qm56m4y1rhm0000gn/T/go-build195617975=/tmp/go-build -gno-record-gcc-switches -fno-common"

Share the Go related settings you have added/edited

    "go.formatTool": "goimports",
    "go.useLanguageServer": true,
    "go.languageServerFlags": [],
    "go.lintOnSave": "off",
    "go.vetOnSave": "off",
    "go.lintTool": "golangci-lint",
    "go.languageServerExperimentalFeatures": {

    
    },
    "go.delveConfig": {
    
        "dlvLoadConfig": {
            "followPointers": true,
            "maxVariableRecurse": 1,
            "maxStringLen": 64,
            "maxArrayValues": 64,
            "maxStructFields": -1
        },
        "apiVersion": 2,
        "showGlobalVariables": true
    },
    "go.testFlags": [
        "-coverpkg=all"
    ],

Describe the bug

Go: Apply Cover Profile does not work.
Using the debugger, I traced this back to go list being ran without a cwd. I am guessing, it is not ran in the workspaceRoot in this case. This leads to it not being able to find the package paths.

By passing along the workspace root when calling applyCodeCoverage from the command handler, seemed to fix this issue for me.

Steps to reproduce the behavior:

  1. Execute Go: Apply Cover Profile
  2. Select some profile
  3. Coverage is not shown in editor.

Screenshots or recordings

N/A

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions