gob

package
v2.779.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package gob provides a streaming gob github.com/alexfalkowski/go-service/v2/encoding/stream.Encoder/ github.com/alexfalkowski/go-service/v2/encoding/stream.Decoder pair used by go-service.

It wraps the standard library encoding/gob package's own NewEncoder/NewDecoder types with one persistent encoder/decoder bound to the writer/reader for the lifetime of the stream, unlike github.com/alexfalkowski/go-service/v2/encoding/gob, which constructs and discards a fresh encoder/decoder per call and rejects trailing values because it models exactly one value per call.

Start with the package-level constructors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
	*gob.Decoder
}

Decoder streams gob values from a reader bound at construction.

Decoder embeds the standard library's encoding/gob.Decoder, so [Decoder.Decode] is the embedded decoder's own method. Decoder satisfies github.com/alexfalkowski/go-service/v2/encoding/stream.Decoder structurally, without this package importing that package.

func NewDecoder

func NewDecoder(r io.Reader, _ ...codec.Option) *Decoder

NewDecoder constructs a streaming gob Decoder bound to r.

Unlike github.com/alexfalkowski/go-service/v2/encoding/gob.Encoder's Decode, the returned decoder allows additional gob values after the first: it does not enforce single-value trailing-data rejection, since a stream is expected to carry many values.

func (*Decoder) Close

func (d *Decoder) Close() error

Close is a no-op: the standard library gob decoder has no finalization state to flush.

type Encoder

type Encoder struct {
	*gob.Encoder
}

Encoder streams gob values to a writer bound at construction.

Encoder embeds the standard library's encoding/gob.Encoder, so [Encoder.Encode] is the embedded encoder's own method. Encoder satisfies github.com/alexfalkowski/go-service/v2/encoding/stream.Encoder structurally, without this package importing that package: github.com/alexfalkowski/go-service/v2/encoding/stream.NewMap imports this package to pre-register the default "gob" kind, and this package importing that one back would be a compile-time import cycle.

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder constructs a streaming gob Encoder bound to w.

Unlike github.com/alexfalkowski/go-service/v2/encoding/gob.Encoder, which constructs a fresh standard library encoder per Encode call, the returned encoder wraps one persistent encoding/gob.Encoder bound to w for the lifetime of the stream — the intended way to use gob for more than one value on the same connection.

func (*Encoder) Close

func (e *Encoder) Close() error

Close is a no-op: the standard library gob encoder has no finalization state to flush.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL