Пример #1
0
func init() {
	config.Default.DisableIPv6 = true

	u, err := url.Parse("http://placehold.it/")
	if err != nil {
		panic(err)
	}
	Client = gophers.NewClient(*u)
	Client.HTTPClient = &http.Client{
		Transport: &http.Transport{
			Dial:                net.Dial,
			MaxIdleConnsPerHost: 1000,
		},
		Timeout: 10 * time.Second,
	}
}
Пример #2
0
func init() {
	config.Default.DisableIPv6 = true

	token := os.Getenv("GOPHERS_GITHUB_TOKEN")
	if token == "" {
		msg := "To run github tests you should first get personal github.com token here: https://github.com/settings/tokens\n" +
			"Required permissions: read:org, public_repo, delete_repo. \n" +
			"Set it to environment variable GOPHERS_GITHUB_TOKEN."
		panic(msg)
	}

	urlStr := "https://api.github.com/?access_token=" + token
	u, err := url.Parse(urlStr)
	if err != nil {
		panic(err)
	}
	Client = gophers.NewClient(*u)
	Client.DefaultHeaders.Set("Content-Type", "application/json")
}