Standard library / testing
testing.T.Helper()
Mark a helper so failures are attributed to its caller. Expected stdout: 'verified\nPASS\n'. Run as a _test.go file using the Go test harness.
Formal Syntax & Structure
go syntaxgo
func (c *T) Helper()Working Example
Example Snippetgo
package main
import ( "fmt" "testing")
func check(t *testing.T, n int) { t.Helper() if n != 4 { t.Fatal(n) }}func TestReference(t *testing.T) { check(t, 4); fmt.Println("verified") }