Godep保存永远无法正常工作

When trying to run godep save, I'm always getting the following error:

godep: [WARNING]: godep should only be used inside a valid go package directory and
godep: [WARNING]: may not function correctly. You are probably outside of your $GOPATH.
godep: [WARNING]:   Current Directory: /Users/username/Development/my-server
godep: [WARNING]:   $GOPATH: /Users/username/Development/my-server

Does anyone know how to solve this issue?

You want to make sure that you run this command from a repo that is also defined in your $GOPATH.

So it would need to be: /Users/username/gosource/src/github/foo/my-server/

This means that not only are all your packages located in your $GOPATH but additionally your own repo is located in your $GOPATH. At this point everything should work as expected.

If you don't have a $GOPATH environment variable defined you need to make sure it is set pre Go1.8.

Try this: echo $GOPATH at the command prompt to see if it's defined.

If not, you'll want to choose a location and set it with: export GOPATH=/your/final/location.

More details can be found here.