Documentation ¶
Overview ¶
Package fmt implements formatted I/O to a JSON stream analogous the the standard library fmt package. Not all functions make sense to use, but all are replicated from the stdlib fmt package. Printing functions that print to os.Stdout and os.Stderr are written to a JSON stream that is output to os.Stdout. All other output io.Writers are treated as normal and all other functions behave as the stdlib fmt functions.
Index ¶
- func Errorf(format string, a ...interface{}) error
- func Fprint(w io.Writer, a ...interface{}) (n int, err error)
- func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error)
- func Fprintln(w io.Writer, a ...interface{}) (n int, err error)
- func Fscan(r io.Reader, a ...interface{}) (n int, err error)
- func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error)
- func Fscanln(r io.Reader, a ...interface{}) (n int, err error)
- func Print(a ...interface{}) (n int, err error)
- func Printf(format string, a ...interface{}) (n int, err error)
- func Println(a ...interface{}) (n int, err error)
- func Scan(a ...interface{}) (n int, err error)
- func Scanf(format string, a ...interface{}) (n int, err error)
- func Scanln(a ...interface{}) (n int, err error)
- func Sprint(a ...interface{}) string
- func Sprintf(format string, a ...interface{}) string
- func Sprintln(a ...interface{}) string
- func Sscan(str string, a ...interface{}) (n int, err error)
- func Sscanf(str string, format string, a ...interface{}) (n int, err error)
- func Sscanln(str string, a ...interface{}) (n int, err error)
- type Formatter
- type GoStringer
- type ScanState
- type Scanner
- type State
- type Stringer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Errorf ¶
Errorf formats according to a format specifier and returns the string as a value that satisfies error.
If the format specifier includes a %w verb with an error operand, the returned error will implement an Unwrap method returning the operand. It is invalid to include more than one %w verb or to supply it with an operand that does not implement the error interface. The %w verb is otherwise a synonym for %v.
func Fprint ¶
Fprint formats using the default formats for its operands and writes to w. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func Fprintf ¶
Fprintf formats according to a format specifier and writes to w. It returns the number of bytes written and any write error encountered.
func Fprintln ¶
Fprintln formats using the default formats for its operands and writes to w. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func Fscan ¶
Fscan scans text read from r, storing successive space-separated values into successive arguments. Newlines count as space. It returns the number of items successfully scanned. If that is less than the number of arguments, err will report why.
func Fscanf ¶
Fscanf scans text read from r, storing successive space-separated values into successive arguments as determined by the format. It returns the number of items successfully parsed. Newlines in the input must match newlines in the format.
func Fscanln ¶
Fscanln is similar to Fscan, but stops scanning at a newline and after the final item there must be a newline or EOF.
func Print ¶
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func Printf ¶
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func Println ¶
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func Scan ¶
Scan scans text read from standard input, storing successive space-separated values into successive arguments. Newlines count as space. It returns the number of items successfully scanned. If that is less than the number of arguments, err will report why.
func Scanf ¶
Scanf scans text read from standard input, storing successive space-separated values into successive arguments as determined by the format. It returns the number of items successfully scanned. If that is less than the number of arguments, err will report why. Newlines in the input must match newlines in the format. The one exception: the verb %c always scans the next rune in the input, even if it is a space (or tab etc.) or newline.
func Scanln ¶
Scanln is similar to Scan, but stops scanning at a newline and after the final item there must be a newline or EOF.
func Sprint ¶
func Sprint(a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func Sprintln ¶
func Sprintln(a ...interface{}) string
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
func Sscan ¶
Sscan scans the argument string, storing successive space-separated values into successive arguments. Newlines count as space. It returns the number of items successfully scanned. If that is less than the number of arguments, err will report why.
Types ¶
type Formatter ¶
Formatter is the interface implemented by values with a custom formatter. The implementation of Format may call Sprint(f) or Fprint(f) etc. to generate its output.
type GoStringer ¶
type GoStringer = fmt.GoStringer
GoStringer is implemented by any value that has a GoString method, which defines the Go syntax for that value. The GoString method is used to print values passed as an operand to a %#v format.
type ScanState ¶
ScanState represents the scanner state passed to custom scanners. Scanners may do rune-at-a-time scanning or ask the ScanState to discover the next space-delimited token.
type Scanner ¶
Scanner is implemented by any value that has a Scan method, which scans the input for the representation of a value and stores the result in the receiver, which must be a pointer to be useful. The Scan method is called for any argument to Scan, Scanf, or Scanln that implements it.
type State ¶
State represents the printer state passed to custom formatters. It provides access to the io.Writer interface plus information about the flags and options for the operand's format specifier.