1
0
mirror of https://github.com/chai2010/advanced-go-programming-book.git synced 2025-05-23 20:02:22 +00:00

Merge pull request #435 from quocanh1897/master

Fix example  code in ch1-04
This commit is contained in:
chai2010 2019-06-26 10:31:33 +08:00 committed by GitHub
commit 351cff1299
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -183,7 +183,7 @@ func CloseFile(f *File) error {
}
// 读文件数据
func ReadFile(f *File, int64 offset, data []byte) int {
func ReadFile(f *File, offset int64, data []byte) int {
// ...
}
```
@ -199,7 +199,7 @@ func (f *File) CloseFile() error {
}
// 读文件数据
func (f *File) ReadFile(int64 offset, data []byte) int {
func (f *File) ReadFile(offset int64, data []byte) int {
// ...
}
```
@ -213,7 +213,7 @@ func (f *File) Close() error {
}
// 读文件数据
func (f *File) Read(int64 offset, data []byte) int {
func (f *File) Read(offset int64, data []byte) int {
// ...
}
```
@ -228,7 +228,7 @@ func (f *File) Read(int64 offset, data []byte) int {
var CloseFile = (*File).Close
// 不依赖具体的文件对象
// func ReadFile(f *File, int64 offset, data []byte) int
// func ReadFile(f *File, offset int64, data []byte) int
var ReadFile = (*File).Read
// 文件处理
@ -250,8 +250,8 @@ var Close = func Close() error {
}
// 绑定到了 f 对象
// func Read(int64 offset, data []byte) int
var Read = func Read(int64 offset, data []byte) int {
// func Read(offset int64, data []byte) int
var Read = func Read(offset int64, data []byte) int {
return (*File).Read(f, offset, data)
}
@ -271,7 +271,7 @@ f, _ := OpenFile("foo.dat")
var Close = f.Close
// 方法值: 绑定到了 f 对象
// func Read(int64 offset, data []byte) int
// func Read(offset int64, data []byte) int
var Read = f.Read
// 文件处理