0
0
Goprogramming~10 mins

Channel creation in Go - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a channel of integers.

Go
ch := make([1])
Drag options to blanks, or click blank then click option'
Achannel int
Bint
Cchan int
Dchan
Attempts:
3 left
💡 Hint
Common Mistakes
Using just the type without 'chan' keyword.
Writing 'channel' instead of 'chan'.
Omitting the 'chan' keyword.
2fill in blank
medium

Complete the code to create a buffered channel of strings with capacity 5.

Go
ch := make(chan string, [1])
Drag options to blanks, or click blank then click option'
A3
B0
C10
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using zero capacity for a buffered channel.
Forgetting the capacity argument.
Using a negative or invalid number.
3fill in blank
hard

Fix the error in the channel creation code.

Go
ch := make(chan int [1])
Drag options to blanks, or click blank then click option'
A 5
B, 5
C; 5
D: 5
Attempts:
3 left
💡 Hint
Common Mistakes
Using space instead of comma between arguments.
Using semicolon or colon instead of comma.
Omitting the comma.
4fill in blank
hard

Fill both blanks to create a buffered channel of floats with capacity 8.

Go
ch := make([1], [2])
Drag options to blanks, or click blank then click option'
Achan float64
Bchan int
C8
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong channel type like chan int.
Using wrong capacity number.
Omitting the capacity for buffered channel.
5fill in blank
hard

Fill all three blanks to create an unbuffered channel of booleans and assign it to variable done.

Go
var done [1]
done = make([2])

// Use the channel
done[3] true
Drag options to blanks, or click blank then click option'
Achan bool
C<-chan bool
D <-
Attempts:
3 left
💡 Hint
Common Mistakes
Using directional channel type <-chan bool incorrectly.
Using function call syntax like () instead of <- for sending.
Declaring variable with wrong type.