ranges

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

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

Go to latest
Published: Feb 15, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

ranges provides methods to expand or condense ranges of like strings. This is used for specifying a list of hosts eg. host[1-10]. The ranges package can expand host[1-10] into a slice of strings: [host1, host2, host3...]. Similarly, it can condense a slice of strings into a compact form: [host1, host2, host5, host6] -> host[1-2,5-6].

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SplitList

func SplitList(in string) ([]string, error)

SplitList takes a string such as "foo,bar[1-3]" and expands it to a fully enumerated list of names.

func UnsplitList

func UnsplitList(vals []string) string

UnsplitList takes a list of strings like ["foo1.bar", "foo2.bar"] and condenses them to "foo[1-2].bar".

Types

type Range

type Range struct {
	Prefix string
	Min    int
	Max    int
}

func NewRange

func NewRange(prefix string, min, max int) (*Range, error)

func (*Range) RangeToInts

func (r *Range) RangeToInts(names []string) []int

func (*Range) SplitRange

func (r *Range) SplitRange(s string) ([]string, error)

func (*Range) UnsplitRange

func (r *Range) UnsplitRange(names []string) (string, error)

Turn an array of node names into a single string like kn[1-5,20]

Jump to

Keyboard shortcuts

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