<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      Go語言交叉編譯工具gox

      基本介紹

      交叉編譯是為了在不同平臺編譯出其他平臺的程序,比如在Linux編譯出Windows程序,在Windows能編譯出Linux程序,32位系統下編譯出64位程序,今天介紹的gox就是其中一款交叉編譯工具。

      配置環境

      首先配置好Go語言的環境變量,并在~/.bash_profile中設置,簡單說明一下為什么要添加至該文件,首先以下代碼在終端執行完成后只對當前會話有效,關閉終端變量就失效了,而.bash_profile文件在用戶每次登錄時都會執行一次,把環境變量設置到該文件中,每次登錄都會初始化環境變量。當然,放在~/.bashrc中也是可以的,它不僅會在登錄時執行,還會在每次打開終端時執行。

      export GOPATH=${HOME}/go
      export GOROOT=/usr/local/go
      export GOBIN=${GOPATH}/bin
      export PATH=${PATH}:${GOBIN}
      

      GOROOT與GOPATH要根據自身情況設置,不要盲目跟從,設置完成后若要該文件立即生效,可以執行source命令。

      source ~/.bash_profile
      

      如果你的終端裝了zsh,可能重新打開終端后依然會失效,那么可以在~/.zshrc文件的最后一行追加上source指令。

      source ~/.bash_profile
      

      gox的安裝

      在終端執行以下指令進行安裝。

      go get github.com/mitchellh/gox
      

      安裝結束后,執行gox -h,如果有展示幫助信息,代表安裝成功。

      ?  ~ gox -h
      Usage: gox [options] [packages]
      
        Gox cross-compiles Go applications in parallel.
      
        If no specific operating systems or architectures are specified, Gox
        will build for all pairs supported by your version of Go.
        ......
      

      gox的使用

      按照慣例,我們先祭出hello,world的演示代碼。

      package main
      
      import "fmt"
      
      func main() {
      	fmt.Print("hello,world")
      }
      

      此時進入項目中的工作目錄($GOPATH/src/[你的項目名]),直接執行gox命令,會生成多達21個不同平臺的可執行文件,橫跨linux、windows、freebsd、darwin等系統。

      ?  hello gox
      Number of parallel builds: 3
      
      -->     linux/amd64: hello
      -->   openbsd/amd64: hello
      -->      darwin/386: hello
      -->    linux/mipsle: hello
      -->     windows/386: hello
      -->   windows/amd64: hello
      -->    darwin/amd64: hello
      -->       linux/386: hello
      -->     linux/s390x: hello
      -->      netbsd/386: hello
      -->       linux/arm: hello
      -->     freebsd/386: hello
      -->    netbsd/amd64: hello
      -->     freebsd/arm: hello
      -->   freebsd/amd64: hello
      -->     openbsd/386: hello
      -->    linux/mips64: hello
      -->      linux/mips: hello
      -->  linux/mips64le: hello
      -->      netbsd/arm: hello
      

      但我并不想一次生成所有平臺的程序,這時就需要gox的參數進行指定,如下所示,os參數指定要生成的系統名稱,arch指定CPU的架構。

      gox -os "windows" -arch amd64
      

      其實它所支持的并不止21款,這些只是默認生成的,下面是gox對各種系統的定義,感興趣的同學可以自行了解。

      Platforms_1_0 = []Platform{
      		{"darwin", "386", true},
      		{"darwin", "amd64", true},
      		{"linux", "386", true},
      		{"linux", "amd64", true},
      		{"linux", "arm", true},
      		{"freebsd", "386", true},
      		{"freebsd", "amd64", true},
      		{"openbsd", "386", true},
      		{"openbsd", "amd64", true},
      		{"windows", "386", true},
      		{"windows", "amd64", true},
      	}
      
      	Platforms_1_1 = append(Platforms_1_0, []Platform{
      		{"freebsd", "arm", true},
      		{"netbsd", "386", true},
      		{"netbsd", "amd64", true},
      		{"netbsd", "arm", true},
      		{"plan9", "386", false},
      	}...)
      
      	Platforms_1_3 = append(Platforms_1_1, []Platform{
      		{"dragonfly", "386", false},
      		{"dragonfly", "amd64", false},
      		{"nacl", "amd64", false},
      		{"nacl", "amd64p32", false},
      		{"nacl", "arm", false},
      		{"solaris", "amd64", false},
      	}...)
      
      	Platforms_1_4 = append(Platforms_1_3, []Platform{
      		{"android", "arm", false},
      		{"plan9", "amd64", false},
      	}...)
      
      	Platforms_1_5 = append(Platforms_1_4, []Platform{
      		{"darwin", "arm", false},
      		{"darwin", "arm64", false},
      		{"linux", "arm64", false},
      		{"linux", "ppc64", false},
      		{"linux", "ppc64le", false},
      	}...)
      
      	Platforms_1_6 = append(Platforms_1_5, []Platform{
      		{"android", "386", false},
      		{"linux", "mips64", false},
      		{"linux", "mips64le", false},
      	}...)
      
      	Platforms_1_7 = append(Platforms_1_5, []Platform{
      		// While not fully supported s390x is generally useful
      		{"linux", "s390x", true},
      		{"plan9", "arm", false},
      		// Add the 1.6 Platforms, but reflect full support for mips64 and mips64le
      		{"android", "386", false},
      		{"linux", "mips64", true},
      		{"linux", "mips64le", true},
      	}...)
      
      	Platforms_1_8 = append(Platforms_1_7, []Platform{
      		{"linux", "mips", true},
      		{"linux", "mipsle", true},
      	}...)
      

      除了剛才的命令外還有另一種生成方式,用斜杠的方式將系統與架構合并批量生成。

      gox -osarch "windows/amd64 linux/amd64"
      

      趕緊把你生成的程序發給小伙伴執行試試吧,以上就是本文全部內容,感謝閱讀。

      posted @ 2019-06-13 22:47  MARIOOW  閱讀(5154)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 霞浦县| 在线天堂最新版资源| 成人免费无遮挡在线播放| 成人伊人青草久久综合网| 久久国产精品伊人青青草| 亚洲精品久久久中文字幕痴女 | 亚洲国产午夜精品理论片在线播放 | 少妇激情一区二区三区视频小说| 久久亚洲精品国产精品| 青青草国产自产一区二区| 国产超碰无码最新上传| 无码国内精品人妻少妇| 国产精品一区二区三区污| 日韩精品国产二区三区| 亚洲精品日韩久久精品| 亚洲av不卡电影在线网址最新| 国产成人啪精品午夜网站| 柠檬福利第一导航在线| 亚洲综合一区国产精品| 在线日韩日本国产亚洲| 国产精品成人av在线观看春天| 国产极品粉嫩尤物一线天| 国产精品乱人伦一区二区| 欧美老少配性行为| 久久av无码精品人妻出轨| 久久精品国产亚洲夜色av| 亚洲一区二区中文av| 久久精品国产亚洲AⅤ无码| 亚洲熟女一区二区av| 亚洲自偷自偷在线成人网站传媒| 国内自拍偷拍一区二区三区| 亚洲av成人区国产精品| 国产精品亚洲а∨天堂2021 | 亚洲国产av无码精品无广告 | 九九热在线精品视频观看| a片在线免费观看| 人人爽天天碰天天躁夜夜躁| 中文字幕日韩有码av| 中文字幕av无码一区二区三区| 蜜臀在线播放一区在线播放 | 国产精品中出一区二区三区|