Fix 2 x panic: runtime error: index out of range
This commit is contained in:
parent
56d57ee97a
commit
065984f42c
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
@ -106,6 +107,12 @@ starts and attaches to it, and enables you to immediately begin debugging your p
|
|||||||
execCommand := &cobra.Command{
|
execCommand := &cobra.Command{
|
||||||
Use: "exec [./path/to/binary]",
|
Use: "exec [./path/to/binary]",
|
||||||
Short: "Runs precompiled binary, attaches and begins debug session.",
|
Short: "Runs precompiled binary, attaches and begins debug session.",
|
||||||
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) == 0 {
|
||||||
|
return errors.New("you must provide a path to a binary")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
os.Exit(execute(0, args, conf))
|
os.Exit(execute(0, args, conf))
|
||||||
},
|
},
|
||||||
@ -239,6 +246,12 @@ starts and attaches to it, and enable you to immediately begin debugging your pr
|
|||||||
Use: "attach [pid]",
|
Use: "attach [pid]",
|
||||||
Short: "Attach to running process and begin debugging.",
|
Short: "Attach to running process and begin debugging.",
|
||||||
Long: "Attach to running process and begin debugging.",
|
Long: "Attach to running process and begin debugging.",
|
||||||
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) == 0 {
|
||||||
|
return errors.New("you must provide a PID")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
pid, err := strconv.Atoi(args[0])
|
pid, err := strconv.Atoi(args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user