mirror of
https://github.com/beego/bee.git
synced 2024-12-22 10:00:50 +00:00
Refactor code for dlv command
This commit is contained in:
parent
ad641afb34
commit
72f144baad
@ -73,7 +73,7 @@ func runDlv(cmd *commands.Command, args []string) int {
|
||||
func runDelve(addr, debugname string) int {
|
||||
beeLogger.Log.Info("Starting Delve Debugger...")
|
||||
|
||||
err := utils.GoBuild(debugname, packageName)
|
||||
err := gobuild(debugname, packageName)
|
||||
if err != nil {
|
||||
beeLogger.Log.Fatalf("%v", err)
|
||||
}
|
||||
@ -89,9 +89,7 @@ func runDelve(addr, debugname string) int {
|
||||
beeLogger.Log.Fatalf("%v", err)
|
||||
}
|
||||
|
||||
//
|
||||
// Create and start the debugger server
|
||||
//
|
||||
listener, err := net.Listen("tcp", addr)
|
||||
if err != nil {
|
||||
beeLogger.Log.Fatalf("Could not start listener: %s", err)
|
||||
@ -110,9 +108,7 @@ func runDelve(addr, debugname string) int {
|
||||
beeLogger.Log.Fatalf("Could not start debugger server: %v", err)
|
||||
}
|
||||
|
||||
//
|
||||
// Start the Delve client REPL
|
||||
//
|
||||
client := rpc2.NewClient(addr)
|
||||
term := terminal.New(client, nil)
|
||||
|
||||
@ -129,3 +125,11 @@ func runDelve(addr, debugname string) int {
|
||||
}
|
||||
return status
|
||||
}
|
||||
|
||||
// gobuild runs the "go build" command on the specified package
|
||||
func gobuild(debugname, pkg string) error {
|
||||
args := []string{"-gcflags", "-N -l", "-o", debugname}
|
||||
args = append(args, utils.SplitQuotedFields("-ldflags='-linkmode internal'")...)
|
||||
args = append(args, pkg)
|
||||
return utils.GoCommand("build", args...)
|
||||
}
|
||||
|
@ -343,17 +343,6 @@ func GoCommand(command string, args ...string) error {
|
||||
return goBuild.Run()
|
||||
}
|
||||
|
||||
// GoBuild runs the "go build" command on the specified package
|
||||
func GoBuild(debugname, pkg string) error {
|
||||
buildFlags := "-ldflags='-linkmode internal'"
|
||||
args := []string{"-gcflags", "-N -l", "-o", debugname}
|
||||
if buildFlags != "" {
|
||||
args = append(args, SplitQuotedFields(buildFlags)...)
|
||||
}
|
||||
args = append(args, pkg)
|
||||
return GoCommand("build", args...)
|
||||
}
|
||||
|
||||
// SplitQuotedFields is like strings.Fields but ignores spaces
|
||||
// inside areas surrounded by single quotes.
|
||||
// To specify a single quote use backslash to escape it: '\''
|
||||
|
Loading…
Reference in New Issue
Block a user