Before you explore the whole codes, please understand the what is the repository pattern and how it works. Some of these articles may help you to understand the concept:
- This boiler plate use GIN as the framework. (GIN)
- This boiler plate use GORM as the ORM. (GORM)
- This boiler plate use Goose as database migration tool. Please intall it before. (Goose)
- This boiler plate use Dep as the dependency management tool. Please install it before. (Dep)
- For live reloading utility on local connection, you can use Codegangsta - Gin.
- Clone this repository
- Run
dep ensure
- If you use Codegangsta - Gin, run
gin r main.go
or if not, you can rungo run main.go
See LICENSE.
Thanks to nicksnyder/go-i18n for the awesome package.
In this boiler plate, I just define two language (english and indonesian). You can override this according to what you need. The value of the language is store in .yaml
file (in this case en.yaml
and id.yaml
).
How to used :
...
import "${GOROOT}/go-boilerplate/lang"
...
func Test() {
...
val := lang.Translate("your_key_on_yaml_file", nil)
// If you need to parse attribute
attribute := map[string]string{"Attribute": "Value"}
val := lang.Translate("your_key_on_yaml_file", attribute)
...
}
...