debuginfo

package
v0.0.0-...-81bc7c3 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generator

func Generator(_ bool) func() InfoSrc

Generator returns the InfoSrc generating function.

Types

type InfoSrc

type InfoSrc interface {
	GetInfo(request.Request) *Values
}

InfoSrc is defined to enable mocking of [GetInfo].

type MockInfoSrc

type MockInfoSrc Values

MockInfoSrc is a mock InfoSrc used for testing.

func (*MockInfoSrc) GetInfo

func (s *MockInfoSrc) GetInfo(request.Request) *Values

GetInfo implements the InfoSrc interface.

type Pair

type Pair struct {
	Key string
	Val string
}

Pair represents a key-value pair of debug info. It is used instead of a map in order to provide a stable output order for metadata.

type Values

type Values []Pair

Values is inspired by [url.Values], but is simplified for this use case:

  • Percent-encoding is not used. This keeps IPv6 addresses human-readable and reduces response bloat.
  • Keys with empty values are omitted from the encoded output.
  • Stable-order iteration is available independent of the syntax, to support TXT record generation, but sorting is avoided. This makes lookups slow, but the lookup methods are only used in the tests.

func (*Values) Add

func (v *Values) Add(key string, val string)

Add appends a key-val pair to the Values.

func (*Values) Encode

func (v *Values) Encode() string

Encode returns the values encoded in key=value style (similar to DNS-SD).

func (*Values) Get

func (v *Values) Get(key string) string

Get returns the first value associated with this key.

func (*Values) Has

func (v *Values) Has(key string) bool

Has returns true if at least one value exists for this key.

Jump to

Keyboard shortcuts

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