BugFix: cli stringSlice bug (#11166)

* fixing stringslice issue and adding one more filter

* fixing linting and improving function based on feedback

* rolling back generic function to check ci

* adding function back in

* testing printing error

* reverting change

* Added gofmt detail flag

* temporary change

* Another flag added

* Revert changes

* Modifed entrypoint

* Another change

* Revert

* Change go image

* Added -e flag

* Switched to alpine image

* Switched go to strech

* Fix typo

* Yet another image added

* Added go alpine

* rolling back generic

* reverting version

* Update go.sum

reverting

* Update go.mod

reverting

* Update Dockerfile

rolling back

* Update entrypoint.sh

rolling back

* Update go.yml

reverting changes

* fixing flag for config

* reverting changes and moving change to another PR

* Update validator/node/node.go

Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>

* updating based on review

* Update container/slice/slice.go

Co-authored-by: Taranpreet26311 <taran@prysmaticlabs.com>
Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
This commit is contained in:
james-prysm
2022-08-08 11:04:34 -05:00
committed by GitHub
parent 4e225fc667
commit bd3dfb27f3
8 changed files with 74 additions and 3 deletions

View File

@@ -363,3 +363,21 @@ func IsInSlots(a types.Slot, b []types.Slot) bool {
}
return false
}
// Unique returns an array with duplicates filtered based on the type given
func Unique(a []string) []string {
if a == nil || len(a) <= 1 {
return a
}
found := map[string]bool{}
result := make([]string, len(a))
end := 0
for i := 0; i < len(a); i++ {
if !found[a[i]] {
found[a[i]] = true
result[end] = a[i]
end += 1
}
}
return result[:end]
}