ngrok是一個ddns服務,爲內網機器綁定一個公網域名,方便開發調試遠程接口(如微信開發)。
linux
以前博文裏面寫過如何安裝ngrok,可是因爲公司裏面的研發工程師的筆記本有windows本和mac本,因此本次主要講怎麼生成windows、mac客戶端。git
準備工做:須要參考http://nanchunle.blog.51cto.com/9244770/1710295,安裝完成ngrokgithub
1、編譯Windwos客戶端golang
cd /usr/local/go/src
GOOS=windows GOARCH=amd64 ./make.bash
cd /usr/local/ngrok
GOOS=windows GOARCH=amd64 make release-client
#同理,這裏的amd64是64位系統,32位改爲386
#應該會在 bin/windows_amd64 目錄下生成ngrok客戶端程序
到這裏,編譯就完成了,就能夠將ngrok.exe下載到windows操做系統。windows
啓動步驟:api
一、將ngrok.exe放在D:\ngrok,而且在D:\ngrok編輯配置文件ngrok.cfgxcode
server_addr: "example.com:4443"
|
./ngrok -config=ngrok.cfg -log=ngrok.log -subdomain=test 8080 |
2、編譯Mac客戶端微信
cd /usr/local/go/src微信開發
GOOS=darwin GOARCH=amd64 ./make.bash
而後回去ngrok目錄,接着編譯:
cd /usr/local/src/ngrok
GOOS=darwin GOARCH=amd64 make release-client
完成後會在 /usr/local/src/ngrok/bin/darwin_amd64/ 下發現 ngrok 文件,將其拷貝到Mac上面,像上面windows
的設置便可使用。
3、注意事項
一、Centos/Linux下源碼安裝golang:
|
二、在步驟GOOS=darwin GOARCH=amd64 make release-client出現錯誤
imports runtime: C source files not allowed when not using cgo or SWIG: atomic_amd64x.c defs.c float.c heapdump.c lfstack.c malloc.c mcache.c mcentral.c mem_darwin.c mfixalloc.c mgc0.c mheap.c msize.c os_darwin.c panic.c parfor.c proc.c runtime.c signal.c signal_amd64x.c signal_unix.c stack.c string.c sys_x86.c make: *** [deps] Error 1 |
解決方法:參考網站 http://stackoverflow.com/questions/27772831/golang-c-source-files-not-allowed-when-not-using-cgo
https://github.com/golang/go/wiki/InstallFromSource#introduction
Introduction This is a companion to http://golang.org/doc/install/source providing additional instructions for various operating systems. Install C toolsOn OS X, a C compiler is bundled in the command line tools for Xcode, and you don't need to install the whole Xcode to compile Go. If you have already installed Xcode 4.3+, you can install command line tools from the Components tab of the Downloads preferences panel. In more recent versions of Xcode, you can use On Ubuntu/Debian, use On RedHat/Centos 6, use On Windows, install |