Răsfoiți Sursa

chore: upgrade to Go 1.27

Apply go fix modernizers, including the Go 1.27 initialization of
promoted fields in composite literals.
Frédéric Guillot 1 oră în urmă
părinte
comite
e5b69b4155

+ 1 - 1
CONTRIBUTING.md

@@ -35,7 +35,7 @@ When reporting bugs:
 ### Requirements
 
 - **Git**
-- **Go >= 1.26**
+- **Go >= 1.27**
 - **PostgreSQL**
 
 ### Getting Started

+ 7 - 9
client/client_test.go

@@ -1371,8 +1371,6 @@ func TestUpdateEnclosure(t *testing.T) {
 	}
 }
 
-func boolPtr(b bool) *bool { return &b }
-
 func TestEntryIDsFilterSerialization(t *testing.T) {
 	tests := []struct {
 		name   string
@@ -1389,7 +1387,7 @@ func TestEntryIDsFilterSerialization(t *testing.T) {
 		},
 		{
 			name:   "starred_false",
-			filter: &EntryIDsFilter{Starred: boolPtr(false)},
+			filter: &EntryIDsFilter{Starred: new(false)},
 			query:  "?starred=false",
 		},
 		{
@@ -1479,12 +1477,12 @@ func TestEntryIDsFilterSerialization(t *testing.T) {
 		},
 		{
 			name:   "globally_visible_true",
-			filter: &EntryIDsFilter{GloballyVisible: boolPtr(true)},
+			filter: &EntryIDsFilter{GloballyVisible: new(true)},
 			query:  "?globally_visible=true",
 		},
 		{
 			name:   "globally_visible_false",
-			filter: &EntryIDsFilter{GloballyVisible: boolPtr(false)},
+			filter: &EntryIDsFilter{GloballyVisible: new(false)},
 			query:  "?globally_visible=false",
 		},
 		{
@@ -1588,7 +1586,7 @@ func TestEntryIDsWithAllFilters(t *testing.T) {
 	filter := &EntryIDsFilter{
 		Limit:           2,
 		Offset:          5,
-		Starred:         boolPtr(false),
+		Starred:         new(false),
 		Status:          "removed",
 		Order:           "published_at",
 		Direction:       "asc",
@@ -1605,7 +1603,7 @@ func TestEntryIDsWithAllFilters(t *testing.T) {
 		Search:          `go & "rss"`,
 		Statuses:        []string{EntryStatusUnread, EntryStatusRead},
 		Tags:            []string{"go", "release notes"},
-		GloballyVisible: boolPtr(false),
+		GloballyVisible: new(false),
 	}
 	expected := &EntryIDsResultSet{Total: 1, EntryIDs: []int64{42}}
 	const expectedURL = "http://mf/v1/entries/ids?after=1700000000&after_entry_id=10" +
@@ -1685,7 +1683,7 @@ func TestEntryIDsWithStarredFilter(t *testing.T) {
 				expectRequest(t, http.MethodGet, "http://mf/v1/entries/ids?starred=true", nil, req)
 				return jsonResponseFrom(t, http.StatusOK, http.Header{}, expected)
 			})))
-	res, err := client.EntryIDsContext(t.Context(), &EntryIDsFilter{Starred: boolPtr(true)})
+	res, err := client.EntryIDsContext(t.Context(), &EntryIDsFilter{Starred: new(true)})
 	if err != nil {
 		t.Fatalf("Expected no error, got %v", err)
 	}
@@ -1727,7 +1725,7 @@ func TestEntryIDsWithCombinedFilter(t *testing.T) {
 				expectRequest(t, http.MethodGet, "http://mf/v1/entries/ids?limit=2&offset=5&starred=false&status=read", nil, req)
 				return jsonResponseFrom(t, http.StatusOK, http.Header{}, expected)
 			})))
-	res, err := client.EntryIDsContext(t.Context(), &EntryIDsFilter{Limit: 2, Offset: 5, Starred: boolPtr(false), Status: EntryStatusRead})
+	res, err := client.EntryIDsContext(t.Context(), &EntryIDsFilter{Limit: 2, Offset: 5, Starred: new(false), Status: EntryStatusRead})
 	if err != nil {
 		t.Fatalf("Expected no error, got %v", err)
 	}

+ 5 - 8
go.mod

@@ -2,8 +2,8 @@ module miniflux.app/v2
 
 // When changing version here don't forget to also upgrade CONTRIBUTING.md
 
