How can we save a text template in a file without doing template.execute

Hi everyone,

i am fairly new in golang. I am trying to read my helm chart text template, make some changes in some of the key-value pairs and then save it again as a diff template.

the problem is I cannot find a way to update values for key-value pairs in the template and also I cannot find a way to save the resulting template to a file.

thanks for your help.

You can store key-values in localStorage (at browser level)

hi silbert,

thanks for the reply, but I am working on text templates not Html.

I use “text files” for logging. It may also work on html templates and vanilla templates. This way I store the log:

func stat(msg string) {
	file, err := os.OpenFile("stat.txt", os.O_APPEND|os.O_WRONLY, 0644)

	if err != nil {

	defer file.Close()

	_, err2 := file.WriteString(msg + "\n")

	if err2 != nil {

thanks silbert, this is not it :slight_smile: the problem with text template is the only way to write them out is with template.execute. i dont wanna do that as it will stop being a template after that function. anyways, i think I figured it out, so will close the thread.

solution: use the root.nodes and iterate through them to save the template in a file.
thanks for your help. have a nice day.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.