From e0ece0dbea4cee280b7a2a608bac3bb791c5dd2e Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Tue, 28 Jan 2025 09:48:12 -0500 Subject: [PATCH] cmd/{apidiff,gorelease}: use types.Alias when >= 1.23 This module's go.mod file specifies go1.22. These two programs use go/types, which materializes aliases as type.Alias when the go version is >= 1.23. Force that materialization with toolchains >= 1.23 despite what the go.mod says. Fixes golang/go#70695. Change-Id: I9401d7f80880fdf59600592baf93bb4c8b7c76ec Reviewed-on: https://go-review.googlesource.com/c/exp/+/645015 LUCI-TryBot-Result: Go LUCI Reviewed-by: Alan Donovan --- cmd/apidiff/gotypesalias.go | 12 ++++++++++++ cmd/apidiff/main.go | 4 ++++ cmd/gorelease/gotypesalias.go | 12 ++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 cmd/apidiff/gotypesalias.go create mode 100644 cmd/gorelease/gotypesalias.go diff --git a/cmd/apidiff/gotypesalias.go b/cmd/apidiff/gotypesalias.go new file mode 100644 index 000000000..657ab4103 --- /dev/null +++ b/cmd/apidiff/gotypesalias.go @@ -0,0 +1,12 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build go1.23 + +//go:debug gotypesalias=1 + +package main + +// Materialize aliases whenever the go toolchain version is after 1.23 (#69772). +// Remove this file after go.mod >= 1.23 (which implies gotypesalias=1). diff --git a/cmd/apidiff/main.go b/cmd/apidiff/main.go index 67261a160..3907f63ba 100644 --- a/cmd/apidiff/main.go +++ b/cmd/apidiff/main.go @@ -1,3 +1,7 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + // Command apidiff determines whether two versions of a package are compatible package main diff --git a/cmd/gorelease/gotypesalias.go b/cmd/gorelease/gotypesalias.go new file mode 100644 index 000000000..657ab4103 --- /dev/null +++ b/cmd/gorelease/gotypesalias.go @@ -0,0 +1,12 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build go1.23 + +//go:debug gotypesalias=1 + +package main + +// Materialize aliases whenever the go toolchain version is after 1.23 (#69772). +// Remove this file after go.mod >= 1.23 (which implies gotypesalias=1).