简体   繁体   English

设置go dep后依赖关系出现问题

[英]Problems with dependencies after setting up go dep

My project is located in $GOPATH/src/smp-cloudupload 我的项目位于$GOPATH/src/smp-cloudupload

I can run dep init without errors. 我可以运行dep init而不会出错。 After that I cant compile the project anymore. 之后,我不能再编译项目了。 One of the errors: 错误之一:

main/scs/scsApiGateway.go:5:2: cannot find package "_/home/dev/go/src/smp-cloudupload/vendor/github.com/dgrijalva/jwt-go" in any of:
/usr/lib/go-1.10/src/_/home/dev/go/src/smp-cloudupload/vendor/github.com/dgrijalva/jwt-go (from $GOROOT)
/home/dev/go/src/_/home/dev/go/src/smp-cloudupload/vendor/github.com/dgrijalva/jwt-go (from $GOPATH)

I am new to GO and I have a feeling, that there are either issues with my project structure or the GOPATH. 我是GO的新手,我有一种感觉,我的项目结构或GOPATH都有问题。 The shown path is wrong. 所示路径错误。 The correct path is: /home/dev/go/src/smp-cloudupload/vendor/github.com/dgrijalva/jwt-go 正确的路径是: /home/dev/go/src/smp-cloudupload/vendor/github.com/dgrijalva/jwt-go

What am I doing wrong? 我究竟做错了什么?

EDIT: 编辑:

Output of echo $GOPATH : dev@dev-VirtualBox:~/go/src/smp-cloudupload/main$ echo $GOPATH echo $GOPATH输出:dev @ dev-VirtualBox:〜/ go / src / smp-cloudupload / main $ echo $ GOPATH

/home/dev/go

I have no idea why there is a underscore in the path. 我不知道为什么路径中会有下划线。 The actual path of my project contains no underscores 我项目的实际路径不包含下划线

I think this is resolved now. 我认为现在已经解决了。 I was running into this problem: https://github.com/Masterminds/glide/issues/602 我遇到了这个问题: https : //github.com/Masterminds/glide/issues/602

After reading this: https://thenewstack.io/understanding-golang-packages/ 阅读此内容后: https : //thenewstack.io/understanding-golang-packages/

I setup my project structure as follows: 我将项目结构设置如下:

/home/dev/go/src/smp-cloudupload
    pkg 
    src
        main
        somepackage
        vendor

And it seems to work 它似乎有效

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

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