linter fixes.

This commit is contained in:
2025-11-16 18:39:18 -08:00
parent 0dcd18c6f1
commit c999bf35b0
4 changed files with 10 additions and 9 deletions

View File

@@ -52,10 +52,11 @@ func TestHotpBadRFC(t *testing.T) {
otp := NewHOTP(testKey, 0, 6)
for i := 0; i < len(rfcHotpExpected); i++ {
code := otp.OTP()
if code == "" {
switch code {
case "":
fmt.Printf("twofactor: failed to produce an OTP\n")
t.FailNow()
} else if code == rfcHotpExpected[i] {
case rfcHotpExpected[i]:
fmt.Printf("twofactor: should not have received a valid OTP\n")
t.FailNow()
}

View File

@@ -71,10 +71,10 @@ func (o OATH) URL(t Type, label string) string {
v.Add("digits", fmt.Sprintf("%d", o.Size()))
}
switch {
case o.algo == crypto.SHA256:
switch o.algo {
case crypto.SHA256:
v.Add("algorithm", "SHA256")
case o.algo == crypto.SHA512:
case crypto.SHA512:
v.Add("algorithm", "SHA512")
}

6
otp.go
View File

@@ -75,10 +75,10 @@ func FromURL(URL string) (OTP, string, error) {
return nil, "", ErrInvalidURL
}
switch {
case u.Host == "totp":
switch u.Host {
case "totp":
return totpFromURL(u)
case u.Host == "hotp":
case "hotp":
return hotpFromURL(u)
default:
return nil, "", ErrInvalidURL

View File

@@ -22,7 +22,7 @@ func TestPadding(t *testing.T) {
for i := 0; i < 300; i++ {
b := randString()
origEncoding := string(b)
modEncoding := strings.Replace(string(b), "=", "", -1)
modEncoding := strings.ReplaceAll(string(b), "=", "")
str, err := base32.StdEncoding.DecodeString(origEncoding)
if err != nil {
fmt.Println("Can't decode: ", string(b))