Categorygithub.com/madhums/go-gin-mgo-demo
modulepackage
0.0.0-20230618211029-ce6400d8a605
Repository: https://github.com/madhums/go-gin-mgo-demo.git
Documentation: pkg.go.dev

# README

go-gin-mgo-demo

A demo CRUD application in golang using the popular gin-gonic framework

Development

  1. Clone the (forked) repo.
  2. Then, run
$ go get github.com/codegangsta/gin

codegangsta/gin is used to to automatically compile files while you are developing

  1. Run
$ go get && go install && PORT=7000 DEBUG=* gin -p 9000 -a 7000 -i run # or run make dev

Then visit localhost:7000

  1. MONGODB_URL and PORT can be configured by setting the env variable.
$ export MONGODB_URL=mongodb://
$ export PORT=7000
  1. godep is used for dependency management. So if you add or remove deps, make sure you run godep save before pushing code. Refer to its documentation for more info on how to use it.

Usage

$ go get github.com/madhums/go-gin-mgo-demo
$ PORT=7000 GIN_MODE=release go-gin-mgo-demo # should start listening on port 7000

Credits

Thanks to all the dependent packages

# Packages

No description provided by the author
Package GinHTMLRender provides some sugar for gin's template rendering This work is based on gin contribs multitemplate render https://github.com/gin-gonic/contrib/blob/master/renders/multitemplate Usage router := gin.Default() // Set html render options htmlRender := GinHTMLRender.New() htmlRender.Debug = gin.IsDebugging() htmlRender.Layout = "layouts/default" // htmlRender.TemplatesDir = "templates/" // default // htmlRender.Ext = ".html" // default // Tell gin to use our html render router.HTMLRender = htmlRender.Create() Structure |-- templates/ |-- |-- 400.html |-- 404.html |-- layouts/ |--- default.html |-- articles/ |--- list.html |--- form.html And if you want to render `templates/articles/list.html` in your handler c.HTML(http.StatusOK, "articles/list", "") .
No description provided by the author
Package middlewares contains gin middlewares Usage: router.Use(middlewares.Connect).
No description provided by the author

# Constants

Port at which the server starts listening.