golang.org/x/tools@v0.21.1-0.20240520172518-788d39e776b1/internal/event/keys/util.go (about)

     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  }