Skip to content

skycoop/gophercises

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gophercises

These are my solutions for Jon Calhoun's gophercises

Exercise 1: Quiz (solution)

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...

Exercise 2: URL Shortener (solution)

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

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

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

Exercise 5: Sitemap Builder

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.

Exercise 6: HackerRank

Huh well I guess this counts as an exercise. Solutions:

Excercise 7: TODO List (solution)

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).