foreword
The beego framework was developed in 2012 and is open sourced by a Chinese bigwig in order to provide an efficient web application development framework.
github address:github.com/beego/beegoSo far, 28.5k stars have been harvested.
Official website address:beego.vip/
It can be seen that this framework is very important. Compared with go developers, it is a good choice to quickly build a set of web applications.
develop
beego installation
On the premise that the computer has installed the go environment, check the local computer go version
go version
go get github.com/beego/beego/v2
bee installation
The bee tool is a project created to assist the rapid development of beego projects. Through bee, you can easily create, hot compile, develop, test, and deploy beego projects.
Versions prior to go 1.16go get -u github.com/beego/bee/v2
go 1.16 and latergo install github.com/beego/bee/v2@latest
Verify that the installation of bee was successful
New Project
In the root directory src of go, execute and bee new beegodemo
you can see the following, create a new beegodemo project file, open this folder with golang to see the directory structure
It can be guessed that main.go must be the entry file. Before running, remember to go mod vendor
download all dependencies first.
run the project
package main
import (
_ "beegodemo/routers"
beego "github.com/beego/beego/v2/server/web"
)
func main() {
beego.Run()
}
Open the main.go file, you can see that there is only one line of code in the main method, and our service can be started.
runbee run
problem log
Most of the main problems encountered are environmental problems
go tool: no such tool compile
If this is prompted after bee run, probably the go version environment does not have this compile tool, you can go to the go version directory to view
Confirm the go version of the current environment, there is this compile in the directory. learn to use
go version
Currently installed go version
go env
View go configuration
cat ~/.zshrc
View environment variables under mac
If there is a problem with running and compiling, first compare the configuration of each environment variable.
Summarize
The beego project was successfully built for the first time, and other development needs to be done in the future, that is, it can be carried out according to the official documents. The various web frameworks of go are still very good, and there are others
Buffalo:gobuffalo.io/
Gin: An HTTP web framework written in Go. It provides a Martini-style API with better performance.github.com/gin-gonic/g…
Iris: Currently the fastest growing Go web framework. Provides full MVC functionality and is future-proof.
Revel: A high productivity, full stack Go web framework.
github.com/revel/revel
This article is participatingTechnical Special Issue 18 - Talking about the Go Language Framework