Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore(go): modernize source and enforce go fix in CI
johnnyjoygha316e7935b11
diff --git a/.github/workflows/backend-tests.yml b/.github/workflows/backend-tests.ymlindex 06a714c5a..acf973a7d 100644--- a/.github/workflows/backend-tests.yml+++ b/.github/workflows/backend-tests.yml@@ -9,6 +9,8 @@ on:- "go.mod"- "go.sum"- "**.go"+ - ".golangci.yaml"+ - ".github/workflows/backend-tests.yml"concurrency:group: ${{ github.workflow }}-${{ github.ref }}@@ -37,6 +39,9 @@ jobs:go mod tidy -go=${{ env.GO_VERSION }}git diff --exit-code+ - name: Verify go fix+ run: go fix -diff ./...+- name: Run golangci-lintuses: golangci/golangci-lint-action@v9with:diff --git a/AGENTS.md b/AGENTS.mdindex a5bb00880..ff5a6198a 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -42,6 +42,8 @@ go test -v -race ./server/... # Server tests with race detectorgo test -v -race ./internal/... # Internal package tests with race detectorgo test -v -run TestFoo ./core/... # Run matching Go tests in one treego mod tidy -go=1.27.0 # Match CI tidy check+go fix ./... # Apply Go modernization fixes+go fix -diff ./... # Match CI modernization checkgolangci-lint run # Go lint, config: .golangci.yaml (includes depguard layering rules)golangci-lint run --fix # Auto-fix lint, including goimports@@ -148,8 +150,8 @@ Black-box service tests live in `server/api/test/`, unit tests next to the code.- Docker excludes `.git`; pass `--build-arg VERSION="$(bash scripts/release_version.sh development-version)"` and`--build-arg COMMIT="$(git rev-parse HEAD)"` when building locally (build frontend assets first).-- Backend CI: Go 1.27.0, `go mod tidy -go=1.27.0`, golangci-lint v2.13.1, test groups `store`, `server`, `internal`, `other`- (`cmd`, `core`, `markdown`, `filter`, `provider`, `proto`).+- Backend CI: Go 1.27.0, `go mod tidy -go=1.27.0`, `go fix -diff ./...`, golangci-lint v2.13.1 (including goimports), test groups+ `store`, `server`, `internal`, `other` (`cmd`, `core`, `markdown`, `filter`, `provider`, `proto`).- Frontend CI: Node 24, pnpm 11.0.1, `pnpm lint`, `pnpm test`, `pnpm build`.- Proto CI: `buf lint` and `buf format` check.- Docker: `scripts/Dockerfile`, Alpine 3.21 runtime, non-root user, port 5230, multi-arch amd64/arm64/arm/v7.diff --git a/filter/ir.go b/filter/ir.goindex c53b2cb1c..dadd5a7ea 100644--- a/filter/ir.go+++ b/filter/ir.go@@ -121,7 +121,7 @@ func (*FieldRef) isValueExpr() {}// LiteralValue holds a literal scalar.type LiteralValue struct {- Value interface{}+ Value any}func (*LiteralValue) isValueExpr() {}diff --git a/filter/parser.go b/filter/parser.goindex c97a61311..5ff270639 100644--- a/filter/parser.go+++ b/filter/parser.go@@ -462,7 +462,7 @@ func getIdentName(expr *exprv1.Expr) (string, error) {return "", errors.New("expression is not an identifier")}-func getConstValue(expr *exprv1.Expr) (interface{}, error) {+func getConstValue(expr *exprv1.Expr) (any, error) {v, ok := expr.ExprKind.(*exprv1.Expr_ConstExpr)if !ok {return nil, errors.New("expression is not a literal")diff --git a/internal/clientip/clientip.go b/internal/clientip/clientip.goindex 235f2b1b8..382862313 100644--- a/internal/clientip/clientip.go+++ b/internal/clientip/clientip.go@@ -10,6 +10,7 @@ import ("net""net/http""net/netip"+ "slices""strings""github.com/labstack/echo/v5"@@ -119,8 +120,8 @@ func (r *Resolver) Resolve(remoteAddr string, header http.Header) string {}}}- for i := len(entries) - 1; i >= 0; i-- {- candidate, ok := parseAddr(entries[i])+ for _, entry := range slices.Backward(entries) {+ candidate, ok := parseAddr(entry)if !ok {// A malformed entry ends the walk; nothing to its left can be trusted.breakdiff --git a/internal/email/email_test.go b/internal/email/email_test.goindex c0c1e4ddc..5e4ddd598 100644--- a/internal/email/email_test.go+++ b/internal/email/email_test.go@@ -128,7 +128,7 @@ func TestSendAsyncConcurrent(t *testing.T) {g := errgroup.Group{}count := 5- for i := 0; i < count; i++ {+ for range count {g.Go(func() error {message := &Message{To: []string{"[email protected]"},diff --git a/internal/email/message_test.go b/internal/email/message_test.goindex feee5493b..c47f2594a 100644--- a/internal/email/message_test.go+++ b/internal/email/message_test.go@@ -156,7 +156,7 @@ func TestMessageFormatSanitizesHeaderValues(t *testing.T) {}formatted := msg.Format("[email protected]\r\nX-Injected-From: bad", "Sender\r\nX-Injected-Name: bad")- headers := strings.SplitN(formatted, "\r\n\r\n", 2)[0]+ headers, _, _ := strings.Cut(formatted, "\r\n\r\n")if strings.Contains(headers, "\r\nX-Injected") {t.Fatalf("header value injection was not sanitized:\n%s", headers)diff --git a/internal/linkmeta/html_meta_extract.go b/internal/linkmeta/html_meta_extract.goindex 246a164b5..86be0d46a 100644--- a/internal/linkmeta/html_meta_extract.go+++ b/internal/linkmeta/html_meta_extract.go@@ -5,6 +5,7 @@ import ("encoding/json""mime""net/url"+ "slices""strings""unicode""unicode/utf8"@@ -409,12 +410,7 @@ func isPotentialHTTPURL(value string) bool {}func containsString(values []string, expected string) bool {- for _, value := range values {- if value == expected {- return true- }- }- return false+ return slices.Contains(values, expected)}func isJSONOEmbedMediaType(value string) bool {diff --git a/internal/linkmeta/html_meta_test.go b/internal/linkmeta/html_meta_test.goindex 6b4df7904..ef8a20528 100644--- a/internal/linkmeta/html_meta_test.go+++ b/internal/linkmeta/html_meta_test.go@@ -432,15 +432,13 @@ func TestHTMLMetaFetcherCoalescesRequests(t *testing.T) {var waitGroup sync.WaitGrouperrorsChannel := make(chan error, requestCount)for range requestCount {- waitGroup.Add(1)- go func() {- defer waitGroup.Done()+ waitGroup.Go(func() {meta, err := fetcher.Get(context.Background(), "http://93.184.216.34/shared")if err == nil && meta.Title != "Shared title" {err = errors.New("unexpected metadata")}errorsChannel <- err- }()+ })}<-startedclose(release)@@ -474,11 +472,9 @@ func TestHTMLMetaFetcherLimitsConcurrency(t *testing.T) {const requestCount = 12var waitGroup sync.WaitGroupfor index := range requestCount {- waitGroup.Add(1)- go func() {- defer waitGroup.Done()+ waitGroup.Go(func() {_, _ = fetcher.Get(context.Background(), "http://93.184.216.34/page?id="+string(rune('a'+index)))- }()+ })}for range maxConcurrentFetches {<-entereddiff --git a/internal/random/random.go b/internal/random/random.goindex a96574fc9..50e209fac 100644--- a/internal/random/random.go+++ b/internal/random/random.go@@ -20,7 +20,7 @@ var alphabet = []rune("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUfunc String(n int) (string, error) {var sb strings.Buildersb.Grow(n)- for i := 0; i < n; i++ {+ for range n {index, err := rand.Int(rand.Reader, big.NewInt(int64(len(alphabet))))if err != nil {return "", errdiff --git a/server/api/attachment_exif_test.go b/server/api/attachment_exif_test.goindex 07f4e3807..fb974101c 100644--- a/server/api/attachment_exif_test.go+++ b/server/api/attachment_exif_test.go@@ -89,8 +89,8 @@ func TestStripImageExif(t *testing.T) {// Create a simple test imageimg := image.NewRGBA(image.Rect(0, 0, 100, 100))// Fill with red color- for y := 0; y < 100; y++ {- for x := 0; x < 100; x++ {+ for y := range 100 {+ for x := range 100 {img.Set(x, y, color.RGBA{R: 255, G: 0, B: 0, A: 255})}}diff --git a/server/api/attachment_media_metadata_test.go b/server/api/attachment_media_metadata_test.goindex b4b230d65..cea163391 100644--- a/server/api/attachment_media_metadata_test.go+++ b/server/api/attachment_media_metadata_test.go@@ -23,21 +23,21 @@ func TestValidateClientMediaMetadata(t *testing.T) {Details: &apipb.MediaMetadata_Photo{Photo: &apipb.PhotoMetadata{CaptureTime: &apipb.MediaCaptureTime{LocalDateTime: "2026-08-10T14:32:18.123",- UtcOffset: proto.String("+08:00"),+ UtcOffset: new("+08:00"),},Location: &apipb.MediaLocation{- Latitude: proto.Float64(1.3521),- Longitude: proto.Float64(103.8198),- AltitudeMeters: proto.Float64(18.4),+ Latitude: new(1.3521),+ Longitude: new(103.8198),+ AltitudeMeters: new(18.4),},SourceExifOrientation: proto.Int32(6),CameraMake: "Apple",CameraModel: "iPhone",LensModel: "Main Camera",- FNumber: proto.Float64(1.78),- ExposureTimeSeconds: proto.Float64(1.0 / 120.0),+ FNumber: new(1.78),+ ExposureTimeSeconds: new(1.0 / 120.0),Iso: proto.Int32(64),- FocalLengthMm: proto.Float64(6.86),+ FocalLengthMm: new(6.86),}},}}@@ -59,7 +59,7 @@ func TestValidateClientMediaMetadata(t *testing.T) {t.Run("accepts video metadata", func(t *testing.T) {metadata, err := validateClientMediaMetadata(&apipb.MediaMetadata{- Details: &apipb.MediaMetadata_Video{Video: &apipb.VideoMetadata{DurationSeconds: proto.Float64(12.5)}},+ Details: &apipb.MediaMetadata_Video{Video: &apipb.VideoMetadata{DurationSeconds: new(12.5)}},}, "video/mp4")require.NoError(t, err)require.Equal(t, 12.5, metadata.GetVideo().GetDurationSeconds())@@ -73,7 +73,7 @@ func TestValidateClientMediaMetadata(t *testing.T) {t.Run("accepts Z UTC offset", func(t *testing.T) {metadata, err := validateClientMediaMetadata(photoOnly(&apipb.PhotoMetadata{- CaptureTime: &apipb.MediaCaptureTime{LocalDateTime: "2026-08-10T14:32:18", UtcOffset: proto.String("Z")},+ CaptureTime: &apipb.MediaCaptureTime{LocalDateTime: "2026-08-10T14:32:18", UtcOffset: new("Z")},}), "image/jpeg")require.NoError(t, err)require.Equal(t, "Z", metadata.GetPhoto().GetCaptureTime().GetUtcOffset())@@ -97,15 +97,15 @@ func TestValidateClientMediaMetadata(t *testing.T) {{name: "control character in camera make", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{CameraMake: "Apple\nCo"})},{name: "null byte in lens model", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{LensModel: "Main\x00Camera"})},{name: "long camera model", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{CameraModel: strings.Repeat("x", maxMediaMetadataStringBytes+1)})},- {name: "non-finite aperture", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{FNumber: proto.Float64(math.NaN())})},+ {name: "non-finite aperture", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{FNumber: new(math.NaN())})},{name: "zero exposure", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{ExposureTimeSeconds: proto.Float64(0)})},{name: "zero ISO", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{Iso: proto.Int32(0)})},{name: "invalid capture format", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{CaptureTime: &apipb.MediaCaptureTime{LocalDateTime: "2026:08:10 14:32:18"}})},{name: "invalid calendar date", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{CaptureTime: &apipb.MediaCaptureTime{LocalDateTime: "2026-02-30T14:32:18"}})},- {name: "invalid offset", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{CaptureTime: &apipb.MediaCaptureTime{LocalDateTime: "2026-08-10T14:32:18", UtcOffset: proto.String("+14:30")}})},+ {name: "invalid offset", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{CaptureTime: &apipb.MediaCaptureTime{LocalDateTime: "2026-08-10T14:32:18", UtcOffset: new("+14:30")}})},{name: "missing longitude", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{Location: &apipb.MediaLocation{Latitude: proto.Float64(1)}})},{name: "latitude out of range", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{Location: &apipb.MediaLocation{Latitude: proto.Float64(91), Longitude: proto.Float64(1)}})},- {name: "non-finite altitude", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{Location: &apipb.MediaLocation{Latitude: proto.Float64(1), Longitude: proto.Float64(1), AltitudeMeters: proto.Float64(math.Inf(1))}})},+ {name: "non-finite altitude", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{Location: &apipb.MediaLocation{Latitude: proto.Float64(1), Longitude: proto.Float64(1), AltitudeMeters: new(math.Inf(1))}})},{name: "negative duration", mimeType: "video/mp4", metadata: &apipb.MediaMetadata{Details: &apipb.MediaMetadata_Video{Video: &apipb.VideoMetadata{DurationSeconds: proto.Float64(-1)}}}},}diff --git a/server/api/attachment_service_storage.go b/server/api/attachment_service_storage.goindex 2bc2cae12..dc4be4051 100644--- a/server/api/attachment_service_storage.go+++ b/server/api/attachment_service_storage.go@@ -9,6 +9,7 @@ import ("os""path/filepath""regexp"+ "slices""strings""time"@@ -226,11 +227,8 @@ func hasSameManagedStorageObject(left, right *store.Attachment) bool {func (s *APIService) cleanupDeletedAttachmentStorage(ctx context.Context, attachments []*store.Attachment) error {var instanceStorageSetting *storepb.InstanceStorageSettingvar instanceStorageSettingErr error- for _, attachment := range attachments {- if store.AttachmentNeedsInstanceStorageSetting(attachment) {- instanceStorageSetting, instanceStorageSettingErr = s.Store.GetInstanceStorageSetting(ctx)- break- }+ if slices.ContainsFunc(attachments, store.AttachmentNeedsInstanceStorageSetting) {+ instanceStorageSetting, instanceStorageSettingErr = s.Store.GetInstanceStorageSetting(ctx)}var firstErr errordiff --git a/server/api/filter_access.go b/server/api/filter_access.goindex a54f9a3b1..331b725a6 100644--- a/server/api/filter_access.go+++ b/server/api/filter_access.go@@ -95,10 +95,8 @@ func collectSpaceFilterNames(condition filterpkg.Condition, negated bool, namesif valueReferencesSpace(condition.Left) {return errors.New("space does not support the in operator")}- for _, value := range condition.Values {- if valueReferencesSpace(value) {- return errors.New("space does not support the in operator")- }+ if slices.ContainsFunc(condition.Values, valueReferencesSpace) {+ return errors.New("space does not support the in operator")}case *filterpkg.ElementInCondition:if condition.Field == "space" || valueReferencesSpace(condition.Element) {@@ -131,10 +129,8 @@ func valueReferencesSpace(value filterpkg.ValueExpr) bool {case *filterpkg.FieldRef:return value.Name == "space"case *filterpkg.FunctionValue:- for _, argument := range value.Args {- if valueReferencesSpace(argument) {- return true- }+ if slices.ContainsFunc(value.Args, valueReferencesSpace) {+ return true}case *filterpkg.FieldAccessorValue:return value.Field == "space"diff --git a/server/api/gateway_marshaler_test.go b/server/api/gateway_marshaler_test.goindex caab32a1d..deca11b0b 100644--- a/server/api/gateway_marshaler_test.go+++ b/server/api/gateway_marshaler_test.go@@ -47,7 +47,7 @@ func TestGatewayMarshalerKeepsMediaMetadataFieldNames(t *testing.T) {Width: proto.Int32(1920),Height: proto.Int32(1080),Details: &apipb.MediaMetadata_Video{Video: &apipb.VideoMetadata{- DurationSeconds: proto.Float64(12.5),+ DurationSeconds: new(12.5),}},},}diff --git a/server/api/ratelimit.go b/server/api/ratelimit.goindex e39f8e249..b27ee20cf 100644--- a/server/api/ratelimit.go+++ b/server/api/ratelimit.go@@ -45,10 +45,7 @@ const (// RESOURCE_EXHAUSTED with an ErrorInfo naming the reason and scope and a RetryInfo// carrying the delay, so an AIP-194 client knows this recovers in seconds.func newRateLimitError(scope ratelimit.Scope, decision ratelimit.Decision) error {- retryAfter := int(math.Ceil(decision.RetryAfter.Seconds()))- if retryAfter < 1 {- retryAfter = 1- }+ retryAfter := max(int(math.Ceil(decision.RetryAfter.Seconds())), 1)st := status.New(codes.ResourceExhausted, rateLimitMessage)detailed, err := st.WithDetails(&errdetails.ErrorInfo{diff --git a/server/api/test/attachment_service_test.go b/server/api/test/attachment_service_test.goindex 0c49feced..75d3a1b75 100644--- a/server/api/test/attachment_service_test.go+++ b/server/api/test/attachment_service_test.go@@ -714,21 +714,21 @@ func TestCreateAttachmentMediaMetadata(t *testing.T) {Details: &apipb.MediaMetadata_Photo{Photo: &apipb.PhotoMetadata{CaptureTime: &apipb.MediaCaptureTime{LocalDateTime: "2026-08-10T14:32:18.123",- UtcOffset: proto.String("+08:00"),+ UtcOffset: new("+08:00"),},Location: &apipb.MediaLocation{- Latitude: proto.Float64(1.3521),- Longitude: proto.Float64(103.8198),- AltitudeMeters: proto.Float64(18.4),+ Latitude: new(1.3521),+ Longitude: new(103.8198),+ AltitudeMeters: new(18.4),},SourceExifOrientation: proto.Int32(6),CameraMake: "Apple",CameraModel: "iPhone",LensModel: "Main Camera",- FNumber: proto.Float64(1.78),- ExposureTimeSeconds: proto.Float64(1.0 / 120.0),+ FNumber: new(1.78),+ ExposureTimeSeconds: new(1.0 / 120.0),Iso: proto.Int32(64),- FocalLengthMm: proto.Float64(6.86),+ FocalLengthMm: new(6.86),}},}@@ -785,7 +785,7 @@ func TestCreateAttachmentMediaMetadata(t *testing.T) {Width: proto.Int32(1920),Height: proto.Int32(1080),Details: &apipb.MediaMetadata_Video{Video: &apipb.VideoMetadata{- DurationSeconds: proto.Float64(12.5),+ DurationSeconds: new(12.5),}},},},@@ -995,7 +995,7 @@ func TestDeleteMotionMediaGroupChecksBeyondDefaultAttachmentPage(t *testing.T) {}},})require.NoError(t, err)- for i := 0; i < 100; i++ {+ for i := range 100 {attachment, err := ts.Store.CreateAttachment(ctx, &store.Attachment{UID: shortuuid.New(), CreatorID: user.ID, Filename: "filler.txt", Type: "text/plain",})diff --git a/server/api/test/auth_service_sso_username_test.go b/server/api/test/auth_service_sso_username_test.goindex b98e6358d..96f14d00c 100644--- a/server/api/test/auth_service_sso_username_test.go+++ b/server/api/test/auth_service_sso_username_test.go@@ -205,7 +205,7 @@ func TestSSOSignInScopesSameIdentifierByProvider(t *testing.T) {users, err := ts.Store.ListUsers(ctx, &store.FindUser{})require.NoError(t, err)require.Len(t, users, 2)- identities, err := ts.Store.ListUserIdentities(ctx, &store.FindUserIdentity{ExternUID: ptr("alice")})+ identities, err := ts.Store.ListUserIdentities(ctx, &store.FindUserIdentity{ExternUID: new("alice")})require.NoError(t, err)require.Len(t, identities, 2)}@@ -228,14 +228,12 @@ func TestConcurrentSSOFirstSignInConvergesOnOneUser(t *testing.T) {errs := make(chan error, signInCount)var waitGroup sync.WaitGroupfor range signInCount {- waitGroup.Add(1)- go func() {- defer waitGroup.Done()+ waitGroup.Go(func() {<-startresponse, err := signInWithTestingSSO(ctx, ts, idpName, "concurrent-code")results <- responseerrs <- err- }()+ })}close(start)@@ -375,7 +373,3 @@ func assertSingleSSOLink(ctx context.Context, t *testing.T, ts *TestService, prorequire.NoError(t, err)require.Len(t, identities, 1)}--func ptr[T any](value T) *T {- return &value-}diff --git a/server/api/test/instance_admin_cache_test.go b/server/api/test/instance_admin_cache_test.goindex 9960dcbc7..170735d91 100644--- a/server/api/test/instance_admin_cache_test.go+++ b/server/api/test/instance_admin_cache_test.go@@ -44,7 +44,7 @@ func TestInstanceAdminRetrieval(t *testing.T) {require.NoError(t, err)// Multiple calls should return consistent admin user (from cache)- for i := 0; i < 5; i++ {+ for range 5 {profile, err := ts.Service.GetInstanceProfile(ctx, &apipb.GetInstanceProfileRequest{})require.NoError(t, err)require.NotNil(t, profile.Admin)diff --git a/server/api/test/instance_service_test.go b/server/api/test/instance_service_test.goindex df7ce6469..c92bdf126 100644--- a/server/api/test/instance_service_test.go+++ b/server/api/test/instance_service_test.go@@ -113,7 +113,7 @@ func TestGetInstanceProfile_Concurrency(t *testing.T) {results := make(chan *apipb.InstanceProfile, numGoroutines)errors := make(chan error, numGoroutines)- for i := 0; i < numGoroutines; i++ {+ for range numGoroutines {go func() {req := &apipb.GetInstanceProfileRequest{}resp, err := ts.Service.GetInstanceProfile(ctx, req)@@ -126,7 +126,7 @@ func TestGetInstanceProfile_Concurrency(t *testing.T) {}// Collect all results- for i := 0; i < numGoroutines; i++ {+ for range numGoroutines {select {case err := <-errors:t.Fatalf("Goroutine returned error: %v", err)diff --git a/server/api/test/memo_attachment_markdown_test.go b/server/api/test/memo_attachment_markdown_test.goindex b1e15812c..bcf31cd0a 100644--- a/server/api/test/memo_attachment_markdown_test.go+++ b/server/api/test/memo_attachment_markdown_test.go@@ -169,7 +169,7 @@ func TestMemoManagedAttachmentImages(t *testing.T) {UID: shortuuid.New(), CreatorID: user.ID, Filename: "referenced.png", Type: "image/png", MemoID: &memoID,})require.NoError(t, err)- for i := 0; i < 100; i++ {+ for i := range 100 {attachment, err := ts.Store.CreateAttachment(ctx, &store.Attachment{UID: shortuuid.New(), CreatorID: user.ID, Filename: fmt.Sprintf("extra-%03d.png", i), Type: "image/png", MemoID: &memoID,})diff --git a/server/api/test/memo_service_benchmark_test.go b/server/api/test/memo_service_benchmark_test.goindex 035b6906c..3a3ad43d3 100644--- a/server/api/test/memo_service_benchmark_test.go+++ b/server/api/test/memo_service_benchmark_test.go@@ -109,7 +109,7 @@ func seedListMemosBenchmarkData(ctx context.Context, stores *store.Store, hostUstopLevelMemos := make([]*store.Memo, 0, benchmarkTopLevelMemoCount)commentParentName := ""- for i := 0; i < benchmarkTopLevelMemoCount; i++ {+ for i := range benchmarkTopLevelMemoCount {visibility := store.Privateif i%4 == 0 {visibility = store.Publicdiff --git a/server/api/test/memo_service_test.go b/server/api/test/memo_service_test.goindex cd66a6c25..315329628 100644--- a/server/api/test/memo_service_test.go+++ b/server/api/test/memo_service_test.go@@ -76,7 +76,7 @@ func TestInstanceAdminIsSuperuserForNamedMemoOperations(t *testing.T) {spaceMemo, err := ts.Service.CreateMemo(ownerCtx, &apipb.CreateMemoRequest{Memo: &apipb.Memo{Content: "members only",Visibility: apipb.Visibility_SPACE,- Space: ptr("spaces/" + space.UID),+ Space: new("spaces/" + space.UID),}})require.NoError(t, err)@@ -119,12 +119,12 @@ func TestInstanceAdminIsSuperuserForNamedMemoOperations(t *testing.T) {})require.NoError(t, err)_, err = ts.Service.UpdateMemo(adminCtx, &apipb.UpdateMemoRequest{- Memo: &apipb.Memo{Name: private.Name, Visibility: apipb.Visibility_SPACE, Space: ptr("spaces/" + space.UID)},+ Memo: &apipb.Memo{Name: private.Name, Visibility: apipb.Visibility_SPACE, Space: new("spaces/" + space.UID)},UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"visibility", "space"}},})require.NoError(t, err, "an administrator places memos in a Space they are not a member of")_, err = ts.Service.UpdateMemo(adminCtx, &apipb.UpdateMemoRequest{- Memo: &apipb.Memo{Name: private.Name, Space: ptr("spaces/does-not-exist")},+ Memo: &apipb.Memo{Name: private.Name, Space: new("spaces/does-not-exist")},UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"space"}},})require.Equal(t, codes.NotFound, status.Code(err), "structural validity still applies")@@ -971,7 +971,7 @@ func TestListMemoCommentsPaginates(t *testing.T) {})require.NoError(t, err)- for i := 0; i < 3; i++ {+ for i := range 3 {_, err = ts.Service.CreateMemoComment(ownerCtx, &apipb.CreateMemoCommentRequest{Parent: memo.Name,Comment: &apipb.Memo{@@ -1008,7 +1008,7 @@ func TestListMemoCommentsFiltersArchivedBeforePagination(t *testing.T) {require.NoError(t, err)comments := make([]*apipb.Memo, 0, 5)- for i := 0; i < 5; i++ {+ for i := range 5 {comment, err := ts.Service.CreateMemoComment(ownerCtx, &apipb.CreateMemoCommentRequest{Parent: memo.Name,Comment: &apipb.Memo{Content: fmt.Sprintf("comment %d", i)},@@ -1197,7 +1197,7 @@ func TestAssignedMemoCommentListingUsesMemoLocalReadAccess(t *testing.T) {contextMemo, err := ts.Service.CreateMemo(ownerCtx, &apipb.CreateMemoRequest{Memo: &apipb.Memo{Content: "assigned public comment context",Visibility: apipb.Visibility_PUBLIC,- Space: ptr("spaces/" + space.UID),+ Space: new("spaces/" + space.UID),}})require.NoError(t, err)comment, err := ts.Service.CreateMemoComment(memberCtx, &apipb.CreateMemoCommentRequest{diff --git a/server/api/test/memo_share_service_test.go b/server/api/test/memo_share_service_test.goindex 803696518..91f70a858 100644--- a/server/api/test/memo_share_service_test.go+++ b/server/api/test/memo_share_service_test.go@@ -83,7 +83,7 @@ func TestDeleteMemoShare_RevalidatesSpaceWriteAuthority(t *testing.T) {}, owner.ID)require.NoError(t, err)memo, err := ts.Service.CreateMemo(ownerCtx, &apipb.CreateMemoRequest{Memo: &apipb.Memo{- Content: "assigned share", Visibility: apipb.Visibility_PUBLIC, Space: ptr("spaces/" + space.UID),+ Content: "assigned share", Visibility: apipb.Visibility_PUBLIC, Space: new("spaces/" + space.UID),}})require.NoError(t, err)share, err := ts.Service.CreateMemoShare(ownerCtx, &apipb.CreateMemoShareRequest{Parent: memo.Name, MemoShare: &apipb.MemoShare{}})@@ -140,7 +140,7 @@ func TestDeleteMemoShare_OwnerCanRevokeLegacyAdminShare(t *testing.T) {})require.NoError(t, err)- share, err := ts.Store.GetMemoShare(ctx, &store.FindMemoShare{UID: ptr(shareToken)})+ share, err := ts.Store.GetMemoShare(ctx, &store.FindMemoShare{UID: new(shareToken)})require.NoError(t, err)require.Nil(t, share)_, err = ts.Service.GetSharedMemo(ctx, &apipb.GetSharedMemoRequest{ShareToken: shareToken})diff --git a/server/api/test/reaction_service_test.go b/server/api/test/reaction_service_test.goindex 4767c3a55..2b74f92c9 100644--- a/server/api/test/reaction_service_test.go+++ b/server/api/test/reaction_service_test.go@@ -202,7 +202,7 @@ func TestAssignedMemoReactionsFollowMemoReadAccess(t *testing.T) {memo, err := ts.Service.CreateMemo(ownerCtx, &apipb.CreateMemoRequest{Memo: &apipb.Memo{Content: "assigned public memo with reactions",Visibility: apipb.Visibility_PUBLIC,- Space: ptr("spaces/" + space.UID),+ Space: new("spaces/" + space.UID),}})require.NoError(t, err)_, err = ts.Service.UpsertMemoReaction(ownerCtx, &apipb.UpsertMemoReactionRequest{diff --git a/server/api/test/user_notification_test.go b/server/api/test/user_notification_test.goindex 6bf8d3eca..903f3d6af 100644--- a/server/api/test/user_notification_test.go+++ b/server/api/test/user_notification_test.go@@ -150,7 +150,7 @@ func TestAssignedPublicMemoCommentNotifiesReadableRemovedAuthor(t *testing.T) {memo, err := ts.Service.CreateMemo(ownerCtx, &apipb.CreateMemoRequest{Memo: &apipb.Memo{Content: "assigned public memo",Visibility: apipb.Visibility_PUBLIC,- Space: ptr("spaces/" + space.UID),+ Space: new("spaces/" + space.UID),}})require.NoError(t, err)require.NoError(t, ts.Store.DeleteSpaceMember(ctx, &store.DeleteSpaceMember{SpaceID: space.ID, UserID: owner.ID}, owner.ID))diff --git a/server/api/test/user_service_pagination_test.go b/server/api/test/user_service_pagination_test.goindex 582ca8e4a..a7244def6 100644--- a/server/api/test/user_service_pagination_test.go+++ b/server/api/test/user_service_pagination_test.go@@ -42,7 +42,7 @@ func TestListUsersPagination(t *testing.T) {// Admin + 5 members = 6 users total.expected := map[string]struct{}{"admin": {}}- for i := 0; i < 5; i++ {+ for i := range 5 {name := fmt.Sprintf("member-%d", i)_, err := ts.CreateRegularUser(ctx, name)require.NoError(t, err)@@ -74,7 +74,7 @@ func TestListUsersDefaultPageSizeReturnsAllWhenSmall(t *testing.T) {admin, err := ts.CreateHostUser(ctx, "admin")require.NoError(t, err)adminCtx := ts.CreateUserContext(ctx, admin.ID)- for i := 0; i < 3; i++ {+ for i := range 3 {_, err := ts.CreateRegularUser(ctx, fmt.Sprintf("member-%d", i))require.NoError(t, err)}diff --git a/server/mcp/adapter.go b/server/mcp/adapter.goindex e07ad3c47..86035d3d7 100644--- a/server/mcp/adapter.go+++ b/server/mcp/adapter.go@@ -161,12 +161,12 @@ func pathPlaceholderNames(path string) []string {// segments match the other arguments. Bare IDs pass through unchanged.func trimResourceNamePrefix(path, parameterName, value string, resolved map[string]string) string {placeholder := "/{" + parameterName + "}"- index := strings.Index(path, placeholder)- if index < 0 {+ before, _, found := strings.Cut(path, placeholder)+ if !found {return value}- prefix, ok := resolvedResourceNamePrefix(path[:index], resolved)+ prefix, ok := resolvedResourceNamePrefix(before, resolved)if !ok || prefix == "" {return value}diff --git a/server/mcp/catalog.go b/server/mcp/catalog.goindex e7faa5a42..25c77373c 100644--- a/server/mcp/catalog.go+++ b/server/mcp/catalog.go@@ -269,9 +269,7 @@ func inputSchemaForOperation(operation *openAPIOperation) jsonSchema {if operation.RequestBody != nil {bodySchema := requestBodySchema(operation)- for name, definition := range extractSchemaDefs(bodySchema) {- defs[name] = definition- }+ maps.Copy(defs, extractSchemaDefs(bodySchema))properties["body"] = bodySchemaif requestBodyRequired(operation) {required = append(required, "body")@@ -331,9 +329,7 @@ func outputSchemaForOperation(operation *openAPIOperation) jsonSchema {func cloneSchema(schema jsonSchema) jsonSchema {clone := jsonSchema{}- for key, value := range schema {- clone[key] = value- }+ maps.Copy(clone, schema)return clone}diff --git a/store/auth_config.go b/store/auth_config.goindex 0b0338139..899e18475 100644--- a/store/auth_config.go+++ b/store/auth_config.go@@ -71,7 +71,7 @@ func (s *Store) applyAuthenticationConfigMutation(ctx context.Context, mutationdefer s.authConfigMu.Unlock()var err error- for attempt := 0; attempt < authenticationMutationMaxAttempts; attempt++ {+ for attempt := range authenticationMutationMaxAttempts {err = s.driver.ApplyAuthenticationConfigMutation(ctx, mutation)if err == nil || !s.driver.IsRetryableAuthenticationMutationError(err) {return errdiff --git a/store/cache/cache_test.go b/store/cache/cache_test.goindex 1be1eca94..877cdab94 100644--- a/store/cache/cache_test.go+++ b/store/cache/cache_test.go@@ -66,13 +66,13 @@ func TestCacheEviction(t *testing.T) {defer cache.Close()// Add 5 items (max capacity)- for i := 0; i < 5; i++ {+ for i := range 5 {key := fmt.Sprintf("key%d", i)cache.Set(ctx, key, i)}// Verify all 5 items are in the cache- for i := 0; i < 5; i++ {+ for i := range 5 {key := fmt.Sprintf("key%d", i)if _, ok := cache.Get(ctx, key); !ok {t.Errorf("Key '%s' should be in the cache", key)@@ -90,7 +90,7 @@ func TestCacheEviction(t *testing.T) {// Some of the original keys should have been evictedevictedCount := 0- for i := 0; i < 5; i++ {+ for i := range 5 {key := fmt.Sprintf("key%d", i)if _, ok := cache.Get(ctx, key); !ok {evictedCount++@@ -121,21 +121,21 @@ func TestCacheConcurrency(t *testing.T) {var wg sync.WaitGroupwg.Add(goroutines)- for i := 0; i < goroutines; i++ {+ for i := range goroutines {go func(id int) {defer wg.Done()baseKey := fmt.Sprintf("worker%d-", id)// Set operations- for j := 0; j < operationsPerGoroutine; j++ {+ for j := range operationsPerGoroutine {key := fmt.Sprintf("%skey%d", baseKey, j)value := fmt.Sprintf("value%d-%d", id, j)cache.Set(ctx, key, value)}// Get operations- for j := 0; j < operationsPerGoroutine; j++ {+ for j := range operationsPerGoroutine {key := fmt.Sprintf("%skey%d", baseKey, j)val, ok := cache.Get(ctx, key)if !ok {@@ -149,7 +149,7 @@ func TestCacheConcurrency(t *testing.T) {}// Delete half the keys- for j := 0; j < operationsPerGoroutine/2; j++ {+ for j := range operationsPerGoroutine / 2 {key := fmt.Sprintf("%skey%d", baseKey, j)cache.Delete(ctx, key)}@@ -167,13 +167,13 @@ func TestCacheConcurrency(t *testing.T) {func TestEvictionCallback(t *testing.T) {ctx := context.Background()- evicted := make(map[string]interface{})+ evicted := make(map[string]any)evictedMu := sync.Mutex{}config := DefaultConfig()config.DefaultTTL = 50 * time.Millisecondconfig.CleanupInterval = 25 * time.Millisecond- config.OnEviction = func(key string, value interface{}) {+ config.OnEviction = func(key string, value any) {evictedMu.Lock()evicted[key] = valueevictedMu.Unlock()diff --git a/store/custom_icon.go b/store/custom_icon.goindex ee814ffe4..4616755b2 100644--- a/store/custom_icon.go+++ b/store/custom_icon.go@@ -19,7 +19,7 @@ func validateLucideIcon(name string) error {if len(name) == 0 || len(name) > 128 {return errors.New("icon name must contain 1 to 128 bytes")}- for _, part := range strings.Split(name, "-") {+ for part := range strings.SplitSeq(name, "-") {if part == "" {return errors.New("icon name must use lowercase kebab-case")}diff --git a/store/db/postgres/common.go b/store/db/postgres/common.goindex b4f074d62..65f5cc54e 100644--- a/store/db/postgres/common.go+++ b/store/db/postgres/common.go@@ -19,7 +19,7 @@ func placeholder(n int) string {func placeholders(n int) string {list := []string{}- for i := 0; i < n; i++ {+ for i := range n {list = append(list, placeholder(i+1))}return strings.Join(list, ", ")diff --git a/store/demo_seed_test.go b/store/demo_seed_test.goindex 795df6137..6fe45ba6e 100644--- a/store/demo_seed_test.go+++ b/store/demo_seed_test.go@@ -43,7 +43,7 @@ func TestDemoSeedUsesDeploymentAuthenticationPolicy(t *testing.T) {require.NoError(t, err)require.True(t, generalSetting.DisallowPasswordAuth)require.False(t, generalSetting.DisallowUserRegistration, "SSO first-login provisioning must remain enabled")- provider, err := stores.GetIdentityProvider(ctx, &store.FindIdentityProvider{UID: ptr("primary-sso")})+ provider, err := stores.GetIdentityProvider(ctx, &store.FindIdentityProvider{UID: new("primary-sso")})require.NoError(t, err)require.NotNil(t, provider)diff --git a/store/deployment_config_test.go b/store/deployment_config_test.goindex 0ef2ce0bf..db3237729 100644--- a/store/deployment_config_test.go+++ b/store/deployment_config_test.go@@ -27,7 +27,7 @@ func TestLoadDeploymentConfigurationPublishesRuntimeOnlyIdentityProvider(t *testrequire.NoError(t, stores.LoadDeploymentConfigurationDir(ctx, dir))- effective, err := stores.GetIdentityProvider(ctx, &store.FindIdentityProvider{UID: ptr("primary-sso")})+ effective, err := stores.GetIdentityProvider(ctx, &store.FindIdentityProvider{UID: new("primary-sso")})require.NoError(t, err)require.NotNil(t, effective)assert.Zero(t, effective.Id)@@ -35,7 +35,7 @@ func TestLoadDeploymentConfigurationPublishesRuntimeOnlyIdentityProvider(t *testassert.Equal(t, "file-secret", effective.Config.GetOauth2Config().ClientSecret)assert.True(t, stores.IsIdentityProviderDeploymentConfigured("primary-sso"))- stored, err := stores.GetStoredIdentityProvider(ctx, &store.FindIdentityProvider{UID: ptr("primary-sso")})+ stored, err := stores.GetStoredIdentityProvider(ctx, &store.FindIdentityProvider{UID: new("primary-sso")})require.NoError(t, err)assert.Nil(t, stored)}@@ -59,10 +59,10 @@ func TestLoadDeploymentConfigurationShadowsWithoutChangingStoredResources(t *teswriteDeploymentGeneralSetting(t, filepath.Join(dir, "memos-instance-setting-general.json"), 4, true)require.NoError(t, stores.LoadDeploymentConfigurationDir(ctx, dir))- effectiveProvider, err := stores.GetIdentityProvider(ctx, &store.FindIdentityProvider{UID: ptr("primary-sso")})+ effectiveProvider, err := stores.GetIdentityProvider(ctx, &store.FindIdentityProvider{UID: new("primary-sso")})require.NoError(t, err)assert.Equal(t, "File SSO", effectiveProvider.Name)- storedProvider, err := stores.GetStoredIdentityProvider(ctx, &store.FindIdentityProvider{UID: ptr("primary-sso")})+ storedProvider, err := stores.GetStoredIdentityProvider(ctx, &store.FindIdentityProvider{UID: new("primary-sso")})require.NoError(t, err)assert.Equal(t, storedID, storedProvider.Id)assert.Equal(t, "Stored SSO", storedProvider.Name)@@ -85,11 +85,11 @@ func TestLoadDeploymentConfigurationReturnsDefensiveClones(t *testing.T) {writeDeploymentGeneralSetting(t, filepath.Join(dir, "memos-instance-setting-general.json"), 2, false)require.NoError(t, stores.LoadDeploymentConfigurationDir(ctx, dir))- provider, err := stores.GetIdentityProvider(ctx, &store.FindIdentityProvider{UID: ptr("primary-sso")})+ provider, err := stores.GetIdentityProvider(ctx, &store.FindIdentityProvider{UID: new("primary-sso")})require.NoError(t, err)provider.Name = "Mutated"provider.Config.GetOauth2Config().ClientSecret = "mutated-secret"- providerAgain, err := stores.GetIdentityProvider(ctx, &store.FindIdentityProvider{UID: ptr("primary-sso")})+ providerAgain, err := stores.GetIdentityProvider(ctx, &store.FindIdentityProvider{UID: new("primary-sso")})require.NoError(t, err)assert.Equal(t, "File SSO", providerAgain.Name)assert.Equal(t, "file-secret", providerAgain.Config.GetOauth2Config().ClientSecret)@@ -116,7 +116,7 @@ func TestLoadDeploymentConfigurationPublishesAtomically(t *testing.T) {require.Error(t, err)assert.ErrorContains(t, err, `unknown field "unknown"`)- provider, getErr := stores.GetIdentityProvider(ctx, &store.FindIdentityProvider{UID: ptr("primary-sso")})+ provider, getErr := stores.GetIdentityProvider(ctx, &store.FindIdentityProvider{UID: new("primary-sso")})require.NoError(t, getErr)assert.Equal(t, "File SSO", provider.Name)}@@ -502,7 +502,3 @@ func assertBool(value bool) string {}return "false"}--func ptr[T any](value T) *T {- return &value-}diff --git a/store/migrator.go b/store/migrator.goindex 1cc643159..026e6b8a1 100644--- a/store/migrator.go+++ b/store/migrator.go@@ -376,7 +376,7 @@ func getSchemaVersionOfMigrateScript(filePath string) (string, error) {return "", err}series := elements[len(elements)-2]- rawSequence := strings.Split(elements[len(elements)-1], MigrateFileNameSplit)[0]+ rawSequence, _, _ := strings.Cut(elements[len(elements)-1], MigrateFileNameSplit)sequence, err := strconv.Atoi(rawSequence)if err != nil {return "", errors.Wrapf(err, "failed to convert migration sequence to int: %s", rawSequence)diff --git a/store/test/attachment_test.go b/store/test/attachment_test.goindex ac2b46f13..c675bf008 100644--- a/store/test/attachment_test.go+++ b/store/test/attachment_test.go@@ -562,7 +562,7 @@ func TestAttachmentListWithPagination(t *testing.T) {ts := NewTestingStore(ctx, t)// Create 5 attachments- for i := 0; i < 5; i++ {+ for i := range 5 {_, err := ts.CreateAttachment(ctx, &store.Attachment{UID: shortuuid.New(),CreatorID: 101,@@ -642,7 +642,7 @@ func TestMemoMutationConcurrentUpdatesNoSQLiteBusy(t *testing.T) {errs := make([]error, workers)var wg sync.WaitGroupcontent := "updated"- for i := 0; i < workers; i++ {+ for i := range workers {wg.Go(func() {<-starterrs[i] = ts.ApplyMemoMutation(ctx, &store.MemoMutation{@@ -681,7 +681,7 @@ func TestMemoMutationConcurrentUpdatesSameMemoNoSQLiteBusy(t *testing.T) {errs := make([]error, workers)var wg sync.WaitGroupcontent := "updated"- for i := 0; i < workers; i++ {+ for i := range workers {wg.Go(func() {<-starterrs[i] = ts.ApplyMemoMutation(ctx, &store.MemoMutation{diff --git a/store/test/filter_helpers_test.go b/store/test/filter_helpers_test.goindex 8e36f78cd..08aa5d1a7 100644--- a/store/test/filter_helpers_test.go+++ b/store/test/filter_helpers_test.go@@ -28,14 +28,6 @@ func formatInt(n int) string {return strconv.Itoa(n)}-// =============================================================================-// Pointer Helpers-// =============================================================================--func boolPtr(b bool) *bool {- return &b-}-// =============================================================================// Test Fixture Builders// =============================================================================@@ -173,7 +165,7 @@ func (tc *MemoFilterTestContext) CreateMemo(b *MemoBuilder) *store.Memo {func (tc *MemoFilterTestContext) PinMemo(memoID int32) {err := tc.Store.UpdateMemo(tc.Ctx, &store.UpdateMemo{ID: memoID,- Pinned: boolPtr(true),+ Pinned: new(true),})require.NoError(tc.T, err)}diff --git a/store/test/inbox_test.go b/store/test/inbox_test.goindex 68e7ab2ef..e757bad28 100644--- a/store/test/inbox_test.go+++ b/store/test/inbox_test.go@@ -215,7 +215,7 @@ func TestInboxListPagination(t *testing.T) {require.NoError(t, err)// Create 5 inboxes- for i := 0; i < 5; i++ {+ for range 5 {_, err = ts.CreateInbox(ctx, &store.Inbox{SenderID: 0,ReceiverID: user.ID,@@ -520,7 +520,7 @@ func TestInboxMessageTypeFilterWithStatusAndPagination(t *testing.T) {require.NoError(t, err)// Create multiple inboxes with various combinations- for i := 0; i < 5; i++ {+ for range 5 {_, err = ts.CreateInbox(ctx, &store.Inbox{SenderID: 0,ReceiverID: user.ID,@@ -533,7 +533,7 @@ func TestInboxMessageTypeFilterWithStatusAndPagination(t *testing.T) {// Archive 2 of themallInboxes, err := ts.ListInboxes(ctx, &store.FindInbox{ReceiverID: &user.ID})require.NoError(t, err)- for i := 0; i < 2; i++ {+ for i := range 2 {_, err = ts.UpdateInbox(ctx, &store.UpdateInbox{ID: allInboxes[i].ID, Status: store.ARCHIVED})require.NoError(t, err)}diff --git a/store/test/instance_setting_test.go b/store/test/instance_setting_test.goindex 8d40d120d..d85dfdc0e 100644--- a/store/test/instance_setting_test.go+++ b/store/test/instance_setting_test.go@@ -200,7 +200,7 @@ func TestCreateInstanceSettingIfNotExistsIsFirstWriterWins(t *testing.T) {}start := make(chan struct{})results := make(chan result, candidateCount)- for i := 0; i < candidateCount; i++ {+ for i := range candidateCount {value := fmt.Sprintf("candidate-%02d", i)go func() {<-startdiff --git a/store/test/memo_test.go b/store/test/memo_test.goindex 51a2d141a..5d25b56cf 100644--- a/store/test/memo_test.go+++ b/store/test/memo_test.go@@ -252,7 +252,7 @@ func TestMemoListWithPagination(t *testing.T) {require.NoError(t, err)// Create 10 memos- for i := 0; i < 10; i++ {+ for i := range 10 {_, err := ts.CreateMemo(ctx, &store.Memo{UID: fmt.Sprintf("memo-%d", i),CreatorID: user.ID,diff --git a/store/test/migrator_test.go b/store/test/migrator_test.goindex 44a677fcc..7b0e07308 100644--- a/store/test/migrator_test.go+++ b/store/test/migrator_test.go@@ -158,7 +158,7 @@ func TestMigrationMultipleReRuns(t *testing.T) {require.NoError(t, err)// Run migration multiple times- for i := 0; i < 3; i++ {+ for i := range 3 {err = ts.Migrate(ctx)require.NoError(t, err, "migration run %d should not fail", i+1)}diff --git a/store/test/user_setting_test.go b/store/test/user_setting_test.goindex 0de61da82..368899386 100644--- a/store/test/user_setting_test.go+++ b/store/test/user_setting_test.go@@ -745,7 +745,7 @@ func TestUserSettingGetUserByPATHashLargeTokenCount(t *testing.T) {// Create many PATs for the same usertokenCount := 10hashes := make([]string, tokenCount)- for i := 0; i < tokenCount; i++ {+ for i := range tokenCount {hashes[i] = "pat-hash-" + string(rune('A'+i)) + "-large-test"err = ts.AddUserPersonalAccessToken(ctx, user.ID, &storepb.PersonalAccessTokensUserSetting_PersonalAccessToken{TokenId: "pat-large-" + string(rune('A'+i)),diff --git a/store/test/user_test.go b/store/test/user_test.goindex baee99445..b12af7aef 100644--- a/store/test/user_test.go+++ b/store/test/user_test.go@@ -48,7 +48,7 @@ func TestUserListByIDList(t *testing.T) {// Create 5 usersvar userIDs []int32- for i := 0; i < 5; i++ {+ for i := range 5 {user, err := createTestingUserWithRole(ctx, ts, fmt.Sprintf("user_list_%d", i), store.RoleUser)require.NoError(t, err)userIDs = append(userIDs, user.ID)@@ -266,7 +266,7 @@ func TestUserListWithLimit(t *testing.T) {ts := NewTestingStore(ctx, t)// Create 5 users- for i := 0; i < 5; i++ {+ for i := range 5 {role := store.RoleUserif i == 0 {role = store.RoleAdmindiff --git a/store/user_unique.go b/store/user_unique.goindex f0d48d671..32df7b759 100644--- a/store/user_unique.go+++ b/store/user_unique.go@@ -43,11 +43,11 @@ func classifyUserUniqueViolation(err error) error {}message := err.Error()for _, marker := range uniqueViolationMarkers {- index := strings.Index(message, marker)- if index < 0 {+ _, after, ok := strings.Cut(message, marker)+ if !ok {continue}- target := message[index+len(marker):]+ target := afterswitch {case strings.Contains(target, "user_identity"):return errors.Wrap(ErrUserIdentityTaken, message)