[#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
+1 -1
View File
@@ -127,7 +127,7 @@ func (s *System) DeletePrefix(prefix string) []error {
Prefix: prefix,
}
// delete all files witht the prefix
// delete all files with the prefix
// ---
iter := s.bucket.List(&opts)
for {
+1 -1
View File
@@ -82,7 +82,7 @@ func TestSanitize(t *testing.T) {
{" ", ` `, "", false},
{"", `[A-Z]`, "", false},
{"abcABC", `[A-Z]`, "abc", false},
{"abcABC", `[A-Z`, "", true}, // invlid pattern
{"abcABC", `[A-Z`, "", true}, // invalid pattern
}
for i, scenario := range scenarios {
+1 -1
View File
@@ -210,7 +210,7 @@ func (s *Provider) Exec(items any) (*Result, error) {
s.perPage = MaxPerPage
}
// normalize page accoring to the total count
// normalize page according to the total count
if s.page <= 0 || totalCount == 0 {
s.page = 1
} else if totalPages := int(math.Ceil(float64(totalCount) / float64(s.perPage))); s.page > totalPages {
+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)
}
+2 -1
View File
@@ -1,10 +1,11 @@
package types_test
import (
"github.com/pocketbase/pocketbase/tools/types"
"strings"
"testing"
"time"
"github.com/pocketbase/pocketbase/tools/types"
)
func TestNowDateTime(t *testing.T) {