From 764e41a50c187da375b6039278bfbb9787852714 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 26 Dec 2012 13:36:45 -0800 Subject: [PATCH] Work around golang.org/issue/4590 Change-Id: Ibde7a93db7dcb8c51eb828b6c4e50505904fce6a --- pkg/client/client.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/client/client.go b/pkg/client/client.go index c192a43cb..867e8960d 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -145,15 +145,18 @@ func (c *Client) SearchExistingFileSchema(wholeRef *blobref.BlobRef) (*blobref.B } var buf bytes.Buffer body := io.TeeReader(io.LimitReader(res.Body, 1<<20), &buf) + type justWriter struct { + io.Writer + } if res.StatusCode != 200 { - io.Copy(struct{ io.Writer }{ioutil.Discard}, body) // golang.org/issue/4589 + io.Copy(justWriter{ioutil.Discard}, body) // golang.org/issue/4589 return nil, fmt.Errorf("client: got status code %d from URL %s; body %s", res.StatusCode, url, buf.String()) } var ress struct { Files []*blobref.BlobRef `json:"files"` } if err := json.NewDecoder(body).Decode(&ress); err != nil { - io.Copy(struct{ io.Writer }{ioutil.Discard}, body) // golang.org/issue/4589 + io.Copy(justWriter{ioutil.Discard}, body) // golang.org/issue/4589 return nil, fmt.Errorf("client: error parsing JSON from URL %s: %v; body=%s", url, err, buf.String()) } if len(ress.Files) == 0 {