From 25d2143a627531fc0475d639c1e8f657ccafa630 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Tue, 20 Sep 2022 13:21:34 +0200 Subject: Golang-ci-lint: Fixes --- cmd/cli/main.go | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'cmd/cli/main.go') diff --git a/cmd/cli/main.go b/cmd/cli/main.go index fe6b40e..caeef1c 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -6,7 +6,7 @@ import ( "os/exec" "strings" - "github.com/jwijenbergh/eduvpn-common" + eduvpn "github.com/jwijenbergh/eduvpn-common" "github.com/jwijenbergh/eduvpn-common/internal/server" ) @@ -27,22 +27,10 @@ func openBrowser(url interface{}) { } fmt.Printf("OAuth: Initialized with AuthURL %s\n", urlString) fmt.Println("OAuth: Opening browser with xdg-open...") - exec.Command("xdg-open", urlString).Start() -} - -// Taken from internal/server.go as it's an internal API for now -// These are used to parse the profile info -type ServerProfile struct { - ID string `json:"profile_id"` - DisplayName string `json:"display_name"` - VPNProtoList []string `json:"vpn_proto_list"` - DefaultGateway bool `json:"default_gateway"` -} -type ServerProfileInfo struct { - Current string `json:"current_profile"` - Info struct { - ProfileList []ServerProfile `json:"profile_list"` - } `json:"info"` + cmdErr := exec.Command("xdg-open", urlString).Start() + if cmdErr != nil { + fmt.Println("OAuth: Browser opened with xdg-open...") + } } // Ask for a profile in the command line @@ -120,7 +108,7 @@ func getConfig(state *eduvpn.VPNState, url string, serverType ServerTypes) (stri func printConfig(url string, serverType ServerTypes) { state := &eduvpn.VPNState{} - state.Register( + registerErr := state.Register( "org.eduvpn.app.linux", "configs", func(old eduvpn.FSMStateID, new eduvpn.FSMStateID, data interface{}) { @@ -128,6 +116,10 @@ func printConfig(url string, serverType ServerTypes) { }, true, ) + if registerErr != nil { + fmt.Printf("Register error: %v", registerErr) + return + } defer state.Deregister() -- cgit v1.2.3