Skip to content

idy/google-taxonomy-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

google-taxonomy-go

Buildtools

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

Data files consideration

I preseve those file in git repo to track the changes when google updates taxonomy layouts.

Usage

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())
}

Testing

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.