From b5859e1dd7c1786fff3585fb2f7eaf88331091e7 Mon Sep 17 00:00:00 2001 From: "Paul \"TBBle\" Hampson" Date: Tue, 27 Feb 2024 20:05:01 +0900 Subject: [PATCH] Rationalise build constraints for Go 1.19 onwards This mostly involves replacing anything that was trying to be "Not Windows" with the new-in-Go-1.19 "unix" build-constraint. Effectively, anything that contained both "linux" and "freebsd" but not "windows", or excluded only "windows", is now "unix". A couple of needless constraints were removed when the filenames already carried the appropriate constraint. A handful of files were renamed, so that now "unix"-suffixed files all use the "unix" constraint, and "other" is used when the constraint is more-complex, for "no specific implementation" cases. Signed-off-by: Paul "TBBle" Hampson --- cmd/nerdctl/container_top_unix_test.go | 2 +- cmd/nerdctl/main_unix.go | 2 +- cmd/nerdctl/network_create_unix.go | 2 +- pkg/buildkitutil/buildkitutil_unix.go | 2 +- pkg/cioutil/container_io_unix.go | 2 +- pkg/cioutil/container_io_windows.go | 2 -- pkg/cmd/container/top_unix.go | 2 +- pkg/cmd/login/login_unix.go | 2 +- pkg/consoleutil/consoleutil_unix.go | 2 +- pkg/containerutil/container_network_manager_other.go | 2 +- pkg/infoutil/infoutil_unix.go | 2 +- pkg/infoutil/infoutil_unix_test.go | 2 +- pkg/ipcutil/ipcutil_linux.go | 2 -- pkg/ipcutil/{ipcutil_unix.go => ipcutil_other.go} | 2 +- pkg/lockutil/lockutil_unix.go | 2 +- pkg/mountutil/{mountutil_other.go => mountutil_unix.go} | 2 +- pkg/mountutil/mountutil_windows.go | 2 -- pkg/netutil/cni_plugin_unix.go | 2 +- pkg/netutil/netutil_linux_test.go | 2 -- pkg/netutil/netutil_unix.go | 2 +- pkg/netutil/netutil_unix_test.go | 2 +- pkg/netutil/netutil_windows_test.go | 2 -- .../{port_allocate_others.go => port_allocate_other.go} | 0 pkg/signalutil/{signals_notlinux.go => signals_other.go} | 0 pkg/systemutil/socket_unix.go | 2 +- 25 files changed, 18 insertions(+), 28 deletions(-) rename pkg/ipcutil/{ipcutil_unix.go => ipcutil_other.go} (97%) rename pkg/mountutil/{mountutil_other.go => mountutil_unix.go} (98%) rename pkg/portutil/{port_allocate_others.go => port_allocate_other.go} (100%) rename pkg/signalutil/{signals_notlinux.go => signals_other.go} (100%) diff --git a/cmd/nerdctl/container_top_unix_test.go b/cmd/nerdctl/container_top_unix_test.go index 45b39f2a64f..3e22f6f11db 100644 --- a/cmd/nerdctl/container_top_unix_test.go +++ b/cmd/nerdctl/container_top_unix_test.go @@ -1,4 +1,4 @@ -//go:build linux || darwin || freebsd || netbsd || openbsd +//go:build unix /* Copyright The containerd Authors. diff --git a/cmd/nerdctl/main_unix.go b/cmd/nerdctl/main_unix.go index 93ac2f9134e..e5370ba6413 100644 --- a/cmd/nerdctl/main_unix.go +++ b/cmd/nerdctl/main_unix.go @@ -1,4 +1,4 @@ -//go:build freebsd || linux +//go:build unix /* Copyright The containerd Authors. diff --git a/cmd/nerdctl/network_create_unix.go b/cmd/nerdctl/network_create_unix.go index 298030ba5bc..5abc60accc4 100644 --- a/cmd/nerdctl/network_create_unix.go +++ b/cmd/nerdctl/network_create_unix.go @@ -1,4 +1,4 @@ -//go:build freebsd || linux +//go:build unix /* Copyright The containerd Authors. diff --git a/pkg/buildkitutil/buildkitutil_unix.go b/pkg/buildkitutil/buildkitutil_unix.go index 521504992d0..5c5498d3aa9 100644 --- a/pkg/buildkitutil/buildkitutil_unix.go +++ b/pkg/buildkitutil/buildkitutil_unix.go @@ -1,4 +1,4 @@ -//go:build freebsd || linux +//go:build unix /* Copyright The containerd Authors. diff --git a/pkg/cioutil/container_io_unix.go b/pkg/cioutil/container_io_unix.go index fd0632c3781..1749a018c98 100644 --- a/pkg/cioutil/container_io_unix.go +++ b/pkg/cioutil/container_io_unix.go @@ -1,4 +1,4 @@ -//go:build !windows +//go:build unix /* Copyright The containerd Authors. diff --git a/pkg/cioutil/container_io_windows.go b/pkg/cioutil/container_io_windows.go index ac1c09625bf..6dde42f12a6 100644 --- a/pkg/cioutil/container_io_windows.go +++ b/pkg/cioutil/container_io_windows.go @@ -1,5 +1,3 @@ -//go:build windows - /* Copyright The containerd Authors. diff --git a/pkg/cmd/container/top_unix.go b/pkg/cmd/container/top_unix.go index 6281c23e072..e5f04ef60d1 100644 --- a/pkg/cmd/container/top_unix.go +++ b/pkg/cmd/container/top_unix.go @@ -1,4 +1,4 @@ -//go:build linux || darwin || freebsd || netbsd || openbsd +//go:build unix /* Copyright The containerd Authors. diff --git a/pkg/cmd/login/login_unix.go b/pkg/cmd/login/login_unix.go index ee536be1721..c1eec8fdf01 100644 --- a/pkg/cmd/login/login_unix.go +++ b/pkg/cmd/login/login_unix.go @@ -1,4 +1,4 @@ -//go:build freebsd || linux +//go:build unix /* Copyright The containerd Authors. diff --git a/pkg/consoleutil/consoleutil_unix.go b/pkg/consoleutil/consoleutil_unix.go index 49cea373bbf..6ffd0cc4dda 100644 --- a/pkg/consoleutil/consoleutil_unix.go +++ b/pkg/consoleutil/consoleutil_unix.go @@ -1,4 +1,4 @@ -//go:build !windows +//go:build unix /* Copyright The containerd Authors. diff --git a/pkg/containerutil/container_network_manager_other.go b/pkg/containerutil/container_network_manager_other.go index 914a3553c1a..1dabe5e6428 100644 --- a/pkg/containerutil/container_network_manager_other.go +++ b/pkg/containerutil/container_network_manager_other.go @@ -1,4 +1,4 @@ -//go:build darwin || freebsd || netbsd || openbsd +//go:build !(linux || windows) /* Copyright The containerd Authors. diff --git a/pkg/infoutil/infoutil_unix.go b/pkg/infoutil/infoutil_unix.go index e49f27e5e05..782a17537f0 100644 --- a/pkg/infoutil/infoutil_unix.go +++ b/pkg/infoutil/infoutil_unix.go @@ -1,4 +1,4 @@ -//go:build freebsd || linux +//go:build unix /* Copyright The containerd Authors. diff --git a/pkg/infoutil/infoutil_unix_test.go b/pkg/infoutil/infoutil_unix_test.go index 47067a8d1fa..208aedbafd3 100644 --- a/pkg/infoutil/infoutil_unix_test.go +++ b/pkg/infoutil/infoutil_unix_test.go @@ -1,4 +1,4 @@ -//go:build freebsd || linux +//go:build unix /* Copyright The containerd Authors. diff --git a/pkg/ipcutil/ipcutil_linux.go b/pkg/ipcutil/ipcutil_linux.go index 1c676abb027..0d1b9f6cbc6 100644 --- a/pkg/ipcutil/ipcutil_linux.go +++ b/pkg/ipcutil/ipcutil_linux.go @@ -1,5 +1,3 @@ -//go:build linux - /* Copyright The containerd Authors. diff --git a/pkg/ipcutil/ipcutil_unix.go b/pkg/ipcutil/ipcutil_other.go similarity index 97% rename from pkg/ipcutil/ipcutil_unix.go rename to pkg/ipcutil/ipcutil_other.go index c5664fc2732..a4c25963cc0 100644 --- a/pkg/ipcutil/ipcutil_unix.go +++ b/pkg/ipcutil/ipcutil_other.go @@ -1,4 +1,4 @@ -//go:build freebsd +//go:build !(linux || windows) /* Copyright The containerd Authors. diff --git a/pkg/lockutil/lockutil_unix.go b/pkg/lockutil/lockutil_unix.go index dbabcbc9b0f..64e9867b044 100644 --- a/pkg/lockutil/lockutil_unix.go +++ b/pkg/lockutil/lockutil_unix.go @@ -1,4 +1,4 @@ -//go:build freebsd || linux +//go:build unix /* Copyright The containerd Authors. diff --git a/pkg/mountutil/mountutil_other.go b/pkg/mountutil/mountutil_unix.go similarity index 98% rename from pkg/mountutil/mountutil_other.go rename to pkg/mountutil/mountutil_unix.go index eed4431382a..5bf7e4d2420 100644 --- a/pkg/mountutil/mountutil_other.go +++ b/pkg/mountutil/mountutil_unix.go @@ -1,4 +1,4 @@ -//go:build !windows +//go:build unix /* Copyright The containerd Authors. diff --git a/pkg/mountutil/mountutil_windows.go b/pkg/mountutil/mountutil_windows.go index eee76ba40b6..7d9ff965349 100644 --- a/pkg/mountutil/mountutil_windows.go +++ b/pkg/mountutil/mountutil_windows.go @@ -1,5 +1,3 @@ -//go:build windows - /* Copyright The containerd Authors. diff --git a/pkg/netutil/cni_plugin_unix.go b/pkg/netutil/cni_plugin_unix.go index 2a0233860f3..cdbb0221b8d 100644 --- a/pkg/netutil/cni_plugin_unix.go +++ b/pkg/netutil/cni_plugin_unix.go @@ -1,4 +1,4 @@ -//go:build freebsd || linux +//go:build unix /* Copyright The containerd Authors. diff --git a/pkg/netutil/netutil_linux_test.go b/pkg/netutil/netutil_linux_test.go index 1f64dbbd5af..4e370baba9b 100644 --- a/pkg/netutil/netutil_linux_test.go +++ b/pkg/netutil/netutil_linux_test.go @@ -1,5 +1,3 @@ -//go:build linux - /* Copyright The containerd Authors. diff --git a/pkg/netutil/netutil_unix.go b/pkg/netutil/netutil_unix.go index 12c39df982a..f5315028f04 100644 --- a/pkg/netutil/netutil_unix.go +++ b/pkg/netutil/netutil_unix.go @@ -1,4 +1,4 @@ -//go:build freebsd || linux +//go:build unix /* Copyright The containerd Authors. diff --git a/pkg/netutil/netutil_unix_test.go b/pkg/netutil/netutil_unix_test.go index 4d9acc7cb91..5a2d66d4451 100644 --- a/pkg/netutil/netutil_unix_test.go +++ b/pkg/netutil/netutil_unix_test.go @@ -1,4 +1,4 @@ -//go:build freebsd || linux +//go:build unix /* Copyright The containerd Authors. diff --git a/pkg/netutil/netutil_windows_test.go b/pkg/netutil/netutil_windows_test.go index 7545230848f..eb26eef9449 100644 --- a/pkg/netutil/netutil_windows_test.go +++ b/pkg/netutil/netutil_windows_test.go @@ -1,5 +1,3 @@ -//go:build windows - /* Copyright The containerd Authors. diff --git a/pkg/portutil/port_allocate_others.go b/pkg/portutil/port_allocate_other.go similarity index 100% rename from pkg/portutil/port_allocate_others.go rename to pkg/portutil/port_allocate_other.go diff --git a/pkg/signalutil/signals_notlinux.go b/pkg/signalutil/signals_other.go similarity index 100% rename from pkg/signalutil/signals_notlinux.go rename to pkg/signalutil/signals_other.go diff --git a/pkg/systemutil/socket_unix.go b/pkg/systemutil/socket_unix.go index b8e2f1e6904..6d41bab69b3 100644 --- a/pkg/systemutil/socket_unix.go +++ b/pkg/systemutil/socket_unix.go @@ -1,4 +1,4 @@ -//go:build freebsd || linux +//go:build unix /* Copyright The containerd Authors.