flagslice

package
v0.0.0-...-b779cef Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package flagslice defines slice types to be used as custom flag types for the flag library.

Slice types as custom flag types allow a flag to be passed multiple times, e.g. to accept multiple options.

var fOpts = &flagslice.FlagStringSlice{}

flag.Var(fOpts, "o", "Options in key/value form, can be passed multiple times")
flag.Parse()

for i, fOpt := range fOpts.Slice() {
	log.Printf("Passed value no. %d: %s", i, fOpt)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlagStringSlice

type FlagStringSlice []string

FlagStringSlice implements the flags.Value interface. Each occurrence of a flag of this type will append the given parameter to the flags' value.

func (*FlagStringSlice) Set

func (fss *FlagStringSlice) Set(value string) error

Set appends the given value to the FlagStringSlice.

func (FlagStringSlice) Slice

func (fss FlagStringSlice) Slice() []string

Slice returns the FlagStringSlice as a string slice.

func (FlagStringSlice) String

func (fss FlagStringSlice) String() string

String implements the Stringer interface.

Jump to

Keyboard shortcuts

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