讀《Introducing Go》O'Reilly , 第1,2章

來源:互聯網
上載者:User
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。很明顯是英文版的,共124頁
很新,2016-1 版
一,開始
二,類型
三,變數
四,控制結構
五,數組
六,函數
七,結構和介面
八,包
九,測試
十,
十一,下一步


一,
安裝 win 版的 go1.5.3.windows-amd64.msi
之後
寫個 hello world! 吧。
弄個新的目錄儲存代碼:
E:\renqiWork\src\golang>


建立個檔案,文字編輯器
notepad hw.go


內容是:
package main


import "fmt"


func main() {
    fmt.Println("Hello, S F")
}


編譯:
go run hw.go


輸出:
Hello, S F


fmt 包是格式化輸入輸出的縮寫。
// , /* */ 是注釋
到 18 頁。就是PDF 的第6頁
godoc fmt Println


第2章 類型,第9頁
go 是靜態類型程式語言,類型定義後不可以改變。


整數:uint8, uint16, uint32, uint64, int8, int16, int32, int64


浮點型, NaN (not a number) ,比如 0/0 產生的。
float32 , float64
第11頁。
//執行命令
//go run floatcal.go


package main


import "fmt"


func main() {
  //Println 是區分大小寫。
  fmt.Println("1.0 + 1.0 = ", 1.0 + 1.0)
}


Strings 字串
fmt.Println(len("hello, world")) // 字串長度:12
fmt.Println("hello, world"[1]) //把字串做為數組第二個下標“e”的 ascii 碼為 101
fmt.Println("hello, " + "world") //字串串連符應用


Booleans 布爾型
&& , ||, ! 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.