cmd/go: do not fix, fmt, or generate in dependency modules
diff --git a/vendor/cmd/go/internal/fix/fix.go b/vendor/cmd/go/internal/fix/fix.go
index 99c7ca5..56f8832 100644
--- a/vendor/cmd/go/internal/fix/fix.go
+++ b/vendor/cmd/go/internal/fix/fix.go
@@ -10,6 +10,9 @@
 	"cmd/go/internal/cfg"
 	"cmd/go/internal/load"
 	"cmd/go/internal/str"
+	"cmd/go/internal/vgo"
+	"fmt"
+	"os"
 )
 
 var CmdFix = &base.Command{
@@ -29,7 +32,15 @@
 }
 
 func runFix(cmd *base.Command, args []string) {
+	printed := false
 	for _, pkg := range load.Packages(args) {
+		if vgo.Enabled() && !pkg.Module.Top {
+			if !printed {
+				fmt.Fprintf(os.Stderr, "vgo: not fixing packages in dependency modules\n")
+				printed = true
+			}
+			continue
+		}
 		// Use pkg.gofiles instead of pkg.Dir so that
 		// the command only applies to this package,
 		// not to packages in subdirectories.
diff --git a/vendor/cmd/go/internal/fmtcmd/fmt.go b/vendor/cmd/go/internal/fmtcmd/fmt.go
index eb96823..c3a90d0 100644
--- a/vendor/cmd/go/internal/fmtcmd/fmt.go
+++ b/vendor/cmd/go/internal/fmtcmd/fmt.go
@@ -6,6 +6,7 @@
 package fmtcmd
 
 import (
+	"fmt"
 	"os"
 	"path/filepath"
 	"runtime"
@@ -16,6 +17,7 @@
 	"cmd/go/internal/cfg"
 	"cmd/go/internal/load"
 	"cmd/go/internal/str"
+	"cmd/go/internal/vgo"
 )
 
 func init() {
@@ -43,6 +45,7 @@
 }
 
 func runFmt(cmd *base.Command, args []string) {
+	printed := false
 	gofmt := gofmtPath()
 	procs := runtime.GOMAXPROCS(0)
 	var wg sync.WaitGroup
@@ -57,6 +60,13 @@
 		}()
 	}
 	for _, pkg := range load.PackagesAndErrors(args) {
+		if vgo.Enabled() && !pkg.Module.Top {
+			if !printed {
+				fmt.Fprintf(os.Stderr, "vgo: not formatting packages in dependency modules\n")
+				printed = true
+			}
+			continue
+		}
 		if pkg.Error != nil {
 			if strings.HasPrefix(pkg.Error.Err, "build constraints exclude all Go files") {
 				// Skip this error, as we will format
diff --git a/vendor/cmd/go/internal/generate/generate.go b/vendor/cmd/go/internal/generate/generate.go
index 75c0d3b..e839f0b 100644
--- a/vendor/cmd/go/internal/generate/generate.go
+++ b/vendor/cmd/go/internal/generate/generate.go
@@ -21,6 +21,7 @@
 	"cmd/go/internal/base"
 	"cmd/go/internal/cfg"
 	"cmd/go/internal/load"
+	"cmd/go/internal/vgo"
 	"cmd/go/internal/work"
 )
 
@@ -152,7 +153,15 @@
 		}
 	}
 	// Even if the arguments are .go files, this loop suffices.
+	printed := false
 	for _, pkg := range load.Packages(args) {
+		if vgo.Enabled() && !pkg.Module.Top {
+			if !printed {
+				fmt.Fprintf(os.Stderr, "vgo: not generating in packages in dependency modules\n")
+				printed = true
+			}
+			continue
+		}
 		for _, file := range pkg.InternalGoFiles() {
 			if !generate(pkg.Name, file) {
 				break
diff --git a/vendor/cmd/go/internal/load/pkg.go b/vendor/cmd/go/internal/load/pkg.go
index f49dfdb..124e42e 100644
--- a/vendor/cmd/go/internal/load/pkg.go
+++ b/vendor/cmd/go/internal/load/pkg.go
@@ -20,6 +20,7 @@
 
 	"cmd/go/internal/base"
 	"cmd/go/internal/cfg"
+	"cmd/go/internal/modinfo"
 	"cmd/go/internal/search"
 	"cmd/go/internal/str"
 	"cmd/go/internal/vgo"
@@ -96,6 +97,8 @@
 	TestImports  []string `json:",omitempty"` // imports from TestGoFiles
 	XTestGoFiles []string `json:",omitempty"` // _test.go files outside package
 	XTestImports []string `json:",omitempty"` // imports from XTestGoFiles
+
+	Module modinfo.ModulePublic
 }
 
 // AllFiles returns the names of all the files considered for the package.
@@ -138,7 +141,7 @@
 	OmitDebug    bool                 // tell linker not to write debug information
 	GobinSubdir  bool                 // install target would be subdir of GOBIN
 
-	ModuleInfo string // add this ModuleInfo to package main
+	BuildInfo string // add this info to package main
 
 	Asmflags   []string // -asmflags for this package
 	Gcflags    []string // -gcflags for this package
@@ -1198,8 +1201,9 @@
 		return
 	}
 
+	p.Module = vgo.PackageModuleInfo(p.ImportPath)
 	if p.Name == "main" {
-		p.Internal.ModuleInfo = vgo.PackageModuleInfo(p.ImportPath, p.Deps)
+		p.Internal.BuildInfo = vgo.PackageBuildInfo(p.ImportPath, p.Deps)
 	}
 }
 
diff --git a/vendor/cmd/go/internal/modinfo/info.go b/vendor/cmd/go/internal/modinfo/info.go
new file mode 100644
index 0000000..6dff2d2
--- /dev/null
+++ b/vendor/cmd/go/internal/modinfo/info.go
@@ -0,0 +1,11 @@
+// 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.
+
+package modinfo
+
+type ModulePublic struct {
+	Top     bool
+	Path    string
+	Version string
+}
diff --git a/vendor/cmd/go/internal/vgo/build.go b/vendor/cmd/go/internal/vgo/build.go
index 37d14f3..46c0618 100644
--- a/vendor/cmd/go/internal/vgo/build.go
+++ b/vendor/cmd/go/internal/vgo/build.go
@@ -7,6 +7,7 @@
 import (
 	"bytes"
 	"cmd/go/internal/base"
+	"cmd/go/internal/modinfo"
 	"cmd/go/internal/module"
 	"cmd/go/internal/search"
 	"encoding/hex"
@@ -18,7 +19,19 @@
 	infoEnd, _   = hex.DecodeString("f932433186182072008242104116d8f2")
 )
 
-func PackageModuleInfo(path string, deps []string) string {
+func PackageModuleInfo(path string) modinfo.ModulePublic {
+	var info modinfo.ModulePublic
+	if search.IsStandardImportPath(path) {
+		return info
+	}
+	target := findModule(path, path)
+	info.Top = target.Path == buildList[0].Path
+	info.Path = target.Path
+	info.Version = target.Version
+	return info
+}
+
+func PackageBuildInfo(path string, deps []string) string {
 	if search.IsStandardImportPath(path) {
 		return ""
 	}
@@ -49,6 +62,7 @@
 			mv = "(devel)"
 		}
 		fmt.Fprintf(&buf, "dep\t%s\t%s\t%s\n", mod.Path, mod.Version, findModHash(mod))
+		// TODO: replacements
 	}
 	return buf.String()
 }
