commit 1ebfcf084f07b10ba31f44b4c5fd5362fac857cc
parent 133075b5c5319609a4917c20cf0b900575ba5202
Author: Sean Enck <sean@ttypty.com>
Date: Fri, 13 Jan 2023 18:55:47 -0500
gofumpt
Diffstat:
10 files changed, 17 insertions(+), 27 deletions(-)
diff --git a/cmd/main.go b/cmd/main.go
@@ -17,10 +17,8 @@ import (
"github.com/enckse/lockbox/internal/totp"
)
-var (
- //go:embed "vers.txt"
- version string
-)
+//go:embed "vers.txt"
+var version string
type (
callbackFunction func([]string) error
diff --git a/internal/backend/actions_test.go b/internal/backend/actions_test.go
@@ -40,7 +40,7 @@ func TestKeyFile(t *testing.T) {
os.Setenv("LOCKBOX_TOTP", "totp")
os.Setenv("LOCKBOX_HOOKDIR", "")
os.Setenv("LOCKBOX_SET_MODTIME", "")
- os.WriteFile("file.key.kdbx", []byte("test"), 0644)
+ os.WriteFile("file.key.kdbx", []byte("test"), 0o644)
tr, err := backend.NewTransaction()
if err != nil {
t.Errorf("failed: %v", err)
@@ -264,7 +264,7 @@ func TestHooks(t *testing.T) {
}
testPath := "hooks.kdbx"
os.RemoveAll(testPath)
- if err := os.MkdirAll(testPath, 0755); err != nil {
+ if err := os.MkdirAll(testPath, 0o755); err != nil {
t.Errorf("failed, mkdir: %v", err)
}
os.Setenv("LOCKBOX_HOOKDIR", testPath)
@@ -276,7 +276,7 @@ func TestHooks(t *testing.T) {
t.Errorf("invalid error: %v", err)
}
sub := filepath.Join(testPath, "subdir")
- if err := os.MkdirAll(sub, 0755); err != nil {
+ if err := os.MkdirAll(sub, 0o755); err != nil {
t.Errorf("failed, mkdir sub: %v", err)
}
if _, err := backend.NewHook("b", backend.InsertAction); err.Error() != "found subdirectory in hookdir" {
@@ -286,7 +286,7 @@ func TestHooks(t *testing.T) {
t.Errorf("failed rmdir: %v", err)
}
script := filepath.Join(testPath, "testscript")
- if err := os.WriteFile(script, []byte{}, 0644); err != nil {
+ if err := os.WriteFile(script, []byte{}, 0o644); err != nil {
t.Errorf("unable to write script: %v", err)
}
h, err = backend.NewHook("a", backend.InsertAction)
diff --git a/internal/backend/core.go b/internal/backend/core.go
@@ -56,10 +56,9 @@ func create(file, key, keyFile string) error {
return err
}
db.Credentials = creds
- db.Content.Root =
- &gokeepasslib.RootData{
- Groups: []gokeepasslib.Group{root},
- }
+ db.Content.Root = &gokeepasslib.RootData{
+ Groups: []gokeepasslib.Group{root},
+ }
if err := db.LockProtectedEntries(); err != nil {
return err
}
diff --git a/internal/backend/query.go b/internal/backend/query.go
@@ -95,7 +95,6 @@ func (t *Transaction) QueryCallback(args QueryOptions) ([]QueryEntity, error) {
return
}
}
-
} else {
if args.Mode == ExactMode {
if path != args.Criteria {
diff --git a/internal/backend/query_test.go b/internal/backend/query_test.go
@@ -233,5 +233,4 @@ func TestSetModTime(t *testing.T) {
if err == nil || !strings.Contains(err.Error(), "parsing time") {
t.Errorf("invalid error: %v", err)
}
-
}
diff --git a/internal/backend/types.go b/internal/backend/types.go
@@ -102,6 +102,4 @@ const (
modTimeKey = "ModTime"
)
-var (
- errPath = errors.New("input paths must contain at LEAST 2 components")
-)
+var errPath = errors.New("input paths must contain at LEAST 2 components")
diff --git a/internal/cli/core.go b/internal/cli/core.go
@@ -62,10 +62,8 @@ const (
BashDefaultsCommand = "-defaults"
)
-var (
- //go:embed "completions.bash"
- bashCompletions string
-)
+//go:embed "completions.bash"
+var bashCompletions string
type (
// Completions handles the inputs to completions for templating
diff --git a/internal/inputs/stdin.go b/internal/inputs/stdin.go
@@ -17,7 +17,8 @@ func termEcho(on bool) {
Dir: "",
Env: []string{},
Files: []uintptr{os.Stdin.Fd(), os.Stdout.Fd(), os.Stderr.Fd()},
- Sys: nil}
+ Sys: nil,
+ }
var ws syscall.WaitStatus
cmd := "echo"
if !on {
diff --git a/internal/totp/core.go b/internal/totp/core.go
@@ -18,10 +18,8 @@ import (
otp "github.com/pquerna/otp/totp"
)
-var (
- // ErrNoTOTP is used when TOTP is requested BUT is disabled
- ErrNoTOTP = errors.New("TOTP is disabled")
-)
+// ErrNoTOTP is used when TOTP is requested BUT is disabled
+var ErrNoTOTP = errors.New("TOTP is disabled")
type (
arguments struct {
diff --git a/scripts/check.go b/scripts/check.go
@@ -63,7 +63,7 @@ func main() {
useKeyFile := ""
if *keyFile {
useKeyFile = filepath.Join(path, "test.key")
- if err := os.WriteFile(useKeyFile, []byte("thisisatest"), 0644); err != nil {
+ if err := os.WriteFile(useKeyFile, []byte("thisisatest"), 0o644); err != nil {
die("unable to write keyfile", err)
}
}