gorreios

package module
v0.0.0-...-1584798 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Instalação

Para instalar o gorreios execute o comando abaixo em seu terminal:

go get github.com/MarcusMann/Gorreios
Como usar:

Para chamar a aplicação dentro do seu arquivo main.go escreva o código abaixo:

package main

import (
	"fmt"

	"github.com/MarcusMann/gorreios"
)

func main() {
	correios, err := gorreios.BuscarViaEndereco("BA", "Salvador", "Pituba")
	if err != nil {
		fmt.Println(err.Error())
	}

	fmt.Println(correios)
}

Ao executar o comando go run main.go ele irá trazer todas as informações possíveis, dos bairros encontrados através do Estado, Cidade e Logradouro. A busca também pode ser realizada por cep, veja:

...
func main() {
	correios, err := gorreios.BuscarViaCep(41820460)
	if err != nil {
		fmt.Println(err.Error())
	}
	
	fmt.Println(correios)
}

Uma outra forma de obter o resultado esperado é chamando a aplicação dessa forma:

package main

import (
	"github.com/MarcusMann/gorreios"
)

func main() {
	gorreios.Flags()
}

Agora você pode executar através de flags, veja:

go run main.go -cep=41820460

Veja um pequeno vídeo abaixo de como funcionar a questão das flags.

asciicast

Você pode ver o vídeo completo diretamente no meu canal do youtube.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Flags

func Flags()

Flags da a possibilidade de instanciar as funções sem ter que chama-las no main()

Types

type Endereco

type Endereco struct {
	Cep         string
	Logradouro  string
	Complemento string
	Bairro      string
	Localidade  string
	Uf          string
	Unidade     string
	Ibge        string
	Gia         string
}

Endereco recupera o endereço através do cep passado

func BuscarViaCep

func BuscarViaCep(cep uint32) (*Endereco, error)

BuscarViaCep recupera os dados passando o cep como argumento.

type EnderecoLista

type EnderecoLista []Endereco

EnderecoLista retorna uma lista de endereços

func BuscarViaEndereco

func BuscarViaEndereco(endereco ...string) (*EnderecoLista, error)

BuscarViaEndereco retorna uma lista dos endereços

Jump to

Keyboard shortcuts

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