Merge pull request #47020 from thaJeztah/fix_go_compilerbug

daemon: work around go1.21 compiler bug
This commit is contained in:
Brian Goff 2024-01-03 16:10:00 -08:00 committed by GitHub
commit e2b78f074b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -351,11 +351,14 @@ func getConfigOrEnv(config string, env ...string) string {
return getEnvAny(env...)
}
// promoteNil converts a nil slice to an empty slice of that type.
// promoteNil converts a nil slice to an empty slice.
// A non-nil slice is returned as is.
func promoteNil[S ~[]E, E any](s S) S {
//
// TODO: make generic again once we are a go module,
// go.dev/issue/64759 is fixed, or we drop support for Go 1.21.
func promoteNil(s []string) []string {
if s == nil {
return S{}
return []string{}
}
return s
}