Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/binary: error in reading bool #12201

lysevi opened this issue Aug 19, 2015 · 1 comment

encoding/binary: error in reading bool #12201

lysevi opened this issue Aug 19, 2015 · 1 comment


Copy link

lysevi commented Aug 19, 2015

go 1.4.2 windows7 x64

package main


type Header struct {
    IsFull        bool

func main(){
    for i:=0;i<1024;i++{
    var pi Header
    buf := bytes.NewReader(a)
    err := binary.Read(buf, binary.LittleEndian, &pi)

result: "binary.Read: invalid type *main.Header"

but, if o change type of Header.IsFull from bool to byte or int8 (or something else int*), then all works done

Copy link

This is working as expected. The encoding/binary package, as the documentation says, "implements simple translation between numbers and byte sequences." The type bool is not a number.

@mikioh mikioh changed the title error in encoding/binary Read encoding/binary: error in reading bool Aug 21, 2015
@golang golang locked and limited conversation to collaborators Aug 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

3 participants