Skip to content

capybara-alt/msgutil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Massage Util

Table of contents

Usage

  • Execute command below to install this library
~$ go get github.com/capybara-alt/msgutil
# or
~$ go install github.com/capybara-alt/msgutil
  • Create message resource file (json file like below)

{
  "errors": {
    "login": "login failed",
    "validate": {
      "email": "Invalid mail address",
      "password": "Invalid password"
      "profession": "Professions must be {{0}}"
  },
  "info": {
    "login": "success!!"
  },
}

  • Call function "Init" to initialize message resource
    msgutil.Init("path to resource file")
  • Call function "GetMessage" or "GetMessageArgs" to get message defined in resource file
    msgutil.GetMessage("errors", "login")
    // or
    msgutil.GetMessageArgs([]string{"errors","validate","profession"}, "Engineer/Manager")

About

Manage message resource in golang application

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages