From 3ef9e0c337ed2eec1be47766aa4253e973a0d839 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 25 Feb 2017 23:35:03 +0100 Subject: Set limit at minimal names count --- philo.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'philo.go') diff --git a/philo.go b/philo.go index 811c698..030195c 100644 --- a/philo.go +++ b/philo.go @@ -1,6 +1,7 @@ package main import ( + "errors" "flag" "fmt" "math/rand" @@ -106,6 +107,9 @@ func (n Names) String() string { 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