t := template.Must(template.New("").Parse(someInfileTemplate))
err = t.Execute(os.Stdout, links)
I was able to render and print the template to the os.Stdout.
Now I have expanded the code and am taking a outFileFlag which is a String flag from argparse module which returns a pointer to string. argparse should not be a problem because stdlib flag module returns the same pointer to string.
I tried using ioutil.WriteFile but got confused.
How do I convert a pointer to a string to io.Writer which template.Execute takes?
No need to open Stdout. It is already ready to use as it is defined in os.go
Stdin = NewFile(uintptr(syscall.Stdin), “/dev/stdin”)
Stdout = NewFile(uintptr(syscall.Stdout), “/dev/stdout”)
Stderr = NewFile(uintptr(syscall.Stderr), “/dev/stderr”)