Skip to content

Latest commit

 

History

History
70 lines (52 loc) · 1.65 KB

README.md

File metadata and controls

70 lines (52 loc) · 1.65 KB

Lagoinha

Library to get full address of a Brazilian zip code.
Works with VipCep, Correios, and many more.


gopherbadger-tag-do-not-edit

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! (onde é que eu tô, lagoinha, CEP, endereço...)

Install

go get -u https://github.com/IgorHalfeld/lagoinha.git

How to use

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

chResp, chErr := lagoinha.GetAddress("04568000", &lagoinha.GetAddressOptions{
	PreferenceForAPI: "ViaCEP",
})

logo by @nelsonsecco