Giter Site home page Giter Site logo

bee's Introduction

bee

Bee is a command-line tool facilitating development of Beego-based application.

Build Status Build Status

Requirements

  • Go version >= 1.13

Installation

To install or update bee use the go install command:

go install github.com/beego/bee/v2@latest

Then you can add bee binary to PATH environment variable in your ~/.bashrc or ~/.bash_profile file:

export PATH=$PATH:<your_main_gopath>/bin

Installing and updating bee prior Go version 1.17

To install bee use the go get command:

go get github.com/beego/bee/v2

If you already have bee installed, updating bee is simple:

go get -u github.com/beego/bee/v2

Basic commands

Bee provides a variety of commands which can be helpful at various stages of development. The top level commands include:

    version     Prints the current Bee version
    migrate     Runs database migrations
    api         Creates a Beego API application
    bale        Transforms non-Go files to Go source files
    fix         Fixes your application by making it compatible with newer versions of Beego
    pro         Source code generator
    dlv         Start a debugging session using Delve
    dockerize   Generates a Dockerfile and docker-compose.yaml for your Beego application
    generate    Source code generator
    hprose      Creates an RPC application based on Hprose and Beego frameworks
    new         Creates a Beego application
    pack        Compresses a Beego application into a single file
    rs          Run customized scripts
    run         Run the application by starting a local development server
    server      serving static content over HTTP on port
    update      Update Bee

bee version

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.

bee new

To create a new Beego web application:

$ bee new my-web-app
2020/09/14 22:28:51 INFO     ▶ 0001 generate new project support go modules.
2020/09/14 22:28:51 INFO     ▶ 0002 Creating application...
	create	 /Users/beeuser/learn/my-web-app/go.mod
	create	 /Users/beeuser/learn/my-web-app/
	create	 /Users/beeuser/learn/my-web-app/conf/
	create	 /Users/beeuser/learn/my-web-app/controllers/
	create	 /Users/beeuser/learn/my-web-app/models/
	create	 /Users/beeuser/learn/my-web-app/routers/
	create	 /Users/beeuser/learn/my-web-app/tests/
	create	 /Users/beeuser/learn/my-web-app/static/
	create	 /Users/beeuser/learn/my-web-app/static/js/
	create	 /Users/beeuser/learn/my-web-app/static/css/
	create	 /Users/beeuser/learn/my-web-app/static/img/
	create	 /Users/beeuser/learn/my-web-app/views/
	create	 /Users/beeuser/learn/my-web-app/conf/app.conf
	create	 /Users/beeuser/learn/my-web-app/controllers/default.go
	create	 /Users/beeuser/learn/my-web-app/views/index.tpl
	create	 /Users/beeuser/learn/my-web-app/routers/router.go
	create	 /Users/beeuser/learn/my-web-app/tests/default_test.go
	create	 /Users/beeuser/learn/my-web-app/main.go
2020/09/14 22:28:51 SUCCESS  ▶ 0003 New application successfully created!

For more information on the usage, run bee help new.

bee run

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.

bee pack

To compress a Beego application into a single deployable file:

$ bee pack
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v2.0.0
2016/12/26 22:29:29 INFO     ▶ 0001 Packaging application on '/home/beeuser/.go/src/github.com/user/my-web-app'...
2016/12/26 22:29:29 INFO     ▶ 0002 Building application...
2016/12/26 22:29:29 INFO     ▶ 0003 Using: GOOS=linux GOARCH=amd64
2016/12/26 22:29:31 SUCCESS  ▶ 0004 Build Successful!
2016/12/26 22:29:31 INFO     ▶ 0005 Writing to output: /home/beeuser/.go/src/github.com/user/my-web-app/my-web-app.tar.gz
2016/12/26 22:29:31 INFO     ▶ 0006 Excluding relpath prefix: .
2016/12/26 22:29:31 INFO     ▶ 0007 Excluding relpath suffix: .go:.DS_Store:.tmp
2016/12/26 22:29:32 SUCCESS  ▶ 0008 Application packed!

For more information on the usage, run bee help pack.

bee rs

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

bee api

To create a Beego API application:

