Skip to content

Commit

Permalink
33. 延迟的使用例 - defer sample
Browse files Browse the repository at this point in the history
  • Loading branch information
komavideo committed Feb 9, 2021
1 parent 9139145 commit 543e62a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Lesson33/README.md
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Go语言初学入门教学
30. 空接口的类型转换
31. 定义标签
32. 延迟调用 - defer
33. 延迟的使用例 - defer sample

## 课程文件

Expand Down

0 comments on commit 543e62a

Please sign in to comment.