google-taxonomy-go

module
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2017 License: MIT

README

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL