From 6571642c66bfcef49a1cc18b950b09f13131dd5a Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 26 Feb 2017 00:00:50 +0100 Subject: Split files --- names.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 names.go (limited to 'names.go') diff --git a/names.go b/names.go new file mode 100644 index 0000000..56a0a68 --- /dev/null +++ b/names.go @@ -0,0 +1,21 @@ +package main + +import ( + "errors" + "fmt" + "strings" +) + +type Names []string + +func (n Names) String() string { + return fmt.Sprint(strings.Join(n, ",")) +} + +func (n *Names) Set(s string) error { + *n = Names(strings.Split(s, ",")) + if len(*n) < 2 { + return errors.New("at least 2 names are required") + } + return nil +} -- cgit v1.2.3