Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/appleboy/go-twzipcode-plugin
Go plugin with TWZipCode
https://github.com/appleboy/go-twzipcode-plugin
golang golang-plugin twzipcode
Last synced: about 2 months ago
JSON representation
Go plugin with TWZipCode
- Host: GitHub
- URL: https://github.com/appleboy/go-twzipcode-plugin
- Owner: appleboy
- License: mit
- Created: 2017-04-08T06:00:40.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-09T06:25:33.000Z (almost 8 years ago)
- Last Synced: 2024-04-14T09:03:50.129Z (10 months ago)
- Topics: golang, golang-plugin, twzipcode
- Language: Go
- Size: 18.6 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-twzipcode-plugin
Go plugin with TWZipCode. This plugin support is currently only available on **Linux**.
## Installation
install `go-bindata` tool
```sh
$ go get -u github.com/jteeuwen/go-bindata/...
```generate bind data.
```sh
$ go-bindata -pkg twzipcode -o twzipcode/twzipcode.go twzipcode/twzipcode.json
```build plugin
```sh
$ go build -buildmode=plugin -o go-twzipcode.so go-twzipcode.go
```## Example
[embedmd]:# (example/example.go go)
```go
package mainimport (
"log"
"plugin"
)func main() {
file := "go-twzipcode.so"
p, err := plugin.Open(file)
if err != nil {
log.Fatalf("%s plugin file not found. Details: %s", file, err.Error())
}GetTWZipCode, err := p.Lookup("GetTWZipCode")
if err != nil {
log.Fatalf("GetTWZipCode function not found. Details: %s", err.Error())
}getTWZipCode, ok := GetTWZipCode.(func(string, string) (string, error))
if !ok {
log.Fatal("Unable to cast func type")
}code, _ := getTWZipCode("基隆市", "仁愛區")
log.Println("基隆市仁愛區:", code)
code, _ = getTWZipCode("高雄市", "苓雅區")
log.Println("高雄市苓雅區:", code)
}
```