Scott's Blog

学则不固, 知则不惑

0%

Python 与 Go 开发环境配置

简要记录我的 Git, Docker, Mysql, Python, Go 开发环境配置。

CentOS 7 开发环境配置

Git

略过。

Docker

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 安装
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

# 开机自启动
systemctl enable docker

# 启动
systemctl start docker

# 查看 docker 进程
docker ps -a

# 配置 docker 阿里云镜像,容器镜像服务

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://8szzfxmd.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

# 安装 docker-compose
curl -L https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose


如何检查进程?

Mysql

1
2
3
4
5
6
7
8
9
10
11
12
# 安装 mysql
docker pull mysql:5.7

# 启动 mysql
docker run -p 3306:3306 --name mymysql -v $PWD/conf:/etc/mysql/conf.d -V $PWD/logs:logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=1234@Abc -d mysql:5.7

# 检查 docker 的容器
docker ps -a (ps: Process Status, from linux)

# 进入 mysql 容器并启动 bash
docker exec -it a7a8e9df1270 /bin/bash
myql -uroot -pyoupassword

Python

1
2
3
# anaconda in centos7
curl -O https://repo.anaconda.com/archive/Anaconda3-5.3.1-Linux-x86_64.sh
bash naconda3-5.3.1-Linux-x86_64.sh

Install & uninstall Anaconda on centos7

Go

1
2
3
4
5
# go 环境变量
go env

# 设置 go module
go env -w GO111MODULE=on
1
2
3
4
5
6
7
8
9
10
11
package main

func main() {
println("hello golang")
}

// 命令行运行
go run .\hello.go

// 编译文件, c/c++ -> .so .lib .dll; java -> .class; go -> windows exe
go build .\hello.go