diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2021-02-19 14:59:03 +0000 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2021-02-19 14:59:03 +0000 |
| commit | d5f1d60b6848cd8a37cf97aff1367f23af28df91 (patch) | |
| tree | 06357efeddd0c7e3581552cb73633d002de5e5f0 /cmd | |
| parent | d99285e57351176b5e1cdb7a7086c3003a2a5d83 (diff) | |
Use fmt.Fprint to write the body and log any error
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/go-import-redirect/main.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/cmd/go-import-redirect/main.go b/cmd/go-import-redirect/main.go index 5aedde8..c4079cf 100644 --- a/cmd/go-import-redirect/main.go +++ b/cmd/go-import-redirect/main.go @@ -9,6 +9,7 @@ package main import ( "context" + "fmt" "log" "net" "net/http" @@ -37,7 +38,9 @@ func redirect(resp http.ResponseWriter, req *http.Request) { resp.Header().Set("Location", "https://pkg.go.dev/"+pkg) resp.WriteHeader(http.StatusFound) } - resp.Write([]byte(internal.GetBody(pkg))) + if _, err := fmt.Fprint(resp, internal.GetBody(pkg)); err != nil { + log.Println("fmt.Fprint:", err) + } } func main() { |
