f_string

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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FStringer

type FStringer interface {
	// FString traverses the format string.
	//
	// Parameters:
	//   - trav: The traverser to use. Assumed to be non-nil.
	//
	// Returns:
	//   - error: An error if the format string could not be traversed.
	FString(trav Traverser) error
}

FStringer is the interface for a format string traverser.

type Traverser

type Traverser interface {
	// WriteLine writes a line to the traverser.
	//
	// Parameters:
	//   - str: The line to write.
	//
	// Returns:
	//   - error: An error if the line could not be written.
	WriteLine(str string) error

	io.Writer
}

Traverser is the interface for a format string traverser.

type Traversor

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

Traversor is the traverser.

func New

func New(w io.Writer) *Traversor

New creates a new traverser.

Parameters:

  • w: The writer to write to.

Returns:

  • *Traversor: The new traverser. Never returns nil.

If w is nil, it is set to io.Discard.

func (*Traversor) IndentBy

func (t *Traversor) IndentBy(n int) (*Traversor, error)

IndentBy increments the indent level by n.

Parameters:

  • n: The amount to increment the indent level by.

Returns:

  • *Traversor: The traverser.
  • error: An error if the traverser could not be created.

If the new indent level is less than 0, it is set to 0.

func (*Traversor) Write

func (t *Traversor) Write(data []byte) (int, error)

Write writes data to the traverser.

Parameters:

  • data: The data to write.

Returns:

  • int: The number of bytes written.
  • error: An error if the data could not be written.

Always returns len(data) when error is nil.

func (*Traversor) WriteLine

func (t *Traversor) WriteLine(str string) error

WriteLine writes a line to the traverser.

Parameters:

  • str: The line to write.

Returns:

  • error: An error if the line could not be written.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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