DEV Community

Discussion on: GoLang Templating

 
12mohaned profile image
mohaned mashaly • Edited

the first version was right I reverted the changes, If your question is how you're not going to handle the exception if there's an error, well It depends, if you're using this in a production environment or a user is going to interact with application you must add an else statement which shows to the user an error happened or output a user friendly message or you will provide a bad user experience for the user, but since the tutorial focused on Golang Templating I didn't bother trying to deal with exceptions, but of-course it would be more convenient to add something like this in case you're dealing with a user
for example you can add log.fatal(err) also this won't be user friendly it will be for you as a developer to know what is the error.
Hope this answers your question

Thread Thread
 
sennasemakula profile image
Senna • Edited

You must have changed the code because I was referring to when you had:

if (err != nil) {
t.Execute(...)
}

I can see you have fixed this now.