Go basic Learning Record-write Web application-readjust project directory structure (i)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.