Skip to content

v1.0.0: switch data source, embed.FS, drop bindata#63

Draft
pariz wants to merge 18 commits intomasterfrom
v1
Draft

v1.0.0: switch data source, embed.FS, drop bindata#63
pariz wants to merge 18 commits intomasterfrom
v1

Conversation

@pariz
Copy link
Copy Markdown
Owner

@pariz pariz commented Apr 27, 2026

Summary

Rebuilds gountries' data pipeline from scratch and lands it as a draft v1.0.0. The previous setup (custom `gountries-creator` + manual `go-bindata` regen + `pariz/countries` source repo) had drifted out of date and the regen step was undocumented. Replaced with a fully automated, weekly-refreshed pipeline backed by two actively maintained upstream projects.

What changed

Data sources (now vendored as git submodules under `third_party/`):

Embedding: `go-bindata` → `//go:embed` (stdlib, Go 1.16+). `bindata.go` deleted.

Pipeline:

  • `cmd/sync-data` — Go program that merges both upstreams into the canonical `data/yaml/` shape
  • `.github/workflows/sync-upstream.yml` — weekly cron that bumps both submodules, regenerates, tests, opens a PR

API surface (breaking):

  • Removed all `Asset*` exports from the deleted `bindata.go`
  • Added `Country.AltSpellings []string` (new field) — populated from gem `unofficial_names` + mledoze `altSpellings`, indexed by `FindCountryByName` so short forms ("United States", "USA") still resolve
  • `NewFromPath` now reads through `os.DirFS` internally (signature unchanged)
  • `go.mod` bumped from 1.17 → 1.21

Data shape changes (visible to consumers):

  • 249 countries (unchanged)
  • 200 subdivision files / 5,059 entries (previously 195 / much sparser)
  • Sweden: 23 translations (was 7), accurate borders, TLDs, native names
  • Czech Republic → Czechia (ISO since 2016)
  • Bulgaria currency reflects EUR transition (1 Jan 2026)
  • Distances slightly different due to fresher coordinates

Tests

  • All existing tests pass after data-drift updates (region/currency counts, distance examples, Czechia naming).
  • New `TestDataInvariants` guards against silent upstream regressions: country count bounds, key-field presence, canary lookups, Sweden borders, subdivision presence for major countries.

Migration for downstream users

Pin the old release if needed:
```
go get github.com/pariz/gountries@v0.1.6
```

Otherwise, see CHANGELOG.md for the full migration list.

License

Go code stays MIT. Embedded `data/yaml/` becomes a Derivative Database under ODbL by virtue of incorporating mledoze fields. Querying the data through this Go API does not propagate ODbL to downstream apps (it produces a Produced Work, not a Derivative Database).

Plan

  1. Open this draft (now)
  2. Sit on it briefly for self-review
  3. Tag `v1.0.0-beta.1` for community trial
  4. Tag `v1.0.0` once happy

claude added 18 commits April 27, 2026 21:15
BREAKING CHANGES:
- Removed all generated Asset*/AssetDir/AssetNames/AssetInfo functions (bindata.go deleted)
- New Country.AltSpellings field, indexed by FindCountryByName for short-form lookups
- NewFromPath now takes a directory path read via os.DirFS; layout still expects countries/ + subdivisions/ subdirs
- Embedded YAML data is now loaded via //go:embed (Go 1.16+)
The name-match branch had `==` instead of `!=`, so callers passing
`Country{Name.Common: "Sweden"}` got back every country *except*
Sweden. Fix swaps the comparison to `!strings.EqualFold(...)` matching
the convention of every other filter branch.
Both populateCountries and populateSubdivisions used to swallow
yaml.Unmarshal errors with `continue`, producing a Query with arbitrary
gaps and no signal to the operator. Now they panic with the offending
filename — fail-loud is correct for embedded data the auto-sync
workflow regenerates.
- 3× SA6005: replace strings.ToLower(x) != strings.ToLower(y) with !strings.EqualFold
- 3× S1002: drop redundant ==true / ==false comparisons
- ST1000: add package doc comment
- ST1020: complete FindCountryByNativeName godoc
- Add .golangci.yml (staticcheck minus QF noise + errcheck/govet/ineffassign/unused/misspell)
- Add Lint job to CI workflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants