Skip to content

Commit 32b0cd7

Browse files
committed
Rename to geozip
1 parent 3fd053f commit 32b0cd7

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Postcode
1+
# Geozip
22

33
## Overview
4-
The `postcode` package is designed for fetching and parsing postal code data, specifically from the GeoNames geographical database (https://www.geonames.org/).
4+
The `geozip` package is designed for fetching and parsing postal code data, specifically from the GeoNames geographical database (https://www.geonames.org/).
55
It offers a straightforward interface to download postal code data for various countries and parse them into a structured Go data type.
66

77
## Features
@@ -13,7 +13,7 @@ It offers a straightforward interface to download postal code data for various c
1313
To use the `postcode` package in your Go project, simply execute the following command:
1414

1515
```bash
16-
go get github.com/ngrash/postcode
16+
go get github.com/ngrash/geozip
1717
```
1818

1919
## Usage
@@ -25,11 +25,11 @@ Example:
2525
```go
2626
package main
2727

28-
import "github.com/ngrash/postcode"
28+
import "github.com/ngrash/geozip"
2929

3030
func main() {
3131
var previousEtag string
32-
entries, modified, newEtag, err := postcode.FetchCountry("US", previousEtag)
32+
entries, modified, newEtag, err := geozip.FetchCountry("US", previousEtag)
3333
if err != nil {
3434
// Handle error
3535
}

postcode.go renamed to geozip.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Package postcode provides functionality specifically for downloading and parsing
1+
// Package geozip provides functionality specifically for downloading and parsing
22
// postal code data from the GeoNames geographical database (https://www.geonames.org/).
3-
package postcode
3+
package geozip
44

55
import (
66
"archive/zip"

postcode_test.go renamed to geozip_test.go

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package postcode_test
1+
package geozip_test
22

33
import (
4-
"github.com/ngrash/postcode"
4+
"github.com/ngrash/geozip"
55
"net/http"
66
"os"
77
"testing"
@@ -15,7 +15,7 @@ func (fn RoundTripperFunc) RoundTrip(req *http.Request) (*http.Response, error)
1515

1616
func TestFetchCountry_NotModified(t *testing.T) {
1717
const requestEtag = "current_etag"
18-
postcode.HTTPClient.Transport = RoundTripperFunc(func(r *http.Request) (*http.Response, error) {
18+
geozip.HTTPClient.Transport = RoundTripperFunc(func(r *http.Request) (*http.Response, error) {
1919
if got, want := r.URL.String(), "https://download.geonames.org/export/zip/DE.zip"; got != want {
2020
t.Errorf("client requested %q, want %q", got, want)
2121
}
@@ -29,7 +29,7 @@ func TestFetchCountry_NotModified(t *testing.T) {
2929
StatusCode: http.StatusNotModified,
3030
}, nil
3131
})
32-
entries, modified, newEtag, err := postcode.FetchCountry("de", requestEtag)
32+
entries, modified, newEtag, err := geozip.FetchCountry("de", requestEtag)
3333
if entries != nil {
3434
t.Errorf("entries = %v, want nil", entries)
3535
}
@@ -49,7 +49,7 @@ func TestFetchCountry_Modified(t *testing.T) {
4949
requestEtag = "old_etag"
5050
responseEtag = "new_etag"
5151
)
52-
postcode.HTTPClient.Transport = RoundTripperFunc(func(r *http.Request) (*http.Response, error) {
52+
geozip.HTTPClient.Transport = RoundTripperFunc(func(r *http.Request) (*http.Response, error) {
5353
if got, want := r.URL.String(), "https://download.geonames.org/export/zip/DE.zip"; got != want {
5454
t.Errorf("client requested %q, want %q", got, want)
5555
}
@@ -71,7 +71,7 @@ func TestFetchCountry_Modified(t *testing.T) {
7171
},
7272
}, nil
7373
})
74-
entries, modified, newEtag, err := postcode.FetchCountry("de", requestEtag)
74+
entries, modified, newEtag, err := geozip.FetchCountry("de", requestEtag)
7575
if got, want := len(entries), 16477; got != want {
7676
t.Errorf("len(entries) = %v, want %v", got, want)
7777
}
@@ -96,40 +96,40 @@ func TestFetchCountry_Modified(t *testing.T) {
9696
idx := line - 1
9797
entry := entries[idx]
9898

99-
if got, want := entry[postcode.CountryCode], fields[0]; got != want {
99+
if got, want := entry[geozip.CountryCode], fields[0]; got != want {
100100
t.Errorf("entries[%d]: CountryCode = %v, want %v", idx, got, want)
101101
}
102-
if got, want := entry[postcode.PostalCode], fields[1]; got != want {
102+
if got, want := entry[geozip.PostalCode], fields[1]; got != want {
103103
t.Errorf("entries[%d]: PostalCode = %v, want %v", idx, got, want)
104104
}
105-
if got, want := entry[postcode.PlaceName], fields[2]; got != want {
105+
if got, want := entry[geozip.PlaceName], fields[2]; got != want {
106106
t.Errorf("entries[%d]: PlaceName = %v, want %v", idx, got, want)
107107
}
108-
if got, want := entry[postcode.AdminName1], fields[3]; got != want {
108+
if got, want := entry[geozip.AdminName1], fields[3]; got != want {
109109
t.Errorf("entries[%d]: AdminName1 = %v, want %v", idx, got, want)
110110
}
111-
if got, want := entry[postcode.AdminCode1], fields[4]; got != want {
111+
if got, want := entry[geozip.AdminCode1], fields[4]; got != want {
112112
t.Errorf("entries[%d]: AdminCode1 = %v, want %v", idx, got, want)
113113
}
114-
if got, want := entry[postcode.AdminName2], fields[5]; got != want {
114+
if got, want := entry[geozip.AdminName2], fields[5]; got != want {
115115
t.Errorf("entries[%d]: AdminName2 = %v, want %v", idx, got, want)
116116
}
117-
if got, want := entry[postcode.AdminCode2], fields[6]; got != want {
117+
if got, want := entry[geozip.AdminCode2], fields[6]; got != want {
118118
t.Errorf("entries[%d]: AdminCode2 = %v, want %v", idx, got, want)
119119
}
120-
if got, want := entry[postcode.AdminName3], fields[7]; got != want {
120+
if got, want := entry[geozip.AdminName3], fields[7]; got != want {
121121
t.Errorf("entries[%d]: AdminName3 = %v, want %v", idx, got, want)
122122
}
123-
if got, want := entry[postcode.AdminCode3], fields[8]; got != want {
123+
if got, want := entry[geozip.AdminCode3], fields[8]; got != want {
124124
t.Errorf("entries[%d]: AdminCode3 = %v, want %v", idx, got, want)
125125
}
126-
if got, want := entry[postcode.Latitude], fields[9]; got != want {
126+
if got, want := entry[geozip.Latitude], fields[9]; got != want {
127127
t.Errorf("entries[%d]: Latitude = %v, want %v", idx, got, want)
128128
}
129-
if got, want := entry[postcode.Longitude], fields[10]; got != want {
129+
if got, want := entry[geozip.Longitude], fields[10]; got != want {
130130
t.Errorf("entries[%d]: Longitude = %v, want %v", idx, got, want)
131131
}
132-
if got, want := entry[postcode.Accuracy], fields[11]; got != want {
132+
if got, want := entry[geozip.Accuracy], fields[11]; got != want {
133133
t.Errorf("entries[%d]: Accuracy = %v, want %v", idx, got, want)
134134
}
135135
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
module github.com/ngrash/postcode
1+
module github.com/ngrash/geozip
22

33
go 1.21

0 commit comments

Comments
 (0)