From 7b121842aaffd4380ae2f486de94a7648f816bab Mon Sep 17 00:00:00 2001 From: Evan Jones Date: Fri, 1 Dec 2023 12:38:47 -0500 Subject: [PATCH] Run gofmt 1.19; Fix bundle-import.sh to generate correct output Go 1.19 introduced gofmt formatting changes. This change runs gofmt from Go 1.19, since commit 09f2d70be7d3 on 2023-07-14 updated to use that version. It also fixes bundle-import.sh to generate the correct output. The changes are: * Add the new "//go:build" format lines * Put "// +build" tags on one line * Ensure the correct number of newlines With these changes, future runs of bundle-import.sh should generate output that is not changed by running gofmt, with one exception: The libs line for Windows has a \r\n line ending, since it comes from the pkg-config .pc file which has \r\n line endings. I have left this unmodified. kafka/README.md: Update link to correct location See Go 1.19 release notes for details about gofmt changes: https://tip.golang.org/doc/go1.19#go-doc --- kafka/README.md | 2 +- kafka/build_darwin_amd64.go | 2 +- kafka/build_darwin_arm64.go | 2 +- kafka/build_glibc_linux_amd64.go | 4 ++-- kafka/build_glibc_linux_arm64.go | 4 ++-- kafka/build_musl_linux_amd64.go | 4 ++-- kafka/build_musl_linux_arm64.go | 4 ++-- kafka/build_windows.go | 4 ++-- kafka/librdkafka_vendor/bundle-import.sh | 17 +++++++++++------ 9 files changed, 24 insertions(+), 19 deletions(-) diff --git a/kafka/README.md b/kafka/README.md index 9924630a8..d3a5e5221 100644 --- a/kafka/README.md +++ b/kafka/README.md @@ -78,7 +78,7 @@ For each release candidate and final release, perform the following steps: ### Update bundle to latest librdkafka -See instructions in [kafka/librdkafka/README.md](kafka/librdkafka/README.md). +See instructions in [kafka/librdkafka_vendor/README.md](kafka/librdkafka_vendor/README.md). ### Update librdkafka version requirement diff --git a/kafka/build_darwin_amd64.go b/kafka/build_darwin_amd64.go index 3d871c75f..a71e926db 100644 --- a/kafka/build_darwin_amd64.go +++ b/kafka/build_darwin_amd64.go @@ -1,6 +1,6 @@ +//go:build !dynamic // +build !dynamic - // This file was auto-generated by librdkafka_vendor/bundle-import.sh, DO NOT EDIT. package kafka diff --git a/kafka/build_darwin_arm64.go b/kafka/build_darwin_arm64.go index 3f60b0480..85e7e32ab 100644 --- a/kafka/build_darwin_arm64.go +++ b/kafka/build_darwin_arm64.go @@ -1,6 +1,6 @@ +//go:build !dynamic // +build !dynamic - // This file was auto-generated by librdkafka_vendor/bundle-import.sh, DO NOT EDIT. package kafka diff --git a/kafka/build_glibc_linux_amd64.go b/kafka/build_glibc_linux_amd64.go index 122bc7214..5f0453f24 100644 --- a/kafka/build_glibc_linux_amd64.go +++ b/kafka/build_glibc_linux_amd64.go @@ -1,5 +1,5 @@ -// +build !dynamic -// +build !musl +//go:build !dynamic && !musl +// +build !dynamic,!musl // This file was auto-generated by librdkafka_vendor/bundle-import.sh, DO NOT EDIT. diff --git a/kafka/build_glibc_linux_arm64.go b/kafka/build_glibc_linux_arm64.go index 8949aabe2..0c042126c 100644 --- a/kafka/build_glibc_linux_arm64.go +++ b/kafka/build_glibc_linux_arm64.go @@ -1,5 +1,5 @@ -// +build !dynamic -// +build !musl +//go:build !dynamic && !musl +// +build !dynamic,!musl // This file was auto-generated by librdkafka_vendor/bundle-import.sh, DO NOT EDIT. diff --git a/kafka/build_musl_linux_amd64.go b/kafka/build_musl_linux_amd64.go index 19fca092e..425f58e5d 100644 --- a/kafka/build_musl_linux_amd64.go +++ b/kafka/build_musl_linux_amd64.go @@ -1,5 +1,5 @@ -// +build !dynamic -// +build musl +//go:build !dynamic && musl +// +build !dynamic,musl // This file was auto-generated by librdkafka_vendor/bundle-import.sh, DO NOT EDIT. diff --git a/kafka/build_musl_linux_arm64.go b/kafka/build_musl_linux_arm64.go index 39f57b425..1f43149a8 100644 --- a/kafka/build_musl_linux_arm64.go +++ b/kafka/build_musl_linux_arm64.go @@ -1,5 +1,5 @@ -// +build !dynamic -// +build musl +//go:build !dynamic && musl +// +build !dynamic,musl // This file was auto-generated by librdkafka_vendor/bundle-import.sh, DO NOT EDIT. diff --git a/kafka/build_windows.go b/kafka/build_windows.go index aca6a9aff..fcd6a5ed6 100644 --- a/kafka/build_windows.go +++ b/kafka/build_windows.go @@ -1,12 +1,12 @@ +//go:build !dynamic // +build !dynamic - // This file was auto-generated by librdkafka_vendor/bundle-import.sh, DO NOT EDIT. package kafka // #cgo CFLAGS: -DUSE_VENDORED_LIBRDKAFKA -DLIBRDKAFKA_STATICLIB -// #cgo LDFLAGS: ${SRCDIR}/librdkafka_vendor/librdkafka_windows.a -lws2_32 -lsecur32 -lcrypt32 +// #cgo LDFLAGS: ${SRCDIR}/librdkafka_vendor/librdkafka_windows.a -lws2_32 -lsecur32 -lcrypt32 import "C" // LibrdkafkaLinkInfo explains how librdkafka was linked to the Go client diff --git a/kafka/librdkafka_vendor/bundle-import.sh b/kafka/librdkafka_vendor/bundle-import.sh index 065c6f875..1d9f15705 100755 --- a/kafka/librdkafka_vendor/bundle-import.sh +++ b/kafka/librdkafka_vendor/bundle-import.sh @@ -46,14 +46,19 @@ setup_build() { local apath=$2 local pc=$3 local srcinfo=$4 - local build_tag= + # Go 1.19 gofmt requires //go:build and +build tags on one line + # See: https://pkg.go.dev/cmd/go#hdr-Build_constraints + local build_constraints="!dynamic" + local build_tags="!dynamic" local gpath="../build_${btype}.go" local dpath="librdkafka_${btype}.a" if [[ $btype =~ ^glibc_linux.*$ ]]; then - build_tag="// +build !musl" + build_tags+=",!musl" + build_constraints+=" && !musl" elif [[ $btype =~ ^musl_linux.*$ ]]; then - build_tag="// +build musl" + build_tags+=",musl" + build_constraints+=" && musl" fi local dynlibs=$(parse_pc_dynlibs $pc) @@ -61,11 +66,11 @@ setup_build() { echo "Copying $apath to $dpath" cp "$apath" "$dpath" - echo "Generating $gpath (extra build tag: $build_tag)" + echo "Generating $gpath (build constraints: $build_constraints; build tags: $build_tags)" cat >$gpath <