$ bee api my-api
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v2.0.0
2020/09/14 22:35:11 INFO     ▶ 0001 generate api project support go modules.
2020/09/14 22:35:11 INFO     ▶ 0002 Creating API...
	create	 /Users/beeuser/code/learn/my-api/go.mod
	create	 /Users/beeuser/code/learn/my-api
	create	 /Users/beeuser/code/learn/my-api/conf
	create	 /Users/beeuser/code/learn/my-api/controllers
	create	 /Users/beeuser/code/learn/my-api/tests
	create	 /Users/beeuser/code/learn/my-api/conf/app.conf
	create	 /Users/beeuser/code/learn/my-api/models
	create	 /Users/beeuser/code/learn/my-api/routers/
	create	 /Users/beeuser/code/learn/my-api/controllers/object.go
	create	 /Users/beeuser/code/learn/my-api/controllers/user.go
	create	 /Users/beeuser/code/learn/my-api/tests/default_test.go
	create	 /Users/beeuser/code/learn/my-api/routers/router.go
	create	 /Users/beeuser/code/learn/my-api/models/object.go
	create	 /Users/beeuser/code/learn/my-api/models/user.go
	create	 /Users/beeuser/code/learn/my-api/main.go
2020/09/14 22:35:11 SUCCESS  ▶ 0003 New API successfully created!

For more information on the usage, run bee help api.

bee hprose

To create an Hprose RPC application based on Beego:

$ bee hprose my-rpc-app
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v2.0.0
2020/09/14 22:36:39 INFO     ▶ 0001 generate api project support go modules.
2020/09/14 22:36:39 INFO     ▶ 0002 Creating Hprose application...
	create	 /Users/beeuser/code/learn/my-rpc-app/go.mod
	create	 /Users/beeuser/code/learn/my-rpc-app
	create	 /Users/beeuser/code/learn/my-rpc-app/conf
	create	 /Users/beeuser/code/learn/my-rpc-app/conf/app.conf
	create	 /Users/beeuser/code/learn/my-rpc-app/models
	create	 /Users/beeuser/code/learn/my-rpc-app/models/object.go
	create	 /Users/beeuser/code/learn/my-rpc-app/models/user.go
	create	 /Users/beeuser/code/learn/my-rpc-app/main.go
2020/09/14 22:36:39 SUCCESS  ▶ 0003 New Hprose application successfully created!

For more information on the usage, run bee help hprose.

bee bale

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.

bee migrate

For database migrations, use bee migrate.

For more information on the usage, run bee help migrate.

bee generate

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 dockerize

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 dlv

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.

bee pro

bee pro toml

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!

bee pro gen

Source code generator by beegopro.toml

$ bee pro gen
2020/09/14 23:01:13 INFO     ▶ 0001 Create /Users/beeuser/.beego/beego-pro Success!
2020/09/14 23:01:13 INFO     ▶ 0002 git pull /Users/beeuser/.beego/beego-pro
2020/09/14 23:01:15 INFO     ▶ 0003 Using 'example' as name
2020/09/14 23:01:15 INFO     ▶ 0004 Using 'example' as package name from controllers
2020/09/14 23:01:15 INFO     ▶ 0005 create file '/Users/beeuser/code/learn/my-web-app/controllers/bee_default_controller.go' from controllers
2020/09/14 23:01:15 INFO     ▶ 0006 Using 'example' as name
2020/09/14 23:01:15 INFO     ▶ 0007 Using 'example' as package name from controllers
2020/09/14 23:01:15 INFO     ▶ 0008 create file '/Users/beeuser/code/learn/my-web-app/controllers/example.go' from controllers
2020/09/14 23:01:15 INFO     ▶ 0009 Using 'example' as name
2020/09/14 23:01:15 INFO     ▶ 0010 Using 'example' as package name from models
2020/09/14 23:01:15 INFO     ▶ 0011 create file '/Users/beeuser/code/learn/my-web-app/models/bee_default_model.go' from models
2020/09/14 23:01:15 INFO     ▶ 0012 Using 'example' as name
2020/09/14 23:01:15 INFO     ▶ 0013 Using 'example' as package name from models
2020/09/14 23:01:15 INFO     ▶ 0014 create file '/Users/beeuser/code/learn/my-web-app/models/example.go' from models
2020/09/14 23:01:15 INFO     ▶ 0015 Using 'example' as name
2020/09/14 23:01:15 INFO     ▶ 0016 Using 'example' as package name from routers
2020/09/14 23:01:15 INFO     ▶ 0017 create file '/Users/beeuser/code/learn/my-web-app/routers/example.go' from routers
2020/09/14 23:01:15 INFO     ▶ 0018 Using 'example' as name
2020/09/14 23:01:15 INFO     ▶ 0019 Using 'example' as package name from example
2020/09/14 23:01:15 INFO     ▶ 0020 create file '/Users/beeuser/code/learn/my-web-app/ant/src/pages/example/list.tsx' from example
2020/09/14 23:01:15 INFO     ▶ 0021 Using 'example' as name
2020/09/14 23:01:15 INFO     ▶ 0022 Using 'example' as package name from example
2020/09/14 23:01:15 INFO     ▶ 0023 create file '/Users/beeuser/code/learn/my-web-app/ant/src/pages/example/formconfig.tsx' from example
2020/09/14 23:01:15 INFO     ▶ 0024 Using 'example' as name
2020/09/14 23:01:15 INFO     ▶ 0025 Using 'example' as package name from example
2020/09/14 23:01:15 INFO     ▶ 0026 create file '/Users/beeuser/code/learn/my-web-app/ant/src/pages/example/create.tsx' from example
2020/09/14 23:01:15 INFO     ▶ 0027 Using 'example' as name
2020/09/14 23:01:15 INFO     ▶ 0028 Using 'example' as package name from example
2020/09/14 23:01:15 INFO     ▶ 0029 create file '/Users/beeuser/code/learn/my-web-app/ant/src/pages/example/update.tsx' from example
2020/09/14 23:01:15 INFO     ▶ 0030 Using 'example' as name
2020/09/14 23:01:15 INFO     ▶ 0031 Using 'example' as package name from example
2020/09/14 23:01:15 INFO     ▶ 0032 create file '/Users/beeuser/code/learn/my-web-app/ant/src/pages/example/info.tsx' from example
2020/09/14 23:01:15 INFO     ▶ 0033 Using 'example' as name
2020/09/14 23:01:15 INFO     ▶ 0034 Using 'example' as package name from sql
2020/09/14 23:01:15 INFO     ▶ 0035 create file '/Users/beeuser/code/learn/my-web-app/sql/example_up.sql' from sql
2020/09/14 23:01:15 INFO     ▶ 0036 2020/09/14 23:01:15 INFO     ▶ 0001 db exec info ./sql/example_up.sql
2020/09/14 23:01:15 SUCCESS  ▶ 0002 Migration successfully generated!
2020/09/14 23:01:15 INFO     ▶ 0037 Using 'example' as name
2020/09/14 23:01:15 INFO     ▶ 0038 Using 'example' as package name from sql
2020/09/14 23:01:15 INFO     ▶ 0039 create file '/Users/beeuser/code/learn/my-web-app/sql/example_down.sql' from sql
2020/09/14 23:01:15 SUCCESS  ▶ 0040 Gen successfully generated!

Shortcuts

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.

Help

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:

$ bee help run
USAGE
  bee run [appname] [watchall] [-main=*.go] [-downdoc=true]  [-gendoc=true] [-vendor=true] [-e=folderToExclude]  [-tags=goBuildTags] [-runmode=BEEGO_RUNMODE]

OPTIONS
  -downdoc
      Enable auto-download of the swagger file if it does not exist.

  -e=[]
      List of paths to exclude.

  -gendoc
      Enable auto-generate the docs.

  -main=[]
      Specify main go files.

  -runmode
      Set the Beego run mode.

  -tags
      Set the build tags. See: https://golang.org/pkg/go/build/

  -vendor=false
      Enable watch vendor folder.

DESCRIPTION
  Run command will supervise the filesystem of the application for any changes, and recompile/restart it.

Contributing

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.

Found a bug?

Please submit an issue on GitHub and we will follow up. Even better, we would appreciate a Pull Request with a fix for it!

  • If the bug was found in a release, it is best to base your work on master and submit your PR against it.
  • If the bug was found on develop (the development branch), base your work on develop and submit your PR against it.

Please follow the Pull Request Guidelines.

Want a feature?

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.

Submission Guidelines

Submitting an issue

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:

  • An overview of the issue
  • Your use case (why is this a bug for you?)
  • The version of bee you are running (include the output of bee version)
  • Steps to reproduce the issue
  • Eventually, logs from your application.
  • Ideally, a suggested fix

The more information you give us, the more able to help we will be!

Submitting a Pull Request

  • First of all, make sure to base your work on the 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
      

Licence

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.

bee's People

Contributors

amrfaissal avatar askuy avatar astaxie avatar codeskyblue avatar dependabot[bot] avatar fanngyuan avatar flycash avatar franzwilhelm avatar frederic-zhou avatar gadelkareem avatar gnanakeethan avatar ihippik avatar lao-liu avatar lnzd avatar luhuisicnu avatar miraclesu avatar ogero avatar qida avatar rpsteinbrueck avatar s00500 avatar sergeylanzman avatar slene avatar taveek avatar tnextday avatar tossp avatar unknwon avatar wangle201210 avatar westonplatter avatar yitea avatar zhengyang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bee's Issues

Can not set arguments when use bee run

Hi team,
When i used bee run, I can not set more arguments. But I use go run in same project, it worked.

Example:

var runMode = flag.String("runmode", "dev", "run mode dev/prod")

func main() {

    flag.Parse()
    fmt.Println(*runMode)

    if beego.RunMode == "dev" {
        beego.DirectoryIndex = true
        beego.StaticDir["/swagger"] = "swagger"
    }

    beego.Run()
}

bee run appName -runmode=prod
It will print dev

go run main.go -runmode=prod
It will print prod

How to set arguments which mode bee run and go run ?

NFS support

I moved this ticket to howeyc/fsnotify#107

So, in case of this ticket, is it possible to send some signal/message/etc to bee api for run rebuild?

重复编译的问题

关于热升级 watch.go中有对于重复编译的控制 1秒延时
但是这我这边一侧还是出现了反复编译的问题
我的升级方法是一个代码压缩包直接unzip
然后从日志看到bee工具还是反复编译了11次
就是我这批文件的数量

我已经fork这个项目,稍候看看这个要怎么改

Suggestion: "bee new" return os.Exit(1) when successful

bee new myprj dlin@u40 ~/go/src$
[INFO] Creating application...
/home/dlin/go/src/myprj/
/home/dlin/go/src/myprj/conf/
/home/dlin/go/src/myprj/controllers/
/home/dlin/go/src/myprj/models/
/home/dlin/go/src/myprj/routers/
/home/dlin/go/src/myprj/tests/
/home/dlin/go/src/myprj/static/
/home/dlin/go/src/myprj/static/js/
/home/dlin/go/src/myprj/static/css/
/home/dlin/go/src/myprj/static/img/
/home/dlin/go/src/myprj/views/
/home/dlin/go/src/myprj/conf/app.conf
/home/dlin/go/src/myprj/controllers/default.go
/home/dlin/go/src/myprj/views/index.tpl
/home/dlin/go/src/myprj/routers/router.go
/home/dlin/go/src/myprj/tests/default_test.go
/home/dlin/go/src/myprj/main.go
13-12-26 11:43:15 [SUCC] New application successfully created!
And it return error code '2'

Best practice with bower_components

I use Bower to use my dependencies in my beego app. The /static directory already contains a structure for imgs, css etc. Bower stores usually the files of each dependencie e.g. Bootstrap 3 in /bower_components, but this behavior would break the default folder structure of beego?

Has anyone a good idea to combine both?

bee new 与 run 应该在任何路径使用

我用windows系统,切换路径太麻烦.我希望BEE可以和REVEL一样在任何路径使用new,run命令,这样多方便.代码放在$GOPATH\src我不反对.但是我在其他路径就不能使用bee命令了,这个我认为应该改进.

使用swagger时的错误

bee:1.2.2
beego:1.4.1
go:1.3.3 windows/amd64

问题1:
参考:http://my.oschina.net/astaxie/blog/284072

运行"bee run -gendoc=true -downdoc=true"后,swagger下载正常,控制台也提示了"Start delete src file swagger.zip",发现swagger.zip已解压但并没有删除.而且访问http://127.0.0.1:8080/swagger/swagger-1/,提示"Forbidden(403页)".

问题2:
参考:http://beego.me/docs/advantage/docs.md

按照docs.md尝试生成文档时,发现bee中没有"bee rundocs"命令

beego https的一个bug

在启用https关闭http的时候 bee run会默认显示Running on :8080 但是不能访问8080,可以访问https监听的端口。

bee 版本1.4.1

bee migrate无法连接slqite3

bee.json

{
  "database": {
    "driver": "sqlite",
    "conn": "./data/dev.db"
  }
}

显示如下:

2014/11/14 04:05:23 [INFO] Detected bee.json
2014/11/14 04:05:23 [INFO] Using 'sqlite' as 'driver'
2014/11/14 04:05:23 [INFO] Using './data/dev.db' as 'conn'
2014/11/14 04:05:23 [INFO] Running all outstanding migrations
2014/11/14 04:05:23 [ERRO] Could not connect to sqlite: ./data/dev.db

API Swagger Annotation with different request / response models

I'm experiencing an issue with the generated Swagger docs when my controller is annotated to return a different object type than the request body type.

Consider (when @param and @success objects are both NewUserRequest):

// @Title Test
// @Description Test
// @Param body body models.users.NewUserRequest true "User"
// @Success 200 {object} models.users.NewUserRequest
// @Failure 400 auth
// @router /test [post]
func (this *PublicServicesController) Test() {

}

Swagger UI looks like:

swagger_1

