From 12b57d263fc9d8a406e5c0b2cda7d22b50b844fe Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 10 Sep 2019 11:36:03 -0400 Subject: [PATCH] go fmt --- cmd/passgo-gui/main.go | 8 +++--- cmd/passgo/main.go | 2 +- impl_android.go | 1 - impl_darwin.go | 63 +++++++++++++++++++++--------------------- main.go | 30 ++++++++++---------- 5 files changed, 51 insertions(+), 53 deletions(-) diff --git a/cmd/passgo-gui/main.go b/cmd/passgo-gui/main.go index dba5889..4f47e6a 100644 --- a/cmd/passgo-gui/main.go +++ b/cmd/passgo-gui/main.go @@ -84,7 +84,7 @@ var ( store passgo.Store reload chan struct{} updated chan struct{} - chdir chan struct{} + chdir chan struct{} passch chan []byte ) @@ -223,7 +223,7 @@ func eventLoop() { log(Info, err) return } - for i,n := range ids { + for i, n := range ids { if i >= len(idBtns) { idBtns = append(idBtns, &Button{ Face: face, @@ -443,7 +443,7 @@ func eventLoop() { c2 := flex.End(idLabel.Layout(ops, cs)) var c3 layout.FlexChild //if len(idBtns) == 0 { - updateIdBtns() + updateIdBtns() //} cs = flex.Rigid() if len(idBtns) == 0 { // still zero after update @@ -496,7 +496,7 @@ func eventLoop() { insValue = passvalEd.Text() for _, n := range pathnames { if insName == n { - log(Info,"Password exists") + log(Info, "Password exists") page = confirmPage w.Invalidate() return diff --git a/cmd/passgo/main.go b/cmd/passgo/main.go index 3f60e23..aea6e5b 100644 --- a/cmd/passgo/main.go +++ b/cmd/passgo/main.go @@ -69,7 +69,7 @@ func main() { if opts.clip { passgo.Clip(p) } else { - fmt.Print(p) + fmt.Println(p) } default: usage() diff --git a/impl_android.go b/impl_android.go index 73e42c6..e6929bb 100644 --- a/impl_android.go +++ b/impl_android.go @@ -22,4 +22,3 @@ func (s *Store) nativeEncrypt(pw string) ([]byte, error) { func nativeIdentities() ([]string, error) { return nil, fmt.Errorf("NOT IMPLEMENTED") } - diff --git a/impl_darwin.go b/impl_darwin.go index 8841770..db3e260 100644 --- a/impl_darwin.go +++ b/impl_darwin.go @@ -11,14 +11,14 @@ import ( "os/exec" "os/user" "path" - "strings" "strconv" + "strings" "sync" "golang.org/x/crypto/openpgp" - "github.com/jcmdev0/gpgagent" "github.com/fsnotify/fsnotify" + "github.com/jcmdev0/gpgagent" ) func (s *Store) nativeDecrypt(name string) (string, error) { @@ -51,7 +51,7 @@ func (s *Store) nativeEncrypt(pw string) ([]byte, error) { } var ( - idMux sync.Mutex + idMux sync.Mutex cachedIdentities []string ) @@ -59,11 +59,11 @@ func nativeIdentities() ([]string, error) { idMux.Lock() defer idMux.Unlock() if cachedIdentities != nil { - ret := make([]string,len(cachedIdentities)) + ret := make([]string, len(cachedIdentities)) copy(ret, cachedIdentities) return ret, nil } - ret := make([]string,0) + ret := make([]string, 0) fmt.Println("calling gpg") output, err := exec.Command("gpg", "--list-secret-keys", "--with-colons").Output() if err != nil { @@ -71,9 +71,9 @@ func nativeIdentities() ([]string, error) { } scanner := bufio.NewScanner(bytes.NewBuffer(output)) for scanner.Scan() { - fs := strings.Split(scanner.Text(),":") + fs := strings.Split(scanner.Text(), ":") if fs[0] == "uid" { - fmt.Printf("%s: %s\n",fs[0], fs[9]) + fmt.Printf("%s: %s\n", fs[0], fs[9]) ret = append(ret, fs[9]) } } @@ -151,31 +151,31 @@ func setAgentInfo() { } func GPGPrompt(keys []openpgp.Key, symmetric bool) ([]byte, error) { - conn, err := gpgagent.NewGpgAgentConn() - if err != nil { - return nil, err - } - defer conn.Close() + conn, err := gpgagent.NewGpgAgentConn() + if err != nil { + return nil, err + } + defer conn.Close() - for _, key := range keys { - cacheId := strings.ToUpper(hex.EncodeToString(key.PublicKey.Fingerprint[:])) - request := gpgagent.PassphraseRequest{CacheKey: cacheId} - for i := 0; i < 3; i++ { - var passphrase string - passphrase, err = conn.GetPassphrase(&request) - if err != nil { - continue - } - err = key.PrivateKey.Decrypt([]byte(passphrase)) - if err != nil { - conn.RemoveFromCache(cacheId) - continue - } - return []byte(passphrase), nil - } - return nil, err - } - return nil, fmt.Errorf("Unable to find key") + for _, key := range keys { + cacheId := strings.ToUpper(hex.EncodeToString(key.PublicKey.Fingerprint[:])) + request := gpgagent.PassphraseRequest{CacheKey: cacheId} + for i := 0; i < 3; i++ { + var passphrase string + passphrase, err = conn.GetPassphrase(&request) + if err != nil { + continue + } + err = key.PrivateKey.Decrypt([]byte(passphrase)) + if err != nil { + conn.RemoveFromCache(cacheId) + continue + } + return []byte(passphrase), nil + } + return nil, err + } + return nil, fmt.Errorf("Unable to find key") } func init() { @@ -211,4 +211,3 @@ func Clip(x string) { cmd.Stdin = b cmd.Run() } - diff --git a/main.go b/main.go index 67e804c..f4531a7 100644 --- a/main.go +++ b/main.go @@ -19,12 +19,12 @@ import ( ) var ( - basename *regexp.Regexp - ask openpgp.PromptFunction - Keyring openpgp.KeyRing - krTime time.Time - useNative bool - homeDir string + basename *regexp.Regexp + ask openpgp.PromptFunction + Keyring openpgp.KeyRing + krTime time.Time + useNative bool + homeDir string ) func init() { @@ -33,8 +33,8 @@ func init() { } type Store struct { - Dir string - Id string + Dir string + Id string Empty bool } @@ -107,7 +107,7 @@ func (s *Store) SetID(id string) error { return err } } - return ioutil.WriteFile(path.Join(s.Dir, ".gpg-id"), []byte(id + "\n"), 0644) + return ioutil.WriteFile(path.Join(s.Dir, ".gpg-id"), []byte(id+"\n"), 0644) } type caseInsensitive []os.FileInfo @@ -279,11 +279,11 @@ func (s *Store) Insert(name, value string) error { var enc []byte var err error //if useNative { // golang openpgp code not implemented yet - fmt.Println("Calling nativeEncrypt") - enc, err = s.nativeEncrypt(value) - if err != nil { - return err - } + fmt.Println("Calling nativeEncrypt") + enc, err = s.nativeEncrypt(value) + if err != nil { + return err + } //} - return ioutil.WriteFile(path.Join(s.Dir, name + ".gpg"), enc, 0644) + return ioutil.WriteFile(path.Join(s.Dir, name+".gpg"), enc, 0644) }