Write a function starting with Example followed by the target name and include an Output comment to create a testable Go example.
Write a testable example function by defining a function with the Example prefix followed by the name of the function or type it demonstrates, and include a // Output: comment at the end to specify the expected stdout for the go test runner to verify.
// ExampleInt_SetInt64 demonstrates setting an integer value.
func ExampleInt_SetInt64() {
z := &Int{}
z.SetInt64(42)
fmt.Println(z.Len())
// Output: 6
}
Example functions are special test cases that double as live documentation for your code. They run automatically when you execute go test, ensuring your examples stay accurate and up-to-date. Think of them as a recipe that not only shows how to cook a dish but also automatically checks if the final taste matches the description.