简体   繁体   English

在vscode的文件夹供应商中找不到软件包-Golang

[英]Cannot find package in folder vendor in vscode - Golang

I cloned code here: https://github.com/kkdai/line-login-go . 我在这里克隆了代码: https : //github.com/kkdai/line-login-go

I deployed on heroku and ran successfully. 我在heroku上部署并成功运行。 But I get: cannot find package on VSCode 但我得到:在VSCode上cannot find package

找不到软件包vscode

Normally, if I put the project in the src directory, and set GOPATH , it will not report an error. 通常,如果将项目放在src目录中,并设置GOPATH ,则不会报告错误。

But this project doesn't follow that structure, packages are in the vendor/ directory. 但是该项目没有采用这种结构,包位于vendor/目录中。

What do I have to do to handle the error? 我该怎么办才能解决该错误?

You could try and use/add go modules to your cloned project (with Go 1.11+, and GO111MODULE=on set): 您可以尝试使用/添加go模块到克隆的项目中(使用Go 1.11+,并且GO111MODULE=on设置):

go mod init github.com/kkdai/line-login-go
go mod vendor

Then you should have all missing dependencies added to your vendor folder. 然后,应该将所有缺少的依赖项添加到供应商文件夹中。
And you would not even need GOPATH anymore. 而且您甚至不需要GOPATH

As seen in kardianos/govendor/issue 424 , go mod should recognize vendor/vendor.json and import the right references previously declared and managed by govendor . kardianos / govendor / issue 424中所示go mod应该识别vendor/vendor.json并导入先前由govendor声明和管理的正确引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM