zipcode

package module
v0.0.0-...-607e9df Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2013 License: MIT Imports: 4 Imported by: 0

README

zipcode
=======

zipcode is a simple Go library that provides lookups for U.S. ZIP Codes.

It builds its database from the CSV file located here:

	http://www.boutell.com/zipcodes/

Usage
-----

import (
	"fmt"
	"github.com/publicgoodsw/zipcode"
)

func main() {
	zdb, _ := zipcode.NewDB("zipcode.csv")
	zip, _ := zdb.Lookup("21230")
	fmt.Printf("ZIP Code: %+v", zip)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidZIP = errors.New("invalid ZIP Code")
	ErrZIPExist   = errors.New("ZIP Code doesn't exist")
)

Functions

func ValidateZIP

func ValidateZIP(code string) bool

Types

type DB

type DB map[string]ZIPCode

func NewDB

func NewDB(r io.Reader) (DB, error)

func (DB) Lookup

func (db DB) Lookup(code string) (*ZIPCode, error)

type ZIPCode

type ZIPCode struct {
	Code  string
	City  string
	State string
	Lat   float64
	Lng   float64
	TZ    string
	DST   bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL