optimize: softlink the plugin to $GOPATH/bin (#235)

This commit is contained in:
GuangyuFan 2022-09-20 14:55:43 +08:00 committed by GitHub
parent 02f9247392
commit 419a448536
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -75,7 +75,12 @@ func lookupTool(idlType string) (string, error) {
if err != nil {
return "", fmt.Errorf("failed to get executable path: %s", err)
}
dir := filepath.Dir(path)
gopath, err := util.GetGOPATH()
if err != nil {
return "", err
}
// softlink the plugin to "$GOPATH/bin"
dir := gopath + string(os.PathSeparator) + "bin"
if tool == meta.TpCompilerProto {
pgh, err := exec.LookPath(meta.ProtocPluginName)
linkName := filepath.Join(dir, meta.ProtocPluginName)