<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] > [go-awesome]([https://shockerli.net/post/go-awesome/#%E5%AD%A6%E4%B9%A0%E9%A1%B9%E7%9B%AE](https://shockerli.net/post/go-awesome/#%E5%AD%A6%E4%B9%A0%E9%A1%B9%E7%9B%AE)) ## 安裝配置 ### 類linux 配置 go 有4個環境變量需要設置: GOROOT、 GOPATH、 GOBIN,以及PATH 需要設置到某一個 profile文件中(`~/bash_profile`或`/etc/profile`) ``` > tar -zxvf go1.18.3.linux-amd64.tar.gz > mv go /usr/local/ > vim /etc/profile export GOROOT=/usr/local/go export GOBIN=$GOROOT/bin export PATH=$PATH:$GOBIN ``` 添加到對應的`profile` 配置文件中 eg: `source .zshrc` 或`source .bashrc` ### mac 1. 安裝 `brew install go` 2. 如果 goland 編輯器 無法調試 `https://developer.apple.com/download/more/` 下載 `Command Line tools(macoS 10.13) for Xcode 9.1` ## 編譯安裝 ``` wget https://storage.googleapis.com/golang/go<VERSION>.src.tar.gz tar -zxvf go<VERSION>.src.tar.gz sudo mv go $GOROOT cd $GOROOT/src ./all.bash ``` > 完全不想運行包的測試,你可以直接運行 ./make.bash 來進行單純的構建過程 **注意事項** q:` ‘make[2]: Leaving directory '/localusr/go/src/pkg/net’` a:暫時關閉防火墻 or ` export DISABLE_NET_TESTS=1` ## golang 插件 ### golangci-lint 語法檢查工具,比 gometalinter 快五倍,網址[github.com/golangci/golangci-lin](https://github.com/golangci/golangci-lint) 各個平臺[下載](https://github.com/golangci/golangci-lint/releases) ## 制作開源模塊需要注意到事情 ``` export GO111MODULE=on mkdir -p src/github.com/idcpj/red_packet cd src/github.com/idcpj/red_packet go mod init github.com/idcpj/red_packet > tree ├── README.md ├── app.go ├── brun │?? ├── config.ini │?? └── main.go ├── go.mod ├── go.sum ├── infra │?? ├── base │?? │?? ├── dbx.go │?? │?? ├── log.go │?? │?? └── props.go │?? ├── boot.go ``` 執行自己的模塊時候,需要在 `brun/main.go` 中初始化整個模塊(存在 `ini()` 函數) main.go ``` _ "github.com/idcpj/red_packet" ``` 在 go.mod 中 添加(編譯時,總是 編輯線上 githhub.com 的版本) ``` module github.com/idcpj/red_packet // indirect ``` 執行 ``` cd brun go run main.go ``` ### 版本控制 自定義模塊,在 release 中 添加 版本 `v0.0.1` 即可 ## 下載被墻的包 1. 方法一 如需官方包下載`golang.org/x/time/rate` ``` cd $GOPATH/src/golang.rog/x/ git clone http://github.com/golang/time.git time ``` 下載第三方包 ``` cd $GOPATH/src/github.com/go-sql-driver/ git clone https://github.com/go-sql-driver/mysql 如果有些需要執行命令 如goimports go install golang.org/x/tools/cmd/goimports ``` 2. 方法二 goproxy 國內源加速 ``` export GO111MODULE=on //必須有 mod export GOPROXY=https://goproxy.cn ``` 3. 方法三:Go version >= 1.13 `go env -w GOPROXY=https://goproxy.cn` 4. 方法四: 用 mod 的 replace 代替 ``` replace ( golang.org/x/sys => github.com/golang/sys latest ) ``` ## 確定GOARCH 參數 執行`arch` or `lscpu` ``` amd64 架構 : X86_64 arm64 架構 : aarch64 mipsle 架構(通過 lscpu 查看): Architecture: mips64 Byte Order: Little Endian //小端序 mips 架構(通過 lscpu 查看): Architecture: mips64 Byte Order: Big Endian //小端序 支持的所有平臺是: GOOS:android,darwin,ios,linux,windows GOARCH: ,386,amd64,arm-5,arm-6,arm-7,arm64,mips,,mipslemips64mips64le ``` ## 在不同平臺編譯指定文件 unix 下編譯 ``` CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build main.go ``` Windows 下編譯 ``` //mac SET CGO_ENABLED=0 SET GOOS=darwin SET GOARCH=amd64 go build main.go //linux SET CGO_ENABLED=0 SET GOOS=linux SET GOARCH=amd64 go build main.go ``` ``` GOOS:目標平臺的操作系統(darwin、freebsd、linux、windows) GOARCH:目標平臺的體系架構(386、amd64、arm) ``` ## 錯誤 ### 出現undefined 錯誤 設置編輯器用 包的形式編譯 或者 指定需要的包 `go run main.go hub.go `
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看