mirror of
https://github.com/beego/bee.git
synced 2024-11-26 06:21:34 +00:00
Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
1b71193c49
@ -10,10 +10,13 @@ install:
|
|||||||
- go get -u honnef.co/go/tools/cmd/staticcheck
|
- go get -u honnef.co/go/tools/cmd/staticcheck
|
||||||
- go get -u honnef.co/go/tools/cmd/unused
|
- go get -u honnef.co/go/tools/cmd/unused
|
||||||
- go get -u github.com/mdempsky/unconvert
|
- go get -u github.com/mdempsky/unconvert
|
||||||
|
- go get -u github.com/gordonklaus/ineffassign
|
||||||
script:
|
script:
|
||||||
|
- find . ! \( -path './vendor' -prune \) -type f -name '*.go' -print0 | xargs -0 gofmt -l -s
|
||||||
- go vet $(go list ./... | grep -v /vendor/)
|
- go vet $(go list ./... | grep -v /vendor/)
|
||||||
- structcheck $(go list ./... | grep -v /vendor/)
|
- structcheck $(go list ./... | grep -v /vendor/)
|
||||||
- gosimple -ignore "$(cat gosimple.ignore)" $(go list ./... | grep -v /vendor/)
|
- gosimple -ignore "$(cat gosimple.ignore)" $(go list ./... | grep -v /vendor/)
|
||||||
- staticcheck $(go list ./... | grep -v /vendor/)
|
- staticcheck $(go list ./... | grep -v /vendor/)
|
||||||
- unused $(go list ./... | grep -v /vendor/)
|
- unused $(go list ./... | grep -v /vendor/)
|
||||||
- unconvert $(go list ./... | grep -v /vendor/)
|
- unconvert $(go list ./... | grep -v /vendor/)
|
||||||
|
- ineffassign .
|
||||||
|
9
Makefile
9
Makefile
@ -1,3 +1,5 @@
|
|||||||
|
VERSION = $(shell grep 'const version' cmd/commands/version/version.go | sed -E 's/.*"(.+)"$$/v\1/')
|
||||||
|
|
||||||
.PHONY: all test clean build install
|
.PHONY: all test clean build install
|
||||||
|
|
||||||
GOFLAGS ?= $(GOFLAGS:)
|
GOFLAGS ?= $(GOFLAGS:)
|
||||||
@ -18,3 +20,10 @@ bench: install
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
go clean $(GOFLAGS) -i ./...
|
go clean $(GOFLAGS) -i ./...
|
||||||
|
|
||||||
|
publish:
|
||||||
|
mkdir -p bin/$(VERSION)
|
||||||
|
cd bin/$(VERSION)
|
||||||
|
xgo -v -x --targets="windows/*,darwin/*,linux/386,linux/amd64,linux/arm-5,linux/arm64" -out bee_$(VERSION) github.com/beego/bee
|
||||||
|
cd ..
|
||||||
|
ghr -u beego -r bee $(VERSION) $(VERSION)
|
@ -417,7 +417,7 @@ func packDirectory(output io.Writer, excludePrefix []string, excludeSuffix []str
|
|||||||
func packApp(cmd *commands.Command, args []string) int {
|
func packApp(cmd *commands.Command, args []string) int {
|
||||||
output := cmd.Out()
|
output := cmd.Out()
|
||||||
curPath, _ := os.Getwd()
|
curPath, _ := os.Getwd()
|
||||||
thePath := ""
|
var thePath string
|
||||||
|
|
||||||
nArgs := []string{}
|
nArgs := []string{}
|
||||||
has := false
|
has := false
|
||||||
|
@ -503,9 +503,7 @@ func (mysqlDB *MysqlDB) GetColumns(db *sql.DB, table *Table, blackList map[strin
|
|||||||
|
|
||||||
// GetGoDataType maps an SQL data type to Golang data type
|
// GetGoDataType maps an SQL data type to Golang data type
|
||||||
func (*MysqlDB) GetGoDataType(sqlType string) (string, error) {
|
func (*MysqlDB) GetGoDataType(sqlType string) (string, error) {
|
||||||
var typeMapping = map[string]string{}
|
if v, ok := typeMappingMysql[sqlType]; ok {
|
||||||
typeMapping = typeMappingMysql
|
|
||||||
if v, ok := typeMapping[sqlType]; ok {
|
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
return "", fmt.Errorf("data type '%s' not found", sqlType)
|
return "", fmt.Errorf("data type '%s' not found", sqlType)
|
||||||
@ -766,7 +764,7 @@ func writeModelFiles(tables []*Table, mPath string, selectedTables map[string]bo
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template := ""
|
var template string
|
||||||
if tb.Pk == "" {
|
if tb.Pk == "" {
|
||||||
template = StructModelTPL
|
template = StructModelTPL
|
||||||
} else {
|
} else {
|
||||||
|
@ -369,7 +369,7 @@ func writeHproseModelFiles(tables []*Table, mPath string, selectedTables map[str
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template := ""
|
var template string
|
||||||
if tb.Pk == "" {
|
if tb.Pk == "" {
|
||||||
template = HproseStructModelTPL
|
template = HproseStructModelTPL
|
||||||
} else {
|
} else {
|
||||||
|
@ -216,7 +216,7 @@ func GenerateDocs(curpath string) {
|
|||||||
for _, p := range params {
|
for _, p := range params {
|
||||||
switch pp := p.(type) {
|
switch pp := p.(type) {
|
||||||
case *ast.CallExpr:
|
case *ast.CallExpr:
|
||||||
controllerName := ""
|
var controllerName string
|
||||||
if selname := pp.Fun.(*ast.SelectorExpr).Sel.String(); selname == "NSNamespace" {
|
if selname := pp.Fun.(*ast.SelectorExpr).Sel.String(); selname == "NSNamespace" {
|
||||||
s, params := analyseNewNamespace(pp)
|
s, params := analyseNewNamespace(pp)
|
||||||
for _, sp := range params {
|
for _, sp := range params {
|
||||||
@ -298,12 +298,10 @@ func analyseNSInclude(baseurl string, ce *ast.CallExpr) string {
|
|||||||
}
|
}
|
||||||
if apis, ok := controllerList[cname]; ok {
|
if apis, ok := controllerList[cname]; ok {
|
||||||
for rt, item := range apis {
|
for rt, item := range apis {
|
||||||
tag := ""
|
tag := cname
|
||||||
if baseurl != "" {
|
if baseurl != "" {
|
||||||
rt = baseurl + rt
|
rt = baseurl + rt
|
||||||
tag = strings.Trim(baseurl, "/")
|
tag = strings.Trim(baseurl, "/")
|
||||||
} else {
|
|
||||||
tag = cname
|
|
||||||
}
|
}
|
||||||
if item.Get != nil {
|
if item.Get != nil {
|
||||||
item.Get.Tags = []string{tag}
|
item.Get.Tags = []string{tag}
|
||||||
@ -749,7 +747,6 @@ func parseObject(d *ast.Object, k string, m *swagger.Schema, realTypes *[]string
|
|||||||
if st.Fields.List != nil {
|
if st.Fields.List != nil {
|
||||||
m.Properties = make(map[string]swagger.Propertie)
|
m.Properties = make(map[string]swagger.Propertie)
|
||||||
for _, field := range st.Fields.List {
|
for _, field := range st.Fields.List {
|
||||||
realType := ""
|
|
||||||
isSlice, realType, sType := typeAnalyser(field)
|
isSlice, realType, sType := typeAnalyser(field)
|
||||||
if (isSlice && isBasicType(realType)) || sType == "object" {
|
if (isSlice && isBasicType(realType)) || sType == "object" {
|
||||||
if len(strings.Split(realType, " ")) > 1 {
|
if len(strings.Split(realType, " ")) > 1 {
|
||||||
@ -765,7 +762,7 @@ func parseObject(d *ast.Object, k string, m *swagger.Schema, realTypes *[]string
|
|||||||
mp := swagger.Propertie{}
|
mp := swagger.Propertie{}
|
||||||
if isSlice {
|
if isSlice {
|
||||||
mp.Type = "array"
|
mp.Type = "array"
|
||||||
if isBasicType(realType) {
|
if isBasicType(strings.Replace(realType, "[]", "", -1)) {
|
||||||
typeFormat := strings.Split(sType, ":")
|
typeFormat := strings.Split(sType, ":")
|
||||||
mp.Items = &swagger.Propertie{
|
mp.Items = &swagger.Propertie{
|
||||||
Type: typeFormat[0],
|
Type: typeFormat[0],
|
||||||
@ -868,7 +865,7 @@ func parseObject(d *ast.Object, k string, m *swagger.Schema, realTypes *[]string
|
|||||||
func typeAnalyser(f *ast.Field) (isSlice bool, realType, swaggerType string) {
|
func typeAnalyser(f *ast.Field) (isSlice bool, realType, swaggerType string) {
|
||||||
if arr, ok := f.Type.(*ast.ArrayType); ok {
|
if arr, ok := f.Type.(*ast.ArrayType); ok {
|
||||||
if isBasicType(fmt.Sprint(arr.Elt)) {
|
if isBasicType(fmt.Sprint(arr.Elt)) {
|
||||||
return false, fmt.Sprintf("[]%v", arr.Elt), basicTypes[fmt.Sprint(arr.Elt)]
|
return true, fmt.Sprintf("[]%v", arr.Elt), basicTypes[fmt.Sprint(arr.Elt)]
|
||||||
}
|
}
|
||||||
if mp, ok := arr.Elt.(*ast.MapType); ok {
|
if mp, ok := arr.Elt.(*ast.MapType); ok {
|
||||||
return false, fmt.Sprintf("map[%v][%v]", mp.Key, mp.Value), "object"
|
return false, fmt.Sprintf("map[%v][%v]", mp.Key, mp.Value), "object"
|
||||||
|
@ -360,7 +360,7 @@ func isParameterChar(b byte) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cw *colorWriter) Write(p []byte) (int, error) {
|
func (cw *colorWriter) Write(p []byte) (int, error) {
|
||||||
r, nw, first, last := 0, 0, 0, 0
|
var r, nw, first, last int
|
||||||
if cw.mode != DiscardNonColorEscSeq {
|
if cw.mode != DiscardNonColorEscSeq {
|
||||||
cw.state = outsideCsiCode
|
cw.state = outsideCsiCode
|
||||||
cw.resetBuffer()
|
cw.resetBuffer()
|
||||||
|
Loading…
Reference in New Issue
Block a user