format

package
v0.0.0-...-07cef3f Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2012 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read

func Read(fmtStr string, input string, data interface{}) error

See ParseFormat for a description of the format string.

func Write

func Write(fmtStr string, data interface{}) (string, error)

See ParseFormat for a description of the format string.

Types

type Format

type Format []FormatPart

A Format describes a particular way of representing a record as a string.

func ParseFormat

func ParseFormat(fmtStr string) (Format, error)

Creates a Format object that can be used to efficiently read and write records from the given format string.

func (Format) Read

func (fmt Format) Read(input string, data interface{}) error

func (Format) Write

func (fmt Format) Write(data interface{}) (string, error)

type FormatPart

type FormatPart interface {
	Write(interface{}) (string, error)

	// Match returns true if this FormatPart can be applied to the
	// beginning of the given string without error.
	Match(string) bool
	Read(string, interface{}, FormatPart) (string, error)
}

Jump to

Keyboard shortcuts

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