Go语言使用http下载文件

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

    package main  
      
    import (  
        "fmt"  
        "io"  
        "net/http"  
        "os"  
    )  
      
    var (  
        url = "http://127.0.0.1:1789/src/qq.exe"  
    )  
      
    func main() {  
        res, err := http.Get(url)  
        if err != nil {  
            panic(err)  
        }  
        f, err := os.Create("qq.exe")  
        if err != nil {  
            panic(err)  
        }  
        io.Copy(f, res.Body)  
    }