verb

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPrefix is the default prefix for format strings.
	DefaultPrefix rune = '%'
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder is a builder for format strings.

func (Builder) Build

func (b Builder) Build() FormatFn

Build builds a new format function.

Returns:

  • FormatFn: The new format function. Never returns nil.

func (*Builder) Register

func (b *Builder) Register(verb rune)

Register registers a format verb. Does nothing if the receiver is nil.

Verbs that are the same as the prefix are ignored.

Parameters:

  • verb: The format verb to register.

func (*Builder) Reset

func (b *Builder) Reset()

Reset resets the builder to make it reusable.

func (*Builder) SetPrefix

func (b *Builder) SetPrefix(char rune)

SetPrefix sets the prefix for specifying format verbs. Does nothing if the receiver is nil.

Parameters:

  • char: The prefix to set.

type FormatFn

type FormatFn func(format string, data Formatter) (string, error)

FormatFn is the type for a format function.

Parameters:

  • format: The format string.
  • data: The data to format.

Returns:

  • string: The formatted string.
  • error: An error if the format could not be formatted.

type Formatter

type Formatter interface {
	// Format formats the data using the format string.
	//
	// Parameters:
	//   - format: The format string.
	//
	// Returns:
	//   - string: The formatted string.
	//   - error: An error if the format could not be formatted.
	Format(verb string) (string, error)
}

Formatter is the interface for a formatter.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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