Example #1
0
func FileReplace(path string, data map[string]string) {
	rawContent, err := utils.ReadFile(path)
	checkErr(err)

	rawContent = []byte(StringReplace(string(rawContent), data))
	checkErr(utils.WriteFile(path, rawContent, false))
}
Example #2
0
func FileReplaceToken(path, token, newContent string) bool {
	contents, err := utils.ReadFile(path)
	if err != nil {
		return false
	}

	newContent, ok := ReplaceToken(token, string(contents), newContent)
	if !ok {
		return false
	}

	contents = []byte(newContent)

	if err := utils.WriteFile(path, []byte(contents), false); err != nil {
		return false
	}

	return true
}