github.com/goreleaser/goreleaser@v1.25.1/internal/ids/ids.go (about) 1 // Package ids provides id validation code used my multiple pipes. 2 package ids 3 4 import "fmt" 5 6 // IDs is the IDs type. 7 type IDs struct { 8 ids map[string]int 9 kind string 10 } 11 12 // New IDs. 13 func New(kind string) IDs { 14 return IDs{ 15 ids: map[string]int{}, 16 kind: kind, 17 } 18 } 19 20 // Inc increment the counter of the given id. 21 func (i IDs) Inc(id string) { 22 i.ids[id]++ 23 } 24 25 // Validate errors if there are any ids with counter > 1. 26 func (i IDs) Validate() error { 27 for id, count := range i.ids { 28 if count > 1 { 29 return fmt.Errorf( 30 "found %d %s with the ID '%s', please fix your config", 31 count, i.kind, id, 32 ) 33 } 34 } 35 return nil 36 }