Skip to content

Commit

Permalink
Channel Direction
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya43 committed May 30, 2021
1 parent 497d549 commit 0aab30e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,17 @@ ch := make(chan int)
- There is a buffer between sender and receiver Goroutine.
- We can specify capacity i.e. Buffer size, which indicates the number of elemenets that can be sent without the receiver being ready.
- Sender can keep sending the values until buffer gets full. When the buffer gets full, the sender will get blocked.
- Receiver will keep receiving values until buffer gets empty. When the buffer gets empty, the receiver will get blocked.
- Receiver will keep receiving values until buffer gets empty. When the buffer gets empty, the receiver will get blocked.

-----------

## Channel Direction:
- When using channels as a function parameters, we can specify if a channel is meant to only send or receive values.
- This will increase the Type Safety of our program.
- For e.g.
```go
func(in <-chan string, out chan<- string) {
// in: This channel can only receive values of type string
// out: This channel can only send values of type string
}
```

0 comments on commit 0aab30e

Please sign in to comment.