Комментарии:
What's the color theme are you using?
Thanks
Im wondering why the wg.done() was not called? and without that how did the wg know that all goroutes are comeplted?
ОтветитьIf I apply to be a partner on the website, are there translation subtitles? thai😢
ОтветитьFrom now on I am calling my wait groups "weegee" :D
ОтветитьAmazing video! I learned to add the waiter and the close into an anonymous go routine and keep the code out of the anonymous go routine.
Thanks for this rich material
Done decrement the number inside the wg.add
Ответитьsuper clear and easy to understand thank u
ОтветитьI think you could skip the wg in the last example by using just an int that is decremented inside the for loop and making the loop sync inside the main. When the last value is received and the counter is zero, just close the channel and the execution of the main function continues
ОтветитьWhat about the switch{} block and label brakes in for loop instead of using the waitgroups along with channels?
ОтветитьYOU ARE HIM
ОтветитьHmm, shouldn't it be better if we just defer the Chan closing instead of using sleep?
ОтветитьVolume becomes lower and lower with every next video, please make it at least a little bit louder, it's becoming hard to listen. Thanks for your work.
ОтветитьWhen you demonstrated channels, I think you can make(chan string, size) so you can mimick the config you had with waitgroups. You'll only be expecting 3 messages into the channel and then close it.
ОтветитьBest video on channels and waitgroups ❤
ОтветитьWhy don't we add wg.Done in the local function instead of sleep
ОтветитьGreat video, both well explained and helpful, thank you!
ОтветитьAre there any disadvantages of using this approach? For example if we need to make multiple parallel requests to fetch different type of results.
func main() {
start := time.Now()
var r1 string
var r2 int
var r3 time.Time
wg := sync.WaitGroup{}
wg.Add(3)
go func(wg *sync.WaitGroup) {
r1 = "Hello"
time.Sleep(1 * time.Second)
wg.Done()
}(&wg)
go func(wg *sync.WaitGroup) {
r2 = 42
time.Sleep(2 * time.Second)
wg.Done()
}(&wg)
go func(wg *sync.WaitGroup) {
r3 = time.Now()
time.Sleep(3 * time.Second)
wg.Done()
}(&wg)
wg.Wait()
fmt.Println(r1, r2, r3)
fmt.Printf("took: %v\n", time.Since(start))
}
GG video man. When I was learning golang the when to use go routines with channels was a bit hard to understand and I wish your video was out back then! Cheers mate good job
ОтветитьThanks Anthony, just a quick question
is it a possible to close the channel inside the go routine in this way
go func() {
for res := range resultch {
fmt.Println(res)
}
fmt.println()
close(resultch)
}()
if it is possible, is it considered a good practice?
Would it make sense to invert your example, pass the wg.Wait to your anonymous function and have the channel for on the main thread to get results back to main thread? I suppose you could also pass a slice to the function instead of the wg
ОтветитьPlease make a video on different rate limiting patterns
ОтветитьBut it feels like using both channels with waitgroups are taking more resources. Didn't test myself but heard using channels is much efficient and preffered than wg. Any other approaches to control that job is done? contexts?
ОтветитьGreat - really good simple demo - thanks
ОтветитьNee maat gewoon assembly
ОтветитьG.O.A.T as always ❤
Ответитьlegend back
Ответитьpls make a video about fan-in, fan-out patterns and usage of select keyword when working with multiple channels (also would be great if buffers, read and write chanells would be also discussed). My appreciation, maestro!
Ответить2
Ответить1
Ответить