1
0
mirror of https://github.com/beego/bee.git synced 2024-11-23 22:10:54 +00:00

using beego v2

This commit is contained in:
Ming Deng 2020-12-14 13:08:47 +08:00
parent 9d68c302bd
commit cdb41fad3f
16 changed files with 38 additions and 38 deletions

View File

@ -355,7 +355,7 @@ Breakpoint 1 set at 0x40100f for main.main() ./main.go:8
> main.main() ./main.go:8 (hits goroutine(1):1 total:1) (PC: 0x40100f) > main.main() ./main.go:8 (hits goroutine(1):1 total:1) (PC: 0x40100f)
3: import ( 3: import (
4: _ "github.com/user/myapp/routers" 4: _ "github.com/user/myapp/routers"
5: beego "github.com/beego/beego/server/web" 5: beego "github.com/beego/beego/v2/server/web"
6: ) 6: )
7: 7:
=> 8: func main() { => 8: func main() {

View File

@ -76,7 +76,7 @@ var apiMaingo = `package main
import ( import (
_ "{{.Appname}}/routers" _ "{{.Appname}}/routers"
beego "github.com/beego/beego/server/web" beego "github.com/beego/beego/v2/server/web"
) )
func main() { func main() {
@ -93,8 +93,8 @@ var apiMainconngo = `package main
import ( import (
_ "{{.Appname}}/routers" _ "{{.Appname}}/routers"
beego "github.com/beego/beego/server/web" beego "github.com/beego/beego/v2/server/web"
"github.com/beego/beego/client/orm" "github.com/beego/beego/v2/client/orm"
{{.DriverPkg}} {{.DriverPkg}}
) )
@ -113,7 +113,7 @@ module %s
go %s go %s
require github.com/beego/beego %s require github.com/beego/beego/v2 %s
require github.com/smartystreets/goconvey v1.6.4 require github.com/smartystreets/goconvey v1.6.4
` `
@ -129,7 +129,7 @@ package routers
import ( import (
"{{.Appname}}/controllers" "{{.Appname}}/controllers"
beego "github.com/beego/beego/server/web" beego "github.com/beego/beego/v2/server/web"
) )
func init() { func init() {
@ -298,7 +298,7 @@ import (
"{{.Appname}}/models" "{{.Appname}}/models"
"encoding/json" "encoding/json"
beego "github.com/beego/beego/server/web" beego "github.com/beego/beego/v2/server/web"
) )
// Operations about object // Operations about object
@ -391,7 +391,7 @@ import (
"{{.Appname}}/models" "{{.Appname}}/models"
"encoding/json" "encoding/json"
beego "github.com/beego/beego/server/web" beego "github.com/beego/beego/v2/server/web"
) )
// Operations about Users // Operations about Users
@ -516,8 +516,8 @@ import (
"path/filepath" "path/filepath"
_ "{{.Appname}}/routers" _ "{{.Appname}}/routers"
beego "github.com/beego/beego/server/web" beego "github.com/beego/beego/v2/server/web"
"github.com/beego/beego/core/logs" "github.com/beego/beego/v2/core/logs"
. "github.com/smartystreets/goconvey/convey" . "github.com/smartystreets/goconvey/convey"
) )

View File

@ -49,7 +49,7 @@ module %s
go %s go %s
require github.com/beego/beego %s require github.com/beego/beego/v2 %s
require github.com/smartystreets/goconvey v1.6.4 require github.com/smartystreets/goconvey v1.6.4
` `

View File

@ -366,8 +366,8 @@ const (
import( import(
"os" "os"
"github.com/beego/beego/client/orm" "github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/client/orm/migration" "github.com/beego/beego/v2/client/orm/migration"
_ "{{DriverRepo}}" _ "{{DriverRepo}}"
) )

View File

@ -70,7 +70,7 @@ var maingo = `package main
import ( import (
_ "{{.Appname}}/routers" _ "{{.Appname}}/routers"
beego "github.com/beego/beego/server/web" beego "github.com/beego/beego/v2/server/web"
) )
func main() { func main() {
@ -82,7 +82,7 @@ var router = `package routers
import ( import (
"{{.Appname}}/controllers" "{{.Appname}}/controllers"
beego "github.com/beego/beego/server/web" beego "github.com/beego/beego/v2/server/web"
) )
func init() { func init() {
@ -93,7 +93,7 @@ var goMod = `module %s
go %s go %s
require github.com/beego/beego %s require github.com/beego/beego/v2 %s
require github.com/smartystreets/goconvey v1.6.4 require github.com/smartystreets/goconvey v1.6.4
` `
var test = `package test var test = `package test
@ -106,7 +106,7 @@ import (
"path/filepath" "path/filepath"
_ "{{.Appname}}/routers" _ "{{.Appname}}/routers"
beego "github.com/beego/beego/server/web" beego "github.com/beego/beego/v2/server/web"
. "github.com/smartystreets/goconvey/convey" . "github.com/smartystreets/goconvey/convey"
) )
@ -140,7 +140,7 @@ func TestBeego(t *testing.T) {
var controllers = `package controllers var controllers = `package controllers
import ( import (
beego "github.com/beego/beego/server/web" beego "github.com/beego/beego/v2/server/web"
) )
type MainController struct { type MainController struct {

View File

@ -161,7 +161,7 @@ func GetBeegoVersion() string {
} }
} }
return "Beego is not installed. Please do consider installing it first: https://github.com/beego/beego. " + return "Beego is not installed. Please do consider installing it first: https://github.com/beego/beego/v2. " +
"If you are using go mod, and you don't install the beego under $GOPATH/src/github.com/astaxie, just ignore this." "If you are using go mod, and you don't install the beego under $GOPATH/src/github.com/astaxie, just ignore this."
} }

View File

@ -1023,7 +1023,7 @@ import (
"reflect" "reflect"
"strings" "strings"
{{timePkg}} {{timePkg}}
"github.com/beego/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
{{modelStruct}} {{modelStruct}}
@ -1172,7 +1172,7 @@ import (
"strconv" "strconv"
"strings" "strings"
beego "github.com/beego/beego/server/web" beego "github.com/beego/beego/v2/server/web"
) )
// {{ctrlName}}Controller operations for {{ctrlName}} // {{ctrlName}}Controller operations for {{ctrlName}}
@ -1347,7 +1347,7 @@ package routers
import ( import (
"{{pkgPath}}/controllers" "{{pkgPath}}/controllers"
beego "github.com/beego/beego/server/web" beego "github.com/beego/beego/v2/server/web"
) )
func init() { func init() {

View File

@ -78,7 +78,7 @@ func GenerateController(cname, currpath string) {
var controllerTpl = `package {{packageName}} var controllerTpl = `package {{packageName}}
import ( import (
beego "github.com/beego/beego/server/web" beego "github.com/beego/beego/v2/server/web"
) )
// {{controllerName}}Controller operations for {{controllerName}} // {{controllerName}}Controller operations for {{controllerName}}
@ -166,7 +166,7 @@ import (
"strconv" "strconv"
"strings" "strings"
beego "github.com/beego/beego/server/web" beego "github.com/beego/beego/v2/server/web"
) )
// {{controllerName}}Controller operations for {{controllerName}} // {{controllerName}}Controller operations for {{controllerName}}

View File

@ -47,7 +47,7 @@ import (
"{{.Appname}}/models" "{{.Appname}}/models"
"github.com/hprose/hprose-golang/rpc" "github.com/hprose/hprose-golang/rpc"
beego "github.com/beego/beego/server/web" beego "github.com/beego/beego/v2/server/web"
) )
func logInvokeHandler( func logInvokeHandler(
@ -90,8 +90,8 @@ import (
"{{.Appname}}/models" "{{.Appname}}/models"
"github.com/hprose/hprose-golang/rpc" "github.com/hprose/hprose-golang/rpc"
beego "github.com/beego/beego/server/web" beego "github.com/beego/beego/v2/server/web"
"github.com/beego/beego/client/orm" "github.com/beego/beego/v2/client/orm"
{{.DriverPkg}} {{.DriverPkg}}
) )
@ -419,7 +419,7 @@ import (
"reflect" "reflect"
"strings" "strings"
{{timePkg}} {{timePkg}}
"github.com/beego/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
{{modelStruct}} {{modelStruct}}

View File

@ -238,7 +238,7 @@ func GenerateMigration(mname, upsql, downsql, curpath string) {
const ( const (
MigrationHeader = `package main MigrationHeader = `package main
import ( import (
"github.com/beego/beego/client/orm/migration" "github.com/beego/beego/v2/client/orm/migration"
) )
// DO NOT MODIFY // DO NOT MODIFY

View File

@ -145,7 +145,7 @@ import (
"reflect" "reflect"
"strings" "strings"
{{timePkg}} {{timePkg}}
"github.com/beego/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
{{modelStruct}} {{modelStruct}}

View File

@ -35,8 +35,8 @@ import (
yaml "gopkg.in/yaml.v2" yaml "gopkg.in/yaml.v2"
"github.com/beego/beego/server/web/swagger" "github.com/beego/beego/v2/server/web/swagger"
"github.com/beego/beego/core/utils" "github.com/beego/beego/v2/core/utils"
beeLogger "github.com/beego/bee/logger" beeLogger "github.com/beego/bee/logger"
) )
@ -429,7 +429,7 @@ func analyseControllerPkg(localName, pkgpath string) {
if isSystemPackage(pkgpath) { if isSystemPackage(pkgpath) {
return return
} }
if pkgpath == "github.com/beego/beego/server/web" { if pkgpath == "github.com/beego/beego/v2/server/web" {
return return
} }
if localName != "" { if localName != "" {

4
go.mod
View File

@ -3,7 +3,7 @@ module github.com/beego/bee
go 1.13 go 1.13
require ( require (
github.com/beego/beego v1.12.4-0.20201213162117-e2a859d1564a github.com/beego/beego/v2 v2.0.0
github.com/davecgh/go-spew v1.1.1 github.com/davecgh/go-spew v1.1.1
github.com/flosch/pongo2 v0.0.0-20200529170236-5abacdfa4915 github.com/flosch/pongo2 v0.0.0-20200529170236-5abacdfa4915
github.com/fsnotify/fsnotify v1.4.9 github.com/fsnotify/fsnotify v1.4.9
@ -17,4 +17,4 @@ require (
gopkg.in/yaml.v2 v2.3.0 gopkg.in/yaml.v2 v2.3.0
) )
//replace github.com/beego/beego => ../beego //replace github.com/beego/beego/v2 => ../beego

View File

@ -30,7 +30,7 @@ var DefaultBeegoPro = &Container{
ApiPrefix: "/api", ApiPrefix: "/api",
EnableModule: nil, EnableModule: nil,
Models: make(map[string]TextModel), Models: make(map[string]TextModel),
GitRemotePath: "https://github.com/beego/beego-pro.git", GitRemotePath: "https://github.com/beego/beego/v2-pro.git",
Branch: "master", Branch: "master",
GitLocalPath: system.BeegoHome + "/beego-pro", GitLocalPath: system.BeegoHome + "/beego-pro",
EnableFormat: true, EnableFormat: true,

View File

@ -88,7 +88,7 @@ func IsInGOPATH(thePath string) bool {
// IsBeegoProject checks whether the current path is a Beego application or not // IsBeegoProject checks whether the current path is a Beego application or not
func IsBeegoProject(thePath string) bool { func IsBeegoProject(thePath string) bool {
mainFiles := []string{} mainFiles := []string{}
hasBeegoRegex := regexp.MustCompile(`(?s)package main.*?import.*?\(.*?github.com/beego/beego".*?\).*func main()`) hasBeegoRegex := regexp.MustCompile(`(?s)package main.*?import.*?\(.*?github.com/beego/beego/v2".*?\).*func main()`)
c := make(chan error) c := make(chan error)
// Walk the application path tree to look for main files. // Walk the application path tree to look for main files.
// Main files must satisfy the 'hasBeegoRegex' regular expression. // Main files must satisfy the 'hasBeegoRegex' regular expression.

View File

@ -14,4 +14,4 @@
package utils package utils
const BEEGO_VERSION = "v1.12.4-0.20201213162117-e2a859d1564a" const BEEGO_VERSION = "v2.0.0"