Go,CopyFile 实现 + 异常处理
package copyfile import ( "io" "os" ) func CopyFile(dst, src String) (w int64, err error) { srcFile, err := os.Open(src) if err != nil { return } defer srcFile.Close() dstFile, err := os.Open(dst) if err != nil { return } defer dstFile.Close() return io.Copy(dstFile, srcFile) }
有疑问加站长微信联系(非本文作者)