func CopyGopath(packageName, newGopath string, keepTests bool) error {
	ctx := build.Default
	rootPkg, err := ctx.Import(packageName, "", 0)
	if err != nil {
		return err
	}
	allDeps, err := findDeps(packageName, &ctx)
	if err != nil {
		return err
	}
	for dep := range allDeps {
		pkg, err := build.Default.Import(dep, rootPkg.Dir, 0)
		if err != nil {
			return err
		}
		if pkg.Goroot {
			continue
		}
		if err := copyDep(pkg, newGopath, keepTests); err != nil {
			return err
		}
	}
	if !keepTests {
		ctx.GOPATH = newGopath
		allDeps, err = findDeps(packageName, &ctx)
		if err != nil {
			return err
		}
	}
	if err := removeUnusedPkgs(newGopath, allDeps); err != nil {
		return err
	}
	return nil
}
CopyGopath creates a new Gopath with a copy of a package
and all of its dependencies.
package main
import (
	"fmt"
	"go/build"
	"io"
	"os"
	"path/filepath"
	"strings"
	"golang.org/x/tools/refactor/importgraph"
)