MCPcopy Create free account
hub / github.com/bytebase/bytebase / Uniq

Function Uniq

backend/common/util.go:247–260  ·  view source on GitHub ↗

Uniq returns a new slice with duplicate elements removed, preserving order.

(array []T)

Source from the content-addressed store, hash-verified

245
246// Uniq returns a new slice with duplicate elements removed, preserving order.
247func Uniq[T comparable](array []T) []T {
248 res := make([]T, 0, len(array))
249 seen := make(map[T]struct{}, len(array))
250
251 for _, e := range array {
252 if _, ok := seen[e]; ok {
253 continue
254 }
255 seen[e] = struct{}{}
256 res = append(res, e)
257 }
258
259 return res
260}

Callers 3

GetUserRolesInIamPolicyFunction · 0.92
HasSheetsMethod · 0.92
convertToStoreIamPolicyFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected