本教程适用于 Mac 系统
CLI Proxy API
Go 环境
地址:https://golang.google.cn/dl/
Apple Silicon 下载 Apple macOS (ARM64)
1
2
3
4
5
6
7
8
9
10
vim ~/.zshrc
export PATH = $PATH :/usr/local/go/bin # Go 的可执行文件目录
export GOPATH = $HOME /go # 工作目录
export PATH = $PATH :$GOPATH /bin # GOPATH的bin目录
source ~/.zshrc
# 检查版本
go version
安装
设置代理
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
# 取消代理
go env -w GOPROXY = direct
# 官方全球代理
go env -w GOPROXY = https://proxy.golang.com.cn,direct
go env -w GOSUMDB = sum.golang.google.cn
# 或者
go env -w GOPROXY = https://goproxy.io,direct
go env -w GOSUMDB = gosum.io+ce6e7565+AY5qEHUk/qmHc5btzW45JVoENfazw8LielDsaI+lEbq6
# 七牛云
go env -w GOPROXY = https://goproxy.cn,direct
go env -w GOSUMDB = goproxy.cn/sumdb/sum.golang.org
# 阿里云
go env -w GOPROXY = https://mirrors.aliyun.com/goproxy/,direct
# GOSUMDB 不支持
# GoCenter
go env -w GOPROXY = https://gocenter.io,direct
# 不支持 GOSUMDB
# 百度
go env -w GOPROXY = https://goproxy.bj.bcebos.com/,direct
# 不支持 GOSUMDB
1
2
3
4
git clone https://github.com/router-for-me/CLIProxyAPI.git
cd CLIProxyAPI
cp config.example.yaml config.yaml
go build -o cli-proxy-api ./cmd/server
开机自启
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
mkdir -p ~/Library/LaunchAgents
cat > ~/Library/LaunchAgents/com.cli-proxy-api.plist << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.cli-proxy-api</string>
<key>ProgramArguments</key>
<array>
<!-- 替换下面的路径 -->
<string>xxxxxx/CLIProxyAPI/cli-proxy-api</string>
</array>
<key>WorkingDirectory</key>
<!-- 替换下面的路径 -->
<string>xxxxxx/CLIProxyAPI</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<!-- 替换下面的路径 -->
<string>xxxxxx/CLIProxyAPI/app.log</string>
<key>StandardErrorPath</key>
<!-- 替换下面的路径 -->
<string>xxxxxx/CLIProxyAPI/app.log</string>
</dict>
</plist>
EOF
# 启动:
launchctl load ~/Library/LaunchAgents/com.cli-proxy-api.plist
# 停止并卸载服务(不再开机自启)
launchctl unload ~/Library/LaunchAgents/com.cli-proxy-api.plist
# 重新加载并启动(修改配置后使用)
launchctl load ~/Library/LaunchAgents/com.cli-proxy-api.plist
# 手动启动(如果服务未运行)
launchctl start com.cli-proxy-api
# 手动停止
launchctl stop com.cli-proxy-api
# 查看服务状态
launchctl list | grep cli-proxy-api