Go语言使用http下载文件

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)
}


原文:https://blog.csdn.net/fyxichen/article/details/46915285

猜你喜欢

转载自blog.csdn.net/zhizhengguan/article/details/89066645