diff --git a/vendor/cmd/go/internal/work/build.go b/vendor/cmd/go/internal/work/build.go
index c6ab084..a9274db 100644
--- a/vendor/cmd/go/internal/work/build.go
+++ b/vendor/cmd/go/internal/work/build.go
@@ -5,9 +5,11 @@
 package work
 
 import (
+	"bytes"
 	"errors"
 	"fmt"
 	"go/build"
+	"io/ioutil"
 	"os"
 	"os/exec"
 	"path"
@@ -271,7 +273,24 @@
 
 var pkgsFilter = func(pkgs []*load.Package) []*load.Package { return pkgs }
 
-var runtimeVersion = runtime.Version()
+var runtimeVersion = getRuntimeVersion()
+
+func getRuntimeVersion() string {
+	data, err := ioutil.ReadFile(filepath.Join(cfg.GOROOT, "src/runtime/internal/sys/zversion.go"))
+	if err != nil {
+		base.Fatalf("vgo: %v", err)
+	}
+	i := bytes.Index(data, []byte("TheVersion = `"))
+	if i < 0 {
+		base.Fatalf("vgo: cannot find TheVersion")
+	}
+	data = data[i+len("TheVersion = `"):]
+	j := bytes.IndexByte(data, '`')
+	if j < 0 {
+		base.Fatalf("vgo: cannot find TheVersion")
+	}
+	return string(data[:j])
+}
 
 func runBuild(cmd *base.Command, args []string) {
 	BuildInit()
diff --git a/vendor/cmd/go/internal/work/exec.go b/vendor/cmd/go/internal/work/exec.go
index 1c47bfd..a1d68d2 100644
--- a/vendor/cmd/go/internal/work/exec.go
+++ b/vendor/cmd/go/internal/work/exec.go
@@ -299,7 +299,7 @@
 		}
 	}
 
-	fmt.Fprintf(h, "moduleinfo %q\n", p.Internal.ModuleInfo)
+	fmt.Fprintf(h, "buildinfo %q\n", p.Internal.BuildInfo)
 
 	return h.Sum()
 }
@@ -579,8 +579,8 @@
 	}
 
 	// TODO(vgo): If have module info, write file to objdir, add to gofiles.
-	if p.Internal.ModuleInfo != "" {
-		if err := b.writeFile(objdir+"_gomod_.go", vgo.ModInfoProg(p.Internal.ModuleInfo)); err != nil {
+	if p.Internal.BuildInfo != "" {
+		if err := b.writeFile(objdir+"_gomod_.go", vgo.ModInfoProg(p.Internal.BuildInfo)); err != nil {
 			return err
 		}
 		gofiles = append(gofiles, objdir+"_gomod_.go")