mirror of
https://github.com/rjNemo/go-pass-gen
synced 2026-06-06 02:46:40 +00:00
fix: lint issues
This commit is contained in:
parent
9af2f6486c
commit
d29ad13fed
7 changed files with 18 additions and 18 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package passGen
|
||||
package passgen
|
||||
|
||||
const (
|
||||
// LOWERCASE characters if latin alphabet
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package passGen
|
||||
package passgen
|
||||
|
||||
type Options struct {
|
||||
// Length of the new password
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// Package passGen creates a random password.
|
||||
package passGen
|
||||
// Package passgen creates a random password.
|
||||
package passgen
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
|
|
@ -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)
|
||||
}
|
||||
Loading…
Reference in a new issue