golang.recipes which is a resource of Go files that convey examples of Go. My last semester of school was so packed that I only programmed in Go once. Getting back into it was intimidating, but I'm glad I got over the hump.
Learning about so many things in such a short amount of time makes retention difficult. I thought it'd be nice to share some of the examples I've created whenever I learn something new. It would be great to see contributors add their own snippets.
The project is available on Github here. Just developing this project alone has taught me so much. I'm not sure how much mileage others will get from it, but I plan to keep on developing the "Cookbook" for as long as I am learning something.
(I'll be editing this post to add more technical details as I work on things)
The most notable of the packages used to develop the server include html/template and bufio. Thanks to them, the recipe list is generated automatically.
To retrieve all of the file names in the recipes directory, I used the
ReadDir function from the
io/ioutil package. The recipe names are included on the first line of every file, so all I had to do was read the first line and keep everything minus the comment tokens.
html/template package is pretty complex, way more than I described it to be in my last post. One nifty thing I had to do was call a method from the templating file.
Apologies if this post isn't as thorough on the technical details as usual!
- SSL Support, just as a learning experience.
- Test support.
- Recipes are sorted alphabetically, I'm planning on separating them by category soon.
- Syntax highlighting for recipes!
- New Pages; a contributors page would be nice.
- Need to ask permission for Go Playground support.
- Major renaming and refactoring. Page templates are scattered and recipes should be categorized...