Skip to content

Instantly share code, notes, and snippets.

@kamal-kambe
Created August 1, 2019 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamal-kambe/e935c97ac4ab151f076776e137b7a87b to your computer and use it in GitHub Desktop.
Save kamal-kambe/e935c97ac4ab151f076776e137b7a87b to your computer and use it in GitHub Desktop.
package main
import (
"net/http"
"sample-app/handler"
"sample-app/provider"
"sample-app/provider/sql"
"sample-app/service"
)
func main() {
// Initialize DB
db, err := provider.InitDB()
if err != nil {
panic(err)
}
defer db.Close()
// create storage factory
storageFactory := sql.NewStorage(db)
// create service factory
serviceFactory := service.New(storageFactory)
r := handler.InitRouter(serviceFactory)
if err := http.ListenAndServe(":8080", r); err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment