

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Welcome to 'Learn the HTTP Protocol'
incomplete
2: TheStartup™
incomplete
3: 8 Bytes
incomplete
4: Newlines
incomplete
5: Channel Refactor
incomplete
This lesson's interactive features are locked, please to keep using them
If you wrote your code like mine, there's a good chance that you've got a little state machine going on directly inside your main function.
Let's refactor our code so that we have a nice reusable function that reads lines from a TCP connection.
func getLinesChannel(f io.ReadCloser) <-chan string
"read: " or add a newline character at the end. Instead, it sends one line at a time to the channel.os.File implements io.ReadCloser, so you can pass your file directly to your new function."read: " and followed by a newline.Your code should behave the same way as before, but now the logic for reading lines is encapsulated in a reusable function.
Run and submit the CLI tests.