/flagslice

Go package for reading flags into a slice

Primary LanguageGoMIT LicenseMIT

flagslice

PkgGoDev

This package provides a reflect based solution for reading flags into a slice.

Supported Types:

  • bool
  • int
  • int64
  • uint
  • uint64
  • float64
  • string
  • time.Duration
  • anything implementing flag.Value

Example

package main

import (
	"flag"
	"fmt"

	"github.com/icholy/flagslice"
)

func main() {
	var names []string
	flagslice.Var(&names, "name", "a name")
	flag.Parse()
	for _, name := range names {
		fmt.Println(name)
	}
}