头图

Install docker

brew cask install docker

Install ubuntn using docker

docker pull ubuntu

Start the container

docker run --name=ubuntn --volume=~/WorkSpace:/root/workspace -d -it  ubuntu:latest
  • ~/WorkSpace : working directory on your computer
  • /root/workspace : working directory inside the container

View container id

docker ps | grep ubuntn

Enter the container

docker exec -it ubuntn bash

renew

apt-get update -y
apt-get upgrade -y

install software

apt-get install -y vim git curl git mercurial make binutils bison gcc build-essential

Configuration git

git config --global url."https://github.com.cnpmjs.org/".insteadOf "https://github.com/"

Mainly solve the problem of timeout when using https to pull the project.

Configure the container

vim ~/.bashrc

Append at the end of the file

export LANG="en_US.UTF-8" # 设置系统语言为 en_US.UTF-8,避免终端出现中文乱码
export PS1="[\u@dev \W]\$ " # 默认的 PS1 设置会展示全部的路径,为了防止过长,这里只展示:"用户名@dev 最后的目录名"
export WORKSPACE="$HOME/workspace" # 设置工作目录,放go代码的位置
export PATH="$PATH/bin:$PATH" # 将 $HOME/bin 目录加入到 PATH 变量中

# Default entry folder
cd $WORKSPACE # 登录系统,默认进入 workspace 目录

Install go version management tool gvm

bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
source /root/.gvm/scripts/gvm

It is convenient to switch the go version for data comparison when learning.

Install go

gvm install go1.17 -B

Set goproxy

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct

Installation and debugging tools

go install github.com/go-delve/delve/cmd/dlv@latest

CoolCold
53 声望3 粉丝

go~ go~ go~