-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
99 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,6 @@ | |
</body> | ||
<!--after body because document.body may be null--> | ||
<!--available in CN and Global--> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected].2/index.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected].4/index.js"></script> | ||
<!-- <script src="http://127.0.0.1:8080/npm-publish/index.js"></script> --> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package test_explorer | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
"runtime" | ||
"strconv" | ||
|
||
"github.com/xhd2015/xgo/support/cmd" | ||
"github.com/xhd2015/xgo/support/netutil" | ||
) | ||
|
||
func setupOpenHandler(server *http.ServeMux) { | ||
server.HandleFunc("/openVscode", func(w http.ResponseWriter, r *http.Request) { | ||
handleOpenFile(w, r, func(file string, line int) error { | ||
if line > 0 { | ||
return cmd.Debug().Run("code", "--goto", fmt.Sprintf("%s:%d", file, line)) | ||
} | ||
return cmd.Debug().Run("code", file) | ||
}) | ||
}) | ||
server.HandleFunc("/openGoland", func(w http.ResponseWriter, r *http.Request) { | ||
handleOpenFile(w, r, func(file string, line int) error { | ||
// see https://www.jetbrains.com/help/go/working-with-the-ide-features-from-command-line.html#standalone | ||
// and https://www.jetbrains.com/help/go/opening-files-from-command-line.html#macos | ||
// open -na "GoLand.app" --args "$@" | ||
var args []string | ||
if line > 0 { | ||
args = append(args, "--line", strconv.Itoa(line)) | ||
} | ||
args = append(args, file) | ||
switch runtime.GOOS { | ||
case "darwin": | ||
return cmd.Debug().Run("open", append([]string{"-na", "GoLand.app", "--args"}, args...)...) | ||
case "linux": | ||
return cmd.Debug().Run("goland.sh", args...) | ||
case "windows": | ||
return cmd.Debug().Run("goland64.exe", args...) | ||
default: | ||
return fmt.Errorf("open goland not supported on %s", runtime.GOOS) | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
func handleOpenFile(w http.ResponseWriter, r *http.Request, callback func(file string, line int) error) { | ||
netutil.SetCORSHeaders(w) | ||
netutil.HandleJSON(w, r, func(ctx context.Context, r *http.Request) (interface{}, error) { | ||
q := r.URL.Query() | ||
file := q.Get("file") | ||
line := q.Get("line") | ||
|
||
lineNum, _ := strconv.Atoi(line) | ||
return nil, callback(file, lineNum) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters