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 package cmd
var ( var (
// The Length of the generated password. // Length of the generated password.
Length int Length int
// WithNumbers is set to true if the new password must contain numbers. // WithNumbers is set to true if the new password must contain numbers.
WithNumbers bool WithNumbers bool

View file

@ -6,7 +6,7 @@ import (
"github.com/fatih/color" "github.com/fatih/color"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/rjNemo/go-pass-gen/passGen" "github.com/rjNemo/go-pass-gen/passgen"
) )
func init() { func init() {
@ -20,7 +20,7 @@ var newPasswordCommand = &cobra.Command{Use: "new",
Short: "New Password", Short: "New Password",
Long: "Create a secure password", Long: "Create a secure password",
Run: func(cmd *cobra.Command, args []string) { 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() password := pg.NewPassword()
display(password) 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 package cmd
import ( import (
@ -9,11 +9,11 @@ import (
// rootCommand initializes the command-line interface application. // rootCommand initializes the command-line interface application.
var rootCommand = &cobra.Command{ var rootCommand = &cobra.Command{
Use: "passGen", Use: "passgen",
Short: "PassGen", Short: "PassGen",
Long: "Password Generator", Long: "Password Generator",
Run: func(cmd *cobra.Command, args []string) { 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 ( const (
// LOWERCASE characters if latin alphabet // LOWERCASE characters if latin alphabet

View file

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

View file

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

View file

@ -1,18 +1,18 @@
package passGen_test package passgen_test
import ( import (
"math/rand" "math/rand"
"strings" "strings"
"testing" "testing"
"github.com/rjNemo/go-pass-gen/passGen" "github.com/rjNemo/go-pass-gen/passgen"
) )
func TestGeneratePasswordWithGivenCharacterNumber(t *testing.T) { func TestGeneratePasswordWithGivenCharacterNumber(t *testing.T) {
opts := passGen.Options{ opts := passgen.Options{
Length: rand.Intn(12), Length: rand.Intn(12),
} }
pg := passGen.NewPasswordGenerator(opts) pg := passgen.NewPasswordGenerator(opts)
if password := pg.NewPassword(); len(password) != opts.Length { if password := pg.NewPassword(); len(password) != opts.Length {
t.Errorf("Expected a password to be %d characters long, got %d", opts.Length, len(password)) 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) { func TestGeneratePasswordWithDefaultCharacterNumber(t *testing.T) {
pg := passGen.NewPasswordGenerator(passGen.Options{}) pg := passgen.NewPasswordGenerator(passgen.Options{})
if password := pg.NewPassword(); len(password) != 6 { if password := pg.NewPassword(); len(password) != 6 {
t.Errorf("Expected a password to be %d characters long, got %d", 6, len(password)) 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) { func TestGeneratePasswordWithLettersAndNumbers(t *testing.T) {
opts := passGen.Options{ opts := passgen.Options{
WithNumbers: true, WithNumbers: true,
} }
pg := passGen.NewPasswordGenerator(opts) pg := passgen.NewPasswordGenerator(opts)
if password := pg.NewPassword(); !containNumbers(password) { if password := pg.NewPassword(); !containNumbers(password) {
t.Errorf("Expected password to contain NUMBERS, got %q", 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 { func containNumbers(str string) bool {
return strings.ContainsAny(str, passGen.NUMBERS) return strings.ContainsAny(str, passgen.NUMBERS)
} }