From bd4ff31775f698013768c21521bf22ba6d0c5e10 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 25 Jan 2024 11:18:44 +0100 Subject: [PATCH] add more //go:build directives to prevent downgrading to go1.16 language This is a follow-up to 2cf230951fe29e2c2eda9eed43042524435c761a, adding more directives to adjust for some new code added since: Before this patch: make -C ./internal/gocompat/ GO111MODULE=off go generate . GO111MODULE=on go mod tidy GO111MODULE=on go test -v # github.com/docker/docker/internal/sliceutil internal/sliceutil/sliceutil.go:3:12: type parameter requires go1.18 or later (-lang was set to go1.16; check go.mod) internal/sliceutil/sliceutil.go:3:14: predeclared comparable requires go1.18 or later (-lang was set to go1.16; check go.mod) internal/sliceutil/sliceutil.go:4:19: invalid map key type T (missing comparable constraint) # github.com/docker/docker/libnetwork libnetwork/endpoint.go:252:17: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod) # github.com/docker/docker/daemon daemon/container_operations.go:682:9: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod) daemon/inspect.go:42:18: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod) With this patch: make -C ./internal/gocompat/ GO111MODULE=off go generate . GO111MODULE=on go mod tidy GO111MODULE=on go test -v === RUN TestModuleCompatibllity main_test.go:321: all packages have the correct go version specified through //go:build --- PASS: TestModuleCompatibllity (0.00s) PASS ok gocompat 0.031s make: Leaving directory '/go/src/github.com/docker/docker/internal/gocompat' Signed-off-by: Sebastiaan van Stijn --- daemon/container_operations.go | 3 +++ daemon/inspect.go | 3 +++ internal/sliceutil/sliceutil.go | 3 +++ libnetwork/endpoint.go | 3 +++ 4 files changed, 12 insertions(+) diff --git a/daemon/container_operations.go b/daemon/container_operations.go index 5df9640bb9..f4ccb14fdb 100644 --- a/daemon/container_operations.go +++ b/daemon/container_operations.go @@ -1,3 +1,6 @@ +// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: +//go:build go1.19 + package daemon // import "github.com/docker/docker/daemon" import ( diff --git a/daemon/inspect.go b/daemon/inspect.go index 915b9d810b..179c7264c9 100644 --- a/daemon/inspect.go +++ b/daemon/inspect.go @@ -1,3 +1,6 @@ +// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: +//go:build go1.19 + package daemon // import "github.com/docker/docker/daemon" import ( diff --git a/internal/sliceutil/sliceutil.go b/internal/sliceutil/sliceutil.go index 66d90f2dc9..626bbf5bcb 100644 --- a/internal/sliceutil/sliceutil.go +++ b/internal/sliceutil/sliceutil.go @@ -1,3 +1,6 @@ +// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: +//go:build go1.19 + package sliceutil func Dedup[T comparable](slice []T) []T { diff --git a/libnetwork/endpoint.go b/libnetwork/endpoint.go index ce799e36ae..f171bc1602 100644 --- a/libnetwork/endpoint.go +++ b/libnetwork/endpoint.go @@ -1,3 +1,6 @@ +// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: +//go:build go1.19 + package libnetwork import (