I am brand new to Go, started learning it less then a manth ago for a pet project. Coming from C/C++ I quite like it a lot, thanks!!!
I am building my pet project using code from the examples and I fear I have found a bug or an inconsistency in documentation.
I am trying to use template.Parse(string) but it is NOT defined when I build my code. If I replace it with template.ParseFiles(filename) then it works great.
Just to double check that I do not have a wrong version of Go installed (I am under Ubuntu 17.10 and followed the online instructions to install Go), I have tried the very same on the interactive “Try Go” home page and I have the very same problem: template.Parse is not defined.
// You can edit this code!
// Click here and start typing.
package main
import "fmt"
import “html/template”
func main() {
t,_ := template.Parse(“just test that it builds”)
fmt.Println(“Hello, 世界”)
}
So why with ParseFiles it does BUILD while with Parse it DOES NOT BUILD? If it did build with both or did not build with either, I would have proceeded further in debugging and double checking the reference code I have been studying and adapting from, which is:
Just go down to the usage of templates and ParseFiles, I started dynamically modifying the template from the Golang code before parsing it as I needed to add more code with a for loop rather than just reading from the file.
Thanks a lot, you have helped me move forward anyway!