第四週: 網頁專家 - 線上學 html 編輯與 CSS 產生器
+ Go Again.
markdown 語言, 跟 html 很像, 但一般網頁不能直接看.
用文字檔, 來表現類似 html 的結果
(10 分鐘)
func main() { fmt.Println(add(1 + 2)) } |
|
主程式:
整個程式 只會執行 main() 這個主程式
副程式:
main() 以外的 functions, 要在先定義, 之後被其它程式來叫用
func add(x, y int) int {
return x + y
}
func main() { fmt.Println(1) // ... 2 to 6 fmt.Println(7) fmt.Println(8) fmt.Println(9) fmt.Println(10) } |
|
例如, 從 1 印到 10
func main() { for j := 1; j <= 10; j++ { fmt.Println(j) } } |
|
例如, 從 1 印到 10, 如果用變數, 才能用的 for loop 的好處
註解: fmt.Println(), 可印出不只一個東西, 多個可用逗點分開
例如 fmt.Println(i, "x", j, "=", i * j)
(最好跟右邊這個長得一模一樣)