beego is an open-source, high-performance web framework for the Go programming language.

Overview

Beego Build Status GoDoc Foundation Go Report Card

Beego is used for rapid development of enterprise application in Go, including RESTful APIs, web apps and backend services.

It is inspired by Tornado, Sinatra and Flask. beego has some Go-specific features such as interfaces and struct embedding.

architecture

Beego is compos of four parts:

  1. Base modules: including log module, config module, governor module;
  2. Task: is used for running timed tasks or periodic tasks;
  3. Client: including ORM module, httplib module, cache module;
  4. Server: including web module. We will support gRPC in the future;

Please use RELEASE version, or master branch which contains the latest bug fix

Quick Start

Official website

Example

If you could not open official website, go to beedoc

Web Application

Http Request

Create hello directory, cd hello directory

mkdir hello
cd hello

Init module

go mod init

Download and install

go get github.com/beego/beego/[email protected]

Create file hello.go

package main

import "github.com/beego/beego/v2/server/web"

func main() {
	web.Run()
}

Build and run

go build hello.go
./hello

Go to http://localhost:8080

Congratulations! You've just built your first beego app.

Features

Modules

Community

License

beego source code is licensed under the Apache Licence, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html).

Issues
  • Automatic Parameter Router

    Automatic Parameter Router

    This is a POC for a feature i've been working on that I'd like to get reviewed before I complete the work (to make sure the direction is ok) The idea is to make Comments Controller even more "magical" by translating request parameters to method parameters.

    [See updated information below]

    Let me know if the direction looks ok and I will complete the missing parts. Also if you think this is good, please review the changes. Note that most changes are in new files and there should be no changes to current flows. Changes in existing files are minimal.

    kind/experimental status/in-review 
    opened by eyalpost 34
  • Security Concerns: Generating Random Bytes

    Security Concerns: Generating Random Bytes

    Hi,

    I couldn't see any existing issues on this (I also can't read Chinese) so apologies if they have been pointed out. Stemmed from a Reddit discussion I was curious about beego's API and took a look at the source and discovered these potential flaws.

    First up: your session IDs are not securely generated and may be predictable

    • In session.go you use a combination of crypto/rand, time.Unix and a SHA-1 hash to generate a session ID. You should just use crypto/rand and base32 encode it as per gorilla/sessions, as otherwise you are introducing predictability into your session ID generation.
    • Your XSRF tokens, by default, expire in 60s. From a usability perspective this isn't a sane default: if a user takes > 60s to fill out a form or submit something, they'll error. There's no need for such an aggressive default.
    • Your XSRF tokens are only 15 bytes long, but your session IDs are 24 bytes long. Why the difference? I suggest following gorilla/sessions, Django & Rails' lead here and reading 32 bytes out (for all short-lived secure tokens). Share a GenerateRandomBytes(n int) function throughout your application rather than inventing the wheel, which leads me to...
    • RandomCreateBytes here may end up truncating the generated string, making it less secure. Just base32 encode it. Look at securecookie's GenerateRandomKey() function. I'd suggest returning []byte, err instead of return nil on an error though, as otherwise you need to manually check for nil (for safety). Better to just return an explicit error.

    I have not been through the source in full, but these issues were the most glaring and I recommend resolving them ASAP. I also recommend instructing users on how to generate secure, persistent XSRF session keys and session cookie keys using either crypto/rand to save to file (I'd suggest using a CLI flag to allow this to be done as a once off, and using log.Fatal if no keys are present) or the OpenSSL CLI to do the same.

    opened by elithrar 34
  • When i run bee command. the error encountered:

    When i run bee command. the error encountered: "dyld: attempt to run simulator program outside simulator (DYLD_ROOT_PATH not set)"

    Please answer these questions before submitting your issue. Thanks!

    1. What version of Go and beego are you using (bee version)? go version go1.14.6 darwin/amd64

    2. What operating system and processor architecture are you using (go env)? mac os catalina 10.15.4 ,6-Core Intel Core i7 go env: image

    3. What did you do? I installed the Go from pkg below image and then i used the command below to set the proxy:

    go env -w GO111MODULE=on
    go env -w GOPROXY=https://goproxy.io,direct
    

    and then I used the command below to install the beego and bee:

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

    so far so good.

    1. What did you expect to see? I want to use the bee new *** to create a project.

    2. What did you see instead? when I ran the command "bee" or "bee new ***", i encountered the error below: image

    I reboot the mac, uninstall go and re-install go and bee for 3 times, it doesn't work. can someone help me? thanks.

    kind/question area/bee 
    opened by xiaohui-gsv 33
  • 用SaveToFile文件上传后,一直占着虚拟内存没有释放

    用SaveToFile文件上传后,一直占着虚拟内存没有释放

    发现在windows中用SaveToFile保存上传后的文件,一直占着虚拟内存没有释放,再上传多几次C盘就满了 有什么方法比较优化的呢? 代码如下:

    package main
    
    import (
        "github.com/astaxie/beego"
    )
    
    type UploadController struct {
        beego.Controller
    }
    func (this *UploadController) Post() {
        _, h, _ := this.GetFile("uploadfile")
        this.SaveToFile("uploadfile", "./static/files/"+h.Filename)
        this.Ctx.Redirect(302, "/upload")
    
    }
    
    func main() {
        beego.Router("/upload", &UploadController{})
        beego.Run()
    }
    
    opened by mrcuix 31
  • Module latest found, but does not contain package beego/server/web

    Module latest found, but does not contain package beego/server/web

    Please answer these questions before submitting your issue. Thanks!

    1. What version of Go and beego are you using (bee version)? Go version : go1.15.4 Bee version: v1.12.0
    2. What operating system and processor architecture are you using (go env)?
    GOARCH="amd64"
    GOBIN=""
    GOCACHE="/Users/theo/Library/Caches/go-build"
    GOENV="/Users/theo/Library/Application Support/go/env"
    GOEXE=""
    GOFLAGS=""
    GOHOSTARCH="amd64"
    GOHOSTOS="darwin"
    GOINSECURE=""
    GOMODCACHE="/Users/theo/go/pkg/mod"
    GONOPROXY=""
    GONOSUMDB=""
    GOOS="darwin"
    GOPATH="/Users/theo/go"
    GOPRIVATE=""
    GOPROXY="https://proxy.golang.org,direct"
    GOROOT="/usr/local/Cellar/go/1.15.4/libexec"
    GOSUMDB="sum.golang.org"
    GOTMPDIR=""
    GOTOOLDIR="/usr/local/Cellar/go/1.15.4/libexec/pkg/tool/darwin_amd64"
    GCCGO="gccgo"
    AR="ar"
    CC="clang"
    CXX="clang++"
    CGO_ENABLED="1"
    GOMOD="/dev/null"
    CGO_CFLAGS="-g -O2"
    CGO_CPPFLAGS=""
    CGO_CXXFLAGS="-g -O2"
    CGO_FFLAGS="-g -O2"
    CGO_LDFLAGS="-g -O2"
    PKG_CONFIG="pkg-config"
    GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/zl/4vn0pm8x4lz1h2bm6y5kkdnm0000gn/T/go-build854159209=/tmp/go-build -gno-record-gcc-switches -fno-common"
    
    1. What did you do?

    I created a new installation of Beego using the bee api my-api command and then I add this code into controllers/object.go:

    package controllers
    
    import (
    	"my-app/models"
    	"encoding/json"
    
    	beego "github.com/astaxie/beego/server/web"
    )
    
    // Operations about object
    type ObjectController struct {
    	beego.Controller
    }
    
    1. What did you expect to see? I am expecting to see the messages Built successfully and app is running

    2. What did you see instead?

    2020/11/11 15:33:47 INFO     ▶ 0002 Initializing watcher...
    go: finding module for package github.com/astaxie/beego/server/web
    controllers/object.go:7:2: module github.com/astaxie/[email protected] found (v1.12.3), but does not contain package github.com/astaxie/beego/server/web
    2020/11/11 15:33:49 ERROR    ▶ 0003 Failed to build the application: go: finding module for package github.com/astaxie/beego/server/web
    controllers/object.go:7:2: module github.com/astaxie/[email protected] found (v1.12.3), but does not contain package github.com/astaxie/beego/server/web
    
    inactive-issue 
    opened by thitami 28
  • beego 时区问题

    beego 时区问题

    用的是最新的 linux: [[email protected]]# date Fri Jan 3 12:00:56 CST 2014

    mysql: mysql> select now(); +---------------------+ | now() | +---------------------+ | 2014-01-03 12:01:13 | +---------------------+ 1 row in set (0.00 sec)

    如果程序中 不设置orm.DefaultTimeLoc = time.UTC 则慢8小时 但是获取的时间是对的 now := time.Now() fmt.Println(now) fmt.Println(now.Location()) fmt.Println(now.Zone())

    2014-01-03 12:03:50.31161402 +0800 CST Local CST 28800

    设置的话慢16小时

    opened by w123dog 27
  • c.Ctx.Input.RequestBody empty value

    c.Ctx.Input.RequestBody empty value

    this is happen after I update beego to 1.6.1.

    this is my code func (c *AuthController) Login() {

        var data models.User
        if err := json.Unmarshal(c.Ctx.Input.RequestBody, &data); err != nil {
            c.Ctx.Output.SetStatus(400)
            fmt.Println(c.Ctx.Input.RequestBody)
            c.Ctx.Output.Body([]byte("empty title"))
            return
        }
        res := struct{  
            Data []*models.User 
        }{}
    
        var cond *orm.Condition
        cond = orm.NewCondition()
    
        cond = cond.And("username", data.Username)
        cond = cond.And("password", data.Password)
        lim :=1
    
        var qs orm.QuerySeter
        qs = orm.NewOrm().QueryTable("user").SetCond(cond).Limit(lim)
        _,err := qs.All(&res.Data)
        if err != nil {
            c.Ctx.Output.SetStatus(400)
            c.Ctx.Output.Body([]byte(err.Error()))
            return
        }
        result := struct{   
            Success bool
            Message string
        }{} 
    }
    

    curl -X POST http://lo0/login -d '{"username" : "admin", "password":"admin"}' empty title

    [email protected] ~/go/src/github.com/goldalworming/auth $ go run main.go [] <----fmt.Println return this empty array

    opened by goldalworming 26
  • Beego ORM模块建议

    Beego ORM模块建议

    例如,我有如下代码:

    var hotCourse []models.VCourse sql = "SELECT * FROM v_course ORDER BY hits DESC LIMIT 4" o.Raw(sql).QueryRows(&hotCourse)

    传入的hotCourse对应的models.VCourse里面的字段与数据库里面的字段顺序要一致才能将预期的字段值设置到VCourse的字段里面去。

    如: type VCourse struct{ Id int64 Name string }

    那么sql语句里面必须SELECT id,name FROM table才能将字段的值绑定上去。这很不方便。

    我希望是这样的: 当我的结构体只有两个字段:Id与Name,那么,在结果绑定到结构体上的时候,先遍历结构体的字段,按照Model的定义(即与表字段之间的定义)进行查找SQL里面的字段,然后将该字段的值绑定到结构体的对应字段上。这样就很完善了。

    在编写代码的时候,就不用再担心字段顺序的问题了。也不用担心,结构体的字段只有2个,而SQL字段有3个,导致匹配不上而报错了。

    能否请设计ORM的大神改善一下原生SQL语句的智能能力呢。谢谢!

    opened by fingerQin 25
  • Cors problems

    Cors problems

    I have a problem with cors and beego. This is my code:

    func main(){
    beego.InsertFilter("*", beego.BeforeRouter,cors.Allow(&cors.Options{
            AllowAllOrigins: true,
            AllowMethods: []string{"GET", "DELETE", "PUT", "PATCH", "OPTIONS"},
            AllowHeaders: []string{"Origin", "Access-Control-Allow-Origin"},
            ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin"},
            AllowCredentials: true,
        }))
    beego.Run()
    }
    

    I receive this answer: "XMLHttpRequest cannot load http://localhost:8080/. No 'Access-Control-Allow-Origin' header is present on the requested resource"

    I can't figure it out. Do you have any ideas? Thanks for any help.

    opened by peterpalace 24
  • 注解路由未生成?

    注解路由未生成?

    runmode已经设置成了dev,注解也写了,但是未生成commentsRouter.go文件 OS win 10,beego版本 master版本

    runmode = "dev"
    

    router.go

    func init() {
    	ns := beego.NewNamespace("/admin",
    
    		beego.NSNamespace("/contents",
    			beego.NSInclude(
    				&controllers.ContentController{},
    			),
    		),
    	)
    	beego.AddNamespace(ns)
    }
    

    controllers/content.go

    type ContentController struct {
    	BaseController
    }
    
    // @router / [get]
    func (this *ContentController) GetContents() {
    	defer this.ServeJSON()
            // .....
    }
    
    opened by pigLoveRabbit520 23
  • Support get environment variables in config

    Support get environment variables in config

    get environment variable if config item has prefix $ENV_ $$env ${env}. if environment variable is empty or not exist then return default value (split with ||). e.g.

    token = ${TOKEN||astaxie}
    [demo]
    password = ${MyPWD}
    user = ${MyUser||beego}
    

    the result of config.String("demo::password") is the $MyPWD environment variable. some people need it , such as #1283 .

    status/accepted 
    opened by ysqi 23
  • After SessionRegenerateID, beegosessionID cookie's secure flag is missing

    After SessionRegenerateID, beegosessionID cookie's secure flag is missing

    1. What version of Go and beego are you using (bee version)? 1.12.10

    2. What operating system and processor architecture are you using (go env)?

    GO111MODULE=""
    GOARCH="amd64"
    GOBIN=""
    GOCACHE="/home/gpadmin/.cache/go-build"
    GOENV="/home/gpadmin/.config/go/env"
    GOEXE=""
    GOEXPERIMENT=""
    GOFLAGS="-mod=vendor"
    GOHOSTARCH="amd64"
    GOHOSTOS="linux"
    GOINSECURE=""
    GOMODCACHE="/home/gpadmin/gopath/pkg/mod"
    GONOPROXY=""
    GONOSUMDB=""
    GOOS="linux"
    GOPATH="/home/gpadmin/gopath"
    GOPRIVATE=""
    GOPROXY="https://goproxy.cn"
    GOROOT="/usr/local/go"
    GOSUMDB="sum.golang.org"
    GOTMPDIR=""
    GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
    GOVCS=""
    GOVERSION="go1.18.3"
    GCCGO="gccgo"
    GOAMD64="v1"
    AR="ar"
    CC="gcc"
    CXX="g++"
    CGO_ENABLED="1"
    GOMOD="/dev/null"
    GOWORK=""
    CGO_CFLAGS="-g -O2"
    CGO_CPPFLAGS=""
    CGO_CXXFLAGS="-g -O2"
    CGO_FFLAGS="-g -O2"
    CGO_LDFLAGS="-g -O2"
    PKG_CONFIG="pkg-config"
    GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3060323132=/tmp/go-build -gno-record-gcc-switches"
    
    1. What did you do? If possible, provide a recipe for reproducing the error. A complete runnable program is good.
    • beegosessionID cookie's secure flag was set before login,
    • After a user login, SessionRegenerateID is called
    • This secure flag is missing
    1. What did you expect to see? Expect beegosessionID cookie's secure flag is still set

    2. What did you see instead? Saw beegosessionID cookie's secure flag is missing.

    3. RCA It's because this line is not added after this line L330:

    http.Secure = manager.isSecure(r)
    

    And if possible, could you please also set Domain and SameSite to keep align with L315 - L317? Like this: image

    opened by yangru 0
  • beego orm many to many issue

    beego orm many to many issue

    Please answer these questions before submitting your issue. Thanks!

    1. What version of Go and beego are you using (bee version)?

    Go version: 1.16.4 bee version


    | ___
    | |/ / ___ ___ | ___ \ / _ \ / _
    | |
    / /| /| / __/ _| ___| v2.0.2

    ├── GoVersion : go1.16.4 ├── GOOS : linux ├── GOARCH : amd64 ├── NumCPU : 4 ├── GOPATH : /root/goworkspace/packages ├── GOROOT : /usr/local/go ├── Compiler : gc └── Published : 2020-12-16

    1. What operating system and processor architecture are you using (go env)?

    os : linux ,

    Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian

    1. What did you do?

    Hi Team. I am using ENTERPRISE model and ROLES model using two Many-To-Many relationships (dependent table:TestEnterprisesTestRoless )

    package models

    import ( "github.com/astaxie/beego/orm" )

    //enterprise ... parent type ENTERPRISE struct {

        ID         int64  `orm:"pk;auto;column(id)" json:"id"`
    FIRST_NAME string `validate:"required" json:"first_name" orm:"column(first_name);size(100);default(null)"`
    EMAIL      string `validate:"required" json:"email" orm:"unique;column(email);size(100);default(null)"`
    LAST_NAME  string `validate:"required" json:"last_name" orm:"column(last_name);default(null)"`
    CREATED_AT time.Time `orm:"auto_now;type(datetime);column(createdAt);default(null)"`
    UPDATED_AT time.Time `orm:"auto_now_add;type(datetime);column(updatedAt);default(null)"`
    ROLES []*ROLES `json:"roles" orm:"rel(m2m);rel_through(ftp-api/services.TestEnterprisesTestRoless);column(role_id);default(null)"`
    

    }

    type ROLES struct {

       ID         int64         `orm:"pk;auto;column(id)" json:"id"`
    NAME       string        `validate:"required" json:"name" orm:"unique;column(name);size(100);default(null)"`
    ACTION     string        `validate:"required" json:"action" orm:"unique;column(action);size(100);default(null)"`
    ENTERPRISE []*ENTERPRISE `validate:"required" json:"enterprise" orm:"reverse(many);column(enterprise_id);rel_through(ftp-api/services.TestEnterprisesTestRoless);default(null)"`
    

    } type TestEnterprisesTestRoless struct {

         ID         int64         `orm:"pk;auto;column(id)" json:"id"`
    ENTERPRISE *ENTERPRISE `orm:"rel(fk);column(enterprise_id)"`
    ROLES      *ROLES      `orm:"rel(fk);column(role_id)"`
    

    }

    var OrmConnection orm.Ormer

    func (enterpriseObj *ENTERPRISE) TableName() string { return "test_enterprises" }

    func (addrObj *TestEnterprisesTestRoless) TableName() string { return "test_enterprises_test_roless" } func (roleObj *ROLES) TableName() string { return "test_roles" }

    //loading the schemas orm.RegisterModel(new(ROLES), new(ENTERPRISE), new(TestEnterprisesTestRoless))

    I am able to create enterprise and roles individually (but the enterprise_id and role_id is not storing in the test_enterprises_test_roless table), my question is :

    how to fetch enterprises with dependent roles and same as how to fetch roles with dependent enterprises

    I have tried using below queries

    1 : //FetchRoleData ... fetching headers and dependent enterprises

    func FetchRoleData() ([]ROLES, error) {

    roleObj := make([]ROLES, 0)
    tableName := new(ROLES).TableName()
    querySet := OrmConnection.QueryTable(tableName)
    
    //if any filter/limit required need to be applied to wuery set
    num, err := querySet.RelatedSel().All(&roleObj)
    if err != nil {
    	return roleObj, err
    }
    for _, role := range roleObj {
    	OrmConnection.LoadRelated(&role, "TestEnterprisesTestRoless", "role_id")
    }
    log.Printf("selectd %d rows", num)
    return roleObj, nil
    

    }

    for the above getting error as " name &{%!s(int64=1) enterprise5 download []} for model TestEnterprisesTestRoless is not an available rel/reverse field"

    func FetchRoleData() ([]ROLES, error) {

    roleObj := make([]ROLES, 0)
    tableName := new(ROLES).TableName()
    querySet := OrmConnection.QueryTable(tableName)
    
    //if any filter/limit required need to be applied to wuery set
    num, err := querySet.RelatedSel("TestEnterprisesTestRoless").All(&roleObj)
    if err != nil {
    	return roleObj, err
    }
    log.Printf("selectd %d rows", num)
    return roleObj, nil
    

    }

    for the above getting error as "unknown model/table name TestEnterprisesTestRoless"

    1. What did you expect to see?

    sample expected result :

    1. role { "name":"sample rolename", "action":"update", "enterprises":[ { // enterprise attached to this role }, { // enterprise attached to this role } ] }

    2. Enterprise { "firstName":"", "lastName":"",

      "roles":[ { // role attached to this enterprise }, { // role attached to this enterprise } ] }

    3. What did you see instead?

    name &{%!s(int64=1) enterprise5 download []} for model TestEnterprisesTestRoless is not an available rel/reverse field" unknown model/table name `TestEnterprisesTestRoless

    do i need to change anything in the models or do i need to change query in different way

    any response will be helpful and appreciated

    kind/bug 
    opened by srisaim249 0
  • the var Field of Error is

    the var Field of Error is "", in beego/validation/validation.go-- func (v *Validation) apply(chk Validator, obj interface{}) *Result

    English Only. Please use English because others could join the discussion if they got similar issue!

    Please answer these questions before submitting your issue. Thanks!

    1. What version of Go and beego are you using (bee version)? github.com/beego/beego v1.12.9

    2. What operating system and processor architecture are you using (go env)? windows10

    3. What did you do? in beego/validation/validation.go ` func (v *Validation) apply(chk Validator, obj interface{}) *Result { if nil == obj { if chk.IsSatisfied(obj) { return &Result{Ok: true} } } else if reflect.TypeOf(obj).Kind() == reflect.Ptr { if reflect.ValueOf(obj).IsNil() { if chk.IsSatisfied(nil) { return &Result{Ok: true} } } else { if chk.IsSatisfied(reflect.ValueOf(obj).Elem().Interface()) { return &Result{Ok: true} } } } else if chk.IsSatisfied(obj) { return &Result{Ok: true} }

      // Add the error to the validation context. key := chk.GetKey() Name := key Field := "" Label := "" parts := strings.Split(key, ".") if len(parts) == 3 { Field = parts[0] Name = parts[1] Label = parts[2] if len(Label) == 0 { Label = Field } }

      err := &Error{ Message: Label + " " + chk.DefaultMessage(), Key: key, Name: Name, Field: Field, Value: obj, Tmpl: MessageTmpls[Name], LimitValue: chk.GetLimitValue(), } v.setError(err)

      // Also return it in the result. return &Result{ Ok: false, Error: err, } } _in beego/validation/util.go_ // Get Match function // May be get NoMatch function in the future func getRegFuncs(tag, key string) (vfs []ValidFunc, str string, err error) { tag = strings.TrimSpace(tag) index := strings.Index(tag, "Match(/") if index == -1 { str = tag return } end := strings.LastIndex(tag, "/)") if end < index { err = fmt.Errorf("invalid Match function") return } reg, err := regexp.Compile(tag[index+len("Match(/") : end]) if err != nil { return } vfs = []ValidFunc{{"Match", []interface{}{reg, key + ".Match"}}} str = strings.TrimSpace(tag[:index]) + strings.TrimSpace(tag[end+len("/)"):]) return } ` when my valid string has string match, I don't get var Field , because, the function of getRegFuncs don't get xxx.Match.xxx but xxx.Match

    4. What did you expect to see? I hope I can get the Field value of Error when my valid format has errors.

    5. What did you see instead?

    func getRegFuncs(tag, key string) (vfs []ValidFunc, str string, err error) { tag = strings.TrimSpace(tag) index := strings.Index(tag, "Match(/") if index == -1 { str = tag return } end := strings.LastIndex(tag, "/)") if end < index { err = fmt.Errorf("invalid Match function") return } reg, err := regexp.Compile(tag[index+len("Match(/") : end]) if err != nil { return } vfs = []ValidFunc{{"Match", []interface{}{reg, key + ".Match"}}} str = strings.TrimSpace(tag[:index]) + strings.TrimSpace(tag[end+len("/)"):]) return } instead

    func getRegFuncs(tag, key label string) (vfs []ValidFunc, str string, err error) { tag = strings.TrimSpace(tag) index := strings.Index(tag, "Match(/") if index == -1 { str = tag return } end := strings.LastIndex(tag, "/)") if end < index { err = fmt.Errorf("invalid Match function") return } reg, err := regexp.Compile(tag[index+len("Match(/") : end]) if err != nil { return } vfs = []ValidFunc{{"Match", []interface{}{reg, key + ".Match" + "." + label}}} str = strings.TrimSpace(tag[:index]) + strings.TrimSpace(tag[end+len("/)"):]) return }

    opened by swf2020 3
Releases(v2.0.4)
  • v2.0.2(Jan 27, 2022)

    Change Log

    Incompatible Changes:

    We remove the comments router generation function. So you have to run bee generate routers command to generate the routers. Here is the command:

    bee generate routers [-ctrlDir=/path/to/controller/directory] [-routersFile=/path/to/routers/file.go] [-routersPkg=myPackage]
        -ctrlDir: the directory contains controllers definition. Bee scans this directory and its subdirectory to generate routers info
        -routersFile: output file. All generated routers info will be output into this file.
                  If file not found, Bee create new one, or Bee truncates it.
                  The default value is "routers/commentRouters.go"
        -routersPkg: package declaration.The default value is "routers".
                  When you pass routersFile parameter, youd better pass this parameter
    
    Source code(tar.gz)
    Source code(zip)
  • v2.0.2-beta.1(Sep 15, 2021)

    We focus on four things:

    1. Improve code quality;
    2. Fix bugs;
    3. Introduce error code for some modules. We will design error code for other modules in the future if we got good feedback;
    4. Add some convininet functions for web module;

    CHANGE LOG

    • Add a custom option for whether to escape HTML special characters when processing http request parameters. 4701
    • Always set the response status in the CustomAbort function. 4686
    • Add template functions eq,lt to support uint and int compare. 4607
    • Migrate tests to GitHub Actions. 4663
    • Add http client and option func. 4455
    • Add: Convenient way to generate mock object 4620
    • Infra: use dependabot to update dependencies. 4623
    • Lint: use golangci-lint. 4619
    • Chore: format code. 4615
    • Test on Go v1.15.x & v1.16.x. 4614
    • Env: non-empty GOBIN & GOPATH. 4613
    • Chore: update dependencies. 4611
    • Update orm_test.go/TestInsertOrUpdate with table-driven. 4609
    • Add: Resp() method for web.Controller. 4588
    • Web mock and test support. 4565 4574
    • Error codes definition of cache module. 4493
    • Remove generateCommentRoute http hook. Using bee generate routers commands instead.4486 bee PR 762
    • Fix: /abc.html/aaa match /abc/aaa. 4459
    • ORM mock. 4407
    • Add sonar check and ignore test. 4432 4433
    • Update changlog.yml to check every PR to develop branch.4427
    • Fix 4396: Add context.param module into adapter. 4398
    • Support RollbackUnlessCommit API. 4542
    • Fix 4503 and 4504: Add when to Write([]byte) method and add prefix to writeMsg. 4507
    • Fix 4480: log format incorrect. 4482
    • Remove duration from prometheus labels. 4391
    • Fix unknown escape sequence in generated code. 4385
    • Fix 4590: Forget to check URL when FilterChain invoke next(). 4593
    • Fix 4727: CSS when request URI is invalid. 4729
    • Using fixed name commentRouter.go as generated file name. 4385
    • Fix 4383: ORM Adapter produces panic when using orm.RegisterModelWithPrefix. 4386
    • Support 4144: Add new api for order by for supporting multiple way to query 4294
    • Support session Filter chain. 4404
    • Feature issue #4402 finish router get example. 4416
    • Implement context.Context support and deprecate QueryM2MWithCtx and QueryTableWithCtx 4424
    • Finish timeout option for tasks #4441 4441
    • Error Module brief design & using httplib module to validate this design. 4453
    • Fix 4444: panic when 404 not found. 4446
    • Fix 4435: fix panic when controller dir not found. 4452
    • Hotfix:reflect.ValueOf(nil) in getFlatParams 4716
    • Fix 4456: Fix router method expression 4456
    • Remove some go get lines in .travis.yml file 4469
    • Fix 4451: support QueryExecutor interface. 4461
    • Add some testing scripts 4461
    • Refactor httplib: Move debug code to a filter 4440
    • fix: code quality issues 4513
    • Optimize maligned structs to reduce memory foot-print 4525
    • Feat: add token bucket ratelimit filter 4508
    • Improve: Avoid ignoring mistakes that need attention 4548
    • Integration: DeepSource 4560
    • Integration: Remove unnecessary function call 4577
    • Feature issue #4402 finish router get example. 4416
    • Proposal: Add Bind() method for web.Controller 4491
    • Optimize AddAutoPrefix: only register one router in case-insensitive mode. 4582
    • Init exceptMethod by using reflection. 4583
    • Deprecated BeeMap and replace all usage with sync.map 4616
    • TaskManager support graceful shutdown 4635
    • Add comments to web.Config, rename RouterXXX to CtrlXXX, define HandleFunc 4714
    • Refactor: Move BindXXX and XXXResp methods to context.Context. 4718
    • Fix 4728: Print wrong file name. 4737
    • fix bug:reflect.ValueOf(nil) in getFlatParams 4715
    • Fix 4736: set a fixed value "/" to the "Path" of "_xsrf" cookie. 4736 4739
    • Fix 4734: do not reset id in Delete function. 4738 4742
    • Fix 4699: Remove Remove goyaml2 dependency. 4755
    • Fix 4698: Prompt error when config format is incorrect. 4757
    • Fix 4674: Tx Orm missing debug log 4756
    • Fix 4759: fix numeric notation of permissions 4759

    Fix Sonar

    Fix lint and format code

    Source code(tar.gz)
    Source code(zip)
  • v2.0.1(Dec 14, 2020)

    When we release v2.0.0, something wrong and then we re-release v2.0.0.

    But the checksum in sum.golang.cn is immutable, so we release this version

    Source code(tar.gz)
    Source code(zip)
  • v2.0.0(Dec 14, 2020)

    Refactor

    1. Support the new project structure. We split the whole framework into four parts: 1.1 server: including web module. 1.2 client: including ORM, cache, httplib modules. 1.3 task: supporting timed tasks and other cyclic tasks. 1.4 core: including validation, config, logs and admin modules.
    2. Add adapter module which is used to reduce the effort of upgrading Beego from v1.x to v2.x
    3. Add context.Context for cache, httplib, session, task, ORM modules' API.
    4. Add error as a return value for cache, httplib, session, task. Now users are able to know more info about what happen inside Beego.
    5. Decouple modules from each other. All modules only depend on core package.
    6. Support tracing, metrics in ORM, web, httplib modules.
    7. Introduce filter-chain patter to support AOP.

    Feature:

    1. Allow Healthcheck endpoint return JSON for Kubernetes. 4055
    2. Support ClientAuth for TLS. 4116
    3. orm.RawSeter supports orm.Fielder. 4191
    4. Add a new MySQL operator for strict case-sensitive query. 4198
    5. Using filter-chain pattern in orm module. Support opentracing and prometheus by using filter. 4141
    6. Support prometheus filter for httplib module. 4145
    7. Add additional options to redis session prov. 4137
    8. Support default value filter for orm module. 4156
    9. Add methods Unmarshaler, Sub, OnChange for Configer module. 4175
    10. Custom Log Formatter. 4174, 4179, 4188
    11. Support the time precision for time.Time type. 4186
    12. Support etcd in Config module. 4195
    13. Optimize rawSet.QueryRows to avoid many unnecessary calls to parseStructTag. 4210
    14. Allow users to ignore some table when run ORM commands. 4211
    15. PostgresQueryBuilder 4205
    16. Provides a powerful LogFormatter implementation PatternLogFormatter.4229
    17. Support custom ES index name. 4233
    18. Support multiple web servers. 4234
    19. Support toml config. 4262
    20. Using unmarshaler to parse config in web module. 4266
    21. Add MaxUploadFile to provide more safety uploading control. 4275
    22. Support using json string to init session. 4277
    23. Support global instance for config module. 4278

    Fix:

    1. Fix reconnection bug in logs/conn.go. 4056
    2. Return 413 when request payload too large. 4058
    3. Fix index out of range in session module when len(sid) < 2. 4068
    4. Fix concurrent issue of context/input Query method. 4066
    5. Allow using environment variable to specific the config file. 4111
    6. XSRF add secure and http only flag. 4126
    7. Fix temporary create failed on Windows 4244
    8. Fix:return error after inserting data when primary key is string. 4150
    9. Fix the bug that Fielder's SetRaw is not called when calling orm.Raw() to query from database. 4160
    10. Fix: return error when calling InsertOrUpdate is successful with string primary key. 4158
    11. Fix the problem that the nested structure of queryRow() cannot assign values 4173
    12. Empty field in validator.Error when label struct tag is not declared. 4225
    13. Fix deadlock in task module. 4246
    14. Fix: form entity too large casue run out of memory. 4272

    Doc:

    1. Fix typo. 4251, 4135, 4107
    Source code(tar.gz)
    Source code(zip)
  • v2.0.0-beta(Nov 7, 2020)

    Refactor

    1. Support the new project structure.
    2. Add adapter module which is used to adapt v1.x to v2.x.
    3. Add context.Context for cache, httplib, session, task, orm modules' API.
    4. Add error as a return value for cache, httplib, session, task.
    5. Decouple modules from each other. All modules only depend on core package.

    Feature:

    1. Allow Healthcheck endpoint return JSON for Kubernetes (Experimental). 4055
    2. Support ClientAuth for TLS. 4116
    3. orm.RawSeter support orm.Fielder. 4191
    4. Add a new MySQL operator for strict case sensitive query. 4198
    5. Using filter-chain pattern in orm module. Support opentracing and prometheus by using filter. 4141
    6. Support prometheus filter for httplib module. 4145
    7. Add additional options to redis session prov. 4137
    8. Support default value filter for orm module. 4156
    9. Add methods Unmarshaler, Sub, OnChange for Configer module. 4175
    10. Custom Log Formatter. 4174, 4179, 4188
    11. Implement the time precison for time.Time type. 4186
    12. Support etcd. 4195
    13. Optimize rawSet.QueryRows to avoid many unnecessary calls to parseStructTag. 4210
    14. Allow users to ignore some table when run orm commands. 4211
    15. PostgresQueryBuilder 4205
    16. Provides a quick format method by PatternLogFormatter struct. 4229
    17. Support custom ES index name. 4233 18 Support multiple web server. 4234
    18. Support toml config. 4262
    19. Using unmarshaler to parse config in web module. 4266
    20. Add MaxUploadFile to provide more safety uploading control. 4275
    21. Support using json string to init session. 4277
    22. Support global instance for config module. 4278

    Fix:

    1. Fix reconnection bug in logs/conn.go. 4056
    2. Return 403 when request payload too large. 4058
    3. Fix race condition for Prepare Statement cache. 4061
    4. Fix index out of range in session module when len(sid) < 2. 4068
    5. Fix concurrent issue of context/input Query method. 4066
    6. Allow using environment variable to specific the config file. 4111
    7. XSRF add secure and http only flag. 4126
    8. Fix temporary create failed on Windows 4244
    9. Session: adds CookieSameSite to ManagerConfig. 4226
    10. Make stmt cache smaller to avoid too many statement error. 4261
    11. Fix:return error after inserting data when primary key is string. 4150 12.Fix the bug that Fielder's SetRaw is not called when calling orm.Raw() to query from database. 4160
    12. Fix: return error when calling InsertOrUpdate is successful with string primary key. 4158
    13. Fix the problem that the nested structure of queryRow() cannot assign values 4173
    14. Empty field in validator.Error when label struct tag is not declared. 4225
    15. Fix deadlock in task module. 4246
    16. Fix: form entity too large casue run out of memory. 4272

    Doc:

    1. Fix typo. 4251, 4135, 4107
    Source code(tar.gz)
    Source code(zip)
  • v1.12.3(Nov 5, 2020)

    Feature:

    1. Allow Healthcheck endpoint return JSON for Kubernetes. 4055
    2. Support ClientAuth for TLS. 4116
    3. orm.RawSeter support orm.Fielder. 4191
    4. Add a new MySQL operator for strict case sensitive query. 4198

    Fix:

    1. Fix reconnection bug in logs/conn.go. 4056
    2. Return 403 when request payload too large. 4058
    3. Fix race condition for Prepare Statement cache. 4061
    4. Fix index out of range in session module when len(sid) < 2. 4068
    5. Fix concurrent issue of context/input Query method. 4066
    6. Allow using environment variable to specific the config file. 4111
    7. XSRF add secure and http only flag. 4126
    8. Fix temporary create failed on Windows 4244
    9. Session: adds CookieSameSite to ManagerConfig. 4226
    10. Make stmt cache smaller to avoid too many statement error. 4261

    Doc:

    1. Fix typo. 4251
    Source code(tar.gz)
    Source code(zip)
  • v1.12.2(Jul 1, 2020)

    • Fix old process didn't exist when graceful restart in beego 1.12.0 #4005
    • Enhance: Print stack while orm abnormally exit #3743
    • Enhance: Replacing lock with read lock in GetMapData #3803
    • Fix: Get the real location of the log directory if the path is symbolic path #3818
    • Fix: Cache, context, session: add lock to fix inconsistent field protection #3922
    • Fix: Encoded url(with slash) router mismatch problem #3943
    • Fix: genRouterCode method generate wrong codes #3981
    • Enhance: Using LRU algorithm, ignoring big file and using max cache size to reduce the memory usage of file cache #3984
    • Fix: Set max DB connections #3985
    • Fix: SQLite don't support SELECT ... FOR UPDATE #3992
    • Enhance: Add Transfer-Encoding header in httplib's PostFile method #3993
    • Enhance: Support bit operation in ORM #3994
    • Fix: net/http Middleware set via RunWithMiddleware or App.Run(middleware) doesn't work when "BConfig.Listen.Graceful" is set to true #3995
    • Fix: Empty field in validator.Error when label struct tag is not declared #4001
    • Fix: panic: send on closed channel after closing logger #4004
    • Enhance: Store RouterPattern before filter execute #4007
    • Fix: Using HTMLEscapeString in adminui.go to avoid XSS attack #4018
    • Fix: Process not closed when graceful set to true #4005
    • Enhance: Use scan instead of keys in redis #4016
    • Feature: Support prometheus #4021
    • Fix: Can't create more than max_prepared_stmt_count statements #4025
    • Enhance: Support more mobile number pattern #4027
    • Fix: Can't set section name #4027
    • Fix: strings.Repeat panic in orm/db.go #4032
    • Enhance: Make redis client idle timeout configurable #4033
    Source code(tar.gz)
    Source code(zip)
  • v1.10.0(Jul 21, 2018)

    • Update log.go add GetLevel Function to Log #2970
    • Fix a typo "conflict" #2971
    • Bug on private fields #2978
    • Fix access log console unexpected '\n' at end of each log. #2976
    • Fix Documentation for HTTP status codes descriptions. #2992
    • Redis cache: make MaxIdle configurable #3004
    • Update: Fix migration generate SQL #3017
    • Handle pointer validation #3046
    • Fix the issue TaseCase TestFormatHeader_0 is failed #3066
    • Fix BEEGO_RUNMODE #3064
    • Swagger: Allow example values with different types, allow example for enum. #3085
    • Fix the bug: unable to add column with ALTER TABLE #2999
    • Set default Beego RunMode to production #3076
    • Fix typo #3103
    • In dev mode, template parse error cause program lock #3126
    • Amend a very minor typo in a variable name #3115
    • When log maxSize set big int,FileWrite Init fail #3109
    • Change github.com/garyburd/redigo to newest branch github.com/gomodul… #3100
    • ExecElem.FieldByName as local variable #3039
    • Allow log prefix #3145
    • Refactor yaml config for support multilevel #3127
    • Create redis_cluster.go #3175
    • Add field comment on create table #3190
    • Update: use PathEscape replace QueryEscape #3200
    • Update gofmt #3206
    • Update: Htmlquote Htmlunquote #3202
    • Add 'FOR UPDATE' support for querySet #3208
    • Debug stringsToJSON #3171
    • Fix defaut value bug, and add config for maxfiles #3185
    • Fix: correct MaxIdleConnsPerHost value to net/http default 100. #3230
    • Fix: When multiply comment routers on one func #3217
    • Send ErrNoRows if the query returns zero rows ... in method orm_query… #3247
    • Fix typo #3245
    • Add session redis IdleTimeout config #3239
    • Fix the wrong status code in prod #3226
    • Add method to set the data depending on the accepted #3182
    • Fix Unexpected EOF bug in staticfile #3152
    • Add code style for logs README #3146
    • Fix response http code #3142
    • Improve access log #3141
    • Auto create log dir #3105
    • Html escape before display path, avoid xss #3022
    • Acquire lock when access config data #3250
    • Fix orm fields SetRaw function error judge problem #2985
    • Fix template rendering with automatic mapped parameters (see #2979) #2981
    • Fix the model can not be registered correctly on Ubuntu 32bit #2997
    • Feature/yaml #3181
    • Feature/autocert #3249
    Source code(tar.gz)
    Source code(zip)
  • v1.9.0(Aug 24, 2017)

    1. Fix the new repo address for casbin #2654
    2. Fix cache/memory fatal error: concurrent map iteration and map write #2726
    3. AddAPPStartHook func modify #2724
    4. Fix panic: sync: negative WaitGroup counter #2717
    5. incorrect error rendering (wrong status) #2712
    6. validation: support int64 int32 int16 and int8 type #2728
    7. validation: support required option for some struct tag valids #2741
    8. Fix big form parse issue #2725
    9. File log add RotatePerm #2683
    10. Fix Oracle placehold #2749
    11. Supported gzip for req.Header has Content-Encoding: gzip #2754
    12. Add new Database Migrations #2744
    13. Beego auto generate sort ControllerComments #2766
    14. added statusCode and pattern to FilterMonitorFunc #2692
    15. fix the bugs in the "ParseBool" function in the file of config.go #2740
    Source code(tar.gz)
    Source code(zip)
  • v1.8.3(May 19, 2017)

    1. Trim required string. #2365
    2. Add an authorization plugin that supports ACL, RBAC based on casbin #2620
    3. Fix sqllite delete filter #2636
    4. Swagger support security setting #2640
    5. Automatic param router #2586
    6. Allow o.Raw(sql).QueryRows(&container) nested #2637
    7. Fix form parse timestamp format #2652
    8. Fix for xsrf panic error #2315
    Source code(tar.gz)
    Source code(zip)
Owner
beego Framework
beego Framework
letgo is an open-source, high-performance web framework for the Go programming language.

high-performance Lightweight web framework for the Go programming language. golang web framework,高可用golang web框架,go语言 web框架 ,go web

wjp 352 Jun 26, 2022
A Go API project using Beego(Go Framework) with Swagger UI

Beego_API_with_swagger_UI Descriptions This is a Go API project using Beego(Go F

A.R partha 0 Dec 20, 2021
henrylee2cn 1.6k Jun 26, 2022
High performance, minimalist Go web framework

Supported Go versions As of version 4.0.0, Echo is available as a Go module. Therefore a Go version capable of understanding /vN suffixed imports is r

LabStack LLC 22.7k Jun 24, 2022
Gearbox :gear: is a web framework written in Go with a focus on high performance

gearbox ⚙️ is a web framework for building micro services written in Go with a focus on high performance. It's built on fasthttp which is up to 10x fa

Gearbox 645 Jun 21, 2022
hiboot is a high performance web and cli application framework with dependency injection support

Hiboot - web/cli application framework About Hiboot is a cloud native web and cli application framework written in Go. Hiboot is not trying to reinven

hidevops.io 175 Jun 12, 2022
Gearbox :gear: is a web framework written in Go with a focus on high performance

gearbox ⚙️ is a web framework for building micro services written in Go with a focus on high performance. It's built on fasthttp which is up to 10x fa

Gearbox 645 Jun 21, 2022
High performance, simple Go web framework

Elton Elton的实现参考了koa以及echo,中间件的调整均为洋葱模型:请求由外至内,响应由内至外。主要特性如下: 处理函数(中间件)均以返回error的形式响应出错,方便使用统一的出错处理中间件将出错统一转换为对应的输出(JSON),并根据出错的类型等生成各类统计分析 成功响应数据直接赋值

Tree Xie 59 May 15, 2022
Dragon 🐲 🐲 🐲 is an enterprise high performance web framework with Go for the feature and comfortable develop.

Dragon start dragon ab performance Dragon ?? ?? ?? is a lightweight high performance web framework with Go for the feature and comfortable develop. 中文

dragon 7 Mar 28, 2022
Dragon 🐲 🐲 🐲 is a lightweight high performance web framework with Go for the feature and comfortable develop.

Dragon project new link start dragon ab performance Dragon ?? ?? ?? is a lightweight high performance web framework with Go for the feature and comfor

azerothyang 13 Apr 6, 2022
A high productivity, full-stack web framework for the Go language.

Revel Framework A high productivity, full-stack web framework for the Go language. Current Version: 1.0.0 (2020-07-11) Supports go.mod package managem

Revel Framework 12.6k Jun 25, 2022
Goal is a toolkit for high productivity web development in Go language in the spirit of Revel Framework that is built around the concept of code generation.

Goal Goal is a set of tools for high productivity web development in Go language. Goal, being mostly inspired by Revel Framework and its discussions,

null 88 Sep 27, 2021
GoFrame is a modular, powerful, high-performance and enterprise-class application development framework of Golang.

GoFrame English | 简体中文 GoFrame is a modular, powerful, high-performance and enterprise-class application development framework of Golang. If you're a

GoFrame 7.7k Jun 30, 2022
Flamingo Framework and Core Library. Flamingo is a go based framework for pluggable web projects. It is used to build scalable and maintainable (web)applications.

Flamingo Framework Flamingo is a web framework based on Go. It is designed to build pluggable and maintainable web projects. It is production ready, f

Flamingo 302 Jun 17, 2022
Golanger Web Framework is a lightweight framework for writing web applications in Go.

/* Copyright 2013 Golanger.com. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except

golanger 299 Mar 3, 2022
The jin is a simplified version of the gin web framework that can help you quickly understand the core principles of a web framework.

jin About The jin is a simplified version of the gin web framework that can help you quickly understand the core principles of a web framework. If thi

null 8 Dec 27, 2021
Go-app is a package to build progressive web apps with Go programming language and WebAssembly.

Go-app is a package to build progressive web apps with Go programming language and WebAssembly.

Maxence Charriere 6.2k Jun 24, 2022
Tigo is an HTTP web framework written in Go (Golang).It features a Tornado-like API with better performance. Tigo是一款用Go语言开发的web应用框架,API特性类似于Tornado并且拥有比Tornado更好的性能。

Tigo(For English Documentation Click Here) 一个使用Go语言开发的web框架。 相关工具及插件 tiger tiger是一个专门为Tigo框架量身定做的脚手架工具,可以使用tiger新建Tigo项目或者执行其他操作。

Karl 1.3k Jun 28, 2022
Package macaron is a high productive and modular web framework in Go.

Macaron Package macaron is a high productive and modular web framework in Go. Getting Started The minimum requirement of Go is 1.6. To install Macaron

Macaron 3.3k Jun 28, 2022