Now, if I change the @success object to NewUserResponse model:

// @Title Test
// @Description Test
// @Param body body models.users.NewUserRequest true "User"
// @Success 200 {object} models.users.NewUserResponse
// @Failure 400 auth
// @router /test [post]
func (this *PublicServicesController) Test() {

}

I get a broken request data type model in Swagger UI:

swagger_2

Am I using this incorrectly or is this unexpected behavior?

generated code in wrong import path

$ bee new myprj
$ cd myprj ; bee run myprj

13-12-26 11:50:16 [INFO] Initializing watcher...
13-12-26 11:50:16 [TRAC] Directory(/home/dlin/go/src/myprj/controllers)
13-12-26 11:50:16 [TRAC] Directory(/home/dlin/go/src/myprj/models)
13-12-26 11:50:16 [TRAC] Directory(/home/dlin/go/src/myprj)
13-12-26 11:50:16 [INFO] Start building...
main.go:5:2: cannot find package "github.com/astaxie/beego" in any of:
/usr/lib/go/src/pkg/github.com/astaxie/beego (from $GOROOT)
/home/dlin/go/src/github.com/astaxie/beego (from $GOPATH)
13-12-26 11:50:16 [ERRO] ============== Build failed ===================
^C% 11:50:20 2 $ ls

$ grep -r astaxie

tests/default_test.go: "github.com/astaxie/beego"
main.go: "github.com/astaxie/beego"
routers/router.go: "github.com/astaxie/beego"
controllers/default.go: "github.com/astaxie/beego"
controllers/default.go: this.Data["Email"] = "[email protected]"

這代表 generate code 仍在 old import path

符号链接目录问题

在创建app的时候 wg, _ = path.EvalSymlinks(path.Join(wg, "src"))这行代码不知道为何要找到真实路径,难道符号链接的路径不允许吗? 这个问题搞了我好久, 因为mac上的/tmp目录是/private/tmp 的一个符号链接, 我喜欢试验一些东西的时候去/tmp目录测试,结果一直报不在GOPATH里,我觉得这个地方应该两种情况都允许.

是否可以默认把的那两个swagger的json变量作为可导出的

bee docs命令执行过后会生成一个docs.go的文件,生成给swagger的参数。

这里:

var rootinfo string = {{.rootinfo}}
var subapi string = {{.subapi}}

可不可以修改为?

const (
    Rootinfo string = {{.rootinfo}}
        Subapi string = {{.subapi}}
)

subapi 和rootinfo 这两个变量的内容,经过整理以后,可以直接初始化为RBAC的资源列表或者也可以演绎出一些其他的用处,感觉挺好的。

bee api 连接数据库创建文件失败

bee api -driver=mysql -conn="root:(127.0.0.1:3306)/test" 运行后出现创建文件失败
14-08-12 10:45:34 [INFO] Using 'mysql' as 'driver'
14-08-12 10:45:34 [INFO] Using 'root:@tcp(127.0.0.1:3306)/test' as 'conn'
14-08-12 10:45:34 [INFO] Using '' as 'tables'14-08-12 10:45:34 [INFO] Analyzing database tables...
14-08-12 10:45:34 [INFO] Creating model files...
14-08-12 10:45:34 [INFO] Creating controller files...
14-08-12 10:45:34 [INFO] Creating router files...
14-08-12 10:45:34 [ERRO] Could not write router file to /data/wwwroot/web/v3/src/test/routers/router.go

自动化文档生成

// @success 200 {object} controllers.Response

这个 controllers.Response 如果不是struct, 就生成不了.

// @success 200 {object} map[string]string

这个也不行.

// @success 200 {object} map[string]controllers.Response

type Response struct {
      A int
}

这个也一样不行.

No controller files

Hello, First I would like to say thank you so much for this great work.
second I'm having this issue I'm not sure if its me or the tool but when I try to generate a CRUD api through the bee api cli command it works fine but no controller files
here is my input and output

../bin/bee api appname -tables="users,posts,comments" -driver=postgres -conn=postgres://user:[email protected]:5432/dbname?sslmode=disable

