catalog: mmddSnapshot compiles on first use

1ca2c62c4 added a package-level regexp.MustCompile, so
TestNoEagerPackageRegexps was red (catalog.go:1184). It is a
lazyre.New now, as the file's other patterns are, and catalog.go no
longer imports regexp.

Run (mica): go test -count=1 -tags nogui ./internal/catalog . ok;
GOOS=linux and GOOS=windows go vet ./internal/catalog ok.
This commit is contained in:
yetone
2026-11-13 02:00:40 +08:00
parent b552740c4b
commit 19fd0dfb87
+1 -2
View File
@@ -13,7 +13,6 @@ import (
"net/http"
"os"
"path/filepath"
"regexp"
"slices"
"sort"
"strconv"
@@ -1181,7 +1180,7 @@ func makerPriced(all map[string]mdProvider, at int, prefer []string, id string)
// mmddSnapshot is the date a vendor ends a snapshot's id with: -0813,
// -1017 (month and day), -20261017 or -2026-10-17.
var mmddSnapshot = regexp.MustCompile(`-(?:(?:0[1-9]|1[0-2])(?:0[1-9]|[12][0-9]|3[01])|20[0-9]{2}(?:-?)(?:0[1-9]|1[0-2])(?:-?)(?:0[1-9]|[12][0-9]|3[01]))$`)
var mmddSnapshot = lazyre.New(`-(?:(?:0[1-9]|1[0-2])(?:0[1-9]|[12][0-9]|3[01])|20[0-9]{2}(?:-?)(?:0[1-9]|1[0-2])(?:-?)(?:0[1-9]|[12][0-9]|3[01]))$`)
// snapshotOf is an id without the date of its snapshot, as the model it is
// a snapshot of: deepseek-v4.1-flash-1017 is deepseek-v4.1-flash.