MCPcopy
hub / github.com/syncthing/syncthing / UniqueTrimmedStrings

Function UniqueTrimmedStrings

lib/stringutil/stringutil.go:17–30  ·  view source on GitHub ↗

UniqueTrimmedStrings returns a list of all unique strings in ss, in the order in which they first appear in ss, after trimming away leading and trailing spaces.

(ss []string)

Source from the content-addressed store, hash-verified

15// in the order in which they first appear in ss, after trimming away
16// leading and trailing spaces.
17func UniqueTrimmedStrings(ss []string) []string {
18 m := make(map[string]struct{}, len(ss))
19 us := make([]string, 0, len(ss))
20 for _, v := range ss {
21 v = strings.Trim(v, " ")
22 if _, ok := m[v]; ok {
23 continue
24 }
25 m[v] = struct{}{}
26 us = append(us, v)
27 }
28
29 return us
30}
31
32func NiceDurationString(d time.Duration) string {
33 switch {

Callers 12

resolveDeviceAddrsMethod · 0.92
AllAddressesMethod · 0.92
ExternalAddressesMethod · 0.92
LookupMethod · 0.92
CacheMethod · 0.92
findAllVersionsFunction · 0.92
prepareMethod · 0.92
ListenAddressesMethod · 0.92
StunServersMethod · 0.92
fixupAddressesFunction · 0.92
TestUniqueStringsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestUniqueStringsFunction · 0.68