File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -40,17 +40,16 @@ func getPidByPort(port int) (int, error) {
4040 if exitErr .ExitCode () == 1 {
4141 return 0 , nil
4242 }
43- } else {
44- return 0 , err
4543 }
44+ return 0 , err
4645 }
4746
4847 lines := strings .Split (string (output ), "\n " )
4948 for _ , line := range lines {
5049 fields := strings .Fields (line )
5150 if len (fields ) > 0 {
5251 if runtime .GOOS == "windows" {
53- if fields [1 ] == "0.0.0.0:" + strconv .Itoa (port ) {
52+ if len ( fields ) >= 2 && fields [1 ] == "0.0.0.0:" + strconv .Itoa (port ) {
5453 pid , err := strconv .Atoi (fields [len (fields )- 1 ])
5554 if err != nil {
5655 return 0 , err
@@ -89,9 +88,8 @@ func StopOldInstance(port int) error {
8988 err = process .Kill ()
9089 if err != nil {
9190 return err
92- } else {
93- fmt .Printf ("The old instance with pid: %d has been stopped\n " , pid )
9491 }
9592
93+ fmt .Printf ("The old instance with pid: %d has been stopped\n " , pid )
9694 return nil
9795}
You can’t perform that action at this time.
0 commit comments