From 592c97fc8f55d65dc668b1acb3b5bdf46e851f9e Mon Sep 17 00:00:00 2001
From: Matthew Dempsky <mdempsky@google.com>
Date: Fri, 3 Feb 2017 14:38:47 -0800
Subject: [PATCH] cmd/dist: ignore .#foo.go files created by Emacs

go/build already ignores them, but they cause make.bash to fail.

Fixes #18931.

Change-Id: Idd5c8c2a6f2309ecd5f0d669660704d6f5612710
Reviewed-on: https://go-review.googlesource.com/36351
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
---
 src/cmd/dist/buildtool.go | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/cmd/dist/buildtool.go b/src/cmd/dist/buildtool.go
index 716f9942434..2f8136600f4 100644
--- a/src/cmd/dist/buildtool.go
+++ b/src/cmd/dist/buildtool.go
@@ -70,6 +70,13 @@ var bootstrapDirs = []string{
 	"math/big",
 }
 
+// File prefixes that are ignored by go/build anyway, and cause
+// problems with editor generated temporary files (#18931).
+var ignorePrefixes = []string{
+	".",
+	"_",
+}
+
 // File suffixes that use build tags introduced since Go 1.4.
 // These must not be copied into the bootstrap build directory.
 var ignoreSuffixes = []string{
@@ -103,6 +110,11 @@ func bootstrapBuildTools() {
 		xmkdirall(dst)
 	Dir:
 		for _, name := range xreaddirfiles(src) {
+			for _, pre := range ignorePrefixes {
+				if strings.HasPrefix(name, pre) {
+					continue Dir
+				}
+			}
 			for _, suf := range ignoreSuffixes {
 				if strings.HasSuffix(name, suf) {
 					continue Dir
-- 
GitLab