github.com/zxy12/go_duplicate_112_new@v0.0.0-20200807091221-747231827200/src/cmd/go/internal/modfetch/web.go (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build !cmd_go_bootstrap 6 7 package modfetch 8 9 import ( 10 "io" 11 12 web "cmd/go/internal/web2" 13 ) 14 15 // webGetGoGet fetches a go-get=1 URL and returns the body in *body. 16 // It allows non-200 responses, as usual for these URLs. 17 func webGetGoGet(url string, body *io.ReadCloser) error { 18 return web.Get(url, web.Non200OK(), web.Body(body)) 19 } 20 21 // webGetBytes returns the body returned by an HTTP GET, as a []byte. 22 // It insists on a 200 response. 23 func webGetBytes(url string, body *[]byte) error { 24 return web.Get(url, web.ReadAllBody(body)) 25 } 26 27 // webGetBody returns the body returned by an HTTP GET, as a io.ReadCloser. 28 // It insists on a 200 response. 29 func webGetBody(url string, body *io.ReadCloser) error { 30 return web.Get(url, web.Body(body)) 31 }