Hai bản maxminddb-golang (v1 + v2) cùng tồn tại trong go.mod #17

Closed
opened 2026-07-22 11:24:42 +07:00 by claudecode · 1 comment
Owner

Vấn đề

go.mod require oschwald/maxminddb-golang v1.13.1 (v1) làm dep trực tiếp (import trong internal/data/ipdb.go), nhưng v2 (/v2 v2.4.1) cũng bị kéo vào indirect. Lịch sử có PR #8 "update to v2" nhưng import vẫn dùng v1 → cả hai version cùng tồn tại trong build, lãng phí + trùng lặp.

Fix đề xuất

Migrate import sang v2:

import reader "github.com/oschwald/maxminddb-golang/v2"

Sau đó go mod tidy để bỏ v1 ra khỏi go.mod. Kiểm tra LookupNetwork/Reader/Open API tương thích (v2 API gần như giống v1). Chạy test + build để xác nhận.

## Vấn đề go.mod require `oschwald/maxminddb-golang v1.13.1` (v1) làm dep **trực tiếp** (import trong `internal/data/ipdb.go`), nhưng v2 (`/v2 v2.4.1`) cũng bị kéo vào indirect. Lịch sử có PR #8 "update to v2" nhưng import vẫn dùng v1 → cả hai version cùng tồn tại trong build, lãng phí + trùng lặp. ## Fix đề xuất Migrate import sang v2: ```go import reader "github.com/oschwald/maxminddb-golang/v2" ``` Sau đó `go mod tidy` để bỏ v1 ra khỏi go.mod. Kiểm tra `LookupNetwork`/`Reader`/`Open` API tương thích (v2 API gần như giống v1). Chạy test + build để xác nhận.
claudecode added the cleanup label 2026-07-22 11:24:42 +07:00
Author
Owner

Đã sửa trong PR #22 (merge commit 361eb40).

  • go.mod: chỉ còn một bản github.com/oschwald/maxminddb-golang/v2 v2.4.1 (direct). Bản v1.13.1 và dòng indirect v2 trùng đã được gỡ khỏi go.mod + go.sum.
  • internal/data/ipdb.go: import chuyển sang .../v2. v2 là breaking API (LookupNetworkLookup trả Result, dùng netip.Addr), nên internal/data/query.go được adapt (dùng netip.Addr + Result.Decode/Found/Prefix, convert netip.Prefix*net.IPNet để giữ chữ ký handler ổn định).

Verify: go build / go vet / go test -race PASS.

Đã sửa trong PR #22 (merge commit `361eb40`). - `go.mod`: chỉ còn một bản `github.com/oschwald/maxminddb-golang/v2 v2.4.1` (direct). Bản `v1.13.1` và dòng indirect v2 trùng đã được gỡ khỏi `go.mod` + `go.sum`. - `internal/data/ipdb.go`: import chuyển sang `.../v2`. v2 là breaking API (`LookupNetwork` → `Lookup` trả `Result`, dùng `netip.Addr`), nên `internal/data/query.go` được adapt (dùng `netip.Addr` + `Result.Decode/Found/Prefix`, convert `netip.Prefix` → `*net.IPNet` để giữ chữ ký handler ổn định). Verify: `go build` / `go vet` / `go test -race` PASS.
This repo is archived. You cannot comment on issues.
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: public/ip-info#17