daemon: work around go1.21 compiler bug
The Go 1.21.5 compiler has a bug: per-file language version override directives do not take effect when instantiating generic functions which have certain nontrivial type constraints. Consequently, a module-mode project with Moby as a dependency may fail to compile when the compiler incorrectly applies go1.16 semantics to the generic function call. As the offending function is trivial and is only used in one place, work around the issue by converting it to a concretely-typed function. Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
parent
e7001c1455
commit
6d2c4f87af
1 changed files with 6 additions and 3 deletions
|
@ -351,11 +351,14 @@ func getConfigOrEnv(config string, env ...string) string {
|
||||||
return getEnvAny(env...)
|
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.
|
// 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 {
|
if s == nil {
|
||||||
return S{}
|
return []string{}
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue