I am using an infinite for loop with a label. Outside the scope of the for loop, I have a scheduled function running as a go routine. I want to break the for loop from the scheduled function when a certain condition is met. How can I accomplish the same ? This is what I am trying, which obviously won't work due to scope issue.

package main

import (
  "fmt"
  "time"
  "sync"
)

func main() {
  count := 0
  var wg sync.WaitGroup
  wg.Add(1)
  t := time.NewTicker(time.Second*1)

  go func (){
    for {
        fmt.Println("I will print every second", count)
        count++ 
        if count > 5 {
          break myLoop;
          wg.Done()
        }
        <-t.C
    }  
  }()

  i := 1

  myLoop:
  for {
    fmt.Println("iteration", i)
    i++
  }

  wg.Wait()
  fmt.Println("I will execute at the end")

}