提交 495b6549 编写于 作者: 彭世瑜's avatar 彭世瑜

fix

上级 c976dcaa
......@@ -52,6 +52,60 @@ func main() {
}
```
Golang中的特殊写法
```go
package main
import (
"fmt"
)
func main() {
// age处于局部作用域
if age := 18; age > 18 {
fmt.Println("age > 18")
} else {
fmt.Println("age <= 18")
}
// age <= 18
}
```
接收用户输入
```go
package main
import (
"fmt"
)
func main() {
var age int
fmt.Printf("请输入age:\n")
fmt.Scan(&age)
fmt.Printf("age: %v\n", age)
}
```
命令行方式运行
```bash
$ go run main.go
请输入age:
23
age: 23
```
### switch...case
示例
......@@ -81,6 +135,8 @@ func main() {
}
```
> 注意:不能使用0和非0表示真假
## 循环执行
### for
......
......@@ -34,4 +34,4 @@
https://www.bilibili.com/video/BV1ME411Y71o?p=27&spm_id_from=pageDriver&vd_source=efbb4dc944fa761b6e016ce2ca5933da
https://www.bilibili.com/video/BV1zR4y1t7Wj?p=19&spm_id_from=pageDriver&vd_source=efbb4dc944fa761b6e016ce2ca5933da
\ No newline at end of file
https://www.bilibili.com/video/BV1zR4y1t7Wj?p=21&spm_id_from=pageDriver&vd_source=efbb4dc944fa761b6e016ce2ca5933da
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册