Created
July 24, 2019 00:06
-
-
Save nileshsimaria/12a0a478502c71f2b6f09723e9b59686 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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