lockbox

password manager
Log | Files | Refs | README | LICENSE

commit 82a98ca72471b556c42147bb04cb93b7e5e2fe44
parent 502249d4e08501ca95309a4c15d7bfd04f57785c
Author: Sean Enck <sean@ttypty.com>
Date:   Sun,  2 Oct 2022 13:03:39 -0400

specify constants and vars that are static and use them

Diffstat:
Minternal/backend/actions.go | 5++---
Minternal/backend/types.go | 8++++++++
2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/internal/backend/actions.go b/internal/backend/actions.go @@ -3,7 +3,6 @@ package backend import ( "errors" - "fmt" "os" "path/filepath" "strings" @@ -153,9 +152,9 @@ func findAndDo(isAdd bool, entityName string, offset []string, opEntity *gokeepa func splitComponents(path string) ([]string, string, error) { title := filepath.Base(path) - parts := strings.Split(filepath.Dir(path), string(os.PathSeparator)) + parts := strings.Split(filepath.Dir(path), pathSep) if len(parts) < 2 { - return nil, "", fmt.Errorf("input paths must contain at LEAST 3 components (e.g. abc%c123%cxyz)", os.PathSeparator, os.PathSeparator) + return nil, "", errPath } return parts, title, nil } diff --git a/internal/backend/types.go b/internal/backend/types.go @@ -2,6 +2,9 @@ package backend import ( + "fmt" + "os" + "github.com/tobischo/gokeepasslib/v3" ) @@ -62,4 +65,9 @@ const ( notesKey = "Notes" titleKey = "Title" passKey = "Password" + pathSep = string(os.PathSeparator) +) + +var ( + errPath = fmt.Errorf("input paths must contain at LEAST 3 components (e.g. abc%c123%cxyz)", os.PathSeparator, os.PathSeparator) )