đ
abode
Explode one-line address strings using Golang.
This package uses the Google Maps API to geocode the address. Specifically you will require the Geocoding API enabled to translate address strings to detailed address objects.
Don't forget to set your GOOGLE_MAPS_API_KEY
environment variable.
Installation
go get -u github.com/mattevans/abode
Example
Explode your one-line address...
yourAddress := "193 Rogers Ave, Brooklyn, New York"
// Explode our one-line address into components.
address, err := abode.Explode(yourAddress)
if err != nil {
return err
}
Which will give you...
abode.Address{
AddressLine1: "193 Rogers Avenue",
AddressLine2: "Brooklyn"
AddressCity: nil,
AddressState: "New York"
AddressCountry: "United States"
AddressZip: "11216"
AddressLat: 40.6706073,
AddressLng: -73.9530182,
FormattedAddress: "193 Rogers Ave, Brooklyn, NY 11216, USA",
}
Configuration
Each abode.Address{}
component can be tailored to meet your needs. Simply adjust the mapping of the Google Maps Address Components here.
Disclaimer
Ensure your end results are used in conjunction with a Google Map to avoid violating the Google Maps API Terms of Service.