<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## 配置 Go 開發環境 本節將討論使用`runtime` package 的功能和屬性查找有關當前 Go 環境的信息。本節中將程序命名為`goEnv.go`,它將分為兩部分。 第一部分: ```Go package main import ( "fmt" "runtime" ) ``` `runtime` package 包含獲取 runtime 信息的函數和屬性。 `goEnv.go`的第二個代碼部分包含`main()`函數的實現: ```Go func main() { fmt.Print("You are using ", runtime.Compiler, " ") fmt.Println("on a", runtime.GOARCH, "machine") fmt.Println("Using Go version", runtime.Version()) fmt.Println("Number of CPUs:", runtime.NumCPU()) fmt.Println("Number of Goroutines:", runtime.NumGoroutine()) } ``` 在裝有 Go 1.11.4 的 macOS Mojave 機器上執行`goEnv.go`將輸出: ```shell $ go run goEnv.go You are using gc on a amd64 machine Using Go version go1.11.4 Number of CPUs: 8 Number of Goroutines: 1 ``` 同樣的代碼在裝有 Go 1.3.3 的 Debian Linux 機器上輸出如下: ```shell $ go run goEnv.go You are using gc on a amd64 machine Using Go version go1.3.3 Number of CPUs: 1 Number of Goroutines: 4 ``` 在名為`requiredVersion.go`的程序中說明了獲取到有關 Go 環境的信息有什么用處,該程序會告訴你是否使用的是 Go1.8 或更高版本: ```Go package main import ( "fmt" "runtime" "strconv" "strings" ) func main() { myVersion := runtime.Version() major := strings.Split(myVersion, ".")[0][2] minor := strings.Split(myVersion, ".")[1] m1, _ := strconv.Atoi(string(major)) m2, _ := strconv.Atoi(minor) if m1 == 1 && m2 < 8 { fmt.Println("Need Go version 1.8 or higher!") return } fmt.Println("You are using Go version 1.8 or higher!") } ``` `strings`Go 標準包用于拆分從`runtime.Version()`獲得的 Go 版本字符串,以獲取其前兩個部分,而 `strconv.Atoi()`函數用于將字符串轉換為整數。 在 macOS Mojave 機器上執行`requiredVersion.go`將輸出: ```shell $ go run requiredVersion.go You are using Go version 1.8 or higher! ``` 但如果你在 Debian Linux 機器上運行`requiredVersion.go`,它將輸出: ```shell $ go run requiredVersion.go Need Go version 1.8 or higher! ``` 因此,通過調用程序`requiredVersion.go`,你能夠確定 UNIX 計算機是否具有所需的 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>

                              哎呀哎呀视频在线观看