go 基礎安裝

來源:互聯網
上載者:User

一、安裝:

  1、下載GO的地址:https://golang.org/dl/

      點擊安裝包進行安裝(linux直接解壓)

      設定環境變數(linux)
        1. export GOROOT=$PATH:/path/to/go/
        2. export PATH=$PATH:$GOROOT/bin/
        3. export GOPATH=/home/user/project/go
      設定環境變數(window不用設定

  2、IDE選擇(Visual Studio Code)

    下載地址:https://code.visualstudio.com/

    查看>擴充>尋找Go>安裝

  3、調試工具的安裝

    教程:https://github.com/derekparker/delve/tree/master/Documentation/installation

    win: cmd中輸入go get github.com/derekparker/delve/cmd/dlv

  4、目錄

    

  5、環境變數設定

     設定環境變數:(建立)   運用 G:\project>go build -o bin/list.exe go_dev/day2/example1/main  建立運用程式   -o是在bin裡面建立應用程式

 

  6、第一個程式

package main     //定義包名import ("fmt"   //引用fmt包,fmt包實現格式化IO(輸入/輸出)的函數)func main(){
    /* 長段注釋 */fmt.Println("hello world")  //需要列印的內容}

  

  7、列印一個從1到100的 程式

goroute.go
package mainimport ("fmt")func test_goroute(a int ){fmt.Println(a)}

  main.go

package mainimport ("time")func main(){for i := 0; i<100; i++{go test_goroute(i)}time.Sleep(time.Second)}

 

 

    

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.