Standard library / testing

testing.Init()

Register testing flags when using testing utilities outside go test. Repeated sequential calls are harmless; concurrent calls are unsupported. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func Init()

Working Example

Example Snippetgo
package main
import (  "flag"  "fmt"  "testing")
func main() { testing.Init(); testing.Init(); fmt.Println(flag.Lookup("test.short") != nil) }
Go Reference