简体   繁体   中英

Installing serverless with aws-go-dep not working

I'm just getting starting with Golang and Serverless. I've basically gone through these steps on MacOS:

  1. brew install golang
  2. brew install dep
  3. npm install -g serverless
  4. mkdir ~/Projects/testproject
  5. Added export GOPATH="$GOPATH:~/Projects/testproject" to ~/.profile
  6. serverless create -t aws-go-dep -p myservice within the testprojects folder
  7. Run make and get this weird error:
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 :-/

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!

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

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM