Skip to content

isaqueveras/brasilapi-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

brasilapi-go

Cliente em Golang para se comunicar com BrasilApi


CEP (zipcode)

package main

import (
  "context"
  "encoding/json"
  "fmt"

  "github.com/isaqueveras/brasilapi-go"
  "github.com/isaqueveras/brasilapi-go/cep"
  "github.com/isaqueveras/juazeiro"
)

func main() {
  conn, err := juazeiro.NewClient(brasilapi.ServerClient)
  if err != nil {
    panic(err)
  }

  client := cep.NewCepClient(conn)

  var zipcode *cep.Response
  if zipcode, err = client.GetZipCode(context.Background(), &cep.Identifier{
    Cep: pointer("63900-193"),
  }); err != nil {
    panic(err)
  }

  str, _ := json.Marshal(zipcode)
  fmt.Println(string(str))
}

func pointer[t any](value t) *t {
  return &value
}