Go version
1.22
Output of go env in your module/workspace:
What did you do?
t, err := template.New(name).ParseFiles(file)
if err != nil {
log.Error("failed to load template", "err", err.Error())
os.Exit(1)
}
then elsewhere ...
What did you see happen?
On Execute() an error was raised:
name: \"name\" is an incomplete or empty template"
What did you expect to see?
Execute() should execute as expected.
Instead, I had to change template.New(name).ParseFiles(file) to template.ParseFiles(file)
I therefore suggest:
- The preferred option would be chaining
template.New(name).ParseFiles(file) works, as reasonably expected
- It errors out if chained
The present situation is unacceptable because you do not discover the problem until Execute() time and when you do, the error message is not helpful in diagnosing the cause.