Exemple #1
0
func TestFloat64Default(t *testing.T) {
	in, out := float64(5.2), float64(5.2)

	os.Clearenv()

	if got := env.Float64("FLOAT64_DEFAULT", in); got != out {
		t.Errorf(`Float64("FLOAT64_DEFAULT", %v) = %v, want %v`, in, got, out)
	}
}
Exemple #2
0
func TestFloat64(t *testing.T) {
	in, out := float64(1.1), float64(2.5)

	os.Setenv("FLOAT64", "2.5")

	if got := env.Float64("FLOAT64", in); got != out {
		t.Errorf(`Float64("FLOAT64", %v) = %v, want %v`, in, got, out)
	}
}
Exemple #3
0
func ExampleFloat64() {
	os.Setenv("FLOAT64", "1.23")

	fmt.Println(env.Float64("FLOAT64", 0))
	// Output: 1.23
}