The golang implementation of ZenginCode.
ZenginCode is datasets of bank codes and branch codes for japanese.
go get -u github.com/ka2u/zengin-go.git
- ZENGIN_SOURCE_ROOT
- Set the absolute path where is the zengincode source data directory.
- You use zengin source from file(not embed), this is MANDATORY.
- ZENGIN_SOURCE_YAML (OPTIONAL)
- Set the value is TRUE or FALSE If you want to use YAML data. Default data is JSON.
package main
import (
"fmt"
zengincode "github.com/ka2u/zengin-code-go"
)
func main() {
bank, err := zengincode.New()
if err != nil {
fmt.Printf("err %v\n", err)
}
b, err := bank.Find("0005")
if err != nil {
fmt.Printf("err %v\n", err)
} else {
fmt.Printf("bank %s", b.Name)
}
br, err := b.Branches.Find("恵比寿")
if err != nil {
fmt.Printf("err %v\n", err)
} else {
fmt.Printf("branch %s", br.Name)
}
}
Use Statik if You want to use embed zengin source.
statik -source=source-data/data
package main
import (
"fmt"
zengincode "github.com/ka2u/zengin-code-go"
- "your/app/path/statik"
)
func main() {
bank, err := zengincode.NewWithEmbed()
if err != nil {
fmt.Printf("err %v\n", err)
}
b, err := bank.Find("0005")
if err != nil {
fmt.Printf("err %v\n", err)
} else {
fmt.Printf("bank %s", b.Name)
}
br, err := b.Branches.Find("恵比寿")
if err != nil {
fmt.Printf("err %v\n", err)
} else {
fmt.Printf("branch %s", br.Name)
}
}
New() method is very heavy loading process. It is recommended to load and cache at the initial process.
Bug reports and pull requests are welcome on GitHub at https://github.com/ka2u/zengin-go
The library is available as open source under the terms of the MIT License.