drone_plugin/config_handler/util.go

22 lines
302 B
Go
Raw Normal View History

2021-12-28 20:42:51 +08:00
package config_handler
type Set map[int]struct{}
func NewSet() Set {
return make(Set)
}
func (s *Set) Add(data ...int) {
for _, d := range data {
(*s)[d] = struct{}{}
}
}
func (s Set) ToSlice() []int {
ret := make([]int, 0, len(s))
for k := range s {
ret = append(ret, k)
}
return ret
}