https://github.com/igorhalfeld/lagoinha
Library to get full address of a Brazilian zip code
https://github.com/igorhalfeld/lagoinha
go golang
Last synced: over 1 year ago
JSON representation
Library to get full address of a Brazilian zip code
- Host: GitHub
- URL: https://github.com/igorhalfeld/lagoinha
- Owner: IgorHalfeld
- License: mit
- Created: 2019-03-04T20:11:18.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-05-21T17:46:50.000Z (about 2 years ago)
- Last Synced: 2024-11-12T19:44:01.169Z (over 1 year ago)
- Topics: go, golang
- Language: Go
- Homepage:
- Size: 2.3 MB
- Stars: 70
- Watchers: 3
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Lagoinha
Library to get full address of a Brazilian zip code.
Works with VipCep, Correios, and many more.
---
Lagoinha is a package that uses APIs to find complete addresses by a provided zip code. The lib dispatches several requests at the same time and returns with the one that finished first.
### Por que esse nome
It's a Brazilian meme [vídeo](https://www.youtube.com/watch?v=C1Sd_RWF5ks)!
(onde é que eu tô, lagoinha, CEP, endereço...)
### Install
```sh
go get -u https://github.com/IgorHalfeld/lagoinha.git
```
### How to use
```golang
package main
import (
"fmt"
"github.com/igorhalfeld/lagoinha"
)
func main() {
// get amount of cep providers enabled
fmt.Println("Total amount of cep providers:", lagoinha.GetTotalAmountOfCepProviders())
/*
// if you want to use without handling channels
addr, err := lagoinha.GetAddressSync("15809240", &lagoinha.GetAddressOptions{
PreferenceForAPI: "Apicep",
})
*/
chResp, chErr := lagoinha.GetAddress("04568000")
select {
case address := <-chResp:
fmt.Printf("Response: %+v\n", address)
case err := <-chErr:
fmt.Printf("Error: %+v\n", err)
}
}
```
and you can also set a preference api
```golang
chResp, chErr := lagoinha.GetAddress("04568000", &lagoinha.GetAddressOptions{
PreferenceForAPI: "ViaCEP",
})
```
logo by [@nelsonsecco](https://twitter.com/nelsonsecco)