我有一个工作项目,我添加了一些库。一切都很好,直到这一步。然后我将我的代码推送到服务器。我再次尝试将新的克隆存储在存储库中,并且我遇到了以下错误。
去文件找不到错误
当我尝试去做 - (再次回购)我得到
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
这种方法有什么问题?
你可以做几件事。
1.7
export GOPATH=/home/golang/ => try to modify your golang dir here ~$ mkdir -p $GOPATH ~$ go get github.com/jinzhu/gorm
这些问题在这些链接中提到:
我认为最新版本已经解决了这个问题。希望它
我尝试了这种方法,它起作用,因为这是唯一的工作我留下:
新鲜克隆项目并在其中导航;创建了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
文件dependencies.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
我今天遇到了同样的问题,我通过在本地依赖项中初始化一个.git
repo来修复它。所以在github.com/jinzhu/gorm
里面运行:
git init
git add .
git commit -m "first commit"