gophercises
These are my solutions for Jon Calhoun's gophercises
Quiz (solution)
Exercise 1:Completed parts 1 and 2, as well as both bonus tasks. I was already sold on Go's concurrency abstraction but writing
this drove home how powerful it could be. I'm very pleased with the simplicity, although the stupid issue with the
random seed is driving me crazy. For some reason I keep getting the same value out of time.Now()
on my Windows
10 system. I'm still a little unsure on how best to handle command line flags. The flags
module is great for handling
the parsing, but I feel like I'm using it slightly wrong...
URL Shortener (solution)
Exercise 2:I mostly solved the problem. YAML is easy so I ignored that. Overall, this solution is on the way to something more complicated and feature complete, so I think I'll loop back to it after doing some more exercises. TODOs:
- Investigate building a full webapp with Buffalo
Choose Your Own Adventure (solution)
Exercise 3:Fairly simple one. The templating library is a bit odd, but not terrible to work with. TODOs:
- Investigate using pkger for embedding the template files in the binary
- Make it prettier
- CLI version
HTML Link Extractor (solution)
Exercise 4:XML is the worst 😖 I got the href extraction working, don't really feel like doing the text extraction. The
testing
module is cool, but I can see why there are frameworks built on top of it. No one wants to write the standard
set of equality operations required.
TODOs:
- Refactor the recursive algorithms to use goroutines
- Do the text extraction
- Try a testing framework like Testify or maybe a BDD framework if I'm feeling fancy
Sitemap Builder
Exercise 5:Well if the point of #4 was just to build an href extractor, I think I might be ok with where I left it :stuck_out_tongue_closed_eyes:. I'm going to skip this one for the moment and come back when I want to wrangle with XML.
HackerRank
Exercise 6:Huh well I guess this counts as an exercise. Solutions:
TODO List (solution)
Excercise 7:Oh sweet this exercise (despite it's non-obvious name) is exactly what I wanted. I wanted to fiddle with cobra and BoltDB (I'm using the etcd fork since the original isn't being updated and I like etcd).