all: copy+update code from x/build/version/*
From x/build git rev a41435cbf9f.
Renames the "version" package to internal/version too.
Updates golang/go#23223
Change-Id: Idbcedeb5f3ac1f2afe527064be0d6ae8524a0358
Reviewed-on: https://go-review.googlesource.com/123677
Reviewed-by: Andrew Bonventre <andybons@golang.org>
diff --git a/go1.10.1/main.go b/go1.10.1/main.go
new file mode 100644
index 0000000..1c66143
--- /dev/null
+++ b/go1.10.1/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.10.1 command runs the go command from Go 1.10.1.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.10.1
+// $ go1.10.1 download
+//
+// And then use the go1.10.1 command as if it were your normal
+// go command.
+//
+// See the release notes at https://golang.org/doc/devel/release.html#go1.10.minor
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.10.1")
+}
diff --git a/go1.10.2/main.go b/go1.10.2/main.go
new file mode 100644
index 0000000..ceecb46
--- /dev/null
+++ b/go1.10.2/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.10.2 command runs the go command from go1.10.2.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.10.2
+// $ go1.10.2 download
+//
+// And then use the go1.10.2 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.10.2
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.10.2")
+}
diff --git a/go1.10.3/main.go b/go1.10.3/main.go
new file mode 100644
index 0000000..8ab2684
--- /dev/null
+++ b/go1.10.3/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.10.3 command runs the go command from go1.10.3.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.10.3
+// $ go1.10.3 download
+//
+// And then use the go1.10.3 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.10.3
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.10.3")
+}
diff --git a/go1.10/go1.10.go b/go1.10/go1.10.go
new file mode 100644
index 0000000..3838b69
--- /dev/null
+++ b/go1.10/go1.10.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.10 command runs the go command from go1.10.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.10
+// $ go1.10 download
+//
+// And then use the go1.10 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.10
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.10")
+}
diff --git a/go1.10beta1/main.go b/go1.10beta1/main.go
new file mode 100644
index 0000000..035a333
--- /dev/null
+++ b/go1.10beta1/main.go
@@ -0,0 +1,24 @@
+// Copyright 2017 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.
+
+// The go1.10beta1 command runs the go command from go1.10beta1.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.10beta1
+// $ go1.10beta1 download
+//
+// And then use the go1.10beta1 command as if it were your normal go
+// command.
+//
+// See the release notes at https://beta.golang.org/doc/go1.10
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.10beta1")
+}
diff --git a/go1.10beta2/main.go b/go1.10beta2/main.go
new file mode 100644
index 0000000..3aa8027b
--- /dev/null
+++ b/go1.10beta2/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.10beta2 command runs the go command from go1.10beta2.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.10beta2
+// $ go1.10beta2 download
+//
+// And then use the go1.10beta2 command as if it were your normal go
+// command.
+//
+// See the release notes at https://beta.golang.org/doc/go1.10
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.10beta2")
+}
diff --git a/go1.10rc1/main.go b/go1.10rc1/main.go
new file mode 100644
index 0000000..5357da5
--- /dev/null
+++ b/go1.10rc1/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.10rc1 command runs the go command from go1.10rc1.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.10rc1
+// $ go1.10rc1 download
+//
+// And then use the go1.10rc1 command as if it were your normal go
+// command.
+//
+// See the release notes at https://tip.golang.org/doc/go1.10
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.10rc1")
+}
diff --git a/go1.10rc2/main.go b/go1.10rc2/main.go
new file mode 100644
index 0000000..b168e4b
--- /dev/null
+++ b/go1.10rc2/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.10rc2 command runs the go command from go1.10rc2.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.10rc2
+// $ go1.10rc2 download
+//
+// And then use the go1.10rc2 command as if it were your normal go
+// command.
+//
+// See the release notes at https://tip.golang.org/doc/go1.10
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.10rc2")
+}
diff --git a/go1.11beta1/main.go b/go1.11beta1/main.go
new file mode 100644
index 0000000..ab7ee8e
--- /dev/null
+++ b/go1.11beta1/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.11beta1 command runs the go command from go1.11beta1.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.11beta1
+// $ go1.11beta1 download
+//
+// And then use the go1.11beta1 command as if it were your normal go
+// command.
+//
+// See the release notes at https://tip.golang.org/doc/go1.11
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.11beta1")
+}
diff --git a/go1.8.1/main.go b/go1.8.1/main.go
new file mode 100644
index 0000000..149124c
--- /dev/null
+++ b/go1.8.1/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.8.1 command runs the go command from go1.8.1.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.8.1
+// $ go1.8.1 download
+//
+// And then use the go1.8.1 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.8
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.8.1")
+}
diff --git a/go1.8.2/main.go b/go1.8.2/main.go
new file mode 100644
index 0000000..4f12699
--- /dev/null
+++ b/go1.8.2/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.8.2 command runs the go command from go1.8.2.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.8.2
+// $ go1.8.2 download
+//
+// And then use the go1.8.2 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.8
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.8.2")
+}
diff --git a/go1.8.3/main.go b/go1.8.3/main.go
new file mode 100644
index 0000000..297a2a0
--- /dev/null
+++ b/go1.8.3/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.8.3 command runs the go command from go1.8.3.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.8.3
+// $ go1.8.3 download
+//
+// And then use the go1.8.3 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.8
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.8.3")
+}
diff --git a/go1.8.4/main.go b/go1.8.4/main.go
new file mode 100644
index 0000000..85013c3
--- /dev/null
+++ b/go1.8.4/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.8.4 command runs the go command from go1.8.4.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.8.4
+// $ go1.8.4 download
+//
+// And then use the go1.8.4 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.8
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.8.4")
+}
diff --git a/go1.8.5/main.go b/go1.8.5/main.go
new file mode 100644
index 0000000..9b073a7
--- /dev/null
+++ b/go1.8.5/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.8.5 command runs the go command from go1.8.5.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.8.5
+// $ go1.8.5 download
+//
+// And then use the go1.8.5 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.8
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.8.5")
+}
diff --git a/go1.8.6/main.go b/go1.8.6/main.go
new file mode 100644
index 0000000..7ce24df
--- /dev/null
+++ b/go1.8.6/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.8.6 command runs the go command from go1.8.6.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.8.6
+// $ go1.8.6 download
+//
+// And then use the go1.8.6 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.8
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.8.6")
+}
diff --git a/go1.8.7/main.go b/go1.8.7/main.go
new file mode 100644
index 0000000..5374562
--- /dev/null
+++ b/go1.8.7/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.8.7 command runs the go command from go1.8.7.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.8.7
+// $ go1.8.7 download
+//
+// And then use the go1.8.7 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.8
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.8.7")
+}
diff --git a/go1.8/main.go b/go1.8/main.go
new file mode 100644
index 0000000..5c6d564
--- /dev/null
+++ b/go1.8/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.8 command runs the go command from go1.8.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.8
+// $ go1.8 download
+//
+// And then use the go1.8 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.8
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.8")
+}
diff --git a/go1.8beta1/main.go b/go1.8beta1/main.go
new file mode 100644
index 0000000..04320d5
--- /dev/null
+++ b/go1.8beta1/main.go
@@ -0,0 +1,24 @@
+// Copyright 2016 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.
+
+// The go1.8beta1 command runs the go command from go1.8beta1.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.8beta1
+// $ go1.8beta1 download
+//
+// And then use the go1.8beta1 command as if it were your normal go
+// command.
+//
+// See the release notes at https://beta.golang.org/doc/go1.8
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.8beta1")
+}
diff --git a/go1.8beta2/main.go b/go1.8beta2/main.go
new file mode 100644
index 0000000..f4c2389
--- /dev/null
+++ b/go1.8beta2/main.go
@@ -0,0 +1,24 @@
+// Copyright 2016 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.
+
+// The go1.8beta2 command runs the go command from go1.8beta2.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.8beta2
+// $ go1.8beta2 download
+//
+// And then use the go1.8beta2 command as if it were your normal go
+// command.
+//
+// See the release notes at https://beta.golang.org/doc/go1.8
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.8beta2")
+}
diff --git a/go1.8rc1/main.go b/go1.8rc1/main.go
new file mode 100644
index 0000000..4a62bbc
--- /dev/null
+++ b/go1.8rc1/main.go
@@ -0,0 +1,24 @@
+// Copyright 2016 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.
+
+// The go1.8rc1 command runs the go command from go1.8rc1.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.8rc1
+// $ go1.8rc1 download
+//
+// And then use the go1.8rc1 command as if it were your normal go
+// command.
+//
+// See the release notes at https://beta.golang.org/doc/go1.8
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.8rc1")
+}
diff --git a/go1.8rc2/main.go b/go1.8rc2/main.go
new file mode 100644
index 0000000..d8b2099
--- /dev/null
+++ b/go1.8rc2/main.go
@@ -0,0 +1,24 @@
+// Copyright 2016 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.
+
+// The go1.8rc2 command runs the go command from go1.8rc2.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.8rc2
+// $ go1.8rc2 download
+//
+// And then use the go1.8rc2 command as if it were your normal go
+// command.
+//
+// See the release notes at https://beta.golang.org/doc/go1.8
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.8rc2")
+}
diff --git a/go1.8rc3/main.go b/go1.8rc3/main.go
new file mode 100644
index 0000000..b1197fc
--- /dev/null
+++ b/go1.8rc3/main.go
@@ -0,0 +1,24 @@
+// Copyright 2016 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.
+
+// The go1.8rc3 command runs the go command from go1.8rc3.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.8rc3
+// $ go1.8rc3 download
+//
+// And then use the go1.8rc3 command as if it were your normal go
+// command.
+//
+// See the release notes at https://beta.golang.org/doc/go1.8
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.8rc3")
+}
diff --git a/go1.9.1/main.go b/go1.9.1/main.go
new file mode 100644
index 0000000..075f867
--- /dev/null
+++ b/go1.9.1/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.9.1 command runs the go command from go1.9.1.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.9.1
+// $ go1.9.1 download
+//
+// And then use the go1.9.1 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.9
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.9.1")
+}
diff --git a/go1.9.2/main.go b/go1.9.2/main.go
new file mode 100644
index 0000000..cb3c755
--- /dev/null
+++ b/go1.9.2/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.9.2 command runs the go command from go1.9.2.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.9.2
+// $ go1.9.2 download
+//
+// And then use the go1.9.2 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.9
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.9.2")
+}
diff --git a/go1.9.3/main.go b/go1.9.3/main.go
new file mode 100644
index 0000000..28f48cb
--- /dev/null
+++ b/go1.9.3/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.9.3 command runs the go command from go1.9.3.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.9.3
+// $ go1.9.3 download
+//
+// And then use the go1.9.3 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.9
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.9.3")
+}
diff --git a/go1.9.4/main.go b/go1.9.4/main.go
new file mode 100644
index 0000000..6d74de5
--- /dev/null
+++ b/go1.9.4/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.9.4 command runs the go command from go1.9.4.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.9.4
+// $ go1.9.4 download
+//
+// And then use the go1.9.4 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.9
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.9.4")
+}
diff --git a/go1.9.5/main.go b/go1.9.5/main.go
new file mode 100644
index 0000000..93c97d1
--- /dev/null
+++ b/go1.9.5/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.9.5 command runs the go command from Go 1.9.5.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.9.5
+// $ go1.9.5 download
+//
+// And then use the go1.9.5 command as if it were your normal
+// go command.
+//
+// See the release notes at https://golang.org/doc/devel/release.html#go1.9.minor
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.9.5")
+}
diff --git a/go1.9.6/main.go b/go1.9.6/main.go
new file mode 100644
index 0000000..48eeaeb
--- /dev/null
+++ b/go1.9.6/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.9.6 command runs the go command from go1.9.6.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.9.6
+// $ go1.9.6 download
+//
+// And then use the go1.9.6 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.9.6
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.9.6")
+}
diff --git a/go1.9.7/main.go b/go1.9.7/main.go
new file mode 100644
index 0000000..514a606
--- /dev/null
+++ b/go1.9.7/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.9.7 command runs the go command from go1.9.7.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.9.7
+// $ go1.9.7 download
+//
+// And then use the go1.9.7 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.9.7
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.9.7")
+}
diff --git a/go1.9/main.go b/go1.9/main.go
new file mode 100644
index 0000000..49e2e15
--- /dev/null
+++ b/go1.9/main.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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.
+
+// The go1.9 command runs the go command from go1.9.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.9
+// $ go1.9 download
+//
+// And then use the go1.9 command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/go1.9
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.9")
+}
diff --git a/go1.9beta1/main.go b/go1.9beta1/main.go
new file mode 100644
index 0000000..5c339df
--- /dev/null
+++ b/go1.9beta1/main.go
@@ -0,0 +1,24 @@
+// Copyright 2017 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.
+
+// The go1.9beta1 command runs the go command from go1.9beta1.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.9beta1
+// $ go1.9beta1 download
+//
+// And then use the go1.9beta1 command as if it were your normal go
+// command.
+//
+// See the release notes at https://beta.golang.org/doc/go1.9
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.9beta1")
+}
diff --git a/go1.9beta2/main.go b/go1.9beta2/main.go
new file mode 100644
index 0000000..c887378
--- /dev/null
+++ b/go1.9beta2/main.go
@@ -0,0 +1,24 @@
+// Copyright 2017 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.
+
+// The go1.9beta2 command runs the go command from go1.9beta2.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.9beta2
+// $ go1.9beta2 download
+//
+// And then use the go1.9beta2 command as if it were your normal go
+// command.
+//
+// See the release notes at https://beta.golang.org/doc/go1.9
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.9beta2")
+}
diff --git a/go1.9rc1/main.go b/go1.9rc1/main.go
new file mode 100644
index 0000000..5e01704
--- /dev/null
+++ b/go1.9rc1/main.go
@@ -0,0 +1,24 @@
+// Copyright 2017 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.
+
+// The go1.9rc1 command runs the go command from go1.9rc1.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.9rc1
+// $ go1.9rc1 download
+//
+// And then use the go1.9rc1 command as if it were your normal go
+// command.
+//
+// See the release notes at https://tip.golang.org/doc/go1.9
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.9rc1")
+}
diff --git a/go1.9rc2/main.go b/go1.9rc2/main.go
new file mode 100644
index 0000000..0a267d8
--- /dev/null
+++ b/go1.9rc2/main.go
@@ -0,0 +1,24 @@
+// Copyright 2017 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.
+
+// The go1.9rc2 command runs the go command from go1.9rc2.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/go1.9rc2
+// $ go1.9rc2 download
+//
+// And then use the go1.9rc2 command as if it were your normal go
+// command.
+//
+// See the release notes at https://tip.golang.org/doc/go1.9
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("go1.9rc2")
+}
diff --git a/internal/genv/main.go b/internal/genv/main.go
new file mode 100755
index 0000000..1f32863
--- /dev/null
+++ b/internal/genv/main.go
@@ -0,0 +1,86 @@
+// Copyright 2018 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.
+
+// The genv command generates version-specific go command source files.
+package main
+
+import (
+ "bytes"
+ "fmt"
+ "html/template"
+ "io/ioutil"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strings"
+ "time"
+)
+
+func usage() {
+ fmt.Fprintln(os.Stderr, "usage: genv <version>...")
+ os.Exit(2)
+}
+
+func main() {
+ if len(os.Args) == 1 {
+ usage()
+ }
+ for _, version := range os.Args[1:] {
+ if !strings.HasPrefix(version, "go") {
+ failf("version names should have the 'go' prefix")
+ }
+ var buf bytes.Buffer
+ if err := mainTmpl.Execute(&buf, struct {
+ Year int
+ Version string
+ }{time.Now().Year(), version}); err != nil {
+ failf("mainTmpl.execute: %v", err)
+ }
+ path := filepath.Join(os.Getenv("GOPATH"), "src/golang.org/dl", version, "main.go")
+ if err := os.Mkdir(filepath.Dir(path), 0755); err != nil {
+ failf("os.Mkdir: %v", err)
+ }
+ if err := ioutil.WriteFile(path, buf.Bytes(), 0666); err != nil {
+ failf("ioutil.WriteFile: %v", err)
+ }
+ fmt.Println("Wrote", path)
+ if err := exec.Command("gofmt", "-w", path).Run(); err != nil {
+ failf("could not gofmt file %q: %v", path, err)
+ }
+ }
+}
+
+func failf(format string, args ...interface{}) {
+ if len(format) == 0 || format[len(format)-1] != '\n' {
+ format += "\n"
+ }
+ fmt.Fprintf(os.Stderr, format, args...)
+ os.Exit(1)
+}
+
+var mainTmpl = template.Must(template.New("main").Parse(`// Copyright {{.Year}} 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.
+
+// The {{.Version}} command runs the go command from {{.Version}}.
+//
+// To install, run:
+//
+// $ go get golang.org/dl/{{.Version}}
+// $ {{.Version}} download
+//
+// And then use the {{.Version}} command as if it were your normal go
+// command.
+//
+// See the release notes at https://golang.org/doc/{{.Version}}
+//
+// File bugs at https://golang.org/issues/new
+package main
+
+import "golang.org/dl/internal/version"
+
+func main() {
+ version.Run("{{.Version}}")
+}
+`))
diff --git a/internal/version/version.go b/internal/version/version.go
new file mode 100644
index 0000000..95874fa
--- /dev/null
+++ b/internal/version/version.go
@@ -0,0 +1,453 @@
+// Copyright 2016 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.
+
+// The version package permits running a specific version of Go.
+package version
+
+import (
+ "archive/tar"
+ "archive/zip"
+ "compress/gzip"
+ "crypto/sha256"
+ "errors"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "log"
+ "net/http"
+ "os"
+ "os/exec"
+ "os/user"
+ "path"
+ "path/filepath"
+ "runtime"
+ "strings"
+ "time"
+
+ "golang.org/x/build/envutil"
+)
+
+func init() {
+ http.DefaultTransport = &userAgentTransport{http.DefaultTransport}
+}
+
+// Run runs the "go" tool of the provided Go version.
+func Run(version string) {
+ log.SetFlags(0)
+
+ root, err := goroot(version)
+ if err != nil {
+ log.Fatalf("%s: %v", version, err)
+ }
+
+ if len(os.Args) == 2 && os.Args[1] == "download" {
+ if err := install(root, version); err != nil {
+ log.Fatalf("%s: download failed: %v", version, err)
+ }
+ os.Exit(0)
+ }
+
+ if _, err := os.Stat(filepath.Join(root, unpackedOkay)); err != nil {
+ log.Fatalf("%s: not downloaded. Run '%s download' to install to %v", version, version, root)
+ }
+
+ gobin := filepath.Join(root, "bin", "go"+exe())
+ cmd := exec.Command(gobin, os.Args[1:]...)
+ cmd.Stdin = os.Stdin
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+ cmd.Env = envutil.Dedup(caseInsensitiveEnv, append(os.Environ(), "GOROOT="+root))
+ if err := cmd.Run(); err != nil {
+ // TODO: return the same exit status maybe.
+ os.Exit(1)
+ }
+ os.Exit(0)
+}
+
+// install installs a version of Go to the named target directory, creating the
+// directory as needed.
+func install(targetDir, version string) error {
+ if _, err := os.Stat(filepath.Join(targetDir, unpackedOkay)); err == nil {
+ log.Printf("%s: already downloaded in %v", version, targetDir)
+ return nil
+ }
+
+ goURL, err := versionArchiveURL(version)
+ if err != nil {
+ return err
+ }
+ if err := os.MkdirAll(targetDir, 0755); err != nil {
+ return err
+ }
+ res, err := http.Head(goURL)
+ if err != nil {
+ return err
+ }
+ if res.StatusCode == http.StatusNotFound {
+ return fmt.Errorf("no binary release of %v for %v/%v at %v", version, getOS(), runtime.GOARCH, goURL)
+ }
+ if res.StatusCode != http.StatusOK {
+ return fmt.Errorf("server returned %v checking size of %v", http.StatusText(res.StatusCode), goURL)
+ }
+ base := path.Base(goURL)
+ archiveFile := filepath.Join(targetDir, base)
+ if fi, err := os.Stat(archiveFile); err != nil || fi.Size() != res.ContentLength {
+ if err != nil && !os.IsNotExist(err) {
+ // Something weird. Don't try to download.
+ return err
+ }
+ if err := copyFromURL(archiveFile, goURL); err != nil {
+ return fmt.Errorf("error downloading %v: %v", goURL, err)
+ }
+ fi, err = os.Stat(archiveFile)
+ if err != nil {
+ return err
+ }
+ if fi.Size() != res.ContentLength {
+ return fmt.Errorf("downloaded file %s size %v doesn't match server size %v", archiveFile, fi.Size(), res.ContentLength)
+ }
+ }
+ wantSHA, err := slurpURLToString(goURL + ".sha256")
+ if err != nil {
+ return err
+ }
+ if err := verifySHA256(archiveFile, strings.TrimSpace(wantSHA)); err != nil {
+ return fmt.Errorf("error verifying SHA256 of %v: %v", archiveFile, err)
+ }
+ log.Printf("Unpacking %v ...", archiveFile)
+ if err := unpackArchive(targetDir, archiveFile); err != nil {
+ return fmt.Errorf("extracting archive %v: %v", archiveFile, err)
+ }
+ if err := ioutil.WriteFile(filepath.Join(targetDir, unpackedOkay), nil, 0644); err != nil {
+ return err
+ }
+ log.Printf("Success. You may now run '%v'", version)
+ return nil
+}
+
+// unpackArchive unpacks the provided archive zip or tar.gz file to targetDir,
+// removing the "go/" prefix from file entries.
+func unpackArchive(targetDir, archiveFile string) error {
+ switch {
+ case strings.HasSuffix(archiveFile, ".zip"):
+ return unpackZip(targetDir, archiveFile)
+ case strings.HasSuffix(archiveFile, ".tar.gz"):
+ return unpackTarGz(targetDir, archiveFile)
+ default:
+ return errors.New("unsupported archive file")
+ }
+}
+
+// unpackTarGz is the tar.gz implementation of unpackArchive.
+func unpackTarGz(targetDir, archiveFile string) error {
+ r, err := os.Open(archiveFile)
+ if err != nil {
+ return err
+ }
+ defer r.Close()
+ madeDir := map[string]bool{}
+ zr, err := gzip.NewReader(r)
+ if err != nil {
+ return err
+ }
+ tr := tar.NewReader(zr)
+ for {
+ f, err := tr.Next()
+ if err == io.EOF {
+ break
+ }
+ if err != nil {
+ return err
+ }
+ if !validRelPath(f.Name) {
+ return fmt.Errorf("tar file contained invalid name %q", f.Name)
+ }
+ rel := filepath.FromSlash(strings.TrimPrefix(f.Name, "go/"))
+ abs := filepath.Join(targetDir, rel)
+
+ fi := f.FileInfo()
+ mode := fi.Mode()
+ switch {
+ case mode.IsRegular():
+ // Make the directory. This is redundant because it should
+ // already be made by a directory entry in the tar
+ // beforehand. Thus, don't check for errors; the next
+ // write will fail with the same error.
+ dir := filepath.Dir(abs)
+ if !madeDir[dir] {
+ if err := os.MkdirAll(filepath.Dir(abs), 0755); err != nil {
+ return err
+ }
+ madeDir[dir] = true
+ }
+ wf, err := os.OpenFile(abs, os.O_RDWR|os.O_CREATE|os.O_TRUNC, mode.Perm())
+ if err != nil {
+ return err
+ }
+ n, err := io.Copy(wf, tr)
+ if closeErr := wf.Close(); closeErr != nil && err == nil {
+ err = closeErr
+ }
+ if err != nil {
+ return fmt.Errorf("error writing to %s: %v", abs, err)
+ }
+ if n != f.Size {
+ return fmt.Errorf("only wrote %d bytes to %s; expected %d", n, abs, f.Size)
+ }
+ if !f.ModTime.IsZero() {
+ if err := os.Chtimes(abs, f.ModTime, f.ModTime); err != nil {
+ // benign error. Gerrit doesn't even set the
+ // modtime in these, and we don't end up relying
+ // on it anywhere (the gomote push command relies
+ // on digests only), so this is a little pointless
+ // for now.
+ log.Printf("error changing modtime: %v", err)
+ }
+ }
+ case mode.IsDir():
+ if err := os.MkdirAll(abs, 0755); err != nil {
+ return err
+ }
+ madeDir[abs] = true
+ default:
+ return fmt.Errorf("tar file entry %s contained unsupported file type %v", f.Name, mode)
+ }
+ }
+ return nil
+}
+
+// unpackZip is the zip implementation of unpackArchive.
+func unpackZip(targetDir, archiveFile string) error {
+ zr, err := zip.OpenReader(archiveFile)
+ if err != nil {
+ return err
+ }
+ defer zr.Close()
+
+ for _, f := range zr.File {
+ name := strings.TrimPrefix(f.Name, "go/")
+
+ outpath := filepath.Join(targetDir, name)
+ if f.FileInfo().IsDir() {
+ if err := os.MkdirAll(outpath, 0755); err != nil {
+ return err
+ }
+ continue
+ }
+
+ rc, err := f.Open()
+ if err != nil {
+ return err
+ }
+
+ // File
+ if err := os.MkdirAll(filepath.Dir(outpath), 0755); err != nil {
+ return err
+ }
+ out, err := os.OpenFile(outpath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode())
+ if err != nil {
+ return err
+ }
+ _, err = io.Copy(out, rc)
+ rc.Close()
+ if err != nil {
+ out.Close()
+ return err
+ }
+ if err := out.Close(); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+// verifySHA256 reports whether the named file has contents with
+// SHA-256 of the given wantHex value.
+func verifySHA256(file, wantHex string) error {
+ f, err := os.Open(file)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+ hash := sha256.New()
+ if _, err := io.Copy(hash, f); err != nil {
+ return err
+ }
+ if fmt.Sprintf("%x", hash.Sum(nil)) != wantHex {
+ return fmt.Errorf("%s corrupt? does not have expected SHA-256 of %v", file, wantHex)
+ }
+ return nil
+}
+
+// slurpURLToString downloads the given URL and returns it as a string.
+func slurpURLToString(url_ string) (string, error) {
+ res, err := http.Get(url_)
+ if err != nil {
+ return "", err
+ }
+ defer res.Body.Close()
+ if res.StatusCode != http.StatusOK {
+ return "", fmt.Errorf("%s: %v", url_, res.Status)
+ }
+ slurp, err := ioutil.ReadAll(res.Body)
+ if err != nil {
+ return "", fmt.Errorf("reading %s: %v", url_, err)
+ }
+ return string(slurp), nil
+}
+
+// copyFromURL downloads srcURL to dstFile.
+func copyFromURL(dstFile, srcURL string) (err error) {
+ f, err := os.Create(dstFile)
+ if err != nil {
+ return err
+ }
+ defer func() {
+ if err != nil {
+ f.Close()
+ os.Remove(dstFile)
+ }
+ }()
+ c := &http.Client{
+ Transport: &userAgentTransport{&http.Transport{
+ // It's already compressed. Prefer accurate ContentLength.
+ // (Not that GCS would try to compress it, though)
+ DisableCompression: true,
+ DisableKeepAlives: true,
+ Proxy: http.ProxyFromEnvironment,
+ }},
+ }
+ res, err := c.Get(srcURL)
+ if err != nil {
+ return err
+ }
+ defer res.Body.Close()
+ if res.StatusCode != http.StatusOK {
+ return errors.New(res.Status)
+ }
+ pw := &progressWriter{w: f, total: res.ContentLength}
+ n, err := io.Copy(pw, res.Body)
+ if err != nil {
+ return err
+ }
+ if res.ContentLength != -1 && res.ContentLength != n {
+ return fmt.Errorf("copied %v bytes; expected %v", n, res.ContentLength)
+ }
+ pw.update() // 100%
+ return f.Close()
+}
+
+type progressWriter struct {
+ w io.Writer
+ n int64
+ total int64
+ last time.Time
+}
+
+func (p *progressWriter) update() {
+ end := " ..."
+ if p.n == p.total {
+ end = ""
+ }
+ fmt.Fprintf(os.Stderr, "Downloaded %0.1f%% (%d / %d bytes)%s\n",
+ (100.0*float64(p.n))/float64(p.total),
+ p.n, p.total, end)
+}
+
+func (p *progressWriter) Write(buf []byte) (n int, err error) {
+ n, err = p.w.Write(buf)
+ p.n += int64(n)
+ if now := time.Now(); now.Unix() != p.last.Unix() {
+ p.update()
+ p.last = now
+ }
+ return
+}
+
+// getOS returns runtime.GOOS. It exists as a function just for lazy
+// testing of the Windows zip path when running on Linux/Darwin.
+func getOS() string {
+ return runtime.GOOS
+}
+
+// versionArchiveURL returns the zip or tar.gz URL of the given Go version.
+func versionArchiveURL(version string) (string, error) {
+ goos := getOS()
+
+ // TODO: Maybe we should parse
+ // https://storage.googleapis.com/go-builder-data/dl-index.txt ?
+ // Let's just guess the URL for now and see if it's there.
+ // Then we don't have to maintain that txt file too.
+ ext := ".tar.gz"
+ if goos == "windows" {
+ ext = ".zip"
+ }
+ arch := runtime.GOARCH
+ if goos == "linux" && runtime.GOARCH == "arm" {
+ arch = "armv6l"
+ }
+ return "https://storage.googleapis.com/golang/" + version + "." + goos + "-" + arch + ext, nil
+}
+
+const caseInsensitiveEnv = runtime.GOOS == "windows"
+
+// unpackedOkay is a sentinel zero-byte file to indicate that the Go
+// version was downloaded and unpacked successfully.
+const unpackedOkay = ".unpacked-success"
+
+func exe() string {
+ if runtime.GOOS == "windows" {
+ return ".exe"
+ }
+ return ""
+}
+
+func goroot(version string) (string, error) {
+ home, err := homedir()
+ if err != nil {
+ return "", fmt.Errorf("failed to get home directory: %v", err)
+ }
+ return filepath.Join(home, "sdk", version), nil
+}
+
+func homedir() (string, error) {
+ switch getOS() {
+ case "plan9":
+ return "", fmt.Errorf("%q not yet supported", runtime.GOOS)
+ case "windows":
+ if dir := os.Getenv("USERPROFILE"); dir != "" {
+ return dir, nil
+ }
+ return "", errors.New("can't find user home directory; %USERPROFILE% is empty")
+ default:
+ if dir := os.Getenv("HOME"); dir != "" {
+ return dir, nil
+ }
+ if u, err := user.Current(); err == nil && u.HomeDir != "" {
+ return u.HomeDir, nil
+ }
+ return "", errors.New("can't find user home directory; $HOME is empty")
+ }
+}
+
+func validRelPath(p string) bool {
+ if p == "" || strings.Contains(p, `\`) || strings.HasPrefix(p, "/") || strings.Contains(p, "../") {
+ return false
+ }
+ return true
+}
+
+type userAgentTransport struct {
+ rt http.RoundTripper
+}
+
+func (uat userAgentTransport) RoundTrip(r *http.Request) (*http.Response, error) {
+ version := runtime.Version()
+ if strings.Contains(version, "devel") {
+ // Strip the SHA hash and date. We don't want spaces or other tokens (see RFC2616 14.43)
+ version = "devel"
+ }
+ r.Header.Set("User-Agent", "golang-x-build-version/"+version)
+ return uat.rt.RoundTrip(r)
+}