diff --git a/examples.txt b/examples.txt index 6a15cb3..1c34ad2 100644 --- a/examples.txt +++ b/examples.txt @@ -23,7 +23,7 @@ Switch Каналы (Channels) Буферизированный канал (Channel Buffering) Синхронизация канала (Channel Synchronization) -Channel Directions +Направления канала (Channel Directions) Select Timeouts Non-Blocking Channel Operations diff --git a/examples/channel-directions/channel-directions.go b/examples/channel-directions/channel-directions.go index 5f2786c..c5f4de0 100644 --- a/examples/channel-directions/channel-directions.go +++ b/examples/channel-directions/channel-directions.go @@ -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 import "fmt" -// This `ping` function only accepts a channel for sending -// values. It would be a compile-time error to try to -// receive on this channel. +// Функция `ping` принимает канал только для отправки +// значений. При попытке получения значений в этот канал +// в процессе компиляции возниканет ошибка. func ping(pings chan<- string, msg string) { pings <- msg } -// The `pong` function accepts one channel for receives -// (`pings`) and a second for sends (`pongs`). +// Функция `pong` принимает один канал для приема +// (`pings`) и второй для отправки (`pongs`). func pong(pings <-chan string, pongs chan<- string) { msg := <-pings pongs <- msg