-// +heroku goVersion go1.26
-go 1.26.0
+// +heroku goVersion go1.27
+go 1.27.0
 
 require (
 	github.com/PuerkitoBio/goquery v1.14.0
@@ -22,18 +22,15 @@ require (
 	golang.org/x/text v0.44.0
 )
 
-require (
-	github.com/go-webauthn/x v0.3.1 // indirect
-	github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
-	github.com/google/go-tpm v0.9.8 // indirect
-)
-
 require (
 	github.com/beorn7/perks v1.0.1 // indirect
 	github.com/cespare/xxhash/v2 v2.3.0 // indirect
 	github.com/fxamacker/cbor/v2 v2.10.0 // indirect
 	github.com/go-jose/go-jose/v4 v4.1.7 // indirect
 	github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
+	github.com/go-webauthn/x v0.3.1 // indirect
+	github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
+	github.com/google/go-tpm v0.9.8 // indirect
 	github.com/google/uuid v1.6.0 // indirect
 	github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
 	github.com/pandatix/go-abnf v0.5.5 // indirect

+ 2 - 3
internal/fever/isolation_integration_test.go

@@ -4,6 +4,7 @@
 package fever_test
 
 import (
+	"maps"
 	"net/url"
 	"strings"
 	"testing"
@@ -48,9 +49,7 @@ func TestUsersCannotReadOtherUsersData(t *testing.T) {
 	for _, scenario := range itemScenarios {
 		t.Run(scenario.name, func(t *testing.T) {
 			query := selector("items")
-			for key, values := range scenario.params {
-				query[key] = values
-			}
+			maps.Copy(query, scenario.params)
 
 			var result itemsResult
 			intruder.fever.getJSON(t, query, &result)

+ 2 - 3
internal/fever/items_integration_test.go

@@ -5,6 +5,7 @@ package fever_test
 
 import (
 	"cmp"
+	"maps"
 	"net/url"
 	"slices"
 	"strconv"
@@ -108,9 +109,7 @@ func TestItemsSelection(t *testing.T) {
 	for _, scenario := range scenarios {
 		t.Run(scenario.name, func(t *testing.T) {
 			query := selector("items")
-			for key, values := range scenario.params {
-				query[key] = values
-			}
+			maps.Copy(query, scenario.params)
 
 			var result itemsResult
 			user.fever.getJSON(t, query, &result)

+ 2 - 3
internal/googlereader/edit_tag_integration_test.go

@@ -4,6 +4,7 @@
 package googlereader_test
 
 import (
+	"maps"
 	"net/http"
 	"net/url"
 	"slices"
@@ -61,9 +62,7 @@ func TestEditTagEndpoint(t *testing.T) {
 			}
 
 			form := url.Values{"i": {strconv.FormatInt(entries[0].ID, 10), longItemID(entries[1].ID)}}
-			for key, list := range scenario.form {
-				form[key] = list
-			}
+			maps.Copy(form, scenario.form)
 			user.reader.postOK(t, "/reader/api/0/edit-tag", form)
 
 			entries = servertest.FeedEntries(t, user.rest, feedID)

+ 3 - 5
internal/googlereader/stream_integration_test.go

@@ -5,6 +5,7 @@ package googlereader_test
 
 import (
 	"fmt"
+	"maps"
 	"net/http"
 	"net/url"
 	"reflect"
@@ -141,9 +142,7 @@ func TestStreamItemIDsRejectsInvalidStreams(t *testing.T) {
 	for _, scenario := range scenarios {
 		t.Run(scenario.name, func(t *testing.T) {
 			query := url.Values{"output": {"json"}}
-			for key, list := range scenario.query {
-				query[key] = list
-			}
+			maps.Copy(query, scenario.query)
 
 			status, body := user.reader.get(t, "/reader/api/0/stream/items/ids", query)
 			requireStatus(t, status, body, http.StatusBadRequest)
@@ -199,8 +198,7 @@ func TestStreamItemContentsEndpoint(t *testing.T) {
 
 	// The items are sorted newest first.
 	expected := make([]itemResult, 0, len(entries))
-	for index := len(entries) - 1; index >= 0; index-- {
-		entry := entries[index]
+	for index, entry := range slices.Backward(entries) {
 		expected = append(expected, itemResult{
 			ID:         longItemID(entry.ID),
 			Title:      entry.Title,

+ 3 - 6
internal/googlereader/subscription_integration_test.go

@@ -5,6 +5,7 @@ package googlereader_test
 
 import (
 	"fmt"
+	"maps"
 	"net/http"
 	"net/http/httptest"
 	"net/url"
@@ -179,9 +180,7 @@ func TestEditSubscriptionSubscribe(t *testing.T) {
 			fixture := servertest.NewFeedFixture(t)
 
 			form := url.Values{"ac": {"subscribe"}, "s": {"feed/" + fixture.FeedURL}}
-			for key, list := range scenario.form {
-				form[key] = list
-			}
+			maps.Copy(form, scenario.form)
 			user.reader.postOK(t, "/reader/api/0/subscription/edit", form)
 
 			feeds := userFeeds(t, user)
@@ -225,9 +224,7 @@ func TestEditSubscriptionEdit(t *testing.T) {
 			}
 
 			form := url.Values{"ac": {"edit"}, "s": {feedStream(feedID)}}
-			for key, list := range scenario.form {
-				form[key] = list
-			}
+			maps.Copy(form, scenario.form)
 			user.reader.postOK(t, "/reader/api/0/subscription/edit", form)
 
 			feed, err := user.rest.Feed(feedID)

+ 1 - 1
internal/locale/catalog_test.go

@@ -40,7 +40,7 @@ func TestGetTranslationDictConcurrency(t *testing.T) {
 	const iterations = 10
 
 	var wg sync.WaitGroup
-	for i := 0; i < iterations; i++ {
+	for range iterations {
 		for language := range AvailableLanguages {
 			wg.Add(1)
 			go func(language string) {

+ 1 - 1
internal/template/engine_test.go

@@ -37,7 +37,7 @@ func TestRenderConcurrency(t *testing.T) {
 	var mu sync.Mutex
 	mismatches := make(map[string]int)
 
-	for i := 0; i < iterations; i++ {
+	for i := range iterations {
 		language := languages[i%len(languages)]
 		wg.Add(1)
 		go func(language string) {

+ 22 - 24
internal/ui/subscription_submit.go

@@ -90,30 +90,28 @@ func (h *handler) submitSubscription(w http.ResponseWriter, r *http.Request) {
 		v.HTML(w, r, "add_subscription")
 	case n == 1 && subscriptionFinder.IsFeedAlreadyDownloaded():
 		feed, localizedError := feedHandler.CreateFeedFromSubscriptionDiscovery(h.store, user.ID, &model.FeedCreationRequestFromSubscriptionDiscovery{
-			Content:      subscriptionFinder.FeedResponseInfo().Content,
-			ETag:         subscriptionFinder.FeedResponseInfo().ETag,
-			LastModified: subscriptionFinder.FeedResponseInfo().LastModified,
-			FeedCreationRequest: model.FeedCreationRequest{
-				CategoryID:                  subscriptionForm.CategoryID,
-				FeedURL:                     subscriptions[0].URL,
-				AllowSelfSignedCertificates: subscriptionForm.AllowSelfSignedCertificates,
-				Crawler:                     subscriptionForm.Crawler,
-				IgnoreEntryUpdates:          subscriptionForm.IgnoreEntryUpdates,
-				UserAgent:                   subscriptionForm.UserAgent,
-				Cookie:                      subscriptionForm.Cookie,
-				Username:                    subscriptionForm.Username,
-				Password:                    subscriptionForm.Password,
-				ScraperRules:                subscriptionForm.ScraperRules,
-				RewriteRules:                subscriptionForm.RewriteRules,
-				UrlRewriteRules:             subscriptionForm.UrlRewriteRules,
-				BlocklistRules:              subscriptionForm.BlocklistRules,
-				KeeplistRules:               subscriptionForm.KeeplistRules,
-				KeepFilterEntryRules:        subscriptionForm.KeepFilterEntryRules,
-				BlockFilterEntryRules:       subscriptionForm.BlockFilterEntryRules,
-				FetchViaProxy:               subscriptionForm.FetchViaProxy,
-				DisableHTTP2:                subscriptionForm.DisableHTTP2,
-				ProxyURL:                    subscriptionForm.ProxyURL,
-			},
+			Content:                     subscriptionFinder.FeedResponseInfo().Content,
+			ETag:                        subscriptionFinder.FeedResponseInfo().ETag,
+			LastModified:                subscriptionFinder.FeedResponseInfo().LastModified,
+			CategoryID:                  subscriptionForm.CategoryID,
+			FeedURL:                     subscriptions[0].URL,
+			AllowSelfSignedCertificates: subscriptionForm.AllowSelfSignedCertificates,
+			Crawler:                     subscriptionForm.Crawler,
+			IgnoreEntryUpdates:          subscriptionForm.IgnoreEntryUpdates,
+			UserAgent:                   subscriptionForm.UserAgent,
+			Cookie:                      subscriptionForm.Cookie,
+			Username:                    subscriptionForm.Username,
+			Password:                    subscriptionForm.Password,
+			ScraperRules:                subscriptionForm.ScraperRules,
+			RewriteRules:                subscriptionForm.RewriteRules,
+			UrlRewriteRules:             subscriptionForm.UrlRewriteRules,
+			BlocklistRules:              subscriptionForm.BlocklistRules,
+			KeeplistRules:               subscriptionForm.KeeplistRules,
+			KeepFilterEntryRules:        subscriptionForm.KeepFilterEntryRules,
+			BlockFilterEntryRules:       subscriptionForm.BlockFilterEntryRules,
+			FetchViaProxy:               subscriptionForm.FetchViaProxy,
+			DisableHTTP2:                subscriptionForm.DisableHTTP2,
+			ProxyURL:                    subscriptionForm.ProxyURL,
 		})
 		if localizedError != nil {
 			v.Set("form", subscriptionForm)