无法访问Go库

silentsudo:

我有一个工作中的go项目,并在其中添加了一些库。一切正常,直到这一步。然后,我将代码推送到服务器。再次,我尝试重新克隆存储库,但出现以下错误。

去文件找不到错误

当我尝试去获取 -(再次回购)时,我得到了

go get -u github.com/jinzhu/gorm
package github.com/jinzhu/gorm: directory "/testapp/src/github.com/jinzhu/gorm" is not using a known version control system

这种方法有什么问题??

当我检查存储库时,我可以看到git库存储库指向其他一些存储库提交。 在此处输入图片说明

silentsudo:

我尝试了这种方法,并且它起作用了,因为这是我剩下的唯一解决方法:

重新克隆项目并在其中导航;创建install.sh后将设置GOPATH,删除库,然后重新下载。

#!/bin/sh

#GET current working directory
CURRENT_DIR=`pwd`
echo "GOPATH is pointing to ${CURRENT_DIR}"
#Export GOPATH for current working directory
export GOPATH=${CURRENT_DIR}

#Change Directory permission to executable
chmod +x ${GOPATH}

#Delete github dependency so that they can be reinstalled
#Github Issue: https://github.com/golang/go/issues/18591

#Modify this script if you are adding any other packages
rm -rf ${GOPATH}/src/github.com

#dependencies.txt contain list of go get -u (repo path)
#dependencies in new line add any new dependency and execute install.sh again
sh dependencies.txt

文件依赖性.txt

go get -u -v github.com/gorilla/mux
go get -u -v github.com/gorilla/handlers
go get -u -v github.com/dgrijalva/jwt-go

然后最终运行将启动我的应用程序的脚本 run.sh

#!/bin/sh

#GET current working directory
CURRENT_DIR=`pwd`
echo "GOPATH is pointing to ${CURRENT_DIR}"

#Export GOPATH for current working directory
export GOPATH=${CURRENT_DIR}

echo "Starting server at http://localhost:9096"
#Run server instance
go run ${GOPATH}/path/to/main/file/Main.go

所有这些都适用于以下目录结构:

Project Root -----bin -----pkg -----src -----src/github.com/ -----src/github.com/gorilla/mux -----src/github.com/gorilla/handlers -----src/yours/project/code

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章