示例#1
0
文件: bin.go 项目: rjeczalik/bin
func importpkg(path string) (string, error) {
	ex, err := which.NewExec(path)
	if err != nil {
		return "", err
	}
	if ex.Type.GOOS != runtime.GOOS || ex.Type.GOARCH != runtime.GOARCH {
		return "", errors.New("bin: cross-compiling is not supported yet")
	}
	return ex.Import()
}
示例#2
0
文件: main.go 项目: rjeczalik/which
func main() {
	if len(os.Args) != 2 {
		die(usage)
	}
	if ishelp(os.Args[1]) {
		fmt.Println(usage)
		return
	}
	path, err := exec.LookPath(os.Args[1])
	if err != nil {
		die(err)
	}
	ex, err := which.NewExec(path)
	if err != nil {
		die(err)
	}
	fmt.Println(ex.Type)
}