strepr: launchpad.net/strepr Index | Examples | Files

package strepr

import "launchpad.net/strepr"

Package strepr is an implementation of the strepr stable representation algorithm.

For details on strepr, see the specification at:

http://blog.labix.org/2013/06/25/strepr-v1

Index

Examples

Package Files

dumper.go strepr.go

func NewDumper

func NewDumper(w io.Writer) io.WriteCloser

NewDumper returns an io.WriteCloser that expects raw strepr data to be written into it. Once data is written, it will output into w a textual debug dump of the raw data received.

The returned value must be closed after all data is written on it both for the debug dump to report unfinished data and for used resources to be released.

type Encoder

type Encoder struct {
    // contains filtered or unexported fields
}

Encoder streams the strepr stable representation for provided values into an io.Writer.

Code:play 

value := map[string]interface{}{"a": 1, "b": []int{2, 3}}
hash := sha1.New()
strepr.NewEncoder(hash).Encode(value)
fmt.Printf("%x\n", hash.Sum(nil))

Output:

29a77d09441528e02a27dc498d0a757da06250a0

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder returns a new strepr encoder for writing the stable representation for provided values into w.

func (*Encoder) Encode

func (e *Encoder) Encode(v interface{}) error

Encode serializes v's stable representation into e's writer.

Package strepr imports 10 packages (graph). Updated 2013-07-04. Refresh now. Tools for package owners.