Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddTag ¶
AddTag returns a context that has the tags in the given context plus another tag. Tags are deduplicated (see Buffer.AddTag).
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is an immutable list of Tags.
func FromContext ¶
FromContext returns the tags stored in the context (by WithTags, AddTag, or AddTags).
func SingleTagBuffer ¶
SingleTagBuffer returns a Buffer with a single tag.
func (*Buffer) Add ¶
Add returns a new buffer with one more tag. If the tag has the same key as an earlier tag, that tag is overwritten. The receiver can be nil.
func (*Buffer) FormatToString ¶
FormatToString emits the k/v pairs to a strings.Builder.
- the k/v pairs are separated by commas (& no spaces).
- if there is no value, only the key is printed.
- if there is a value, and the key is just 1 character long, the key and the value are concatenated. This supports e.g. printing k="n", v=123 as "n123".
- otherwise, it prints "k=v".
func (*Buffer) Merge ¶
Merge returns a new buffer which contains tags from the receiver, followed by the tags from <other>.
If both buffers have the same tag, the tag will appear only one time, with the value it has in <other>. It can appear either in the place of the tag in <b> or the tag in <other> (depending on which is deemed more efficient).
The method can return <b> or <other> if the result is identical with one of them.
The receiver can be nil.