Conversation
hw07_file_copying/copy.go
Outdated
| } | ||
|
|
||
| fileSize := fileSt.Size() | ||
| fmt.Println(fileSize) |
There was a problem hiding this comment.
Отладочный вывод лучше удалить.
hw07_file_copying/copy.go
Outdated
| } | ||
|
|
||
| func changeZeroLimit(fromPath string, limit int64) int64 { | ||
| fileSt, _ := os.Stat(fromPath) |
There was a problem hiding this comment.
Ошибки стоит проверять всегда, это хороший тон.
| return nil | ||
| } | ||
|
|
||
| func changeZeroLimit(fromPath string, limit int64) int64 { |
There was a problem hiding this comment.
А может ли быть вариант, когда offset + limit > fileSize ? Что тогда делать?
There was a problem hiding this comment.
Внутри openLimitedReader есть проверка на offset, а limit не может быть больше FileSize.
There was a problem hiding this comment.
limit задаётся как внешний параметр, его можно задать и больше чем FileSize, не вижу где в работе проверяется это ограничение.
| } | ||
|
|
||
| func defineLimitedReader(fromPath string, offset, limit int64) (io.Reader, error) { | ||
| reader, err := os.Open(fromPath) |
| return err | ||
| } | ||
|
|
||
| _, err = io.Copy(writer, barReader) |
There was a problem hiding this comment.
Лучше воспользоваться io.CopyN().
There was a problem hiding this comment.
Тогда нужно будет цикл делать?
Я ведь правильно понял, что цель — копировать небольшими «порциями»?
There was a problem hiding this comment.
Он внутри копирует порциями.
|
Здравствуйте! Спасибо за выполнение домашнего задания. Принято 8/10. |
| return err | ||
| } | ||
|
|
||
| _, err = io.Copy(writer, barReader) |
There was a problem hiding this comment.
Он внутри копирует порциями.
| return nil | ||
| } | ||
|
|
||
| func changeZeroLimit(fromPath string, limit int64) int64 { |
There was a problem hiding this comment.
limit задаётся как внешний параметр, его можно задать и больше чем FileSize, не вижу где в работе проверяется это ограничение.
No description provided.