func pathTo(module, file string) (string, error) {
	gopath, ok := os.LookupEnv("GOPATH")
	if !ok {
		var err error
		gopath, err = os.UserHomeDir()
		if err != nil {
			return "", err
		}
		gopath = filepath.Join(gopath, "go")
	}

	cmd := exec.Command("go", "list", "-m", module)
	var buf, stderr bytes.Buffer
	cmd.Stdout = &buf
	cmd.Stderr = &stderr
	err := cmd.Run()
	if err != nil {
		// TODO(kortschak): Make this an error when go1.10 support is dropped.
		log.Printf("module aware go list failed with stderr output %q: %v", stderr.String(), err)
		return filepath.Join(gopath, "src", module, file), nil
	}
	version := strings.TrimSpace(strings.Join(strings.Split(buf.String(), " "), "@"))
	return filepath.Join(gopath, "pkg", "mod", version, file), nil
}
// pathTo returns the path to file within the given module. If running
// in module mode, this will look within the module in $GOPATH/pkg/mod
// at the correct version, otherwise it will find the version installed
// at $GOPATH/src/module/file.
pathTo returns the path to file within the given module. If running
in module mode, this will look within the module in $GOPATH/pkg/mod
at the correct version, otherwise it will find the version installed
at $GOPATH/src/module/file.
// pathTo returns the path to file within the given module . If running // in module mode this will look within the module in $GOPATH / pkg / mod // at the correct version otherwise it will find the version installed // at $GOPATH / src / module / file .
func pathTo(module, file string) (string, error) {
	gopath, ok := os.LookupEnv("GOPATH")
	if !ok {
		var err error
		gopath, err = os.UserHomeDir()
		if err != nil {
			return "", err
		}
		gopath = filepath.Join(gopath, "go")
	}
	cmd := exec.Command("go", "list", "-m", module)
	var buf, stderr bytes.Buffer
	cmd.Stdout = &buf
	cmd.Stderr = &stderr
	err := cmd.Run()
	if err != nil {
		log.Printf("module aware go list failed with stderr output %q: %v", stderr.String(), err)
		return filepath.Join(gopath, "src", module, file), nil
	}
	version := strings.TrimSpace(strings.Join(strings.Split(buf.String(), " "), "@"))
	return filepath.Join(gopath, "pkg", "mod", version, file), nil
}
func pathTo ( module , file string ) ( string , error ) { gopath , ok := os . LookupEnv ( " " ) if ! ok { var err error gopath , err = os . UserHomeDir ( ) if err != nil { return " " , err } gopath = filepath . Join ( gopath , " " ) } cmd := exec . Command ( " " , " " , " " , module ) var buf , stderr bytes . Buffer cmd . Stdout = & buf cmd . Stderr = & stderr err := cmd . Run ( ) if err != nil { log . Printf ( " " , stderr . String ( ) , err ) return filepath . Join ( gopath , " " , module , file ) , nil } version := strings . TrimSpace ( strings . Join ( strings . Split ( buf . String ( ) , " " ) , " " ) ) return filepath . Join ( gopath , " " , " " , version , file ) , nil }
pathTo returns the path to file within the given module.
pathTo returns the path to file within the given module .
// TODO(kortschak): Make this an error when go1.10 support is dropped.