From d8da00355e305f0564a9de6854bf5df1aa4b73d9 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 30 Aug 2021 20:58:22 -0700 Subject: [PATCH] *: add go-1.17+ go:build tags Go 1.17 introduce this new (and better) way to specify build tags. For more info, see https://golang.org/design/draft-gobuild. As a way to seamlessly switch from old to new build tags, gofmt (and gopls) from go 1.17 adds the new tags along with the old ones. Later, when go < 1.17 is no longer supported, the old build tags can be removed. Now, as I started to use latest gopls (v0.7.1), it adds these tags while I edit. Rather than to randomly add new build tags, I guess it is better to do it once for all files. Mind that previous commits removed some tags that were useless, so this one only touches packages that can at least be built on non-linux. Brought to you by go1.17 fmt ./... Signed-off-by: Kir Kolyshkin --- libcontainer/apparmor/apparmor_unsupported.go | 1 + libcontainer/capabilities/capabilities.go | 1 + libcontainer/capabilities/capabilities_unsupported.go | 1 + libcontainer/cgroups/getallpids_go115.go | 1 + libcontainer/configs/cgroup_unsupported.go | 1 + libcontainer/configs/configs_fuzzer.go | 1 + libcontainer/configs/namespaces_syscall.go | 1 + libcontainer/configs/namespaces_syscall_unsupported.go | 1 + libcontainer/configs/namespaces_unsupported.go | 1 + libcontainer/devices/device_unix.go | 1 + libcontainer/devices/device_unix_test.go | 1 + libcontainer/integration/seccomp_test.go | 1 + libcontainer/nsenter/nsenter.go | 1 + libcontainer/nsenter/nsenter_gccgo.go | 1 + libcontainer/nsenter/nsenter_unsupported.go | 1 + libcontainer/seccomp/patchbpf/enosys_linux.go | 1 + libcontainer/seccomp/patchbpf/enosys_linux_test.go | 1 + libcontainer/seccomp/patchbpf/enosys_unsupported.go | 1 + libcontainer/seccomp/seccomp_linux.go | 1 + libcontainer/seccomp/seccomp_unsupported.go | 1 + libcontainer/system/linux.go | 1 + libcontainer/system/syscall_linux_32.go | 1 + libcontainer/system/syscall_linux_64.go | 1 + libcontainer/user/lookup_unix.go | 1 + libcontainer/user/user_fuzzer.go | 1 + libcontainer/userns/userns_fuzzer.go | 1 + libcontainer/userns/userns_unsupported.go | 1 + libcontainer/utils/utils_unix.go | 1 + 28 files changed, 28 insertions(+) diff --git a/libcontainer/apparmor/apparmor_unsupported.go b/libcontainer/apparmor/apparmor_unsupported.go index 1adadafec..684248f25 100644 --- a/libcontainer/apparmor/apparmor_unsupported.go +++ b/libcontainer/apparmor/apparmor_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package apparmor diff --git a/libcontainer/capabilities/capabilities.go b/libcontainer/capabilities/capabilities.go index 1099d32b1..7e938d3f5 100644 --- a/libcontainer/capabilities/capabilities.go +++ b/libcontainer/capabilities/capabilities.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package capabilities diff --git a/libcontainer/capabilities/capabilities_unsupported.go b/libcontainer/capabilities/capabilities_unsupported.go index a3e82ac1f..0eafa4f2c 100644 --- a/libcontainer/capabilities/capabilities_unsupported.go +++ b/libcontainer/capabilities/capabilities_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package capabilities diff --git a/libcontainer/cgroups/getallpids_go115.go b/libcontainer/cgroups/getallpids_go115.go index 2672dd722..6b645ef64 100644 --- a/libcontainer/cgroups/getallpids_go115.go +++ b/libcontainer/cgroups/getallpids_go115.go @@ -1,3 +1,4 @@ +//go:build !go1.16 // +build !go1.16 package cgroups diff --git a/libcontainer/configs/cgroup_unsupported.go b/libcontainer/configs/cgroup_unsupported.go index 2a519f582..7e383020f 100644 --- a/libcontainer/configs/cgroup_unsupported.go +++ b/libcontainer/configs/cgroup_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package configs diff --git a/libcontainer/configs/configs_fuzzer.go b/libcontainer/configs/configs_fuzzer.go index 93bf41c8d..bce829e29 100644 --- a/libcontainer/configs/configs_fuzzer.go +++ b/libcontainer/configs/configs_fuzzer.go @@ -1,3 +1,4 @@ +//go:build gofuzz // +build gofuzz package configs diff --git a/libcontainer/configs/namespaces_syscall.go b/libcontainer/configs/namespaces_syscall.go index 2dc7adfc9..0516dba8d 100644 --- a/libcontainer/configs/namespaces_syscall.go +++ b/libcontainer/configs/namespaces_syscall.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package configs diff --git a/libcontainer/configs/namespaces_syscall_unsupported.go b/libcontainer/configs/namespaces_syscall_unsupported.go index 5d9a5c81f..fbb0d4907 100644 --- a/libcontainer/configs/namespaces_syscall_unsupported.go +++ b/libcontainer/configs/namespaces_syscall_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux && !windows // +build !linux,!windows package configs diff --git a/libcontainer/configs/namespaces_unsupported.go b/libcontainer/configs/namespaces_unsupported.go index cc76e2f58..946db30a5 100644 --- a/libcontainer/configs/namespaces_unsupported.go +++ b/libcontainer/configs/namespaces_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package configs diff --git a/libcontainer/devices/device_unix.go b/libcontainer/devices/device_unix.go index 9369c6f70..e2af4ff2c 100644 --- a/libcontainer/devices/device_unix.go +++ b/libcontainer/devices/device_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package devices diff --git a/libcontainer/devices/device_unix_test.go b/libcontainer/devices/device_unix_test.go index 118c3bfa9..9a93359f4 100644 --- a/libcontainer/devices/device_unix_test.go +++ b/libcontainer/devices/device_unix_test.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package devices diff --git a/libcontainer/integration/seccomp_test.go b/libcontainer/integration/seccomp_test.go index b25413060..ea8ee4199 100644 --- a/libcontainer/integration/seccomp_test.go +++ b/libcontainer/integration/seccomp_test.go @@ -1,3 +1,4 @@ +//go:build linux && cgo && seccomp // +build linux,cgo,seccomp package integration diff --git a/libcontainer/nsenter/nsenter.go b/libcontainer/nsenter/nsenter.go index 07f4d63e4..2d1f3e11c 100644 --- a/libcontainer/nsenter/nsenter.go +++ b/libcontainer/nsenter/nsenter.go @@ -1,3 +1,4 @@ +//go:build linux && !gccgo // +build linux,!gccgo package nsenter diff --git a/libcontainer/nsenter/nsenter_gccgo.go b/libcontainer/nsenter/nsenter_gccgo.go index 63c7a3ec2..86bad539e 100644 --- a/libcontainer/nsenter/nsenter_gccgo.go +++ b/libcontainer/nsenter/nsenter_gccgo.go @@ -1,3 +1,4 @@ +//go:build linux && gccgo // +build linux,gccgo package nsenter diff --git a/libcontainer/nsenter/nsenter_unsupported.go b/libcontainer/nsenter/nsenter_unsupported.go index 2459c6367..a7e049c61 100644 --- a/libcontainer/nsenter/nsenter_unsupported.go +++ b/libcontainer/nsenter/nsenter_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux || !cgo // +build !linux !cgo package nsenter diff --git a/libcontainer/seccomp/patchbpf/enosys_linux.go b/libcontainer/seccomp/patchbpf/enosys_linux.go index e5f867ec6..37a05b5a2 100644 --- a/libcontainer/seccomp/patchbpf/enosys_linux.go +++ b/libcontainer/seccomp/patchbpf/enosys_linux.go @@ -1,3 +1,4 @@ +//go:build cgo && seccomp // +build cgo,seccomp package patchbpf diff --git a/libcontainer/seccomp/patchbpf/enosys_linux_test.go b/libcontainer/seccomp/patchbpf/enosys_linux_test.go index 04328862e..b2ee6255b 100644 --- a/libcontainer/seccomp/patchbpf/enosys_linux_test.go +++ b/libcontainer/seccomp/patchbpf/enosys_linux_test.go @@ -1,3 +1,4 @@ +//go:build cgo && seccomp // +build cgo,seccomp package patchbpf diff --git a/libcontainer/seccomp/patchbpf/enosys_unsupported.go b/libcontainer/seccomp/patchbpf/enosys_unsupported.go index 682131e49..d23167ae3 100644 --- a/libcontainer/seccomp/patchbpf/enosys_unsupported.go +++ b/libcontainer/seccomp/patchbpf/enosys_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux || !cgo || !seccomp // +build !linux !cgo !seccomp package patchbpf diff --git a/libcontainer/seccomp/seccomp_linux.go b/libcontainer/seccomp/seccomp_linux.go index e86d0a954..f46250825 100644 --- a/libcontainer/seccomp/seccomp_linux.go +++ b/libcontainer/seccomp/seccomp_linux.go @@ -1,3 +1,4 @@ +//go:build cgo && seccomp // +build cgo,seccomp package seccomp diff --git a/libcontainer/seccomp/seccomp_unsupported.go b/libcontainer/seccomp/seccomp_unsupported.go index 8b7973e9a..6e593dbec 100644 --- a/libcontainer/seccomp/seccomp_unsupported.go +++ b/libcontainer/seccomp/seccomp_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux || !cgo || !seccomp // +build !linux !cgo !seccomp package seccomp diff --git a/libcontainer/system/linux.go b/libcontainer/system/linux.go index b9fd0832d..bb612daa6 100644 --- a/libcontainer/system/linux.go +++ b/libcontainer/system/linux.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package system diff --git a/libcontainer/system/syscall_linux_32.go b/libcontainer/system/syscall_linux_32.go index c5ca5d862..1acc5cb03 100644 --- a/libcontainer/system/syscall_linux_32.go +++ b/libcontainer/system/syscall_linux_32.go @@ -1,3 +1,4 @@ +//go:build linux && (386 || arm) // +build linux // +build 386 arm diff --git a/libcontainer/system/syscall_linux_64.go b/libcontainer/system/syscall_linux_64.go index e05e30adc..1ed0dba17 100644 --- a/libcontainer/system/syscall_linux_64.go +++ b/libcontainer/system/syscall_linux_64.go @@ -1,3 +1,4 @@ +//go:build linux && (arm64 || amd64 || mips || mipsle || mips64 || mips64le || ppc || ppc64 || ppc64le || riscv64 || s390x) // +build linux // +build arm64 amd64 mips mipsle mips64 mips64le ppc ppc64 ppc64le riscv64 s390x diff --git a/libcontainer/user/lookup_unix.go b/libcontainer/user/lookup_unix.go index 967717a1b..f95c1409f 100644 --- a/libcontainer/user/lookup_unix.go +++ b/libcontainer/user/lookup_unix.go @@ -1,3 +1,4 @@ +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris package user diff --git a/libcontainer/user/user_fuzzer.go b/libcontainer/user/user_fuzzer.go index 8c9bb5df3..e018eae61 100644 --- a/libcontainer/user/user_fuzzer.go +++ b/libcontainer/user/user_fuzzer.go @@ -1,3 +1,4 @@ +//go:build gofuzz // +build gofuzz package user diff --git a/libcontainer/userns/userns_fuzzer.go b/libcontainer/userns/userns_fuzzer.go index 529f8eaea..1e00ab8b5 100644 --- a/libcontainer/userns/userns_fuzzer.go +++ b/libcontainer/userns/userns_fuzzer.go @@ -1,3 +1,4 @@ +//go:build gofuzz // +build gofuzz package userns diff --git a/libcontainer/userns/userns_unsupported.go b/libcontainer/userns/userns_unsupported.go index f45bb0c31..f35c13a10 100644 --- a/libcontainer/userns/userns_unsupported.go +++ b/libcontainer/userns/userns_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package userns diff --git a/libcontainer/utils/utils_unix.go b/libcontainer/utils/utils_unix.go index 387ae509d..3b303e189 100644 --- a/libcontainer/utils/utils_unix.go +++ b/libcontainer/utils/utils_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package utils