golang 微服務架構環境搭建

1.安裝golang語言

從官網下載安裝,具體不贅述了。

2.配置環境變量GOROOT,GOPATH GOROOT 是go安裝路徑;GOPATH 是你的工作路徑

export GOROOT=/home/user/env/go/bin
export GOPATH=/home/user/work/go

3.在GOPATH路徑下面創建文件夾src,pkg,bin ;

4.安裝protobuf ;protobuf

下載protobuf代碼 https://github.com/protocolbuffers/protobuf

cd protobuf
 ./configure --prefix=/usr/local/protobuf
 make
 make check
 make install

配置環境變量

(1) vim /etc/profile,添加

export PATH=$PATH:/usr/local/protobuf/bin/
  export PKG_CONFIG_PATH=/usr/local/protobuf/lib/pkgconfig/
  保存執行,source /etc/profile。同時在~/.profile中添加上面兩行代碼,否則會出現登錄用戶找不到protoc命令。

5.安裝micro環境

micro很多依賴需要訪問golang.org但是被牆的原因可以在github上面下載到目錄src/golang.org/x/下面
如下:
git clone https://github.com/golang/net
git clone https://github.com/golang/text
git clone https://github.com/golang/sys.git
git clone https://github.com/golang/crypto

src:/
mkdir google.golang.org & cd google.golang.org
git clone https://github.com/grpc/grpc-go
mv  grpc-go/  grpc/
git clone https://github.com/google/go-genproto
mv  go-genproto/  genproto/ 

go get github.com/micro/micro
go get github.com/micro/go-micro
go get github.com/micro/cli
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章