mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-11 20:03:58 +02:00
Fix the time template func test
By making it not depend on the locale setup.
This commit is contained in:
@@ -467,3 +467,27 @@ func NormalizeHugoFlags(f *pflag.FlagSet, name string) pflag.NormalizedName {
|
||||
}
|
||||
return pflag.NormalizedName(name)
|
||||
}
|
||||
|
||||
// DiffStringSlices returns the difference between two string slices.
|
||||
// Useful in tests.
|
||||
// See:
|
||||
// http://stackoverflow.com/questions/19374219/how-to-find-the-difference-between-two-slices-of-strings-in-golang
|
||||
func DiffStringSlices(slice1 []string, slice2 []string) []string {
|
||||
diffStr := []string{}
|
||||
m := map[string]int{}
|
||||
|
||||
for _, s1Val := range slice1 {
|
||||
m[s1Val] = 1
|
||||
}
|
||||
for _, s2Val := range slice2 {
|
||||
m[s2Val] = m[s2Val] + 1
|
||||
}
|
||||
|
||||
for mKey, mVal := range m {
|
||||
if mVal == 1 {
|
||||
diffStr = append(diffStr, mKey)
|
||||
}
|
||||
}
|
||||
|
||||
return diffStr
|
||||
}
|
||||
|
Reference in New Issue
Block a user