fmtutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: Apache-2.0, GPL-2.0, GPL-3.0-or-later, + 1 more Imports: 2 Imported by: 0

Documentation

Overview

Package fmtutil provides utilities for implementing the interfaces consumed by the "fmt" package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BitfieldString

func BitfieldString[T ~uint8 | ~uint16 | ~uint32 | ~uint64](bitfield T, bitnames []string, cfg BitfieldFormat) string

func FmtStateString

func FmtStateString(st fmt.State, verb rune) string

FmtStateString returns the fmt.Printf string that produced a given fmt.State and verb.

func FormatByteArrayStringer

func FormatByteArrayStringer(
	obj interface {
		fmt.Stringer
		fmt.Formatter
	},
	objBytes []byte,
	f fmt.State, verb rune,
)

FormatByteArrayStringer is function for helping to implement fmt.Formatter for []byte or [n]byte types that have a custom string representation. Use it like:

type MyType [16]byte

func (val MyType) String() string {
    …
}

func (val MyType) Format(f fmt.State, verb rune) {
    util.FormatByteArrayStringer(val, val[:], f, verb)
}

Types

type BitfieldFormat

type BitfieldFormat uint8
const (
	HexNone BitfieldFormat = iota
	HexLower
	HexUpper
)

Jump to

Keyboard shortcuts

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