create app folder: /Users/me/gocode/src/appname
create conf: /Users/me/gocode/src/appname/conf
create controllers: /Users/me/gocode/src/appname/controllers
create docs: /Users/me/gocode/src/appname/docs
create tests: /Users/me/gocode/src/appname/tests
create conf app.conf: /Users/me/gocode/src/appname/conf/app.conf
create main.go: /Users/me/gocode/src/appname/main.go
2015/02/19 11:26:29 [INFO] Using 'postgres' as 'driver'
2015/02/19 11:26:29 [INFO] Using 'postgres://user:[email protected]:5432/dbname?sslmode=disable' as 'conn'
2015/02/19 11:26:29 [INFO] Using 'users,posts,comments' as 'tables'
2015/02/19 11:26:29 [INFO] Analyzing database tables...
2015/02/19 11:26:29 [INFO] Creating model files...
2015/02/19 11:26:29 [INFO] model => /Users/me/gocode/src/appname/models/users.go
2015/02/19 11:26:29 [INFO] model => /Users/me/gocode/src/appname/models/posts.go
2015/02/19 11:26:29 [INFO] model => /Users/me/gocode/src/appname/models/comments.go

2015/02/19 11:26:29 [INFO] Creating controller files...
2015/02/19 11:26:29 [INFO] Creating router files...
2015/02/19 11:26:29 [INFO] router => /Users/me/gocode/src/appname/routers/router.go

Thanks in advanced.

"bee run server.go" delete the orignal server.go and create a new binary server.go

I meant to input: go run server.go
instead,I inputed: bee run server.go

so,my server.go was replaced with a binary file server.go!!
I think it will be much better if there is a warnning before the bee tool "DELETE" the server.go !!!

++++++++++++++++++++++++++++++++++++++++++++++++++++++++
➜ /Users/wenke/go/src/wenke/websocket_server $bee run server.go
2015/04/16 15:50:52 [INFO] Initializing watcher...
2015/04/16 15:50:52 [TRAC] Directory(/Users/wenke/go/src/wenke/websocket_server)

2015/04/16 15:50:52 [INFO] Start building...
2015/04/16 15:50:53 [EVEN] "/Users/wenke/go/src/wenke/websocket_server/server.go": DELETE
2015/04/16 15:50:53 [SUCC] Build was successful
2015/04/16 15:50:53 [INFO] Restarting server.go ...
2015/04/16 15:50:53 [INFO] ./server.go is running...
2015/04/16 15:50:53 [INFO] Start building...
begin
can't load package: package wenke/websocket_server: read /Users/wenke/go/src/wenke/websocket_server/server.go: unexpected NUL in input
2015/04/16 15:50:53 [ERRO] ============== Build failed ===================
^C%

'bee test ...' should accept 'go test' flags and pass them through

I'm integrating 'bee' workflow into tools like 'gulp' or 'grunt', and it almost work, except 'bee test...' just run 'go test' without any arguments, while I have some basic needs:

  1. run 'go test' in verbose mode (with '-v' flag)
  2. run 'go test' on all sub-packages (with 'go test ./...')

As long as these are specific needs, I think a better and more general approach is to have 'bee test' pass extra flags directly to 'go test', then 'bee test app -v ./...' invokes 'go test -v ./...'.
Another approach is to add an extra field in 'bee.json'. But in a automated workflow, command line arguments are far more friendly than configuration files. So a command line based solution is better.

How do you think about this?
If this approach is acceptable, I'll implement it and send a pull request.

在windows上安装此插件失败

文件监视的库已经更改地址,原地址github.com/howeyc/fsnotify不能用,改为新的地址“gopkg.in/fsnotify.v0",执行go get github.com/beego/bee

bee test can not work well.

測試 apiprj

失敗

$ bee test apiprj
[INFO] Initializing watcher...
[TRAC] Directory(/home/dlin/go/src/apiprj/controllers)
[TRAC] Directory(/home/dlin/go/src/apiprj/models)
[TRAC] Directory(/home/dlin/go/src/apiprj)
[INFO] Start building...

apiprj/controllers

controllers/default.go:25: invalid operation: this.Controller.Ctx.Input.Param[":objectId"](index of type func%28string%29 string)
controllers/default.go:41: invalid operation: this.Controller.Ctx.Input.Param[":objectId"](index of type func%28string%29 string)
controllers/default.go:55: invalid operation: this.Controller.Ctx.Input.Param[":objectId"](index of type func%28string%29 string)
[ERRO] ============== Build failed ===================

測試 myprj

雖成功但不會自動脫離,無法作 batch test.

$ cd ../myprj
$ bee test myprj
[INFO] Initializing watcher...
[TRAC] Directory(/home/dlin/go/src/myprj/controllers)
[TRAC] Directory(/home/dlin/go/src/myprj/models)
[TRAC] Directory(/home/dlin/go/src/myprj)
[INFO] Start building...
[SUCC] Build was successful
[INFO] Restarting myprj ...
[INFO] Start testing...
2013/12/26 11:27:02 [I] Running on :8080
[TRAC] ============== Test Begin ===================
? myprj [no test files]
[TRAC] ============== Test End ===================
[SUCC] Test finish
此處要手動按 ctrl-c

