-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
延迟的使用例 - defer sample | ||
========================== | ||
|
||
## 知识点 | ||
|
||
* 延迟的使用例 - 文件的打开与关闭 | ||
|
||
## 实战演习 | ||
|
||
~~~go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
func main() { | ||
fmt.Println("Helo Go.") | ||
|
||
file, err := os.Create("mytest.txt") | ||
if err != nil { | ||
fmt.Println("我去,出错啦!", err) | ||
} | ||
defer file.Close() | ||
|
||
file.WriteString("我爱Go浪!") | ||
} | ||
~~~ | ||
|
||
## 课程文件 | ||
|
||
https://github.com/komavideo/LearnGo | ||
|
||
## 小马视频频道 | ||
|
||
http://komavideo.com | ||
|
||
## 小马部落(Discord) | ||
|
||
https://discord.gg/VSKw72P |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ Go语言初学入门教学 | |
30. 空接口的类型转换 | ||
31. 定义标签 | ||
32. 延迟调用 - defer | ||
33. 延迟的使用例 - defer sample | ||
|
||
## 课程文件 | ||
|
||
|