Bee is a tool for helping develop with beego app framework.
Bee is a tool for helping develop with beego app framework.
Bee is a command-line tool facilitating development of Beego-based application.
To install or update bee use the go install command:
go install github.com/beego/bee/v2@latest
bee binary to PATH environment variable in your ~/.bashrc or ~/.bash_profile file:export PATH=$PATH:<your_main_gopath>/bin
To install bee use the go get command:
go get github.com/beego/bee/v2
If you already have
beeinstalled, updatingbeeis simple:
go get -u github.com/beego/bee/v2
Bee provides a variety of commands which can be helpful at various stages of development. The top level commands include:
…
To display the current version of bee, beego and go installed on your machine:
$ bee version
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v2.0.4
├── Beego : 2.0.4
├── GoVersion : go1.14.1
├── GOOS : darwin
├── GOARCH : amd64
├── NumCPU : 4
├── GOPATH : /home/beeuser/.go
├── GOROOT : /usr/local/Cellar/go/1.14.1/libexec
├── Compiler : gc
└── Published : 2020-09-13
You can also change the output format using -o flag:
$ bee version -o json
{
"GoVersion": "go1.14.1",
"GOOS": "darwin",
"GOARCH": "amd64",
"NumCPU": 4,
"GOPATH": "/home/beeuser/.go",
"GOROOT": "/usr/local/Cellar/go/1.14.1/libexec",
"Compiler": "gc",
"BeeVersion": "2.0.4",
"BeegoVersion": "2.0.4",
"Published": "2020-09-13"
}
For more information on the usage, run bee help version.
To create a new Beego web application:
…
For more information on the usage, run bee help new.
To run the application we just created, you can navigate to the application folder and execute:
$ cd my-web-app && bee run
For more information on the usage, run bee help run.
To compress a Beego application into a single deployable file:
…
For more information on the usage, run bee help pack.
Inspired by makefile / npm scripts. Run script allows you to run arbitrary commands using Bee. Custom commands are provided from the "scripts" object inside bee.json or Beefile.
To run a custom command, use: $ bee rs mycmd ARGS
$ bee help rs
USAGE
bee rs
DESCRIPTION
Run script allows you to run arbitrary commands using Bee.
Custom commands are provided from the "scripts" object inside bee.json or Beefile.
To run a custom command, use: $ bee rs mycmd ARGS
AVAILABLE SCRIPTS
gtest
APP_ENV=test APP_CONF_PATH=$(pwd)/conf go test -v -cover
gtestall
APP_ENV=test APP_CONF_PATH=$(pwd)/conf go test -v -cover $(go list ./... | grep -v /vendor/)
Run your scripts with:
$ bee rs gtest tests/*.go
$ bee rs gtestall
To create a Beego API application:
…
For more information on the usage, run bee help api.
To create an Hprose RPC application based on Beego:
…
For more information on the usage, run bee help hprose.
To pack all the static files into Go source files:
$ bee bale
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v2.0.0
2020/09/14 22:37:56 SUCCESS ▶ 0001 Baled resources successfully!
For more information on the usage, run bee help bale.
For database migrations, use bee migrate.
For more information on the usage, run bee help migrate.
Bee also comes with a source code generator which speeds up the development.
For example, to generate a new controller named hello:
$ bee generate controller hello
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v2.0.0
2020/09/14 22:38:44 INFO ▶ 0001 Using 'Hello' as controller name
2020/09/14 22:38:44 INFO ▶ 0002 Using 'controllers' as package name
create /Users/beeuser/code/learn/my-api/controllers/hello.go
2020/09/14 22:38:44 SUCCESS ▶ 0003 Controller successfully generated!
For more information on the usage, run bee help generate.
Bee also helps you dockerize your Beego application by generating a Dockerfile and a docker-compose.yaml file.
For example, to generate a Dockerfile with golang:1.20.1 baseimage and exposing port 9000:
$ bee dockerize -baseimage=golang:1.20.1 -expose=9000
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v2.0.4
2023/05/02 21:03:05 INFO ▶ 0001 Generating Dockerfile and docker-compose.yaml...
2023/05/02 21:03:05 SUCCESS ▶ 0002 Dockerfile generated.
2023/05/02 21:03:05 SUCCESS ▶ 0003 docker-compose.yaml generated.
For more information on the usage, run bee help dockerize.
Bee can also help with debugging your application. To start a debugging session:
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v2.0.0
2020/09/14 22:40:12 INFO ▶ 0001 Starting Delve Debugger...
Type 'help' for list of commands.
(dlv) break main.main
Breakpoint 1 set at 0x40100f for main.main() ./main.go:8
(dlv) continue
> main.main() ./main.go:8 (hits goroutine(1):1 total:1) (PC: 0x40100f)
3: import (
4: _ "github.com/user/myapp/routers"
5: beego "github.com/beego/beego/v2/server/web"
6: )
7:
=> 8: func main() {
9: beego.Run()
10: }
11:
For more information on the usage, run bee help dlv.
To create a beegopro.toml file
$ bee pro toml
2020/09/14 22:51:18 SUCCESS ▶ 0001 Successfully created file beegopro.toml
2020/09/14 22:51:18 SUCCESS ▶ 0002 Toml successfully generated!
Source code generator by beegopro.toml
…
Because you'll likely type these generator commands over and over, it makes sense to create aliases:
# Generator Stuff
alias g:a="bee generate appcode"
alias g:m="bee generate model"
alias g:c="bee generate controller"
alias g:v="bee generate view"
alias g:mi="bee generate migration"
These can be stored , for example, in your ~/.bash_profile or ~/.bashrc files.
To print more information on the usage of a particular command, use bee help <command>.
For instance, to get more information about the run command:
…
Bug reports, feature requests and pull requests are always welcome.
We work on two branches: master for stable, released code and develop, a development branch.
It might be important to distinguish them when you are reading the commit history searching for a feature or a bugfix,
or when you are unsure of where to base your work from when contributing.
Please submit an issue on GitHub and we will follow up. Even better, we would appreciate a Pull Request with a fix for it!
master and submit your PR against it.develop (the development branch), base your work on develop and submit your PR against it.Please follow the Pull Request Guidelines.
Feel free to request a feature by submitting an issue on GitHub and open the discussion.
If you'd like to implement a new feature, please consider opening an issue first to talk about it. It may be that somebody is already working on it, or that there are particular issues that you should be aware of before implementing the change. If you are about to open a Pull Request, please make sure to follow the submissions guidelines.
Before you submit an issue, search the archive, maybe you will find that a similar one already exists.
If you are submitting an issue for a bug, please include the following:
bee you are running (include the output of bee version)The more information you give us, the more able to help we will be!
develop branch (the development branch): # a bugfix branch for develop would be prefixed by fix/
# a bugfix branch for master would be prefixed by hotfix/
$ git checkout -b feature/my-feature develop
Please create commits containing related changes. For example, two different bugfixes should produce two separate commits. A feature should be made of commits splitted by logical chunks (no half-done changes). Use your best judgement as to how many commits your changes require.
Write insightful and descriptive commit messages. It lets us and future contributors quickly understand your changes without having to read your changes. Please provide a summary in the first line (50-72 characters) and eventually, go to greater lengths in your message's body. A good example can be found in Angular commit message format.
Please include the appropriate test cases for your patch.
Make sure all tests pass before submitting your changes.
Rebase your commits. It may be that new commits have been introduced on develop.
Rebasing will update your branch with the most recent code and make your changes easier to review:
$ git fetch
$ git rebase origin/develop
Push your changes:
$ git push origin -u feature/my-feature
Open a pull request against the develop branch.
If we suggest changes:
Please make the required updates (after discussion if any)
Only create new commits if it makes sense. Generally, you will want to amend your latest commit or rebase your branch after the new changes:
$ git rebase -i develop
# choose which commits to edit and perform the updates
Re-run the tests
Force push to your branch:
$ git push origin feature/my-feature -f
Copyright 2020 bee authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
No open issues yet, or sync has not completed.