Skip to content

Instantly share code, notes, and snippets.

@nileshsimaria
Created July 24, 2019 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nileshsimaria/12a0a478502c71f2b6f09723e9b59686 to your computer and use it in GitHub Desktop.
Save nileshsimaria/12a0a478502c71f2b6f09723e9b59686 to your computer and use it in GitHub Desktop.
package main
import (
"flag"
"fmt"
)
// MyList is string slice
type MyList []string
func (ml *MyList) String() string {
return fmt.Sprintln(*ml)
}
// Set string value in MyList
func (ml *MyList) Set(s string) error {
*ml = append(*ml, s)
return nil
}
func main() {
var list MyList
flag.Var(&list, "files", "list of files")
flag.Parse()
fmt.Println(list)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment