fix(seed): resolve lint issues (noctx, goconst)

This commit is contained in:
2026-02-22 11:41:33 +01:00
parent 993bab1218
commit 549df60f09

View File

@@ -94,7 +94,7 @@ func run() error {
cacheKey := m.Zip + ":" + m.City + ":" + country
coords, ok := geoCache[cacheKey]
if !ok {
lat, lon, geoErr := geocode(client, m.City, m.Zip, country)
lat, lon, geoErr := geocode(ctx, client, m.City, m.Zip, country)
if geoErr != nil {
slog.Warn("geocode failed, using default", "city", m.City, "zip", m.Zip, "err", geoErr)
lat, lon = 51.1657, 10.4515
@@ -192,7 +192,7 @@ func parseDate(s string) string {
return fmt.Sprintf("2026-%02d-%02d", month, day)
}
func geocode(client *http.Client, city, zip, country string) (float64, float64, error) {
func geocode(ctx context.Context, client *http.Client, city, zip, country string) (float64, float64, error) {
q := url.Values{}
q.Set("format", "json")
q.Set("limit", "1")
@@ -202,7 +202,7 @@ func geocode(client *http.Client, city, zip, country string) (float64, float64,
}
q.Set("countrycodes", strings.ToLower(country))
req, err := http.NewRequest("GET", "https://nominatim.openstreetmap.org/search?"+q.Encode(), nil)
req, err := http.NewRequestWithContext(ctx, "GET", "https://nominatim.openstreetmap.org/search?"+q.Encode(), nil)
if err != nil {
return 0, 0, err
}
@@ -241,6 +241,11 @@ func geocode(client *http.Client, city, zip, country string) (float64, float64,
}
func stateFromZip(zip, country string) string {
const (
niedersachsen = "Niedersachsen"
nrw = "Nordrhein-Westfalen"
bw = "Baden-Württemberg"
)
if country != "DE" || len(zip) < 2 {
return ""
}
@@ -265,25 +270,25 @@ func stateFromZip(zip, country string) string {
case prefix <= 25:
return "Schleswig-Holstein"
case prefix <= 27:
return "Niedersachsen"
return niedersachsen
case prefix == 28:
return "Bremen"
case prefix <= 31:
return "Niedersachsen"
return niedersachsen
case prefix <= 33:
return "Nordrhein-Westfalen"
return nrw
case prefix <= 36:
return "Hessen"
case prefix <= 38:
return "Niedersachsen"
return niedersachsen
case prefix == 39:
return "Sachsen-Anhalt"
case prefix <= 53:
return "Nordrhein-Westfalen"
return nrw
case prefix <= 56:
return "Rheinland-Pfalz"
case prefix <= 59:
return "Nordrhein-Westfalen"
return nrw
case prefix <= 65:
return "Hessen"
case prefix == 66:
@@ -291,15 +296,15 @@ func stateFromZip(zip, country string) string {
case prefix == 67:
return "Rheinland-Pfalz"
case prefix <= 69:
return "Baden-Württemberg"
return bw
case prefix <= 79:
return "Baden-Württemberg"
return bw
case prefix <= 87:
return "Bayern"
case prefix == 88:
return "Baden-Württemberg"
return bw
case prefix == 89:
return "Baden-Württemberg"
return bw
case prefix <= 97:
return "Bayern"
case prefix <= 99: