From fd2f9f3bd1e313f0e26c0fb36e8be6a2c4d17f51 Mon Sep 17 00:00:00 2001 From: Rob Findley Date: Thu, 4 Feb 2021 09:58:04 -0500 Subject: [PATCH] internal/lsp/command: use a build tag to avoid broken generation Modifying command.Interface can prevent re-generation by breaking the build (because command_gen.go is no longer valid). Fix this by using a build tag to only consider the interface during generation. Change-Id: I025879897b0d1d98148654201a54539868e9f578 Reviewed-on: https://go-review.googlesource.com/c/tools/+/289691 Trust: Robert Findley Run-TryBot: Robert Findley gopls-CI: kokoro TryBot-Result: Go Bot Reviewed-by: Rebecca Stambler Reviewed-by: Heschi Kreinick --- internal/lsp/command/command_gen.go | 4 ++++ internal/lsp/command/generate/generate.go | 4 ++++ internal/lsp/command/interface.go | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/lsp/command/command_gen.go b/internal/lsp/command/command_gen.go index 5980f353ca..d3dbfd5125 100644 --- a/internal/lsp/command/command_gen.go +++ b/internal/lsp/command/command_gen.go @@ -2,6 +2,10 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// Don't include this file during code generation, or it will break the build +// if existing interface methods have been modified. +// +build !generate + package command // Code generated by generate.go. DO NOT EDIT. diff --git a/internal/lsp/command/generate/generate.go b/internal/lsp/command/generate/generate.go index d206e22cec..d31b437489 100644 --- a/internal/lsp/command/generate/generate.go +++ b/internal/lsp/command/generate/generate.go @@ -20,6 +20,10 @@ const src = `// Copyright 2021 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. +// Don't include this file during code generation, or it will break the build +// if existing interface methods have been modified. +// +build !generate + package command // Code generated by generate.go. DO NOT EDIT. diff --git a/internal/lsp/command/interface.go b/internal/lsp/command/interface.go index cbfa1c57f5..4f068fa777 100644 --- a/internal/lsp/command/interface.go +++ b/internal/lsp/command/interface.go @@ -12,7 +12,7 @@ // also provided by this package, via code generation. package command -//go:generate go run generate.go +//go:generate go run -tags=generate generate.go import "golang.org/x/tools/internal/lsp/protocol"