在安装yaml的时候不能下载,无反应:
1 | go get gopkg. in /yaml .v1 |
原因git版本太低,需>= 1.7.9.5,通过RPMForge源安装最新版本git解决:
1 | yum --enablerepo=rpmforge-extras install git |
发布时间:August 18, 2014 // 分类:GO // No Comments
在安装yaml的时候不能下载,无反应:
1 | go get gopkg. in /yaml .v1 |
原因git版本太低,需>= 1.7.9.5,通过RPMForge源安装最新版本git解决:
1 | yum --enablerepo=rpmforge-extras install git |
发布时间:August 18, 2014 // 分类:网络工具 // No Comments
SSH默认转发远程服务器端口时监听loop,只能通过本地访问端口,如:
1 | ssh -R 0.0.0.0:9022:localhost:22 root@haiyun.me |
修改配置文件允许自定义监听地址:
1 2 | echo 'GatewayPorts yes' >> /etc/ssh/sshd_config /etc/init .d /sshd restart |
发布时间:August 18, 2014 // 分类:GO // 3 Comments
Centos下使用epel源安装:
1 | yum install golang |
Centos/Linux下源码安装golang:
1 2 3 4 5 6 7 8 | wget https: //dl .google.com /go/go1 .13.4.linux-amd64. tar .gz tar -C /usr/local -xzf go*linux-amd64. tar .gz mkdir $HOME /go echo 'export GOROOT=/usr/local/go' >> ~/.bashrc echo 'export GOPATH=$HOME/go' >> ~/.bashrc echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> ~/.bashrc echo 'export GO111MODULE=auto' >> ~/.bashrc source $HOME/.bashrc |
安装go get工具:
1 | yum install mercurial git bzr subversion |
Windows下安装:
设置环境变量:
1 2 3 4 5 6 | setx GOOS windows setx GOARCH amd64 setx GOROOT "D:\Program Files\go" setx GOBIN "%GOROOT%\bin" setx GO111MODULE auto setx PATH %PATH% ; "D:\Program Files\go\bin" |
交叉编译:
1 2 | CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build main.go CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go |
减小编译生成文件大小:
1 | go build -ldflags "-s -w" |
发布时间:August 18, 2014 // 分类:网络工具 // No Comments
通过ngrok服务器转发端口到本地80:
1 | ngrok 80 |
自定义二级域名,需在ngrok官网注册账号获取auth token:
1 | ngrok -authtoken Co1KiaaAdpapgD -subdomain=example 80 |
转发TCP协议其它端口,
1 | ngrok -authtoken Co1KiaaAdpapgD -proto=tcp 22 |
指定远程服务器端口:
1 2 3 4 5 6 | auth_token: Co1KiaaAdpapgD tunnels: ssh: proto: tcp: "22" remote_port: 52222 |
启动:
1 | ngrok -config ngrok.conf start ssh |