1 package locafero
2 3 import "fmt"
4 5 // NameWithExtensions creates a list of names from a base name and a list of extensions.
6 //
7 // TODO: find a better name for this function.
8 func NameWithExtensions(baseName string, extensions ...string) []string {
9 var names []string
10 11 if baseName == "" {
12 return names
13 }
14 15 for _, ext := range extensions {
16 if ext == "" {
17 continue
18 }
19 20 names = append(names, fmt.Sprintf("%s.%s", baseName, ext))
21 }
22 23 return names
24 }
25 26 // NameWithOptionalExtensions creates a list of names from a base name and a list of extensions,
27 // plus it adds the base name (without any extensions) to the end of the list.
28 //
29 // TODO: find a better name for this function.
30 func NameWithOptionalExtensions(baseName string, extensions ...string) []string {
31 var names []string
32 33 if baseName == "" {
34 return names
35 }
36 37 names = NameWithExtensions(baseName, extensions...)
38 names = append(names, baseName)
39 40 return names
41 }
42