From 72de46f3c750603839ef5e096c7f4bf45d86f708 Mon Sep 17 00:00:00 2001 From: AceVest Date: Mon, 3 Apr 2017 14:21:08 +0800 Subject: [PATCH] go --- learn/go/array.slice.map.go | 9 +++++++++ learn/go/var.go | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/learn/go/array.slice.map.go b/learn/go/array.slice.map.go index 410fd6f..cc8a8fd 100644 --- a/learn/go/array.slice.map.go +++ b/learn/go/array.slice.map.go @@ -27,6 +27,15 @@ func main() { fmt.Println(b) fmt.Println(c) + array_x := [...]string{"a", "b", "c"} + var array_y = [5]int{3: 99, 1: 88} // 只指定初始化某些元素,其它用0初始化 + fmt.Println(array_x[0]) + fmt.Println(array_y[0]) + + for i, v := range(array_y) { + fmt.Printf("array_y[%02d] = %d\n", i, v) + } + // SLICE // []T 表示slice var slice []string diff --git a/learn/go/var.go b/learn/go/var.go index e93c356..fc4dce9 100644 --- a/learn/go/var.go +++ b/learn/go/var.go @@ -19,4 +19,10 @@ func main() { var HOME = os.Getenv("HOME") fmt.Println(HOME) + + data := int64(0x11223Ace45566) + + // [1] 是使用第1个参数 # 是指要打印出 0 0x 0X等前缀 + fmt.Printf("%d %[1]x %#[1]x %#[1]X\n", data); + } -- 2.44.0