Don't use runtime.Version() to find the current go version

That will be the go version at compile time. So read $GOROOT/VERSION, or
fall back to executing `$GOROOT/bin/go version` to find the go version
currently in GOROOT.

Test: Ensure everything rebuilds when switching between go1.8rc2 and go1.8
Change-Id: I8738a7aa249a088b1e0668af260fa3974844dab7
diff --git a/cmd/microfactory/microfactory.go b/cmd/microfactory/microfactory.go
index 3ed5a2c..d0febe7 100644
--- a/cmd/microfactory/microfactory.go
+++ b/cmd/microfactory/microfactory.go
@@ -67,8 +67,22 @@
 	verbose = false
 
 	goToolDir = filepath.Join(runtime.GOROOT(), "pkg", "tool", runtime.GOOS+"_"+runtime.GOARCH)
+	goVersion = findGoVersion()
 )
 
+func findGoVersion() string {
+	if version, err := ioutil.ReadFile(filepath.Join(runtime.GOROOT(), "VERSION")); err == nil {
+		return string(version)
+	}
+
+	cmd := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), "version")
+	if version, err := cmd.Output(); err == nil {
+		return string(version)
+	} else {
+		panic(fmt.Sprintf("Unable to discover go version: %v", err))
+	}
+}
+
 type GoPackage struct {
 	Name string
 
@@ -218,7 +232,7 @@
 	shaFile := p.output + ".hash"
 
 	hash := sha1.New()
-	fmt.Fprintln(hash, runtime.GOOS, runtime.GOARCH, runtime.Version())
+	fmt.Fprintln(hash, runtime.GOOS, runtime.GOARCH, goVersion)
 
 	cmd := exec.Command(filepath.Join(goToolDir, "compile"),
 		"-o", p.output,
diff --git a/soong_ui.bash b/soong_ui.bash
index 724d9c5..e1af359 100755
--- a/soong_ui.bash
+++ b/soong_ui.bash
@@ -53,7 +53,7 @@
 {
     # Increment when microfactory changes enough that it cannot rebuild itself.
     # For example, if we use a new command line argument that doesn't work on older versions.
-    local mf_version=1
+    local mf_version=2
 
     local mf_src="${TOP}/build/soong/cmd/microfactory"