How to access a go variable in html file


I want to access a config file variable in HTML file. Can anyone suggest me how to do this?

Thanks in advance.

This is usually done though a templating system like Pass the variables you need (in a data structure) when executing the template. The placeholders in the template will be replaced with properly escaped values from the specified variables.

@nathankerr, can you provide me a sample for doing it?

Here’s an example by @joncalhoun:

@nathankerr, Thanks.but one problem, I am getting the value in the terminal but I am unable to get it on the browser.Please suggest.

Keep reading to part 2, which starts by executing the template in a web server.

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