How to use callbacks in golang?

I need to use go threads infinite time.

Hi. I’m not really sure what you want to accomplish. Could you be more specific?

There isn’t any “go threads” in Go, there are “Go Routines”.

To terminate a single goroutine just send it a signal, like this:

package main

import (

func main() {
	signal := make(chan struct{})
	go func() {

	// wait for 5 secs then send the signal
	time.Sleep(time.Second * 5)

	// close will unblock every receiver
	fmt.Println("sending the signal")

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.