Goroutine that can be used in the field (errgroup.Group edition)

How to use errgroup to handle multiple asynchronous processes at the end

func main() {
	eg := errgroup.Group{}
	for i := 0; i < 5; i++ {
		i := i //← This is the point
		eg.Go(func() error {
			fmt.Printf("i:%d\n", i)
			return nil
		})
	}
	if err := eg.Wait(); err != nil {
		fmt.Printf("err:%v\n", err)
	}
}

https://play.golang.org/p/MCkoaPl14ZY

reference

Recommended Posts

Goroutine that can be used in the field (errgroup.Group edition)
Goroutine (parallel control) that can be used in the field
A timer (ticker) that can be used in the field (can be used anywhere)
[Django] Field names, user registration, and login methods that can be used in the User model
Functions that can be used in for statements
Basic algorithms that can be used in competition pros
ANTs image registration that can be used in 5 minutes
QPS control that can be used in the field (Rate Limit) Limits execution to n times per second
Scripts that can be used when using bottle in Python
Python standard input summary that can be used in competition pro
Python standard module that can be used on the command line
About the matter that the re.compiled object can be used for the re.match pattern
Easy padding of data that can be used in natural language processing
Hide the warning that zsh can be used by default on Mac
File types that can be used with Go
Building Sphinx that can be written in Markdown
The problem that the ifconfig command cannot be used
A collection of Numpy, Pandas Tips that are often used in the field
A personal memo of Pandas related operations that can be used in practice
Easy program installer and automatic program updater that can be used in any language
Japanese can be used with Python in Docker environment
Python knowledge notes that can be used with AtCoder
Can be used in competition pros! Python standard library
[Django] About users that can be used on template
List the classes that can be referenced by ObjCClass
Summary of statistical data analysis methods using Python that can be used in business
The story that sendmail that can be executed in the terminal did not work with cron
Text analysis that can be done in 5 minutes [Word Cloud]
Implement timer function in pygame
Settings often used in Jupyter
Used in machine learning EDA
Frequently used commands in virtualenv
A timer (ticker) that can be used in the field (can be used anywhere)
8 Frequently Used Commands in Python Django
[Python3] Code that can be used when you want to resize images in folder units
[Atcoder] [C ++] I made a test automation tool that can be used during the contest
I investigated the pretreatment that can be done with PyCaret
Evaluation index that can be specified in GridSearchCV of sklearn
How to set variables that can be used throughout the Django app-useful for templates, etc.-
I made it because I want JSON data that can be used freely in demos and prototypes
I tried to expand the database so that it can be used with PES analysis software
I bought and analyzed the year-end jumbo lottery with Python that can be executed in Colaboratory
Understand the probabilities and statistics that can be used for progress management with a python program
About the matter that torch summary can be really used when building a model with Pytorch
Which octal literals can be used depends on the programming language
Make a Spinbox that can be displayed in Binary with Tkinter
33 strings that should not be used as variable names in python
About character string handling that can be placed in JSON communication
New features in Python 3.9 (1)-Union operators can be used in dictionary types
Make a Spinbox that can be displayed in HEX with Tkinter
Create a custom field where enum can be specified in choices
Can the Kalman filter be used to predict stock price trends?
Confirmation that rkhunter can be installed
Solution to the problem that Ctrl + z cannot be used in Powershell in Docker for windows environment (provisional)
I created a template for a Python project that can be used universally
AtCoder C problem summary that can be solved in high school mathematics
Acoustic signal processing module that can be used with Python-Sounddevice ASIO [Application]
Serverless LINE Bot that can be done in 2 hours (source identifier acquisition)
Mathematical optimization that can be used for free work with Python + PuLP
I made a simple timer that can be started from the terminal
Acoustic signal processing module that can be used with Python-Sounddevice ASIO [Basic]
A story that heroku that can be done in 5 minutes actually took 3 days
[Python3] Code that can be used when you want to cut out an image in a specific size
Words that may be confusing to read at first glance ~ Mainly in the field of Web / machine learning ~
It seems that cancelall childorders can be used to cancel all parent orders (special orders) with the bitflyer API
[Python3] Code that can be used when you want to change the extension of an image at once