package main import ( "fmt" "sync" ) var ( once sync.Once msg string ) func setup() { msg = "Hello, World!" } func printMsg() { once.Do(setup) fmt.Println(msg) } func main() { go printMsg() go printMsg() go printMsg() go printMsg() // Wait for goroutines to complete var wg sync.WaitGroup wg.Add(4) go func() { defer wg.Done() printMsg() }() go func() { defer wg.Done() printMsg() }() go func() { defer wg.Done() printMsg() }() go func() { defer wg.Done() printMsg() }() wg.Wait() // Output: Hello, World! }In this example, we use the `Once` type to ensure that the `setup` function is executed only once, and initialize the `msg` variable with a greeting message. The `printMsg` function is then called multiple times from different goroutines, but the `setup` function is only executed once. Package library: sync package.