52 lines
		
	
	
		
			982 B
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			982 B
		
	
	
	
		
			Markdown
		
	
	
	
	
	
# GoLang
 | 
						||
 | 
						||
## 安装
 | 
						||
 | 
						||
```python
 | 
						||
#查看go root path
 | 
						||
!go env
 | 
						||
#删除目录
 | 
						||
!rm -rf /usr/lib/golang
 | 
						||
#下载解压
 | 
						||
!wget https://golang.google.cn/dl/go1.20.2.linux-amd64.tar.gz
 | 
						||
!tar xvf go1.20.2.linux-amd64.tar.gz
 | 
						||
#移动目录
 | 
						||
!mv go /usr/lib/go
 | 
						||
#加载配置
 | 
						||
%load /etc/profile
 | 
						||
#写入配置
 | 
						||
%%writefile /etc/profile.d/env.sh
 | 
						||
export GO111MODULE=on
 | 
						||
export GOROOT=/usr/local/go
 | 
						||
export GOPATH=/home/gopath
 | 
						||
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
 | 
						||
#激活配置
 | 
						||
!source /etc/profile
 | 
						||
```
 | 
						||
 | 
						||
golang 官网地址: https://golang.google.cn/
 | 
						||
 | 
						||
## 配置
 | 
						||
 | 
						||
```shell
 | 
						||
GO_HOME=C:\App\go
 | 
						||
#新建GO_HOME 系统环境变量后,找到系统环境变量Path,然后编辑 Path
 | 
						||
#新建 %GO_HOME%\bin,指向 go 安装目录的 bin 目录
 | 
						||
 | 
						||
#设置代理
 | 
						||
go env -w GOPROXY=https://goproxy.cn,direct
 | 
						||
 | 
						||
#go init 创建项目
 | 
						||
go mod init example/hello
 | 
						||
```
 | 
						||
 | 
						||
## 安装库
 | 
						||
 | 
						||
- protoc
 | 
						||
 | 
						||
```shell
 | 
						||
go install google.golang.org/protobuf/cmd/protoc-gen-go
 | 
						||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
 | 
						||
```
 | 
						||
 |