internal

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package internal provides various utilities leveraged by the mydyndns CLI application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureLogger

func ConfigureLogger(json bool, lvl int, w io.Writer) (l log.Logger)

ConfigureLogger creates a new Logger for writing structured logs to w. When json is true, log output will be JSON-formatted; when false, logfmt format is used. lvl indicates the effective log level; numeric values correspond to log levels as-follows: 0 = WARN | 1 = INFO | 2 = DEBUG. Any value higher than 2 will be DEBUG. In addition to fields defined on a per-log basis, this function configures a "caller" field included on all logged output when lvl >= 2.

Types

type StringCollection

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

A StringCollection is a container for unique strings. It provides set-like operations for adding and removing members, as well for performing membership checks. All operations are atomic and thread-safe, making StringCollection appropriate for use in concurrent applications.

func NewStringCollection

func NewStringCollection(members ...string) *StringCollection

NewStringCollection returns a pointer to new StringCollection that is initialized with the provided variadic argument values as its members.

func (*StringCollection) Add

func (sc *StringCollection) Add(members ...string)

Add takes a variadic argument of strings and adds them as new members of the StringCollection. If any provided members are already present in the StringCollection, they will be skipped, so it is not necessary to check for membership before calling Add.

func (*StringCollection) Contains

func (sc *StringCollection) Contains(s string) bool

Contains checks whether s is currently a member of the StringCollection.

func (*StringCollection) Len

func (sc *StringCollection) Len() int

Len returns the size (member count) of the StringCollection.

func (*StringCollection) Remove

func (sc *StringCollection) Remove(members ...string)

Remove takes a variadic argument of strings and removes them as members from the StringCollection. If any provided members are not currently present in the StringCollection, they will have no effect on the operation, so it is not necessary to check for membership before calling Remove.

func (*StringCollection) Slice

func (sc *StringCollection) Slice() []string

Slice returns a snapshot of the StringCollection's member values as a new string slice.

func (*StringCollection) String

func (sc *StringCollection) String() string

String returns a string representing the member values of the StringCollection.

Jump to

Keyboard shortcuts

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