beego / bee Goto Github PK
View Code? Open in Web Editor NEWBee is a tool for helping develop with beego app framework.
License: Apache License 2.0
Bee is a tool for helping develop with beego app framework.
License: Apache License 2.0
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?
bee plugin will download the plugin and copy static file to views/
bee docs
命令执行过后会生成一个docs.go的文件,生成给swagger的参数。
这里:
var rootinfo string = {{.rootinfo}}
var subapi string = {{.subapi}}
可不可以修改为?
const (
Rootinfo string = {{.rootinfo}}
Subapi string = {{.subapi}}
)
subapi 和rootinfo 这两个变量的内容,经过整理以后,可以直接初始化为RBAC的资源列表或者也可以演绎出一些其他的用处,感觉挺好的。
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
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
如题
在创建app的时候 wg, _ = path.EvalSymlinks(path.Join(wg, "src"))
这行代码不知道为何要找到真实路径,难道符号链接的路径不允许吗? 这个问题搞了我好久, 因为mac上的/tmp目录是/private/tmp 的一个符号链接, 我喜欢试验一些东西的时候去/tmp目录测试,结果一直报不在GOPATH里,我觉得这个地方应该两种情况都允许.
我用windows系统,切换路径太麻烦.我希望BEE可以和REVEL一样在任何路径使用new,run命令,这样多方便.代码放在$GOPATH\src我不反对.但是我在其他路径就不能使用bee命令了,这个我认为应该改进.
目前bee pack打包的时候会把git的.git, .gitignore这样的文件打包进去,类似的还有.hg .hgignore .hgtags,可以默认忽略掉
关于热升级 watch.go中有对于重复编译的控制 1秒延时
但是这我这边一侧还是出现了反复编译的问题
我的升级方法是一个代码压缩包直接unzip
然后从日志看到bee工具还是反复编译了11次
就是我这批文件的数量
我已经fork这个项目,稍候看看这个要怎么改
new.go 77行,path.EvalSymlinks
后没有判断错误,异常情况(比如gopath目录不存在时)下会导致示例文件中 import 包错误
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.
在启用https关闭http的时候 bee run会默认显示Running on :8080 但是不能访问8080,可以访问https监听的端口。
bee 版本1.4.1
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.
文件监视的库已经更改地址,原地址github.com/howeyc/fsnotify不能用,改为新的地址“gopkg.in/fsnotify.v0",执行go get github.com/beego/bee
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%
> go api
panic: runtime error: index out of range
goroutine 1 [running]:
main.createapi(0x9e5e00, 0x124e2128, 0x0, 0x0, 0x0)
E:/go_workspace/src/github.com/beego/bee/apiapp.go:553 +0x2df0
main.main()
E:/go_workspace/src/github.com/beego/bee/bee.go:113 +0x2e1
我的命令是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]
失敗
$ 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...
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 ===================
雖成功但不會自動脫離,無法作 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
如何实现类似 php 中的 //input 获取非标准的文件上传功能?
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
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:
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.
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
引用配置文件项传入的是字符串,容易出错。目前引用错误,也很难发现。希望能够在编译时进行检查,一旦引用错误,则编译失败。
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 ?
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'
$ 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
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
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
I get this error when I run bee migrate
:
Could not show migrations table: pq: syntax error at or near "LIKE"
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.
无法看版本号.
It would be very nice if bee generate scaffold
generates ready-for-use views like rails do
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
Add bee build
command for build beego app and possible to build cross platform executable.
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?
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]$
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
?
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?
bee sample can download github.com/beego/sample and run sample
bee new,如果目录存在,会直接退出。
我觉得如果加一个参数 -f ,如果目录存在,继续执行。会比较好。
场景:我从 github clone 一个新项目下来。已经存在目录了,我想在这个目录下 bee new 做初始化。
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.
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:
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:
Am I using this incorrectly or is this unexpected behavior?
我使用的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
有问题吗?另外我访问 http://localhost:8080/v1/user/delete 这个路径时,执行了 user.go 下的 get 方法,但没有执行 delete 方法...
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"命令
After updating to
bee :1.2.2
beego :1.4.0
running ' bee rundocs -isDownload=true ' to run the auto-generate documents gives
bee: unknown subcommand "rundocs"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.