From d47869ac2f1addf23a55bc0a6f4c5f2ea25ecfb4 Mon Sep 17 00:00:00 2001 From: Oliver Lowe Date: Tue, 30 Jan 2024 19:40:13 +1100 Subject: [PATCH] lang: types: Fail build if stringer run from GOROOT If stringer is run from GOROOT, it can't find any packages; same error as in https://go.dev/issue/31843. And since GOCACHE is always ignored (see issue above) we can have a bare go generate command. --- lang/types/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lang/types/Makefile b/lang/types/Makefile index 872a6f46..7cef6ba0 100644 --- a/lang/types/Makefile +++ b/lang/types/Makefile @@ -27,6 +27,10 @@ clean: kind_stringer.go: type.go @echo "Generating: type kind strings..." - @# workaround `stringer` regression in golang 1.11 + @# stringer fails if run from GOROOT. @# see: https://github.com/golang/go/issues/31843 - @unset GOCACHE && go generate # GOCACHE is returned to normal on exit... + @if which stringer | grep `go env GOROOT`; then \ + echo "stringer cannot run from GOROOT"; \ + exit 1; \ + fi + @go generate