Go 基本語法
本篇文章主要介紹 Go 程式語言的基本語法
- 變數
- 陣列
- 運算符號
- if condition
- for loop
- for each
- function
- map
- struct
變數
1 | var a int |
陣列
1 | var a int[] |
運算符號 (同 C++)
1 | a == b |
if condition
1 | if a > b { |
for loop
1 | for i := 0; i < 10; i++ { |
for each
1 | for index, element := range array { |
function
1 | func Calculate() { |
map
宣告
1 | var valueByKey = make(map[string]int) |
取值和檢查存在
1 | value, isExisted := valueByKey[key] |
賦值
1 | valueByKey[key] = value |
struct
1 | type Person struct { |
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.