/go-boilerplate

Primary LanguageGoApache License 2.0Apache-2.0

Go(lang) Repository Pattern Boiler Plate

License

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:

Prerequisite

  • 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.

Installation

  1. Clone this repository
  2. Run dep ensure
  3. If you use Codegangsta - Gin, run gin r main.go or if not, you can run go run main.go

License

See LICENSE.

Localization

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)
	...
}
...