From 2cda8c8d90580438863cef4dcd757d1d473c3972 Mon Sep 17 00:00:00 2001 From: alessio Date: Thu, 25 Aug 2016 14:46:28 +0200 Subject: [PATCH] returns also the value of the duplicate --- realize/config.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/realize/config.go b/realize/config.go index 1c9f785..47b0125 100644 --- a/realize/config.go +++ b/realize/config.go @@ -73,20 +73,20 @@ func New(params *cli.Context) *Config { } // Duplicates check projects with same name or same combinations of main/path -func Duplicates(value Project, arr []Project) error { +func Duplicates(value Project, arr []Project) (error, Project) { for _, val := range arr { if value.Path == val.Path || value.Name == val.Name { - return errors.New("There is a duplicate of '" + val.Name + "'. Check your config file!") + return errors.New("There is a duplicate of '" + val.Name + "'. Check your config file!"), val } } - return nil + return nil, Project{} } // Clean duplicate projects func (h *Config) Clean() { arr := h.Projects for key, val := range arr { - if err := Duplicates(val, arr[key+1:]); err != nil { + if err, _ := Duplicates(val, arr[key+1:]); err != nil { h.Projects = append(arr[:key], arr[key+1:]...) break } @@ -139,7 +139,7 @@ func (h *Config) Add(params *cli.Context) error { Ignore: watcherIgnores, }, } - if err := Duplicates(new, h.Projects); err != nil { + if err, _ := Duplicates(new, h.Projects); err != nil { return err } h.Projects = append(h.Projects, new)