22-chan-Empty-Struct

command
v0.0.0-...-9882766 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

chan struct{} are used for signaling. That means we don't necesarily put an empty struct{} on that channel, but we can use it for controlling things in the program by closing the channel when we are done.

In this example we use it to send a signal by closing the channel after 3 seconds, and kind of making a timer. The main program will block on <-c until channel is closed or an struct{} is received, in our example here we close the channel.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL