Skip to content

trevrosen/git-grabber

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-grabber

A presentation

Originally constructed for the March 2017 presentation at the ATX Golang meetup.

A demo app

Sometimes the best way to get a new language into your organization is with a port of something you've already got.

I've used this stack and structure a few times for microservices. I find it easy to deal with and flexible enough to carry forward some of the (sadly necessary) warts that might exist in legacy projects.

What it does

  • Boot
  • Not a whole lot, but not nothin
  • Settle down, this is is just here to demo a structure

Prerequisites/Conventions

  • Use a Makefile to make common tasks easy
  • Use Make to install non-app deps like Ginkgo, Goose, Glide
  • Use jq for grabbing config info in Make tasks
  • Config lives in $HOME/.<APP_NAME>
  • DB info lives in config.json in the config dir
  • Glide is the package manager

Stack

  • Gorilla Mux - URL routing/multiplexing
  • Logrus - configurable logging
  • Negroni - middleware management
  • Viper - unified configuration
  • Gorm - ORM-style DB access
  • Ginkgo - BDD-style testing (just for DB unit tests)
  • Glide - dependency management

Structure

Here's how I structure into subpackages and directories:

  • controllers

    • app.go - routes and the attendant middleware wire-up
    • github_user_controller.go - an example of dividing up the controllers package into handlers corresponding to groups of routes
  • db

    • db.go - interface and concrete type declarations and connection establishment
    • github_user.go - an example of dividing up the db package into type-specific files
  • middleware

    • request_id.go - an example of using middleware to tag incoming requests with a unique string
    • logging.go - an example of using Logrus-powered middleware as a replacement for log
  • _testing

    • main_suite.go - setup for a Ginkgo test suite
    • github_user_test.go - an example of using Ginkgo for database unit testing of concrete-type DB methods

About

Demo app for porting something to Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published