From 04ce17415f25dbf10eba954212c8428ae630df88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Wed, 26 Oct 2022 11:31:22 +0200 Subject: Format with go 1.19 --- download.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'download.go') diff --git a/download.go b/download.go index dfd9a07..130df91 100644 --- a/download.go +++ b/download.go @@ -23,9 +23,9 @@ import ( "io/ioutil" ) -//DownloadedObject is returned by Object.Download(). It wraps the io.ReadCloser -//from http.Response.Body with convenience methods for collecting the contents -//into a byte slice or string. +// DownloadedObject is returned by Object.Download(). It wraps the io.ReadCloser +// from http.Response.Body with convenience methods for collecting the contents +// into a byte slice or string. // // var obj *swift.Object // @@ -38,9 +38,9 @@ import ( // //Do this instead: // str, err := obj.Download(nil).AsString() // -//Since all methods on DownloadedObject are irreversible, the idiomatic way of -//using DownloadedObject is to call one of its members immediately, without -//storing the DownloadedObject instance in a variable first. +// Since all methods on DownloadedObject are irreversible, the idiomatic way of +// using DownloadedObject is to call one of its members immediately, without +// storing the DownloadedObject instance in a variable first. // // var obj *swift.Object // @@ -55,13 +55,13 @@ type DownloadedObject struct { err error } -//AsReadCloser returns an io.ReadCloser containing the contents of the -//downloaded object. +// AsReadCloser returns an io.ReadCloser containing the contents of the +// downloaded object. func (o DownloadedObject) AsReadCloser() (io.ReadCloser, error) { return o.r, o.err } -//AsByteSlice collects the contents of this downloaded object into a byte slice. +// AsByteSlice collects the contents of this downloaded object into a byte slice. func (o DownloadedObject) AsByteSlice() ([]byte, error) { if o.err != nil { return nil, o.err @@ -74,7 +74,7 @@ func (o DownloadedObject) AsByteSlice() ([]byte, error) { return slice, closeErr } -//AsString collects the contents of this downloaded object into a string. +// AsString collects the contents of this downloaded object into a string. func (o DownloadedObject) AsString() (string, error) { slice, err := o.AsByteSlice() return string(slice), err -- cgit v1.2.3 From 8b38a040830109f19550e7329b82ec5caf76b321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Wed, 26 Oct 2022 15:23:04 +0200 Subject: Fix linting errors --- download.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'download.go') diff --git a/download.go b/download.go index 130df91..8367f3d 100644 --- a/download.go +++ b/download.go @@ -20,7 +20,6 @@ package schwift import ( "io" - "io/ioutil" ) // DownloadedObject is returned by Object.Download(). It wraps the io.ReadCloser @@ -31,7 +30,7 @@ import ( // // //Do NOT do this! // reader, err := obj.Download(nil).AsReadCloser() -// bytes, err := ioutil.ReadAll(reader) +// bytes, err := io.ReadAll(reader) // err := reader.Close() // str := string(bytes) // @@ -66,12 +65,12 @@ func (o DownloadedObject) AsByteSlice() ([]byte, error) { if o.err != nil { return nil, o.err } - slice, err := ioutil.ReadAll(o.r) + slice, err := io.ReadAll(o.r) closeErr := o.r.Close() if err == nil { err = closeErr } - return slice, closeErr + return slice, err } // AsString collects the contents of this downloaded object into a string. -- cgit v1.2.3