go func() { defer close(done) for i := 0; i < 3; i++ { ch <- i time.Sleep(100 * time.Millisecond) } close(ch) }()
go func() { for { select { case v, ok := <-ch: if !ok { fmt.Println("channel closed") return } fmt.Println("received:", v) default: fmt.Println("default case") time.Sleep(50 * time.Millisecond) } } }()
<-done time.Sleep(500 * time.Millisecond) }
Хинт: Код показывает, как работает select с default при чтении из канала — если данных нет, выбирается default, не блокируя выполнение.
Ответ:
🔄 Что делает программа: Одна горутина пишет 0, 1, 2 в канал ch с паузой 100мс, затем закрывает канал.
Вторая горутина читает из ch через select:
если данные есть → received: N
если нет → default case
если канал закрыт → channel closed
📤 Что выведет (примерно):
default case default case received: 0 default case received: 1 default case received: 2 channel closed Порядок может немного отличаться из-за гонки между горутинами, но общая структура будет именно такая.
go func() { defer close(done) for i := 0; i < 3; i++ { ch <- i time.Sleep(100 * time.Millisecond) } close(ch) }()
go func() { for { select { case v, ok := <-ch: if !ok { fmt.Println("channel closed") return } fmt.Println("received:", v) default: fmt.Println("default case") time.Sleep(50 * time.Millisecond) } } }()
<-done time.Sleep(500 * time.Millisecond) }
Хинт: Код показывает, как работает select с default при чтении из канала — если данных нет, выбирается default, не блокируя выполнение.
Ответ:
🔄 Что делает программа: Одна горутина пишет 0, 1, 2 в канал ch с паузой 100мс, затем закрывает канал.
Вторая горутина читает из ch через select:
если данные есть → received: N
если нет → default case
если канал закрыт → channel closed
📤 Что выведет (примерно):
default case default case received: 0 default case received: 1 default case received: 2 channel closed Порядок может немного отличаться из-за гонки между горутинами, но общая структура будет именно такая.
The messaging service and social-media platform owes creditors roughly $700 million by the end of April, according to people briefed on the company’s plans and loan documents viewed by The Wall Street Journal. At the same time, Telegram Group Inc. must cover rising equipment and bandwidth expenses because of its rapid growth, despite going years without attempting to generate revenue.
Export WhatsApp stickers to Telegram on iPhone
You can’t. What you can do, though, is use WhatsApp’s and Telegram’s web platforms to transfer stickers. It’s easy, but might take a while.Open WhatsApp in your browser, find a sticker you like in a chat, and right-click on it to save it as an image. The file won’t be a picture, though—it’s a webpage and will have a .webp extension. Don’t be scared, this is the way. Repeat this step to save as many stickers as you want.Then, open Telegram in your browser and go into your Saved messages chat. Just as you’d share a file with a friend, click the Share file button on the bottom left of the chat window (it looks like a dog-eared paper), and select the .webp files you downloaded. Click Open and you’ll see your stickers in your Saved messages chat. This is now your sticker depository. To use them, forward them as you would a message from one chat to the other: by clicking or long-pressing on the sticker, and then choosing Forward.