[Error]连接接postgresql数据库,生成api项目,运行的时候报错.no buildable Go source files in controllers

我使用的bee版本
# bee version bee :1.2.2 beego :1.4.1 Go :go version go1.3 linux/amd64

错误信息:
controllers目录下没有生成任何文件??

# bee run -gendoc=true -downdoc=true 2014/09/21 08:19:49 [INFO] Uses 'vshophub' as 'appname' 2014/09/21 08:19:49 [INFO] Initializing watcher... 2014/09/21 08:19:49 [TRAC] Directory(/root/projs/vshophub/proj/src/vshophub) 2014/09/21 08:19:49 [TRAC] Directory(/root/projs/vshophub/proj/src/vshophub/models) 2014/09/21 08:19:49 [TRAC] Directory(/root/projs/vshophub/proj/src/vshophub/routers) 2014/09/21 08:19:49 [INFO] Start building... 2014/09/21 08:19:49 [SUCC] generate successfully created! 2014/09/21 08:19:49 ============== generate docs =================== routers/router.go:11:2: no buildable Go source files in /root/projs/vshophub/proj/src/vshophub/controllers 2014/09/21 08:19:50 [ERRO] ============== Build failed =================== Downloading https://github.com/beego/swagger/archive/v1.zip to swagger.zip 157888 bytes downloaded. start to unzip file from swagger.zip to swagger Start delete src file swagger.zip

bee new,如果目录存在,会直接退出

bee new,如果目录存在,会直接退出。

我觉得如果加一个参数 -f ,如果目录存在,继续执行。会比较好。

场景:我从 github clone 一个新项目下来。已经存在目录了,我想在这个目录下 bee new 做初始化。

bee 工具在 $GOPATH 目录下执行,会报错,需要在 $GOPATH/src 目录下执行,说明文档有歧义。

localhost:mygocode ghj1976$ pwd
/Users/ghj1976/project/mygocode
localhost:mygocode ghj1976$ ls
bin pkg src
localhost:mygocode ghj1976$ bee new webtest1
14-04-19 07:41:43 [ERRO] Unable to create an application outside of $GOPATH(/Users/ghj1976/project/mygocode/)
14-04-19 07:41:43 [HINT] Change your work directory by cd ($GOPATH/src)
localhost:mygocode ghj1976$

这里的说明文档有歧义,建议修改:
http://beego.me/docs/install/bee.md

new 命令是新建一个 Web 项目,我们在命令行下执行 bee new <项目名> 就可以创建一个新的项目。但是注意该命令必须在 $GOPATH 下执行。最后会在 $GOPATH 相应目录下生成如下目录结构的项目:

bee new myproject

Possible documentation error on PATH environment variable

I believe that in the documentation...

export PATH=$PATH:<your_main_gopath>/bin/bee

...should actually be

export PATH=$PATH:<your_main_gopath>/bin

or

export PATH=$PATH:$GOPATH/bin

At least, in my installation, there is no "bee" subdirectory - just the binary file.

It may also be useful to let users know that /etc/profile can be edited to make this a system-wide change.

在ben pack命令中我尝试加入-ldflags "-s -w"参数报错

我的命令是bee pack -b -ba="-v -x -ldflags \"-s -w\"" -be="GOARCH=amd64" -o ../ -f="zip"
去掉其中的-ldflags \"-s -w\"就正常了

build tsflow
GOOS windows GOARCH amd64
D:\Develop\Go\bin\go   build -o C:\Users\ttt\AppData\Local\Temp\beePack-2037585800\tsflow.exe -v -x -ldflags "-s -w"
invalid value "\"-s" for flag -ldflags: unterminated " string
usage: build [-o output] [build flags] [packages]

generateDocs - issue with assignment function with args causes wrong base path

Using bee generate docs or bee run -downdoc=true -gendoc=true and the following router.go code will cause the basepath value in docs/docs.go to be incorrect - which causes invalid urls when using swagger.

// @APIVersion 1.0.0
// @Title beego Test API
// @Description beego has a very cool tools to autogenerate documents for your API
// @Contact [email protected]
// @TermsOfServiceUrl http://beego.me/
// @License Apache 2.0
// @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
package routers

import (
        "fmt"

        "github.com/pabdavis/beeapi/controllers"

        "github.com/astaxie/beego"
)

func init() {
        fmt.Println("In router init")

        a := someFunction("wrong basepath")

        ns := beego.NewNamespace("/v1",
                beego.NSNamespace("/object",
                        beego.NSInclude(
                                &controllers.ObjectController{},
                        ),
                ),
                beego.NSNamespace("/user",
                        beego.NSInclude(
                                &controllers.UserController{},
                        ),
                ),
        )
        beego.AddNamespace(ns)
}

It appears that g_docs.go can incorrectly determine the basepath value if an assignment statement calls a function which has an argument (including "") appears before the NewNamespace function call.

160                             f, params := analisysNewNamespace(v)
161                             globalDocsTemplate = strings.Replace(globalDocsTemplate, "{{.version}}", f, -1)

I'll gladly submit a pull request if you have suggestion on how best to handle as I'm not 100% what required order or values are necessary within the router code - thanks

bee api and exotic postgres types

hi,
I've got a postgres database with some exotic types such as uuid and interval. When i run bee api it fails.
What should i do to make it work ?

go get 安装报错

src/github.com/astaxie/beego/logs/log.go:63: function ends without a return statement
src/github.com/astaxie/beego/logs/log.go:76: function ends without a return statement

github.com/astaxie/beego/config

src/github.com/astaxie/beego/config/json.go:40: function ends without a return statement
src/github.com/astaxie/beego/config/json.go:54: function ends without a return statement
src/github.com/astaxie/beego/config/json.go:67: function ends without a return statement
src/github.com/astaxie/beego/config/json.go:80: function ends without a return statement
src/github.com/astaxie/beego/config/json.go:93: function ends without a return statement

Bee test command not found

The "bee test" command is listed in the docs: http://beego.me/docs/install/bee.md#command-test
But it is not available when testing with the latest version of bee:

MacBook-Air-8:app $ bee version
bee :1.2.3
beego :1.4.2
Go :go version go1.3.3 darwin/amd64

MacBook-Air-8:app $ bee test
bee: unknown subcommand "test"
Run 'bee help' for usage.

MacBook-Air-8:app $ bee help
Bee is a tool for managing beego framework.

Usage:

bee command [arguments]

The commands are:

new         Create a Beego application
run         run the app and start a Web server for development
pack        Compress a beego project into a single file
api         create an API beego application
bale        packs non-Go files to Go source files
version     show the Bee, Beego and Go version
generate    source code generator
migrate     run database migrations

Use "bee help [command]" for more information about a command.

Additional help topics:

Use "bee help [topic]" for more information about that topic.

bee can not found my GOPATH

While I did not encounter any problems before.
Logs:

env
GOPATH=/nfs/zfs-student-4/users/2013/mweibel/Dropbox/rendu/goproj
pwd
/nfs/zfs-student-4/users/2013/mweibel/Dropbox/rendu/goproj/src
bee new hop
2015/05/08 16:31:38 [ERRO] Unable to create an application outside of $GOPATH(/nfs/zfs-student-4/users/2013/mweibel/Dropbox/rendu/goproj)

if I give it myself the GOPATH with the env command it works:

env GOPATH=/nfs/zfs-student-4/users/2013/mweibel/Dropbox/rendu/goproj/src bee new framework0
[INFO] Creating application...

I'm using zsh with omzsh

Create new application in another directory than $GOPATH/src

Hi !

When using bee new [app_name] with a custom directory, it returns me the following error :
Unable to create an application outside of $GOPATH
and tells me to create the application in $GOPATH/src, which works.

So, i wonder if it's possible to create app in custom directory, since it's not documented in the bee help command.

bee command is unknown in Powershell

I tried to creat my first beego project. Window's Powershell didn't recognized the bee new projectName command, after I cloned the bee repo. As in the docs described, I switched to %GOPATH%/src and executed the command there. The %GOPATH% was setup successfully, since the import of other packages worked well.

How can I register the bee command in Windows?

mac 在安装Bee的时候提示出错

beego 可以正常安装的,但Bee 工具安装的时候 必须 sudo .
但即使sudo ,却提示 没有设置“GOPATH”
[apple@pc-201009121709 bee]$echo $GOPATH
/Users/apple/work/gopath
[apple@pc-201009121709 bee]$sudo go get github.com/beego/bee
package github.com/beego/bee: cannot download, $GOPATH not set. For more details see: go help gopath
[apple@pc-201009121709 bee]$

关于bee bale中ignore_ext的配置

一般的需要打包的就是html,js,css,png,jpg等等,都是可枚举
所以,ignore_ext改为inc_ext,应该会更好
要不很容易出现下面这种奇葩的东西
qq20140505012741

最后,是否能添加目录过滤比如.git,像我这种前端和服务器端分两个仓库的特别有用。。。。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.