To download taxonomy txt:
buildtools/dl-taxonomy-txt.sh
To clean all generated files:
buildtools/clean.sh
To generate data.go:
go get -u github.com/jteeuwen/go-bindata/...
./buildtools/build.sh
I preseve those file in git repo to track the changes when google updates taxonomy layouts.
See examples/main.go
package main
import (
"fmt"
"github.com/xreception/google-taxonomy-go/taxonomy"
)
const keyLanguage = "en-US"
func main() {
tx, err := taxonomy.NewTaxonomy(keyLanguage, []string{})
if err != nil {
panic(err)
}
infs, err := tx.GetRootsCategoryInfo(keyLanguage)
if err != nil {
panic(err)
}
for _, inf := range infs {
fmt.Printf("%d - %s\n", inf.ID, inf.String())
}
inf, err := tx.GetCategoryInfo(16, keyLanguage)
if err != nil {
panic(err)
}
fmt.Printf("%d - %s\n", inf.ID, inf.String())
}
go test ./taxonomy
# Or run data race test
# go test -race ./taxonomy
We do not test zh-CN
for category language compatibility, as the version of zh-CN
is
very behind the other languages.