lijian 48c2e0e9f9 依赖更新为 go mod 1 rok temu
..
.codebeatignore 48c2e0e9f9 依赖更新为 go mod 1 rok temu
.gitignore 48c2e0e9f9 依赖更新为 go mod 1 rok temu
.travis.yml 48c2e0e9f9 依赖更新为 go mod 1 rok temu
LICENSE e4b36fc702 更新api,删除图片rpc 6 lat temu
Makefile 48c2e0e9f9 依赖更新为 go mod 1 rok temu
README.md 48c2e0e9f9 依赖更新为 go mod 1 rok temu
interpol.go e4b36fc702 更新api,删除图片rpc 6 lat temu
io.go e4b36fc702 更新api,删除图片rpc 6 lat temu
options.go e4b36fc702 更新api,删除图片rpc 6 lat temu

README.md

interpol

License GoDoc Build Status Coverage codebeat badge goreportcard

interpol is a Go package for doing format-string like string interpolation using named parameters.

Currently, a template only accepts variable placeholders delimited by brace characters (eg. "Hello {foo} {bar}").

Install

First, you need to install the package:

go get -u github.com/imkira/go-interpol

Documentation

For advanced usage, make sure to check the available documentation here.

Example

The following code should use interpol.WithMap function, which simply replaces every key with the corresponding value of the specified map. When run, it should output Hello World!!!.

package main

import (
	"fmt"

	"github.com/imkira/go-interpol"
)

func main() {
	m := map[string]string{
		"foo": "Hello",
		"bar": "World",
	}
	str, err := interpol.WithMap("{foo} {bar}!!!", m)
	if err != nil {
		fmt.Printf("Error: %v\n", err)
		return
	}
	fmt.Println(str)
}

Contribute

Found a bug? Want to contribute and add a new feature?

Please fork this project and send me a pull request!

License

go-interpol is licensed under the MIT license:

www.opensource.org/licenses/MIT

Copyright

Copyright (c) 2016 Mario Freitas. See LICENSE for further details.