[英]Installing serverless with aws-go-dep not working
I'm just getting starting with Golang and Serverless.我刚刚开始使用 Golang 和 Serverless。 I've basically gone through these steps on MacOS:我基本上已经在 MacOS 上完成了这些步骤:
export GOPATH="$GOPATH:~/Projects/testproject"
to ~/.profile
添加export GOPATH="$GOPATH:~/Projects/testproject"
到~/.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/我还按照博客文章进行了设置示例: 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"
根据go env
我的路径是: 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.为了解决这个问题,我最终放弃了创建自定义工作区,只是让我的 GOPATH 指向一个一致的文件夹。 GOROOT was pointed to /usr/local/opt/go/libexec (seems to be where Brew installs Go). GOROOT 指向 /usr/local/opt/go/libexec(似乎是 Brew 安装 Go 的地方)。
Small rant: Go's setup experience is terrible .小咆哮:Go 的设置体验很糟糕。 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.本文档可以帮助您设置 Go 特定的开发环境。
In short, you need to set two variables - GOPATH
& GOROOT
.简而言之,您需要设置两个变量 - GOPATH
和GOROOT
。
Here is what your .profile
should look like ...这是您的.profile
应该是什么样子...
# 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.您可以在$GOPATH/src/github.com/*
创建符号链接并将其指向您现有的项目目录。
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现在,您可以在example-project
业务, example-project
~ code/example-project >> make
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.