Skip to content

Marshal* should return the tail... #1

@DisposaBoy

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.

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