I want to store html Template code in Go. Currently it is store in the static files section. But I want to add it in one go the go files. I cannot store it in string format because one of the function requires a html file as a function argument. So is there any way to create create html file at runtime and such that it is not stored.
I tried converting the string to html file and than manually deleting the html file. But I want a programmatic approach.
2
Answers
You can store the HTML content in string and write this content in a temp .HTML file and pass it your function.
If you need to pass HTML file as object to function argument then the embed package should help.
Create a HTML file, embed it in your go code rather than storing as string during compile time. The HTML file does not need to be shipped along with compiled binary.