options

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Overview

Example
macs, err := DefaultInterfaces(1 * time.Second)
if err != nil {
	log.Printf("no interfaces with state UP")
}
log.Printf("mac addresses of interfaces with state UP: %v", macs)
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var DefAllowedNetworks = "127.0.0.1/32"
View Source
var DefBondingMode = "balance-rr"
View Source
var DefDNS = "9.9.9.9,149.112.112.112"
View Source
var DefHostname = "localhost.local"

Defaults optionally set in Makefile, through -ldflags which makes it necessary to keep these as variables and not put them in a struct.

View Source
var DefPassword = "stboot"
View Source
var DefTemplateURL = "https://user:password@stpackage.example.org/os-stable.json"
View Source
var DefUser = "stboot"

Functions

func AddBool

func AddBool(fs *flag.FlagSet, opt *bool, short, long string, value bool)

AddBool adds a bool option to a flag set

func AddInt

func AddInt(fs *flag.FlagSet, opt *int, short, long string, value int)

AddInt adds an int option to a flag set

func AddString

func AddString(fs *flag.FlagSet, opt *string, short, long, value string)

AddString adds a string option to a flag set

func AddStringS

func AddStringS(fs *flag.FlagSet, opt *SliceFlag, short, long, value string)

AddStringS adds a string-slice option to a flag set. If the default value is the empty string, then no value is appended to the list. If the default value contains one or more comma characters, it is split to multiple values.

Examples: - Default value "" would yield nil - Default value "foo" would yield []string{"foo"} - Default value "foo,bar" would yield []string{"foo", "bar"}

func ConstructURL added in v0.3.2

func ConstructURL(url, user, password string) (string, error)

ConstructURL constructs a URL to an OS package server, replacing the first occurrence of "user:password" with the specified user and password.

func DefaultInterfaces

func DefaultInterfaces(waitForInterface time.Duration) ([]net.HardwareAddr, error)

DefaultInterfaces outputs a list with one or more MAC addresses. The associated interfaces have state UP and can thus be used as sane defaults. This corresponds to the network interface flags IFF_UP and IFF_RUNNING.

Interfaces are put into state UP on a best-effort level. If the appropriate permissions are lacking, an interface is simply skipped without any error.

func MaxHost

func MaxHost(network *net.IPNet) string

func New

func New(args []string, usage func(), set func(*flag.FlagSet)) *flag.FlagSet

New initializes a flag set using the provided arguments.

  • args should start with the (sub)command's name
  • usage is a function that prints a usage message
  • set is a function that sets the command's flag arguments

func ValidateHostAndGateway

func ValidateHostAndGateway(optHostIP, optGateway string, optForce, optTryLastIPForGateway bool) (string, error)

Types

type SliceFlag

type SliceFlag struct {
	Values []string
	// contains filtered or unexported fields
}

SliceFlag supports setting multiple string values by repeating an option. For example, "-e foo -e bar" is a list containing ["foo", "bar"]. It is also possible to set multiple values with comma-separation, e.g., "-e foo,bar".

func (*SliceFlag) Set

func (i *SliceFlag) Set(value string) error

func (*SliceFlag) String

func (i *SliceFlag) String() string

Jump to

Keyboard shortcuts

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