Reputation: 1502
I'm just getting starting with Golang and Serverless. I've basically gone through these steps on MacOS:
export GOPATH="$GOPATH:~/Projects/testproject"
to ~/.profile
unable to create lock pkg/dep/sm.lock: Lockfiles must be given as absolute path names
make: *** [build] Error 1
Not sure what I'm doing wrong. Also I followed the blog article for getting setup with the example: https://serverless.com/blog/framework-example-golang-lambda-support/
According to go env
my path is: GOPATH=":/Users/ddibiase-macbook/go:/Users/ddibiase-macbook/Projects/centive/api"
There isn't much helpful documentation online to get through this :-/
Upvotes: 1
Views: 399
Reputation: 2357
You can make a symlink within $GOPATH/src/github.com/*
and point it to your existing project directory.
Create the symlink:
~ >> ln -s $HOME/code/example-project $GOPATH/src/github.com/example-project
Verify it worked
~/go/src/github.com >> ls -l
total 0
drwxr-xr-x 3 trex staff 96 Feb 9 10:20 google
lrwxr-xr-x 1 trex staff 30 Feb 9 15:58 example-project -> /Users/trex/code/example-project
Now you can go about your business in the example-project
with things like
~ code/example-project >> make
Upvotes: 0
Reputation: 1502
To resolve the issue, I ended up giving up on creating a custom workspace and just making my GOPATH point to one consistent folder. GOROOT was pointed to /usr/local/opt/go/libexec (seems to be where Brew installs Go).
Small rant: Go's setup experience is terrible. I get the fact that it's meant to have opinions, but something as simple as workspace placement and setting up paths...this should be taken care of by the installation process and make clearer to the developer installing the build tools. Booo!
Upvotes: 2
Reputation: 1451
This documentation can help you to set up Go specific development environment.
In short, you need to set two variables - GOPATH
& GOROOT
.
Here is what your .profile
should look like ...
# this is mac os specific
export GOPATH=$HOME/Projects
# set goroot
export GOROOT=/usr/local/opt/go/libexec
# set path
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
Upvotes: 0