All Projects → osamingo → go-kenall

osamingo / go-kenall

Licence: MIT License
Unofficially kenall (ケンオール) client written by Go

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to go-kenall

ViaCEP
The ViaCEP API/webservice .NET client
Stars: ✭ 21 (-16%)
Mutual labels:  postalcode

go-kenall

CI codecov Go Report Card Go Reference GitHub license

About

Unofficially kenall (ケンオール) client written by Go.

Install

$ go get github.com/osamingo/[email protected]

Usage

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/osamingo/go-kenall"
)

func main() {
	cli, err := kenall.NewClient(os.Getenv("KENALL_AUTHORIZATION_TOKEN"))
	if err != nil {
		log.Fatal(err)
	}

	resAddr, err := cli.GetAddress(context.Background(), "1000001")
	if err != nil {
		log.Fatal(err)
	}
	addr := resAddr.Addresses[0]
	fmt.Println(addr.Prefecture, addr.City, addr.Town)
	// Output: 東京都 千代田区 千代田

	resCity, err := cli.GetCity(context.Background(), "13")
	if err != nil {
		log.Fatal(err)
	}
	city := resCity.Cities[0]
	fmt.Println(city.Prefecture, city.City)
	// Output: 東京都 千代田区
}

Articles

License

Released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].