I'm using github.com/google/gousb
package to get information on USB devices connected to my machine, but when I call the function gousb.NewContext()
nothing happens and the code just seems to not do anything and doesn't progress past that point.
I've seen a similar but not identical issue:
can't load package: package .: no buildable Go source files
For the above similar issue I checked my GOPATH
and made sure there were no empty packages
I've also asked on github but they couldn't help me as the problem is from my build environment and not gousb itself
I can go get the gousb repo just fine and everything seems to be working, intellisense brings up suggestions and so on.
But when I actually run my program it freezes on gousb.NewContext()
I tracked it down with breakpoints and found the problem is arising from from the line below in the libusb.go
file
if err := fromErrNo(C.libusb_init(&ctx)); err != nil { return nil, err }
Specifically
C.libusb_init(&ctx)
Using the Debugger on VSCode when I "step into" that line above and it goes to a file called _cgo_gotypes.go
and in the files it says:
Could not load source '_cgo_gotypes.go'.
and in the Debug Console it says:
go list failed on .: can't load package: package .: no Go files in C:\Users\TOJ\AppData\Local\Programs\Microsoft VS Code
I have absolutely no idea what's going on and would really appreciate if someone could shed some light.
here's my go env btw:
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\TOJ\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Work\Important\[REPO-NAME]
set GOPROXY=
set GORACE=
set GOROOT=c:\go
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\TOJ\AppData\Local\Temp\go-build424489806=/tmp/go-build -gno-record-gcc-switches
I expected no errors to be thrown and for a *gousb.Context
type to be returned