format code

This commit is contained in:
Deng Ming 2022-12-23 10:25:06 +08:00 committed by Ming Deng
parent ef55bd0fac
commit 0bee140abb
64 changed files with 35 additions and 109 deletions

View File

@ -9,4 +9,4 @@ name = "go"
enabled = true enabled = true
[analyzers.meta] [analyzers.meta]
import_paths = ["github.com/beego/beego"] import_paths = ["github.com/beego/beego/v2"]

View File

@ -38,6 +38,6 @@ linters:
linters-settings: linters-settings:
gci: gci:
local-prefixes: github.com/beego/beego local-prefixes: github.com/beego
goimports: goimports:
local-prefixes: github.com/beego/beego local-prefixes: github.com/beego

View File

@ -89,5 +89,3 @@ Also when filing an issue, make sure to answer these five questions:
Please take a moment to check that an issue doesn't already exist documenting your bug report or improvement proposal. Please take a moment to check that an issue doesn't already exist documenting your bug report or improvement proposal.
If it does, it never hurts to add a quick "+1" or "I have this problem too". This will help prioritize the most common If it does, it never hurts to add a quick "+1" or "I have this problem too". This will help prioritize the most common
problems and requests. problems and requests.
Also, if you don't know how to use it. please make sure you have read through the docs in http://beego.vip/docs

View File

@ -62,3 +62,7 @@ test-orm-tidb: ## Run ORM unit tests on tidb.
.PHONY: test-orm-all .PHONY: test-orm-all
test-orm-all: test-orm-mysql5 test-orm-mysql8 test-orm-pgsql test-orm-tidb test-orm-all: test-orm-mysql5 test-orm-mysql8 test-orm-pgsql test-orm-tidb
.PHONY: fmt
fmt:
goimports -local "github.com/beego/beego" -w .

View File

@ -86,7 +86,6 @@ Congratulations! You've just built your first **beego** app.
## Community ## Community
* [http://beego.vip/community](http://beego.vip/community)
* Welcome to join us in Slack: [https://beego.slack.com invite](https://join.slack.com/t/beego/shared_invite/zt-fqlfjaxs-_CRmiITCSbEqQG9NeBqXKA), * Welcome to join us in Slack: [https://beego.slack.com invite](https://join.slack.com/t/beego/shared_invite/zt-fqlfjaxs-_CRmiITCSbEqQG9NeBqXKA),
* QQ Group ID:523992905 * QQ Group ID:523992905
* [Contribution Guide](https://github.com/beego/beedoc/blob/master/en-US/intro/contributing.md). * [Contribution Guide](https://github.com/beego/beedoc/blob/master/en-US/intro/contributing.md).

View File

@ -28,7 +28,6 @@
// bm.IsExist("astaxie") // bm.IsExist("astaxie")
// bm.Delete("astaxie") // bm.Delete("astaxie")
// //
// more docs http://beego.vip/docs/module/cache.md
package cache package cache
import ( import (

View File

@ -26,7 +26,6 @@
// //
// bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`) // bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`)
// //
// more docs http://beego.vip/docs/module/cache.md
package memcache package memcache
import ( import (

View File

@ -26,7 +26,6 @@
// //
// bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`) // bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`)
// //
// more docs http://beego.vip/docs/module/cache.md
package redis package redis
import ( import (

View File

@ -37,7 +37,6 @@
// cnf.DIY(key string) (interface{}, error) // cnf.DIY(key string) (interface{}, error)
// cnf.GetSection(section string) (map[string]string, error) // cnf.GetSection(section string) (map[string]string, error)
// cnf.SaveConfigFile(filename string) error // cnf.SaveConfigFile(filename string) error
// More docs http://beego.vip/docs/module/config.md
package config package config
import ( import (

View File

@ -26,7 +26,6 @@
// //
// cnf, err := config.NewConfig("xml", "config.xml") // cnf, err := config.NewConfig("xml", "config.xml")
// //
// More docs http://beego.vip/docs/module/config.md
package xml package xml
import ( import (

View File

@ -26,7 +26,6 @@
// //
// cnf, err := config.NewConfig("yaml", "config.yaml") // cnf, err := config.NewConfig("yaml", "config.yaml")
// //
// More docs http://beego.vip/docs/module/config.md
package yaml package yaml
import ( import (

View File

@ -19,7 +19,6 @@
// //
// ctx := context.Context{Request:req,ResponseWriter:rw} // ctx := context.Context{Request:req,ResponseWriter:rw}
// //
// more docs http://beego.vip/docs/module/context.md
package context package context
import ( import (

View File

@ -28,7 +28,6 @@
// } // }
// fmt.Println(str) // fmt.Println(str)
// //
// more docs http://beego.vip/docs/module/httplib.md
package httplib package httplib
import ( import (

View File

@ -30,7 +30,6 @@
// log.Debug("debug") // log.Debug("debug")
// log.Critical("critical") // log.Critical("critical")
// //
// more docs http://beego.vip/docs/module/logs.md
package logs package logs
import ( import (

View File

@ -15,8 +15,6 @@
package logs package logs
import ( import (
"time"
"github.com/beego/beego/v2/core/logs" "github.com/beego/beego/v2/core/logs"
) )
@ -40,30 +38,6 @@ func (o *oldToNewAdapter) Flush() {
o.old.Flush() o.old.Flush()
} }
func (o *oldToNewAdapter) SetFormatter(f logs.LogFormatter) { func (*oldToNewAdapter) SetFormatter(f logs.LogFormatter) {
panic("unsupported operation, you should not invoke this method") panic("unsupported operation, you should not invoke this method")
} }
type newToOldAdapter struct {
n logs.Logger
}
func (n *newToOldAdapter) Init(config string) error {
return n.n.Init(config)
}
func (n *newToOldAdapter) WriteMsg(when time.Time, msg string, level int) error {
return n.n.WriteMsg(&logs.LogMsg{
When: when,
Msg: msg,
Level: level,
})
}
func (n *newToOldAdapter) Destroy() {
panic("implement me")
}
func (n *newToOldAdapter) Flush() {
panic("implement me")
}

View File

@ -51,7 +51,6 @@
// num, err = o.Delete(&u) // num, err = o.Delete(&u)
// } // }
// //
// more docs: http://beego.vip/docs/mvc/model/overview.md
package orm package orm
import ( import (

View File

@ -29,7 +29,6 @@
// go globalSessions.GC() // go globalSessions.GC()
// } // }
// //
// more docs: http://beego.vip/docs/module/session.md
package couchbase package couchbase
import ( import (

View File

@ -29,7 +29,6 @@
// go globalSessions.GC() // go globalSessions.GC()
// } // }
// //
// more docs: http://beego.vip/docs/module/session.md
package memcache package memcache
import ( import (

View File

@ -37,14 +37,12 @@
// go globalSessions.GC() // go globalSessions.GC()
// } // }
// //
// more docs: http://beego.vip/docs/module/session.md
package mysql package mysql
import ( import (
"context" "context"
"net/http" "net/http"
// import mysql driver
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
"github.com/beego/beego/v2/adapter/session" "github.com/beego/beego/v2/adapter/session"

View File

@ -47,14 +47,12 @@
// go globalSessions.GC() // go globalSessions.GC()
// } // }
// //
// more docs: http://beego.vip/docs/module/session.md
package postgres package postgres
import ( import (
"context" "context"
"net/http" "net/http"
// import postgresql Driver
_ "github.com/lib/pq" _ "github.com/lib/pq"
"github.com/beego/beego/v2/adapter/session" "github.com/beego/beego/v2/adapter/session"

View File

@ -29,7 +29,6 @@
// go globalSessions.GC() // go globalSessions.GC()
// } // }
// //
// more docs: http://beego.vip/docs/module/session.md
package redis package redis
import ( import (

View File

@ -29,7 +29,6 @@
// go globalSessions.GC() // go globalSessions.GC()
// } // }
// //
// more docs: http://beego.vip/docs/module/session.md
package redis_cluster package redis_cluster
import ( import (

View File

@ -24,7 +24,6 @@
// go globalSessions.GC() // go globalSessions.GC()
// } // }
// //
// more docs: http://beego.vip/docs/module/session.md
package session package session
import ( import (

View File

@ -106,7 +106,6 @@ func Htmlunquote(text string) string {
// /login?next=/ // /login?next=/
// /user/John%20Doe // /user/John%20Doe
// //
// more detail http://beego.vip/docs/mvc/controller/urlbuilding.md
func URLFor(endpoint string, values ...interface{}) string { func URLFor(endpoint string, values ...interface{}) string {
return web.URLFor(endpoint, values...) return web.URLFor(endpoint, values...)
} }

View File

@ -27,7 +27,6 @@
// //
// AddHealthCheck("database",&DatabaseCheck{}) // AddHealthCheck("database",&DatabaseCheck{})
// //
// more docs: http://beego.vip/docs/module/toolbox.md
package toolbox package toolbox
import ( import (

View File

@ -237,6 +237,7 @@ func (ms *MapSorter) Sort() {
} }
func (ms *MapSorter) Len() int { return len(ms.Keys) } func (ms *MapSorter) Len() int { return len(ms.Keys) }
func (ms *MapSorter) Less(i, j int) bool { func (ms *MapSorter) Less(i, j int) bool {
if ms.Vals[i].GetNext(context.Background()).IsZero() { if ms.Vals[i].GetNext(context.Background()).IsZero() {
return false return false

View File

@ -50,9 +50,5 @@ In your view templates:
</ul> </ul>
{{end}} {{end}}
See also
http://beego.vip/docs/mvc/view/page.md
*/ */
package pagination package pagination

View File

@ -43,7 +43,6 @@
// } // }
// } // }
// //
// more info: http://beego.vip/docs/mvc/controller/validation.md
package validation package validation
import ( import (

View File

@ -28,7 +28,6 @@
// bm.IsExist("astaxie") // bm.IsExist("astaxie")
// bm.Delete("astaxie") // bm.Delete("astaxie")
// //
// more docs http://beego.vip/docs/module/cache.md
package cache package cache
import ( import (

View File

@ -26,7 +26,6 @@
// //
// bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`) // bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`)
// //
// more docs http://beego.vip/docs/module/cache.md
package memcache package memcache
import ( import (

View File

@ -24,12 +24,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/beego/beego/v2/core/berror"
_ "github.com/bradfitz/gomemcache/memcache" _ "github.com/bradfitz/gomemcache/memcache"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/beego/beego/v2/client/cache" "github.com/beego/beego/v2/client/cache"
"github.com/beego/beego/v2/core/berror"
) )
func TestMemcacheCache(t *testing.T) { func TestMemcacheCache(t *testing.T) {

View File

@ -20,8 +20,9 @@ import (
"testing" "testing"
"time" "time"
"github.com/beego/beego/v2/core/berror"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/beego/beego/v2/core/berror"
) )
func TestReadThroughCache_Memory_Get(t *testing.T) { func TestReadThroughCache_Memory_Get(t *testing.T) {

View File

@ -26,7 +26,6 @@
// //
// bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`) // bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`)
// //
// more docs http://beego.vip/docs/module/cache.md
package redis package redis
import ( import (

View File

@ -22,12 +22,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/beego/beego/v2/core/berror"
"github.com/gomodule/redigo/redis" "github.com/gomodule/redigo/redis"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/beego/beego/v2/client/cache" "github.com/beego/beego/v2/client/cache"
"github.com/beego/beego/v2/core/berror"
) )
func TestRedisCache(t *testing.T) { func TestRedisCache(t *testing.T) {

View File

@ -18,8 +18,9 @@ import (
"context" "context"
"time" "time"
"github.com/beego/beego/v2/core/berror"
"golang.org/x/sync/singleflight" "golang.org/x/sync/singleflight"
"github.com/beego/beego/v2/core/berror"
) )
// SingleflightCache // SingleflightCache

View File

@ -10,11 +10,10 @@ import (
"testing" "testing"
"time" "time"
"github.com/beego/beego/v2/core/berror"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/beego/beego/v2/client/cache" "github.com/beego/beego/v2/client/cache"
"github.com/beego/beego/v2/core/berror"
) )
func TestSsdbcacheCache(t *testing.T) { func TestSsdbcacheCache(t *testing.T) {

View File

@ -22,8 +22,9 @@ import (
"testing" "testing"
"time" "time"
"github.com/beego/beego/v2/core/berror"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/beego/beego/v2/core/berror"
) )
func TestWriteThoughCache_Set(t *testing.T) { func TestWriteThoughCache_Set(t *testing.T) {

View File

@ -28,7 +28,6 @@
// } // }
// fmt.Println(str) // fmt.Println(str)
// //
// more docs http://beego.vip/docs/module/httplib.md
package httplib package httplib
import ( import (

View File

@ -19,7 +19,6 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/stretchr/testify/require"
"io/ioutil" "io/ioutil"
"net" "net"
"net/http" "net/http"
@ -29,6 +28,7 @@ import (
"time" "time"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
) )
func TestResponse(t *testing.T) { func TestResponse(t *testing.T) {

View File

@ -151,9 +151,3 @@ like this:
note: not recommend use this in product env. note: not recommend use this in product env.
## Docs
more details and examples in docs and test
[documents](http://beego.vip/docs/mvc/model/overview.md)

View File

@ -51,7 +51,6 @@
// num, err = o.Delete(&u) // num, err = o.Delete(&u)
// } // }
// //
// more docs: http://beego.vip/docs/mvc/model/overview.md
package orm package orm
import ( import (

View File

@ -27,7 +27,6 @@
// //
// AddHealthCheck("database",&DatabaseCheck{}) // AddHealthCheck("database",&DatabaseCheck{})
// //
// more docs: http://beego.vip/docs/module/toolbox.md
package admin package admin
// AdminCheckList holds health checker map // AdminCheckList holds health checker map

View File

@ -37,7 +37,6 @@
// cnf.DIY(key string) (interface{}, error) // cnf.DIY(key string) (interface{}, error)
// cnf.GetSection(section string) (map[string]string, error) // cnf.GetSection(section string) (map[string]string, error)
// cnf.SaveConfigFile(filename string) error // cnf.SaveConfigFile(filename string) error
// More docs http://beego.vip/docs/module/config.md
package config package config
import ( import (

View File

@ -19,8 +19,9 @@ import (
"os" "os"
"strings" "strings"
"github.com/beego/beego/v2/core/config"
"github.com/pelletier/go-toml" "github.com/pelletier/go-toml"
"github.com/beego/beego/v2/core/config"
) )
const keySeparator = "." const keySeparator = "."

View File

@ -26,7 +26,6 @@
// //
// cnf, err := config.NewConfig("xml", "config.xml") // cnf, err := config.NewConfig("xml", "config.xml")
// //
// More docs http://beego.vip/docs/module/config.md
package xml package xml
import ( import (
@ -39,11 +38,11 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/beego/x2j"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
"github.com/beego/beego/v2/core/config" "github.com/beego/beego/v2/core/config"
"github.com/beego/beego/v2/core/logs" "github.com/beego/beego/v2/core/logs"
"github.com/beego/x2j"
) )
// Config is a xml config parser and implements Config interface. // Config is a xml config parser and implements Config interface.

View File

@ -21,7 +21,6 @@
// //
// cnf, err := config.NewConfig("yaml", "config.yaml") // cnf, err := config.NewConfig("yaml", "config.yaml")
// //
// More docs http://beego.vip/docs/module/config.md
package yaml package yaml
import ( import (

View File

@ -11,7 +11,9 @@ import (
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal var _ = proto.Marshal
var _ = fmt.Errorf var _ = fmt.Errorf
var _ = math.Inf var _ = math.Inf
var ( var (
@ -339,6 +341,7 @@ func encodeFixed64Log(data []byte, offset int, v uint64) int {
data[offset+7] = uint8(v >> 56) data[offset+7] = uint8(v >> 56)
return offset + 8 return offset + 8
} }
func encodeFixed32Log(data []byte, offset int, v uint32) int { func encodeFixed32Log(data []byte, offset int, v uint32) int {
data[offset] = uint8(v) data[offset] = uint8(v)
data[offset+1] = uint8(v >> 8) data[offset+1] = uint8(v >> 8)
@ -346,6 +349,7 @@ func encodeFixed32Log(data []byte, offset int, v uint32) int {
data[offset+3] = uint8(v >> 24) data[offset+3] = uint8(v >> 24)
return offset + 4 return offset + 4
} }
func encodeVarintLog(data []byte, offset int, v uint64) int { func encodeVarintLog(data []byte, offset int, v uint64) int {
for v >= 1<<7 { for v >= 1<<7 {
data[offset] = uint8(v&0x7f | 0x80) data[offset] = uint8(v&0x7f | 0x80)
@ -447,6 +451,7 @@ func sovLog(x uint64) (n int) {
} }
return n return n
} }
func sozLog(x uint64) (n int) { func sozLog(x uint64) (n int) {
return sovLog((x << 1) ^ (x >> 63)) return sovLog((x << 1) ^ (x >> 63))
} }

View File

@ -30,7 +30,6 @@
// log.Debug("debug") // log.Debug("debug")
// log.Critical("critical") // log.Critical("critical")
// //
// more docs http://beego.vip/docs/module/logs.md
package logs package logs
import ( import (

View File

@ -50,9 +50,5 @@ In your view templates:
</ul> </ul>
{{end}} {{end}}
See also
http://beego.vip/docs/mvc/view/page.md
*/ */
package pagination package pagination

View File

@ -43,7 +43,6 @@
// } // }
// } // }
// //
// more info: http://beego.vip/docs/mvc/controller/validation.md
package validation package validation
import ( import (

View File

@ -19,7 +19,6 @@
// //
// ctx := context.Context{Request:req,ResponseWriter:rw} // ctx := context.Context{Request:req,ResponseWriter:rw}
// //
// more docs http://beego.vip/docs/module/context.md
package context package context
import ( import (

View File

@ -97,7 +97,9 @@ type ControllerComments struct {
type ControllerCommentsSlice []ControllerComments type ControllerCommentsSlice []ControllerComments
func (p ControllerCommentsSlice) Len() int { return len(p) } func (p ControllerCommentsSlice) Len() int { return len(p) }
func (p ControllerCommentsSlice) Less(i, j int) bool { return p[i].Router < p[j].Router } func (p ControllerCommentsSlice) Less(i, j int) bool { return p[i].Router < p[j].Router }
func (p ControllerCommentsSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } func (p ControllerCommentsSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
// Controller defines some basic http request handler operations, such as // Controller defines some basic http request handler operations, such as

View File

@ -12,6 +12,5 @@ beego is inspired by Tornado, Sinatra and Flask with the added benefit of some G
beego.Run() beego.Run()
} }
more information: http://beego.vip
*/ */
package web package web

View File

@ -29,7 +29,6 @@
// go globalSessions.GC() // go globalSessions.GC()
// } // }
// //
// more docs: http://beego.vip/docs/module/session.md
package couchbase package couchbase
import ( import (

View File

@ -29,7 +29,6 @@
// go globalSessions.GC() // go globalSessions.GC()
// } // }
// //
// more docs: http://beego.vip/docs/module/session.md
package memcache package memcache
import ( import (

View File

@ -37,7 +37,6 @@
// go globalSessions.GC() // go globalSessions.GC()
// } // }
// //
// more docs: http://beego.vip/docs/module/session.md
package mysql package mysql
import ( import (
@ -47,7 +46,6 @@ import (
"sync" "sync"
"time" "time"
// import mysql driver
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
"github.com/beego/beego/v2/server/web/session" "github.com/beego/beego/v2/server/web/session"

View File

@ -47,7 +47,6 @@
// go globalSessions.GC() // go globalSessions.GC()
// } // }
// //
// more docs: http://beego.vip/docs/module/session.md
package postgres package postgres
import ( import (
@ -57,7 +56,6 @@ import (
"sync" "sync"
"time" "time"
// import postgresql Driver
_ "github.com/lib/pq" _ "github.com/lib/pq"
"github.com/beego/beego/v2/server/web/session" "github.com/beego/beego/v2/server/web/session"

View File

@ -29,7 +29,6 @@
// go globalSessions.GC() // go globalSessions.GC()
// } // }
// //
// more docs: http://beego.vip/docs/module/session.md
package redis package redis
import ( import (

View File

@ -29,7 +29,6 @@
// go globalSessions.GC() // go globalSessions.GC()
// } // }
// //
// more docs: http://beego.vip/docs/module/session.md
package redis_cluster package redis_cluster
import ( import (

View File

@ -24,7 +24,6 @@
// go globalSessions.GC() // go globalSessions.GC()
// } // }
// //
// more docs: http://beego.vip/docs/module/session.md
package session package session
import ( import (

View File

@ -242,7 +242,6 @@ func Htmlunquote(text string) string {
// /login?next=/ // /login?next=/
// /user/John%20Doe // /user/John%20Doe
// //
// more detail http://beego.vip/docs/mvc/controller/urlbuilding.md
func URLFor(endpoint string, values ...interface{}) string { func URLFor(endpoint string, values ...interface{}) string {
return BeeApp.Handlers.URLFor(endpoint, values...) return BeeApp.Handlers.URLFor(endpoint, values...)
} }

View File

@ -697,6 +697,7 @@ func (ms *MapSorter) Sort() {
} }
func (ms *MapSorter) Len() int { return len(ms.Keys) } func (ms *MapSorter) Len() int { return len(ms.Keys) }
func (ms *MapSorter) Less(i, j int) bool { func (ms *MapSorter) Less(i, j int) bool {
if ms.Vals[i].GetNext(context.Background()).IsZero() { if ms.Vals[i].GetNext(context.Background()).IsZero() {
return false return false