Beego Bee installation and create, run the project

1. Introduction

  1. What is Bee?

The bee tool is a project created to assist in the rapid development of Beego projects. It is easy to create , hot compile, develop, test and deploy Beego projects through bee
  1. Beego Chinese Documentation

Beego Chinese Documentation: Introduction to Beego
  1. Prerequisites

Before installing bee, you must first install the Go development environment in advance. For the Go environment installation, see [go study notes. Chapter 2] 2. The development tools of the go language and the installation and configuration of the SDK . After installing the Go development environment, You can install Bee

2. Installation

  1. Detect Go environment

After Beego V2 , it is required to use the go mod feature. Make sure to enable the go mod feature : that is, set GO111MODULE=on, use go env to check whether the value of GO111MODULE is on, as shown in the following figure:
If GO111MODULE is empty or off , use the following command to modify the value of GO111MODULE to on
go env -w GO111MODULE=on
If you are in China, it is recommended to set GORPOXY at the same time. If you do not set it, it may cause the dependency download to fail. It is best to suggest setting GORPOXY
go env -w GOPROXY=https://goproxy.cn,direct
  1. Download and install Bee

If the version of go is greater than go1.16, execute the following command on the command line:
go install github.com/beego/bee/v2@latest
If the version of go is less than go1.16, use the following command to install:"
go get -u github.com/beego/bee/v2

Open the command terminal, enter the installation command according to the version of go, wait for the installation to complete, after the installation is complete, there will be bee.exe executable file in the bin directory of GOPATH, open the terminal and enter bee version to check whether bee is installed successfully

The same operation is also performed in the linux environment. Find the bin directory under GOPATH and run ./bee version to check whether bee is installed successfully.
  1. Configure bee system variables

At this time, if you execute the bee version command in other places, if an error is reported, you need to configure bee.exe into the system variable . After configuration, open the terminal in any folder and enter bee version to check whether the bee system variable is configured successfully. , so that the project can be created in the project src directory

In the Linux system, it is also necessary to configure the bee under the bin to the system environment variable, as shown in the following figure:

After configuration, run source /etc/profile

3. Create a project

  1. Create a beego project

Execute the following command in a folder to create a beego project of beegodemo , both linux and windows are the same command
bee new beegodemo
After the command is executed successfully, a folder named beegodemo will be created in the current directory, and then enter the beegodemo folder

The project structure is as follows:

  1. Execute the go mod tidy command

Enter the beegodemo folder from the command line, execute the go mod tidy command, and generate the go.sum file
go mod tidy
  1. Startup project

Use bee run to try to start the project
bee run
  1. access

The browser accesses http://localhost:8080, and the following interface appears, which means that the creation of a beego project and the installation of the bee tool have been completed

Guess you like

Origin blog.csdn.net/zhoupenghui168/article/details/131446012