mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 00:43:26 +08:00
阅读并校对12.1 到 12.7
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# 用切片读写文件
|
||||
|
||||
切片提供了标准的Go方法来处理I/O缓冲,下面`cat`函数的第二版中,在一个切片缓冲内使用无线for循环(直到文件尾部EOF)读取文件,并写入到标准输出。
|
||||
切片提供了 Go 中处理 I/O 缓冲的标准方式,下面 `cat` 函数的第二版中,在一个切片缓冲内使用无限 for 循环(直到文件尾部 EOF)读取文件,并写入到标准输出(`os.Stdout`)。
|
||||
|
||||
```go
|
||||
func cat(f *os.File) {
|
||||
@@ -22,7 +22,7 @@ func cat(f *os.File) {
|
||||
}
|
||||
|
||||
```
|
||||
代码来自于`cat2.go`,使用了os包中的`os.file`和`Read`方法;`cat2.go`与`cat.go`具有同样的功能。
|
||||
下面的代码来自于 `cat2.go`,使用了 os 包中的 `os.file` 和 `Read` 方法;`cat2.go` 与 `cat.go` 具有同样的功能。
|
||||
|
||||
|
||||
示例 12.14 [cat2.go](examples/chapter_12/cat2.go):
|
||||
@@ -75,5 +75,5 @@ func main() {
|
||||
## 链接
|
||||
|
||||
- [目录](directory.md)
|
||||
- 上一节:[用buffer读取文件](12.5.md)
|
||||
- 下一节:[用defer关闭文件](12.7.md)
|
||||
- 上一节:[用 buffer 读取文件](12.5.md)
|
||||
- 下一节:[用 defer 关闭文件](12.7.md)
|
||||
|
Reference in New Issue
Block a user