golang有没有复制大文件如 10G 20G的文件 并且返回任务复制进度条的第三方包呢?

hellsam · · 1194 次点击
复制进度和uuid感觉完全不相关吧 自己写一个复制应该不复杂。 只要实现了 `io.Seeker` 接口的对象,通过调用Seek就可以得到文件大小。 然后自己做一个fileWriter,copy一段,看看是否达到下一个1%,就可以报告下进度了。 ```go // Seeker is the interface that wraps the basic Seek method. // // Seek sets the offset for the next Read or Write to offset, // interpreted according to whence: // SeekStart means relative to the start of the file, // SeekCurrent means relative to the current offset, and // SeekEnd means relative to the end. // Seek returns the new offset relative to the start of the // file and an error, if any. // // Seeking to an offset before the start of the file is an error. // Seeking to any positive offset is legal, but the behavior of subsequent // I/O operations on the underlying object is implementation-dependent. // type Seeker interface { // Seek(offset int64, whence int) (int64, error) // } f.Seek(0, io.SeekStart) fileSize, _ := f.Seek(0, io.SeekEnd) ```
#1