Re: [go-nuts] Re: Idiomatic way to reference custom error codes

2017-01-25 Thread John Beckett
Thanks Pierre, that looks like a simple and quite clean implementation. Although it's easier to use an iota for the numbering, does that open up any issues with keeping the documentation up to date? I know it's easier to program and extend, but it's also less obvious when codes change. Is there a

Re: [go-nuts] Re: Idiomatic way to reference custom error codes

2017-01-25 Thread John Beckett
> > Since it is an HTTP Api, what about returning a standard HTTP status line, > maybe with some non standard status code) and additional details about the > error in the response body, JSON encoded? That is exactly what we do. We return a HTTP status, but in addition, we return a JSON encoded b

Re: [go-nuts] Converting escaped unicode to utf8

2016-12-26 Thread John Beckett
Thanks Roger. That is a really elegant solution. On 26 December 2016 at 17:32, roger peppe wrote: > On 26 December 2016 at 07:23, JohnGB wrote: > > It *should* have a JSON body, but in this particular case I can't be sure > > that it will, as I'm trying to log requests when there are errors, w

Re: [go-nuts] Re: zip files created with archive/zip aren't recognised as zip files by java.util.zip

2016-10-29 Thread John Beckett
The code that I wrote to handle this is: func writeZip(data []byte, filename string) error { var fileGZ bytes.Buffer zipper := gzip.NewWriter(&fileGZ) _, err := zipper.Write(data) if err != nil { return err } // call the close explicitly if err = zipper.Close(); err != nil { return err } err =