go-footballdata/example_test.go

50 lines
973 B
Go
Raw Normal View History

2016-06-12 22:39:00 +00:00
package footballdata_test
import (
"fmt"
"net/http"
"github.com/icedream/go-footballdata"
)
func Example() {
// Create client
client := footballdata.NewClient(http.DefaultClient)
// Tell it to use our API token
2016-06-25 10:29:32 +00:00
client.SetToken("<insert your api token here>")
2016-06-12 22:39:00 +00:00
// Get list of seasons...
seasons, err := client.SoccerSeasons().Do()
if err != nil {
panic(err)
}
// ...and print them
for _, season := range seasons {
fmt.Println(season.Id, season.Caption)
}
}
2016-06-26 10:02:53 +00:00
func ExampleClient() {
// Create client
client := footballdata.NewClient(http.DefaultClient)
/* Do something with the client instance... */
seasons, err := client.SoccerSeasons().Do()
if err != nil {
panic(err)
}
for _, season := range seasons {
fmt.Println(season.Id, season.Caption)
}
}
func ExampleClient_withToken() {
// Create client
client := footballdata.NewClient(http.DefaultClient)
// Tell it to use our API token
client.SetToken("<insert your api token here>")
}