Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c33fab4

Browse files
committed
35 - 读取文件
1 parent 30b3771 commit c33fab4

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

‎README.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ $ go get github.com/Tinywan/golang-tutorial
7373
###### 30 - 错误处理
7474
###### 31 - 自定义错误
7575
###### 32 -Panic 和 Recover
76-
###### 33 - 头等函数
77-
######34 - 反射
76+
#### 头等函数
77+
###### 33 - 头等函数
78+
#### 反射
79+
###### 34 - 反射
80+
#### 文件操作
7881
###### [35 - 读文件](/docs/golang_tutorial_35.md)
7982

8083
#### 文档

‎demo/string01.go‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@ package main
22

33
import (
44
"fmt"
5+
"os"
6+
"strings"
57
)
68

7-
var age int
8-
99
func main() {
10-
name := "Tinywan"
11-
fmt.Println(name)
12-
fmt.Println(name)
13-
}
10+
os.Setenv("Name", "Tinywan")
11+
fmt.Println("Name = ", os.Getenv("Name"))
12+
fmt.Println("Bar", os.Getenv("bar"))
13+
fmt.Println()
14+
15+
fmt.Println()
16+
for _, e := range os.Environ() {
17+
pair := strings.Split(e, "=")
18+
fmt.Println(pair[0])
19+
}
20+
}
21+
go

‎docs/golang_tutorial_35.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11

22
35 - 读取文件
33
========================
4-
4+
<div align="center">
5+
<img src="../images/golang-read-files.png"/><br><br>
6+
</div>
57
上一节:[第十六篇 结构体](/docs/golang_tutorial_16.md)
68
下一节:[第十八篇 接口一](/docs/golang_tutorial_18.md)
79

‎images/golang-read-files.png‎

28.9 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /