This is a creation in
Article, where the information may have evolved or changed.
Beego Log module is independent, can be written to the console, files, mail and other places, we will each log output point into a adapter. What are the characteristics of Beego's diary? 1. You can output the same log to multiple adapter, so that you can see the program running in the console, and the file can be saved in 2. Can set the level of the log, according to the
Beego is a fast-developing HTTP framework for GO applications that can be used to quickly develop applications such as APIs, Web and backend services, and is a RESTful framework designed to be inspired by the three frameworks of tornado, Sinatra and flask, but with the go A framework designed for some of its own characteristics (interface, struct embedding, etc.).Go is a open source programming language that makes it easy-to-build simple, reliable, an
Beego provides a set of web development frameworks. However, we have encountered some problems in the development process, now summarized as follows.Test 1: Test only the keys arrayFunc (This *: = "make" ([]string, 0)this. Ctx.Input.Bind (keys, "Keys")fmt. Println (keys, len (keys))}Test results:Url:http://api.query.qihoo.net:8090/test/index?keys[]=testkeys[]=testResults: [] 0Repeated tests multiple times with the same resultTest 2: Test the case with
library, the second do the project.Under Mac settings: (assuming ~/workspace_go/demo1is the project catalog)Command-line modification: ~/.bash_profile#set golang path export GOROOT=/usr/local/goexport GOPATH=/usr/local/go_path:~/Workspace_go/demo1export PATH=$PATH:/usr/local/go_path/binModify the system environment: ~/. Macosx/environment.plistplist version="1.0">dict> key>Gopathkey> string>/usr/local/go_path:~/workspace_go/demo1string> key>Gorootkey> string>/usr/local/gostring>
This is a creation in
Article, where the information may have evolved or changed.
Record the use of Beego to delete and change the implementation of the database using MySQL, the complete code is as follows:
PackageMainImport ( _ "Crud_beego/routers"//Auto-Enrollment Routing"FMT" "Github.com/astaxie/beego" "Github.com/astaxie/beego/orm" _ "Github.com/go-sq
This is a creation in
Article, where the information may have evolved or changed.
Configuration environment: Windows7Recommended Ide:liteideGo Download Address: http://www.golangtc.com/downloadBeego Development Document Address: http://beego.me/docs/intro/
Installation steps:First, GO environment installationSecond, configure the system variablesThird, Beego installation
First, GO environment installationAccording to the download address a
1. Uploading Files
1.beego website
View Upload Https://gowalker.org/github.com/astaxie/beego2. Find the SaveToFile method
SaveToFile saves uploaded file to new path. It is only operates the first one of the Mutil-upload form file field.
Func (c *controller) SaveToFile (FromFile, tofile string) error {
File, _, Err: = C.ctx.request.formfile (fromfile) if err! = Nil { return err } defer file. Close () F, err: = OS. Ope
Reference URL: Http://beego.me/quickstartFollow the official website tutorial, execute the commandget github.com/astaxie/get Github.com/beego/beeError (if: Go is already installed, Git is already installed)Error One: go:missing Git command. See Http://golang.org/s/gogetcmdError reason: Although the Git tool is installed natively, the path to git is not found in the environment variablesAdd environment variables toC:\Program Files\git\binError two: exe
need to focus on the logic level of things
The second is lightweight so that their code is very clear, and we can learn and understand some of the details of the language by reading their sources.
Third, the project developers can be based on these frameworks to adapt to their own projects, so as to achieve the creation of two-time framework
So based on these considerations, I want to implement a lightweight framework similar to these languages, so I at the end of the book design two
This is a creation in
Article, where the information may have evolved or changed.
Today when using Beego to do data insertion encountered a problem, my configuration is correct, but the data is always unable to insert, and then opened the log after the discovery:
Must one register DataBase alias named ' Default '
It means that I have to have an alias named:default Database
OK, look at my Code:
Orm. RegisterDatabase ("Postgresdb", "Postgres", "User=pos
Using association queries in Beego (join query)
Document URL: here
//使用实例:article:=new(Article)num,err:= o.QueryTable("go_article").RelatedSel().All(article)
However, the direct use of Relatedsel () is not possible and must first be defined in model:
type User struct { Id int Name string Age int}type Article stuct { Id int Title string Content string User *User `orm:"rel(fk)"` //这样写,默认在Article中应该有一个user_id的字段,如
This is a created
article in which the information may have evolved or changed.
Tried, in the go environment ready in the case, took 2 minutes to complete the Beego installation, Project generation and start-up, the efficiency is good
1. Installation:
Go get Github.com/astaxie/beego
Go get Github.com/beego/bee
2. Build the project structure:
Bee New Hellpg
Beego is a fast-developing HTTP framework for GO applications that can be used to quickly develop applications such as APIs, Web and backend services, and is a RESTful framework designed to be inspired by the three frameworks of tornado, Sinatra and flask, but with the go A framework designed for some of its own characteristics (interface, struct embedding, etc.).1, the installation of BeegoGo get Github.com/astaxie/beegoMore installation information:
# beego_blog#### Code Cloud source:-https://gitee.com/griffin702/beego#### Github source:-https://github.com/griffin702/ beego_blog#### myblog:-http://www.inana.top/Default does not automatically generate the database, the initial use of the project can be directly used in the root directory of the Beego_blog.sql manually import the database initial Administrator account: ' Admin ' password ' 123456 ' Thanks to the original author: Double liu#### upda
This is a created
article in which the information may have evolved or changed.
HTML code:
Beego Code:
Func (this *servicecontroller) Upload () {F, H, _: = this. GetFile ("myfile") //Get uploaded file path: = Sdpath + h.filename//file directory F. Close () //Closes the uploaded file, otherwise the temporary file cannot be purged if this is the case. SaveToFile ("myfile", Path)
This is a creation in
Article, where the information may have evolved or changed. Package Main
Import (
"FMT"
"Github.com/astaxie/beego/orm"
_ "Github.com/go-sql-driver/mysql"
)
Type User struct {
Id int ' orm: ' Auto '
Name String
profile_id int
}
Func init () {
Orm. Registermodel (New User)
Orm. RegisterDatabase ("Default", "MySQL", "Ta3:ta3@/ta3?charset=utf8")
Orm. RUNSYNCDB ("Default", False, True)
}
Func Main () {
VAR (
sSQL string
Tags: tips for sqlite running exec build CGO Development Arch InstallationUse Beego+go-sqlite3 for simple blog development under Windows, but after compiling it into an arm platform, run the exception:Compile parameter settings:SET Goarch=armSET Goos=linuxSET goarm=7Go BuildFirst, prompt sqlite3 application problem, should turn on cgo_enabled=1 this itemSolve:SET Goarch=armSET Goos=linuxSET goarm=7SET cgo_enabled=1SET CC=ARM-LINUX-GNUEABIHF-GCCGo Buil
This is a created
article in which the information may have evolved or changed.
For beginners of our go language, we like to learn to write small code while learning. After each write, we all want to see the results of the program, although the Go run tool is often easy to run and can see the results directly, but is it annoying to repeat this command every time?
Fortunately the Beego Framework provides a bee tool that would have been used for the
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.