Skip to content

Marshal* should return the tail... #1

Open

Description

@DisposaBoy

Marshal() currently returns the whole bytes buffer which makes it awkward to use correctly.

If you want write a k/v pair you have resort to error-prone hacks like:

val, _ := sb.Marshal(msg)
sp := sb.Len()
key := sb.PutUint64(123).Bytes()[sp:]

A better API is probably something like making all methods return a Result:

type Result struct {
    *Buf
    Err error
    Dat []byte
}

This way chaining works and you can easily extract the data written by the last operation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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