Пример #1
0
func TestURLDefault(t *testing.T) {
	in, out := &url.URL{Host: "example.com"}, &url.URL{Host: "example.com"}

	os.Clearenv()

	if got := env.URL("URL_DEFAULT", in); got.String() != out.String() {
		t.Errorf(`URL("URL_DEFAULT", "%v") = %v, want %v`, in, got, out)
	}
}
Пример #2
0
func TestURL(t *testing.T) {
	in, out := &url.URL{Host: "example.com"}, &url.URL{Host: "example.com"}

	os.Setenv("URL", out.String())

	if got := env.URL("URL", in); got.String() != out.String() {
		t.Errorf(`URL("URL", "%v") = %v, want %v`, in, got, out)
	}
}
Пример #3
0
func ExampleURL() {
	os.Setenv("URL", "http://example.com/foo")

	fmt.Println(env.URL("URL", &url.URL{Host: "fallback"}).String())
	// Output: http://example.com/foo
}