From d29ad13fedd050080c252213a4bd1b09d8f6e1c4 Mon Sep 17 00:00:00 2001 From: Ruidy Nemausat Date: Wed, 20 Oct 2021 17:30:41 +0200 Subject: [PATCH] fix: lint issues --- cmd/flags.go | 2 +- cmd/new.go | 4 ++-- cmd/root.go | 6 +++--- {passGen => passgen}/constants.go | 2 +- {passGen => passgen}/options.go | 2 +- passGen/passGen.go => passgen/passgen.go | 4 ++-- .../passGen_test.go => passgen/passgen_test.go | 16 ++++++++-------- 7 files changed, 18 insertions(+), 18 deletions(-) rename {passGen => passgen}/constants.go (93%) rename {passGen => passgen}/options.go (95%) rename passGen/passGen.go => passgen/passgen.go (94%) rename passGen/passGen_test.go => passgen/passgen_test.go (72%) diff --git a/cmd/flags.go b/cmd/flags.go index 0a2d59c..90bb2e6 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -1,7 +1,7 @@ package cmd var ( - // The Length of the generated password. + // Length of the generated password. Length int // WithNumbers is set to true if the new password must contain numbers. WithNumbers bool diff --git a/cmd/new.go b/cmd/new.go index d00d2f2..6c50325 100644 --- a/cmd/new.go +++ b/cmd/new.go @@ -6,7 +6,7 @@ import ( "github.com/fatih/color" "github.com/spf13/cobra" - "github.com/rjNemo/go-pass-gen/passGen" + "github.com/rjNemo/go-pass-gen/passgen" ) func init() { @@ -20,7 +20,7 @@ var newPasswordCommand = &cobra.Command{Use: "new", Short: "New Password", Long: "Create a secure password", Run: func(cmd *cobra.Command, args []string) { - pg := passGen.NewPasswordGenerator(passGen.Options{Length: Length, WithNumbers: WithNumbers}) + pg := passgen.NewPasswordGenerator(passgen.Options{Length: Length, WithNumbers: WithNumbers}) password := pg.NewPassword() display(password) }} diff --git a/cmd/root.go b/cmd/root.go index 04dc00b..e8f9846 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,4 +1,4 @@ -// Package cmd defines the command-line interface to passGen +// Package cmd defines the command-line interface to passgen package cmd import ( @@ -9,11 +9,11 @@ import ( // rootCommand initializes the command-line interface application. var rootCommand = &cobra.Command{ - Use: "passGen", + Use: "passgen", Short: "PassGen", Long: "Password Generator", Run: func(cmd *cobra.Command, args []string) { - display("** passGen – v0.0.1 **\nUse passGen -h for more information") + display("** passgen – v0.0.1 **\nUse passgen -h for more information") }, } diff --git a/passGen/constants.go b/passgen/constants.go similarity index 93% rename from passGen/constants.go rename to passgen/constants.go index 2757c39..4a8e609 100644 --- a/passGen/constants.go +++ b/passgen/constants.go @@ -1,4 +1,4 @@ -package passGen +package passgen const ( // LOWERCASE characters if latin alphabet diff --git a/passGen/options.go b/passgen/options.go similarity index 95% rename from passGen/options.go rename to passgen/options.go index a6f007f..2573e41 100644 --- a/passGen/options.go +++ b/passgen/options.go @@ -1,4 +1,4 @@ -package passGen +package passgen type Options struct { // Length of the new password diff --git a/passGen/passGen.go b/passgen/passgen.go similarity index 94% rename from passGen/passGen.go rename to passgen/passgen.go index 6a8bd76..1e84ee2 100644 --- a/passGen/passGen.go +++ b/passgen/passgen.go @@ -1,5 +1,5 @@ -// Package passGen creates a random password. -package passGen +// Package passgen creates a random password. +package passgen import ( "math/rand" diff --git a/passGen/passGen_test.go b/passgen/passgen_test.go similarity index 72% rename from passGen/passGen_test.go rename to passgen/passgen_test.go index 7a20feb..f24b289 100644 --- a/passGen/passGen_test.go +++ b/passgen/passgen_test.go @@ -1,18 +1,18 @@ -package passGen_test +package passgen_test import ( "math/rand" "strings" "testing" - "github.com/rjNemo/go-pass-gen/passGen" + "github.com/rjNemo/go-pass-gen/passgen" ) func TestGeneratePasswordWithGivenCharacterNumber(t *testing.T) { - opts := passGen.Options{ + opts := passgen.Options{ Length: rand.Intn(12), } - pg := passGen.NewPasswordGenerator(opts) + pg := passgen.NewPasswordGenerator(opts) if password := pg.NewPassword(); len(password) != opts.Length { t.Errorf("Expected a password to be %d characters long, got %d", opts.Length, len(password)) @@ -20,7 +20,7 @@ func TestGeneratePasswordWithGivenCharacterNumber(t *testing.T) { } func TestGeneratePasswordWithDefaultCharacterNumber(t *testing.T) { - pg := passGen.NewPasswordGenerator(passGen.Options{}) + pg := passgen.NewPasswordGenerator(passgen.Options{}) if password := pg.NewPassword(); len(password) != 6 { t.Errorf("Expected a password to be %d characters long, got %d", 6, len(password)) @@ -28,10 +28,10 @@ func TestGeneratePasswordWithDefaultCharacterNumber(t *testing.T) { } func TestGeneratePasswordWithLettersAndNumbers(t *testing.T) { - opts := passGen.Options{ + opts := passgen.Options{ WithNumbers: true, } - pg := passGen.NewPasswordGenerator(opts) + pg := passgen.NewPasswordGenerator(opts) if password := pg.NewPassword(); !containNumbers(password) { t.Errorf("Expected password to contain NUMBERS, got %q", password) @@ -39,5 +39,5 @@ func TestGeneratePasswordWithLettersAndNumbers(t *testing.T) { } func containNumbers(str string) bool { - return strings.ContainsAny(str, passGen.NUMBERS) + return strings.ContainsAny(str, passgen.NUMBERS) }