fix: lint issues

This commit is contained in:
Ruidy Nemausat 2021-10-20 17:30:41 +02:00
parent 9af2f6486c
commit d29ad13fed
No known key found for this signature in database
GPG key ID: A367830814E7096E
7 changed files with 18 additions and 18 deletions

View file

@ -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

View file

@ -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)
}}

View file

@ -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")
},
}

View file

@ -1,4 +1,4 @@
package passGen
package passgen
const (
// LOWERCASE characters if latin alphabet

View file

@ -1,4 +1,4 @@
package passGen
package passgen
type Options struct {
// Length of the new password

View file

@ -1,5 +1,5 @@
// Package passGen creates a random password.
package passGen
// Package passgen creates a random password.
package passgen
import (
"math/rand"

View file

@ -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)
}