duana1021 2019-07-01 18:10
浏览 72

程序冻结,在gousb.NewContext()上未引发任何错误

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