无法访问Go库

I had a working go project and I added some libraries to it. All was working fine till this step. Then I pushed my code to server. Again I tried to take fresh clone the repository and I am getting following error.

go file not find error

When I try to do go get - (repo again) I get

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

What is wrong in this approach??

And When I am checking repository I can see git library repository point to some other repository commit. enter image description here

I tried this approach and it worked as this was the only work around i was left with:

Fresh clone the project and navigate inside it; Created install.sh which would set GOPATH, remove libraries and then re download it.

#!/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

File 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

Then finally run script which would boot my application 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

All this hold true with following directory structure:

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

There are couple things you can do.

  1. Check your version of your GO if not the latest version then update your GO to version 1.7
  2. Delete the repo and clone again after updating GO.
  3. You could try to create new export for Golang directory with the following step :
export GOPATH=/home/golang/    => try to modify your golang dir here
~$ mkdir -p $GOPATH
~$ go get github.com/jinzhu/gorm

this kind of problem mention in these link :

I think the latest version has fix this issue. Hope it

I ran into the same issue just today and I fixed it by initializing a .git repo inside the local dependency. So inside github.com/jinzhu/gorm run:

git init 

git add . 
git commit -m "first commit"