コード例 #1
0
func main() {
	config := pivnet.ClientConfig{
		Host:      pivnet.DefaultHost,
		Token:     "token-from-pivnet",
		UserAgent: "pivnet-cli-example",
	}

	stdoutLogger := log.New(os.Stdout, "", log.LstdFlags)
	stderrLogger := log.New(os.Stderr, "", log.LstdFlags)

	verbose := false
	logger := logshim.NewLogShim(stdoutLogger, stderrLogger, verbose)

	client := pivnet.NewClient(config, logger)

	products, err := client.Products.List()

	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("products: %v", products)
}
コード例 #2
0
func NewClient(config pivnet.ClientConfig, logger logger.Logger) *Client {
	return &Client{
		client: pivnet.NewClient(config, logger),
	}
}