mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-22 02:32:02 -08:00
2f33fe86f5
* Update dependencies and build to go1.22 * Fix api changes wrt to dependencies * Update golangci config
42 lines
928 B
Go
42 lines
928 B
Go
package locafero
|
|
|
|
import "fmt"
|
|
|
|
// NameWithExtensions creates a list of names from a base name and a list of extensions.
|
|
//
|
|
// TODO: find a better name for this function.
|
|
func NameWithExtensions(baseName string, extensions ...string) []string {
|
|
var names []string
|
|
|
|
if baseName == "" {
|
|
return names
|
|
}
|
|
|
|
for _, ext := range extensions {
|
|
if ext == "" {
|
|
continue
|
|
}
|
|
|
|
names = append(names, fmt.Sprintf("%s.%s", baseName, ext))
|
|
}
|
|
|
|
return names
|
|
}
|
|
|
|
// NameWithOptionalExtensions creates a list of names from a base name and a list of extensions,
|
|
// plus it adds the base name (without any extensions) to the end of the list.
|
|
//
|
|
// TODO: find a better name for this function.
|
|
func NameWithOptionalExtensions(baseName string, extensions ...string) []string {
|
|
var names []string
|
|
|
|
if baseName == "" {
|
|
return names
|
|
}
|
|
|
|
names = NameWithExtensions(baseName, extensions...)
|
|
names = append(names, baseName)
|
|
|
|
return names
|
|
}
|