flag

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SliceFlags

type SliceFlags []string

func (*SliceFlags) Set

func (f *SliceFlags) Set(value string) error

Set is an implementation of the flag.Value interface

Example
package main

import (
	"flag"
	"fmt"

	flag2 "github.com/CarsonSlovoka/slides/internal/flag"
)

func main() {
	var flagSlice flag2.SliceFlags
	flag.Var(&flagSlice, "list", "-list 'b' -list 'b'")
	if err := flag.CommandLine.Parse([]string{
		"-list", "a",
		"-list", "b",
	}); err != nil {
		return
	}
	fmt.Println(flagSlice)
}
Output:

[a b]

func (*SliceFlags) String

func (f *SliceFlags) String() string

String is an implementation of the flag.Value interface

Example
package main

import (
	"fmt"

	flag2 "github.com/CarsonSlovoka/slides/internal/flag"
)

func main() {
	flagSlice := flag2.SliceFlags{"a", "b"}
	fmt.Println(flagSlice.String())
}
Output:

[a b]

Jump to

Keyboard shortcuts

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