Go语言学习: http/fetch 之 upload 请求
利用 fetch 完成上传
安装
go get -u github.com/go-zoox/fetch
main.go
package main
import (
"fmt"
"os"
"github.com/go-zoox/fetch"
)
func main() {
file, _ := os.Open("go.mod")
response, err := fetch.Upload("https://httpbin.zcorky.com/upload", file)
if err != nil {
panic(err)
}
fmt.Println(response.JSON())
}