Example-type Tests: how to represent nil output?

When I run this Example test below using
go test -timeout 30s -tags -run ^ExampleNewSettings$

func ExampleNewSettings() {
	s := NewSettings()
	s.Set("FontName", "Manlo")
	s.Set("FontSize", 12)
	s.Set("FontColor", color.Black)
	fmt.Println(s.Get("FontName"))
	fmt.Println(s.Get("FontSize"))
	fmt.Println(s.Get("FontColor"))
	fmt.Println(s.Get("notfound"))
	//Output:
	//Manlo
	//12
	//color.Black
	//<nil>
}

The test fails no matter how I represent the nil return from the last Println. go test produces

– FAIL: ExampleNewSettings (0.00s)
got:
Manlo true
12 true
{0} true
<nil> false want: Manlo 12 color.Black
FAIL
exit status 1

Is there a way of representing a nil output?

Thanks,

Your expected output bears little resemblance to the actual output. Are you sure the nil is the problem?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.