Standard library / testing
testing.B.Helper()
Mark the calling function as a helper so diagnostic locations point past it. This intentionally failing example demonstrates helper diagnostics. Expected process exit: 1; output contains ['FAIL', 'helper diagnostic', 'after helper']. Run as a _test.go file using the Go test harness.
Formal Syntax & Structure
go syntaxgo
func (c *B) Helper()Working Example
Example Snippetgo
package main
import ( "fmt" "testing")
func check(b *testing.B) { b.Helper(); b.Error("helper diagnostic") }func BenchmarkReference(b *testing.B) { check(b); fmt.Println("after helper") }