$ go version
go version go1.14.1 linux/amd64
go version devel +57e32c4fbd Sun May 10 14:43:46 2020 +0000 linux/amd64
What's wrong
When cgo preprocessing fails, go list -json -compiled -e prints an error on stderr and exits with a non-zero status, but it does not populate the Error field of the package. It is possible to detect that something went wrong because CompiledGoFiles isn't populated, but we can't tell why it failed. Two common reasons are a missing C compiler, and missing libraries.
This has the same root cause as the two linked issues: #34229 and #25842
Currently, go list -e populates the Error field with errors it encounters when loading the package dependency graph. It should also populate the Error field with errors encountered when running cgo, the compiler, and other commands.
jayconrod
added
NeedsFix
The path to resolution is known, but the work has not been done.
and removed
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
labels
May 11, 2020
There's no quick solution currently, but to figure out what's wrong VSCode running the go list command, execute this manually @SeanTolstoyevski@thalesfsp
go list -e -json -compiled -x /absolute/path/to/yourpkg/src.go
For me, it outputs
WORK=/tmp/go-build2892322839
mkdir -p $WORK/b001/
cd /absolute/path/to/yourpkg
TERM='dumb' CGO_LDFLAGS='"-g" "-O2" "-L/absolute/path/to/yourpkg/lib" "-lYourFunc"' /usr/lib/go/pkg/tool/linux_amd64/cgo -objdir $WORK/b001/ -importpath command-line-arguments -- -I $WORK/b001/ -g -O2 -I/absolute/path/to/yourpkg/include -std=c99 ./src.go
# command-line-arguments
In file included from yourpkg/src.go:10:
yourpkg/include/SomeWapper.h:1:10: fatal error: iostream: No such file or directory
1 |#include <iostream>| ^~~~~~~~~~
compilation terminated.
{
"Dir": "/absolute/path/to/yourpkg",
"ImportPath": "command-line-arguments",
"Name": "yourpkg",
"Match": [
"/absolute/path/to/yourpkg/src.go"
],
"Stale": true,
"StaleReason": "build ID mismatch",
"CgoFiles": [
"src.go"
],
# ... more JSON, but no 'CompiledGoFiles' field, VSCode cannot interpret
So I know it's due to the C++ headers included, which is not allowed. Refer golang-nuts
To dismiss the warnings, ignore files (refer) in vscode settings.json (not recommended, file tree won't show)
What version of Go are you using (
go version
)?What's wrong
When cgo preprocessing fails,
go list -json -compiled -e
prints an error on stderr and exits with a non-zero status, but it does not populate the Error field of the package. It is possible to detect that something went wrong because CompiledGoFiles isn't populated, but we can't tell why it failed. Two common reasons are a missing C compiler, and missing libraries.Example output
Related: #34229 and #25842
/cc @bcmills @matloob @heschik
The text was updated successfully, but these errors were encountered: