File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package cli
22
33import (
4+ "context"
45 "fmt"
56 "os"
67 "os/exec"
@@ -16,12 +17,13 @@ func editFileWithEditor(file string) int {
1617
1718 editor = strings .TrimSpace (editor )
1819 args := strings .Split (editor , " " )
19-
2020 editor = args [0 ]
2121 args = append (args [1 :], file )
2222
23- cmd := exec .Command (editor , args ... )
23+ ctx := context .Background ()
24+ cmd := exec .CommandContext (ctx , editor , args ... )
2425
26+ cmd .Stdin = os .Stdin
2527 cmd .Stdin = os .Stdin
2628 cmd .Stdout = os .Stdout
2729 cmd .Stderr = os .Stderr
Original file line number Diff line number Diff line change 11package http
22
33import (
4+ "context"
45 "net"
56 "time"
67)
78
8- // if we can connect to ohmyposh within 200ms, we are connected
9- // otherwise, let's consider being offline
9+ // IsConnected checks if we can connect to ohmyposh within 200ms
10+ // If we can connect, we are connected; otherwise, let's consider being offline
1011func IsConnected () bool {
1112 timeout := 200 * time .Millisecond
12- _ , err := net .DialTimeout ("tcp" , "ohmyposh.dev:80" , timeout )
13- return err == nil
13+ dialer := & net.Dialer {
14+ Timeout : timeout ,
15+ }
16+
17+ ctx := context .Background ()
18+ conn , err := dialer .DialContext (ctx , "tcp" , "ohmyposh.dev:80" )
19+ if err != nil {
20+ return false
21+ }
22+
23+ conn .Close ()
24+ return true
1425}
You can’t perform that action at this time.
0 commit comments