Documentation ¶
Overview ¶
Package format defines the standard interfaces for formatting of values. It deliberately avoids using the fmt package name as it is not a superset of it and direct use of the standard library's fmt package is still likely (e.g. to scan values).
This package is meant to abstract use of either the standard library's fmt package or a localization-aware printer, such as the one provided by golang.org/x/text/message.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockPrinter ¶
type MockPrinter struct { FprintFunc func(io.Writer, ...interface{}) (int, error) FprintfFunc func(io.Writer, interface{}, ...interface{}) (int, error) SprintFunc func(...interface{}) string SprintfFunc func(interface{}, ...interface{}) string }
MockPrinter is a test mock for the Printer interface.
func (*MockPrinter) Fprint ¶
func (m *MockPrinter) Fprint(w io.Writer, vs ...interface{}) (int, error)
func (*MockPrinter) Fprintf ¶
func (m *MockPrinter) Fprintf(w io.Writer, f interface{}, vs ...interface{}) (int, error)
func (*MockPrinter) Sprint ¶
func (m *MockPrinter) Sprint(vs ...interface{}) string
func (*MockPrinter) Sprintf ¶
func (m *MockPrinter) Sprintf(f interface{}, vs ...interface{}) string
type Printer ¶
type Printer interface { Fprint(w io.Writer, vs ...interface{}) (n int, err error) Fprintf(w io.Writer, f interface{}, vs ...interface{}) (n int, err error) Sprint(vs ...interface{}) string Sprintf(f interface{}, vs ...interface{}) string }
Printer defines the methods to print arbitrary values with formatting directives. It deliberately skips the Print variant found in the fmt package as it is merely Fprint with os.Stdout as writer. Similarly, the "ln" variant is also omitted as it can be achieved easily by adding a newline to either of the other variants.