最终的结果是我发现问题出在 net/sendfile_windows.go 这个文件的 sendFile 函数里。
此问题在 win 环境下发生。目前没有解决
linux 大文件下载测试通过 。
“`golang
func sendFile(fd *netFD, r io.Reader) (written int64, err error, handled bool)
“`
golang 源码中这个函数前有一行注释:
// sendFile copies the contents of r to c using the TransmitFile
// system call to minimize copies.
//
// if handled == true, sendFile returns the number of bytes copied and any
// non-EOF error.
//
// if handled == false, sendFile performed no work.
//
// Note that sendfile for windows does not support >2GB file.
func sendFile(fd *netFD, r io.Reader) (written int64, err error, handled bool) {