Screencast Building a Chat Application With Go Electives

  • Carlos Souza
  • 3344 views

Comments

  1. Ryan B Harvey said

    When attempting to go run main.go <ip>, I get an error: Error: listen tcp ,<ip>:8080: bind: can't assign requested address exit status 1

    I've tried changing the IP input, as well as changing the hard-coded port to a 32800's number, but neither has helped.

    Any thoughts on how to fix this?

  2. Eugene said

    Hi guys!

    In other programming languages, resources after use must be closed. How about Go?

  3. Ryan B Harvey said

    Resolved this. Combination of seeing the rest of the segment for how to find the IP, as well as had other things listening on several ports, so had to find an open one to use.

  4. Faculty

    Carlos Souza said

    Glad you solved it, Ryan!

  5. Faculty

    Carlos Souza said

    Hey Eugene. Good call! We must also close resources in Go and we should have done that by calling listener.Close() at the end of the RunHost function and conn.Close() at the end of the RunHost and RunGuest functions.

  6. Faculty

    Carlos Souza said

    I'd also suggest looking into the defer keyword, which defers the execution of a line until the function is finished and it's commonly used to close resources.

  7. Alejandro Socorro said

    Great screencast! Would be great if you guys can make another including goroutines, testing, etc. Thanks again for the amazing contribution!

  8. Alan Thomas said

    Great video to watch after the course. Hoping there will be a follow-up to this, maybe with a multi-threaded chat server accepting connections for multiple clients. This could highlight the use of goroutines as well. Thanks.

  9. Ruslan Sataiev said

    Awesome screencast! Follow-up leveraging goroutines is a great idea! +1

  10. Alexander Lebedev said

    Awesome work! Thank you! BTW, Carlos, rather than use ifconfig | grep em0 ... try just ifconfig em0 ;)

  11. João Henrique Machado Silva said

    Awesome screencast man! Congrats!

  12. devblueray said

    Carlos, have you ever used the Go plugin for intellij? I was curious what you think it compared to VSCode

  13. Faculty

    Carlos Souza said

    Thanks @João! @devblueray Great question, but I have never used Intellij.

  14. oylenshpeegul said

    Instead of looking at os.Args, if we call flag.Args() after calling flag.Parse(), we get the remaining args that are not flags. Then our ip is in the same place in both cases. https://golang.org/pkg/flag/#Args

  15. zukic07 said

    really cool course and screencast, thank you guys!

  16. ykaiboussi said

    Great screencast! thanks guys!

  17. saberlost said

    Why is there not a function that takes an error and if not nil then do the fatal. 1 line instead of 3.

  18. saberlost said

    Also any reason why create a new reader each time? Why not create it outside the loop? Or cannot I continue reading from the buffer?

  19. Faculty

    Carlos Souza said

    @saberlost there could very well be one. Just a coding style difference. I personally don't think it would be a huge improvement in this case. The three lines don't bother me and I actually think it's easier to read but, again, it's up to you.

  20. Faculty

    Carlos Souza said

    @saberlost Yes! You can create the readers outside the loop and pass them as arguments to the handleHost andhandleGuest functions.

  21. Kenneth Wong said

    @Carlos, did u figure out why "mychat/lib" was not automatically imported in the main routine?

  22. Henri Lepic said

    Thank you guys this is a really nice course

  23. Faculty

    Carlos Souza said

    @Kenneth I did not figure it out but I suspect it was a bug on the plugin I was using.

  24. Christopher Nyberg said

    @Carlos, I am having an awful time with this project and the dependency mychat/lib. I read into the issue and only got more confused. Perhaps you can do a little rundown of Go's directory philosophy for the folks unfamiliar with this approach? https://golang.org/doc/code.html#Workspaces

    Thanks and awesome course.

  25. Christopher Nyberg said

    Also, this video really made sense of the whole thing and helped me address some funky issues VScode was throwing: https://www.youtube.com/watch?v=XCsL89YtqCs . Also, for those, like me, that were literally installing go as they went, when you install go and then the vscode plugins, you need to restart, then the second time around, vscode will recognize go and install a bunch of dependencies (9 I think).

    Overall, there was a bit more of a learning curve for a Go project then I expected, but with those links above, I got it figured out.

  26. ekspressdigital said

    What are the whiskeys on your wall?

    Which ones got empty first?

  27. ekspressdigital said

    Mostly a comment about the language itself, but love it how you bring it out as well: It's cool to see how error handling is hadled via returning of tuples and inherently mapping them to variables!

About This Screencast

In this episode, we will take what you learned from the On Track With Golang course to build a simple Go chat application from scratch.

You need to be an enrolled student in order to view this video and subscribe.

Enroll Now