Направления каналов

This commit is contained in:
badkaktus 2019-10-07 22:12:54 +03:00
parent 8cd1fe18bd
commit a791406292
2 changed files with 10 additions and 10 deletions

View File

@ -23,7 +23,7 @@ Switch
Каналы (Channels) Каналы (Channels)
Буферизированный канал (Channel Buffering) Буферизированный канал (Channel Buffering)
Синхронизация канала (Channel Synchronization) Синхронизация канала (Channel Synchronization)
Channel Directions Направления канала (Channel Directions)
Select Select
Timeouts Timeouts
Non-Blocking Channel Operations Non-Blocking Channel Operations

View File

@ -1,21 +1,21 @@
// When using channels as function parameters, you can // При использовании каналов в качестве параметров
// specify if a channel is meant to only send or receive // функции вы можете указать, предназначен ли канал
// values. This specificity increases the type-safety of // только для отправки или получения значений. Эта
// the program. // возможность повышает безопасность программы.
package main package main
import "fmt" import "fmt"
// This `ping` function only accepts a channel for sending // Функция `ping` принимает канал только для отправки
// values. It would be a compile-time error to try to // значений. При попытке получения значений в этот канал
// receive on this channel. // в процессе компиляции возниканет ошибка.
func ping(pings chan<- string, msg string) { func ping(pings chan<- string, msg string) {
pings <- msg pings <- msg
} }
// The `pong` function accepts one channel for receives // Функция `pong` принимает один канал для приема
// (`pings`) and a second for sends (`pongs`). // (`pings`) и второй для отправки (`pongs`).
func pong(pings <-chan string, pongs chan<- string) { func pong(pings <-chan string, pongs chan<- string) {
msg := <-pings msg := <-pings
pongs <- msg pongs <- msg