src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

util.go (488B)


      1 // Copyright 2023 The Go Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 package keys
      6 
      7 import (
      8 	"sort"
      9 	"strings"
     10 )
     11 
     12 // Join returns a canonical join of the keys in S:
     13 // a sorted comma-separated string list.
     14 func Join[S ~[]T, T ~string](s S) string {
     15 	strs := make([]string, 0, len(s))
     16 	for _, v := range s {
     17 		strs = append(strs, string(v))
     18 	}
     19 	sort.Strings(strs)
     20 	return strings.Join(strs, ",")
     21 }