Skip to content

What happens to the anonymous goroutine running in the background? #2

Open
@BSardorbek

Description

@BSardorbek

https://github.com/kevchn/go-concurrency-patterns/blob/9493f7e9f5db056eae29c2faa231ea54c5514545/1-8-timeout-select.go#L29


func generator(msg string) <-chan string { // returns receive-only channel
	ch := make(chan string)
	go func() { // anonymous goroutine
		for i := 0; ; i++ {
			ch <- fmt.Sprintf("%s %d", msg, i)
			time.Sleep(time.Second)
		}
	}()
	return ch
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions