Reproduced
Go basic Learning Record-write Web application-readjust project directory structure (i)
Re-adjust the project directory structure
Some of the previous articles, you can do a simple Web application, but if the use of PHP or Python and other language framework to develop Web applications will find that the structure of the directory is completely a mature architecture, but for Golang, there seems to be no mature architecture, Most of the on-line architecture, is also very casual, such as the most popular Beego, probably looked at the next, the function is complete, can be used directly, but for like I am accustomed to the MVC way, this has to let me feel, this way of writing code, it seems that some let me not accustomed to the very habit, the following let me step on the Make a framework that's right for you to develop.
First of all, we put the view in the previous article to organize, the view.html and edit.html, transferred to the Templates folder, later this folder is our own folder to put the template. At the same time we will view.html and edit.html under the UI, I use the Bootstrap4.0 version, the code is as follows
Templates/view.html
<!doctype html>
Templates/edit.html
<!doctype html>
Modify templates at the same time
Have the original
var templates = template.Must(template.ParseFiles("template/edit.html", "template/view.html"))
Revision changed to
var templates = template.Must(template.ParseFiles("templates/edit.html", "templates/view.html"))
Recompile and run the code
$ go install$ wiki
Perfect, everything is fine. (normal does not mean no problem), back to continue