LGTM On Wed, Feb 8, 2012 at 4:35 PM, <r@golang.org> wrote: > Reviewers: golang-dev_googlegroups.com, > ...
13 years, 3 months ago
(2012-02-09 00:37:06 UTC)
#2
LGTM
On Wed, Feb 8, 2012 at 4:35 PM, <r@golang.org> wrote:
> Reviewers: golang-dev_googlegroups.com,
>
> Message:
> Hello golang-dev@googlegroups.com,
>
> I'd like you to review this change to
> https://go.googlecode.com/hg/
>
>
> Description:
> encoding/binary: slices are allowed; say so
>
> Fixes issue 2629.
>
> Please review this at
http://codereview.appspot.com/**5642069/<http://codereview.appspot.com/5642069/>
>
> Affected files:
> M src/pkg/encoding/binary/**binary.go
>
>
> Index: src/pkg/encoding/binary/**binary.go
> ==============================**==============================**=======
> --- a/src/pkg/encoding/binary/**binary.go
> +++ b/src/pkg/encoding/binary/**binary.go
> @@ -117,11 +117,11 @@
> func (bigEndian) GoString() string { return "binary.BigEndian" }
>
> // Read reads structured binary data from r into data.
> -// Data must be a pointer to a fixed-size value or a slice
> -// of fixed-size values.
> -// A fixed-size value is either a fixed-size arithmetic
> +// Data must be a pointer to a decodable value or a slice
> +// of decodable values.
> +// A decodable value is either a fixed-size arithmetic
> // type (int8, uint8, int16, float32, complex64, ...)
> -// or an array or struct containing only fixed-size values.
> +// or an array, slice or struct containing only decodable values.
> // Bytes read from r are decoded using the specified byte order
> // and written to successive fields of the data.
> func Read(r io.Reader, order ByteOrder, data interface{}) error {
> @@ -176,11 +176,11 @@
> }
>
> // Write writes the binary representation of data into w.
> -// Data must be a fixed-size value or a pointer to
> -// a fixed-size value.
> -// A fixed-size value is either a fixed-size arithmetic
> +// Data must be an encodable value or a pointer to
> +// an encodable value.
> +// An encodable value is either a fixed-size arithmetic
> // type (int8, uint8, int16, float32, complex64, ...)
> -// or an array or struct containing only fixed-size values.
> +// or an array, slice or struct containing only encodable values.
> // Bytes written to w are encoded using the specified byte order
> // and read from successive fields of the data.
> func Write(w io.Writer, order ByteOrder, data interface{}) error {
> @@ -379,6 +379,7 @@
> for i := 0; i < l; i++ {
> d.value(v.Index(i))
> }
> +
> case reflect.Struct:
> l := v.NumField()
> for i := 0; i < l; i++ {
> @@ -434,11 +435,13 @@
> for i := 0; i < l; i++ {
> e.value(v.Index(i))
> }
> +
> case reflect.Struct:
> l := v.NumField()
> for i := 0; i < l; i++ {
> e.value(v.Field(i))
> }
> +
> case reflect.Slice:
> l := v.Len()
> for i := 0; i < l; i++ {
>
>
>
*** Submitted as http://code.google.com/p/go/source/detail?r=199e61e586c9 *** encoding/binary: slices are allowed; say so Fixes issue 2629. R=golang-dev, ...
13 years, 3 months ago
(2012-02-09 00:42:15 UTC)
#3
Slices are only allowed at the top level of Read or Write. They are not ...
13 years, 3 months ago
(2012-02-09 03:00:07 UTC)
#4
Slices are only allowed at the top level of Read or Write.
They are not allowed inside other structures.
If T is a fixed-size value, you can Read a T or a []T
(pre-sized to the appropriate length), and you can
Write a T or a []T. But T cannot (being fixed-size)
itself contain slices.
On Feb 9, 2012, at 2:00 PM, Russ Cox wrote: > Slices are only allowed ...
13 years, 3 months ago
(2012-02-09 03:09:15 UTC)
#5
On Feb 9, 2012, at 2:00 PM, Russ Cox wrote:
> Slices are only allowed at the top level of Read or Write.
> They are not allowed inside other structures.
> If T is a fixed-size value, you can Read a T or a []T
> (pre-sized to the appropriate length), and you can
> Write a T or a []T. But T cannot (being fixed-size)
> itself contain slices.
this package has used up more of my time than any other package i've never used.
-rob
Issue 5642069: code review 5642069: encoding/binary: slices are allowed; say so
(Closed)
Created 13 years, 3 months ago by r
Modified 13 years, 3 months ago
Reviewers: rsc, r2
Base URL:
Comments: 0