Ubuntu Golang 开发环境搭建

go_src

Setup Development Environment

Ubuntu Installation

1
2
3
4
sudo add-apt-repository ppa:gophers/archive
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install build-essential autoconf libtool libsysfs-dev

Download & Install Golang 1.11.5

1
2
3
wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz
sudo tar -xvf go1.11.5.linux-amd64.tar.gz
sudo mv go /usr/local

FIXME: vi ~/.bashrc not useful ???

1
2
3
export GOROOT=/usr/local/go
export GOPATH=$HOME/workspace
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

Build Protobuf from source

1
2
3
4
5
6
7
8
9
git clone https://github.com/google/protobuf.git
cd protobuf/
git clone https://github.com/google/googlemock.git
mv googlemock gmock
./autogen.sh
./configure
make
sudo make install
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/usr/local/lib64:/usr/lib64

Install proto-gen-go

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
GIT_TAG="v1.2.0" # change as needed
go get -d -u github.com/golang/protobuf/protoc-gen-go
git -C "$(go env GOPATH)"/src/github.com/golang/protobuf checkout $GIT_TAG
go install github.com/golang/protobuf/protoc-gen-go
# micro
go get -u github.com/micro/protobuf/protoc
go get -u github.com/micro/protobuf/protoc-gen-go
go install github.com/micro/protobuf/protoc-gen-go
# protoc-gen-micro
go get github.com/micro/protoc-gen-micro
# grpc
go get -v -u github.com/grpc-ecosystem/grpc-gateway
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go install github.com/golang/protobuf/protoc-gen-go

SQL

1
2
3
4
DROP DATABASE txin_user;
CREATE DATABASE txin_user
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_general_ci;