[#38] added lint and used the lint suggestions

This commit is contained in:
Valley
2022-07-09 22:17:41 +08:00
committed by GitHub
parent dfd9528847
commit d64fbf9011
36 changed files with 110 additions and 65 deletions
+2 -1
View File
@@ -9,6 +9,7 @@ import (
func TestRandomString(t *testing.T) {
generated := []string{}
reg := regexp.MustCompile(`[a-zA-Z0-9]+`)
for i := 0; i < 30; i++ {
length := 5 + i
@@ -18,7 +19,7 @@ func TestRandomString(t *testing.T) {
t.Errorf("(%d) Expected the length of the string to be %d, got %d", i, length, len(result))
}
if match, _ := regexp.MatchString("[a-zA-Z0-9]+", result); !match {
if match := reg.MatchString(result); !match {
t.Errorf("(%d) The generated strings should have only [a-zA-Z0-9]+ characters, got %q", i, result)
}