Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Building APIs using Go

550 views

Published on

How i use Go to develop APIs

Published in: Technology
  • Be the first to comment

Building APIs using Go

  1. 1. Building APIs using Go Elton Minetto @eminetto http://eltonminetto.net
  2. 2. This is my approach based on other projects...
  3. 3. No frameworks!
  4. 4. Stdlib + small pieces
  5. 5. • github.com/asaskevich/govalidator • github.com/codegangsta/negroni • github.com/go-sql-driver/mysql • github.com/gorilla/mux • github.com/joho/godotenv • gopkg.in/gorp.v1 • github.com/rubenv/sql-migrate
  6. 6. Project structure
  7. 7. pkg user/ user.go (structs and service interface) user_test.go (tests) mysql.go (implementation of the service interface) middleware/ Cors.go -> add cors headers isAuthenticated.go -> request authentication
  8. 8. api handler/ user.go (define routes, handler implementation) main.go (act as a dependency injection container)
  9. 9. cmd
  10. 10. bin
  11. 11. config
  12. 12. doc
  13. 13. migrations
  14. 14. vendor (e other files)
  15. 15. Links https://github.com/eminetto/go-web-skel Desenvolvendo APIs em Go usando Middlewares Definindo APIs com o API Blueprint Gerenciando dependências em Golang
  16. 16. Contato http://twitter.com/eminetto http://eltonminetto.net http://asemanago.com.br (+550 assinantes) eminetto@gmail.com

×