Fix more lints found by golangci-lint's default config

This commit is contained in:
Sandro Jäckel 2024-03-15 16:23:11 +01:00
parent 1479d9f8fd
commit 17f62c130e
No known key found for this signature in database
GPG Key ID: 3AF5A43A3EECC2E5
12 changed files with 61 additions and 63 deletions

View File

@ -17,7 +17,7 @@ func handleAddSSH(msg messages.IPCMessage, cfg *config.Config, vault *vault.Vaul
req := messages.ParsePayload(msg).(messages.CreateSSHKeyRequest)
cipher, publicKey := ssh.NewSSHKeyCipher(req.Name, vault.Keyring)
response, err = messages.IPCMessageFromPayload(messages.ActionResponse{
_, err = messages.IPCMessageFromPayload(messages.ActionResponse{
Success: true,
})
if err != nil {

View File

@ -162,10 +162,10 @@ func LoginWithMasterpassword(ctx context.Context, email string, cfg *config.Conf
return LoginResponseToken{}, crypto.MasterKey{}, "", err
}
} else if err != nil && strings.Contains(err.Error(), "Captcha required.") {
notify.Notify("Goldwarden", fmt.Sprintf("Captcha required"), "", 0, func() {})
notify.Notify("Goldwarden", "Captcha required", "", 0, func() {})
return LoginResponseToken{}, crypto.MasterKey{}, "", fmt.Errorf("captcha required, please login via the web interface")
} else if err != nil {
notify.Notify("Goldwarden", fmt.Sprintf("Could not login via password: %v", err), "", 0, func() {})
notify.Notify("Goldwarden", fmt.Sprintf("Could not login via password: %s", err.Error()), "", 0, func() {})
return LoginResponseToken{}, crypto.MasterKey{}, "", fmt.Errorf("could not login via password: %v", err)
}

View File

@ -7,7 +7,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"strings"
@ -105,7 +104,7 @@ func makeAuthenticatedHTTPRequest(ctx context.Context, req *http.Request, recv i
return err
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return err
}

View File

@ -99,7 +99,7 @@ func (pe *Pinentry) Get(arg keybase1.SecretEntryArg) (res *keybase1.SecretEntryR
func (pi *pinentryInstance) Close() {
pi.stdin.Close()
pi.cmd.Wait()
_ = pi.cmd.Wait()
}
type pinentryInstance struct {
@ -123,7 +123,6 @@ func (pi *pinentryInstance) Set(cmd, val string, errp *error) {
if string(line) != "OK" {
*errp = fmt.Errorf("Response to " + cmd + " was " + string(line))
}
return
}
func (pi *pinentryInstance) Init() (err error) {

View File

@ -42,9 +42,9 @@ func TypeString(textToType string) {
var sessionHandle dbus.ObjectPath
for {
select {
case message := <-signals:
if state == 0 {
message := <-signals
switch state {
case 0:
log.Info("Selecting Devices")
result := message.Body[1].(map[string]dbus.Variant)
resultSessionHandle := result["session_handle"]
@ -56,16 +56,15 @@ func TypeString(textToType string) {
log.Error("Error selecting devices: %s", res.Err.Error())
}
state = 1
} else if state == 1 {
case 1:
log.Info("Starting Session")
res := obj.Call("org.freedesktop.portal.RemoteDesktop.Start", 0, sessionHandle, "", map[string]dbus.Variant{})
if res.Err != nil {
log.Error("Error starting session: %s", res.Err.Error())
}
state = 2
} else if state == 2 {
case 2:
log.Info("Performing Typing")
state = 3
time.Sleep(1000 * time.Millisecond)
for _, char := range textToType {
if char == '\t' {
@ -82,10 +81,8 @@ func TypeString(textToType string) {
}
bus.Close()
return
} else {
log.Info("State 3")
default:
return
}
}
}
}

View File

@ -49,6 +49,6 @@ var loginCmd = &cobra.Command{
func init() {
vaultCmd.AddCommand(loginCmd)
loginCmd.PersistentFlags().String("email", "", "")
loginCmd.MarkFlagRequired("email")
_ = loginCmd.MarkFlagRequired("email")
loginCmd.PersistentFlags().Bool("passwordless", false, "")
}

View File

@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"os"
"strings"
"github.com/icza/gox/stringsx"
@ -17,7 +18,7 @@ var baseLoginCmd = &cobra.Command{
Short: "Commands for managing logins.",
Long: `Commands for managing logins.`,
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
_ = cmd.Help()
},
}
@ -55,7 +56,7 @@ var getLoginCmd = &cobra.Command{
} else {
fmt.Println(response.Result.Password)
}
break
return
case messages.ActionResponse:
fmt.Println("Error: " + resp.(messages.ActionResponse).Message)
return

View File

@ -54,7 +54,7 @@ var runCmd = &cobra.Command{
command.Stdout = os.Stdout
command.Stderr = os.Stderr
command.Stdin = os.Stdin
command.Run()
_ = command.Run()
},
}

View File

@ -2,6 +2,7 @@ package cmd
import (
"fmt"
"os"
"github.com/quexten/goldwarden/ipc/messages"
"github.com/spf13/cobra"
@ -12,7 +13,7 @@ var sendCmd = &cobra.Command{
Short: "Commands for managing sends",
Long: `Commands for managing sends.`,
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
_ = cmd.Help()
},
}
@ -42,7 +43,7 @@ var sendCreateCmd = &cobra.Command{
switch result.(type) {
case messages.CreateSendResponse:
fmt.Println("Send created: " + result.(messages.CreateSendResponse).URL)
break
return
case messages.ActionResponse:
fmt.Println("Error: " + result.(messages.ActionResponse).Message)
return

View File

@ -23,7 +23,7 @@ var sessionCmd = &cobra.Command{
text = strings.TrimSuffix(text, "\n")
args := strings.Split(text, " ")
rootCmd.SetArgs(args)
rootCmd.Execute()
_ = rootCmd.Execute()
}
},
}

View File

@ -181,7 +181,7 @@ var setupCmd = &cobra.Command{
Short: "Sets up Goldwarden integrations",
Long: "Sets up Goldwarden integrations",
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
_ = cmd.Help()
},
}

View File

@ -2,6 +2,7 @@ package cmd
import (
"fmt"
"os"
"github.com/atotto/clipboard"
"github.com/quexten/goldwarden/ipc/messages"
@ -13,7 +14,7 @@ var sshCmd = &cobra.Command{
Short: "Commands for managing SSH keys",
Long: `Commands for managing SSH keys.`,
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
_ = cmd.Help()
},
}
@ -52,7 +53,7 @@ var sshAddCmd = &cobra.Command{
panic(err)
}
}
break
return
case messages.ActionResponse:
fmt.Println("Error: " + result.(messages.ActionResponse).Message)
return
@ -83,7 +84,7 @@ var listSSHCmd = &cobra.Command{
for _, key := range response.Keys {
fmt.Println(key)
}
break
return
case messages.ActionResponse:
fmt.Println("Error: " + result.(messages.ActionResponse).Message)
return
@ -95,7 +96,7 @@ func init() {
rootCmd.AddCommand(sshCmd)
sshCmd.AddCommand(sshAddCmd)
sshAddCmd.PersistentFlags().String("name", "", "")
sshAddCmd.MarkFlagRequired("name")
_ = sshAddCmd.MarkFlagRequired("name")
sshAddCmd.PersistentFlags().Bool("clipboard", false, "Copy the public key to the clipboard")
sshCmd.AddCommand(listSSHCmd)
}