Create an employee overtime take some system using Beego

Source: Internet
Author: User

Recently in learning Golang, always want to do a website to practice practiced hand, just work really need such an employee overtime take some system to record staff overtime and take some situation, so think with Beego to build this system, learning while doing.

First record in the development process encountered some of the problems it, back to the source code to get up.

Installation of 1.beego. There is nothing wrong with installing the Beego, but there is a problem when installing the Bee tool because I am using it under windows and need GCC support. This needs to install the GCC version software under Windows, I am referring to this post to do, http://jingyan.baidu.com/article/c275f6bacc0126e33c756771.html, install the MinGW. However, after the installation of this tutorial is a bit of a problem, and then I in the C-drive under the creation of a GCC folder, the bin directory about the GCC EXE files are taken over to be able to.

2. About the Beego project. I created a new Beego project according to the process, and it really worked. But then I need to submit the code to Oschina above, and then create a new folder, the original file copy of the past, but found that can not be run, the new folder changes are always unresponsive. Later found that there are mainly 2 problems, the first project file must be placed in the Gopath src directory, in addition to an existing file, you need to switch to the corresponding directory, the execution of Bee run app name after hot compilation.

3. I used MySQL in the project, after I built the model, according to the model of the field to the MySQL to create the corresponding table, the results found no mapping, and then I deleted the table in MySQL, let the Beego program to create their own table according to the model can be. It is found that the table created by Beego is not the same as in the entity class, such as the fields in the Entity class username,mysql the field name of the corresponding table in the database is user_name. So it's better to let Beego go directly to create a data sheet. In addition, MySQL configuration information can be written into the configuration file, and then in the project by reading the contents of the configuration file to connect to the database, it is more convenient, it is important to note that if you want to connect to the remote database, host needs to write TCP (127.0.0.1:3306).

4. I realized the user login function in the project, but did not use the database, directly determine whether the input content matches, if matching will save the user name to the session, and then in other methods to increase the judgment of the session, not empty to normal access, otherwise jump back to the landing page. Note here is to be sure to open the session, because Beego default is not open, open the way there are two, one is written in main.go Beego.sessionon = "true", Another way is to add sessionon= "true" in the app.conf, I am using the second way, because the first way I wrote after compiling but, Sessionon cannot find, do not know is because Beego version of the problem.

5. About deployment. Look at the official document, the deployment is the generation of binary files (EXE) and some static resources and page template package put together, and then put on the server, run EXE file should be able to, here can put EXE file to Windows service inside realize self-start. Set the method to download Instsrv.exe and srvany.exe two files, the command line is located in the Instsrv folder, execute instsrv ServiceName C:\Windows\System32\srvany.exe, If you want to uninstall, execute Instsrv ServiceName remove. After installation, also modify the following registry,

Start-run-regedit, open the registry, and navigate to the following path. Hkey_local_machine\system\currentcontrolset\services\servicename

If the service name does not have a parameters project, right-click the new item on the service names project, name parameters, and then navigate to the parameters item to create a new string value for the following.

The name application value is the address of the program that you want to run as a service.

The name Appdirectory value is the folder path of the program that you want to run as a service.
The name appparameters value is the parameter you need to start the program that you want to run as a service. Next we go into the system service, find servicename this service, double-click into its properties. Settings allow interaction with the desktop. Then start the service.

Instsrv.exe and Srvany.exe two files for: http://download.csdn.net/detail/aiwuziji/9513523

Another thing to note is to change the RunMode, instead of prod this mode of production.

Finally give the source code address: Https://git.oschina.net/snowbird/gotest.git

  

Create an employee overtime take some system using Beego

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.