Skip to content

[Go] why the decode method use reader as input params #1071

Open
@someview

Description

@someview

I have some question about the generator for go. Why use reader as decode input params insteadof []byte or bytes.buffer. For most secenes,
we need start routine for a receive message:this means we need get a business msg buffer, then parse it in other routine. so,why not use []byte or bytes.buffer as input param. Now:

buf := make([]byte,512)
n,err:= conn.Read()
go func() {
   reader := bytes.NewReader(buf[:n])
   xxx.Decode(reader,) // decode buf  to sbe object
}

Actually:

   xxx.Decode([]byte) // decode buf  to sbe object
   xxx.Decode(bytes.buffer) // this is ok

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions