Quickly Start

First make sure you have GO installed, version 1.16 or higher, and that you have set the GOPATH environment variable and added GOPATH/bin to the environment variable.

We recommend that you simply use the latest stable version, as we try to stay on top of the latest version of Go.

Or you can refer:

Windows installation

Linux installation

Mac installation

Please note that after Beego V2 we require the go mod feature, make sure that the go mod feature is turned on, i.e. GO111MODULE=on. More details refer to Go module

Or you can specify the GOPROXY:

  1. GOPROXY=https://goproxy.cn

Next, let’s try to start a hello world example. In this example, we will use the Bee tool to create the hello world project.

More details refer to Bee

Steps

If you already have a development environment installed, then you may consider using our quick install script.

Mac or Linux

Run:

  1. bash <(curl -s https://raw.githubusercontent.com/beego/beego-doc/main/scripts/quickstart.sh)

Or using wget:

  1. bash <(wget -qO- https://raw.githubusercontent.com/beego/beego-doc/main/scripts/quickstart.sh)

Windows

Using curl

  1. bash <(curl -s https://raw.githubusercontent.com/beego/beego-doc/main/scripts/quickstart.bat)

Or wget

  1. bash <(wget -qO- https://raw.githubusercontent.com/beego/beego-doc/main/scripts/quickstart.bat)

Manual Installation

In this section, we will use the go get command, so if you are not familiar with it, we suggest that you read Go get

Always remember, if you experience network problems, or timeout issues, make sure you set up the GOPROXY proxy.

Install Bee

Run:

  1. go get -u github.com/beego/bee/v2@latest

And then

  1. bee version

you can see:

  1. | ___ \
  2. | |_/ / ___ ___
  3. | ___ \ / _ \ / _ \
  4. | |_/ /| __/| __/
  5. \____/ \___| \___| v2.0.x
  6. ├── Beego : Beego is not installed. Please do consider installing it first: https://github.com/beego/beego/v2. If you are using go mod, and you don't install the beego under $GOPATH/src/github.com/beego, just ignore this.
  7. ├── GoVersion : go1.16
  8. ├── GOOS : linux
  9. ├── GOARCH : amd64
  10. ├── NumCPU : 12
  11. ├── GOPATH : /home/xxx/go
  12. ├── GOROOT : /home/aaa/bbb/go
  13. ├── Compiler : gc
  14. └── Published : 2020-12-16

Create Project

Run:

  1. bee new hello
  2. cd hello
  3. go mod tidy

And then:

  1. bee run

you can see:

  1. 2021/03/31 23:29:19 SUCCESS 0004 Built Successfully!
  2. 2021/03/31 23:29:19 INFO 0005 Restarting 'hello'...
  3. 2021/03/31 23:29:19 SUCCESS 0006 './hello' is running...
  4. 2021/03/31 23:29:22.016 [I] [parser.go:413] generate router from comments
  5. 2021/03/31 23:29:22.016 [I] [server.go:241] http server Running on http://:8080