chore(style): fmt code (#534)

This commit is contained in:
q1anx1 2022-08-09 20:10:21 +08:00 committed by GitHub
parent 69d6098eb2
commit a6c327cfdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 157 additions and 144 deletions

View File

@ -22,8 +22,10 @@ import (
"xorm.io/xorm"
)
var adapter *Adapter = nil
var CasdoorOrganization string
var (
adapter *Adapter = nil
CasdoorOrganization string
)
type Session struct {
SessionKey string `xorm:"char(64) notnull pk"`

View File

@ -59,7 +59,6 @@ func (c *ApiController) UpdateFrontConfById() {
err := json.Unmarshal(c.Ctx.Input.RequestBody, &value)
tags := service.Finalword(value)
affect, err := object.UpdateFrontConfById(id, value, tags)
if err != nil {
c.ResponseError(err.Error())
}

View File

@ -58,7 +58,6 @@ func (c *ApiController) GetNode() {
c.ServeJSON()
}
// @Title UpdateNode
// @router /update-node [post]
// @Tag Node API

View File

@ -545,7 +545,6 @@ func (c *ApiController) GetHotTopic() {
res := object.GetHotTopic(limit)
c.ResponseOk(res)
}
// @Title GetSortedTopics

View File

@ -21,8 +21,10 @@ import (
var randomAvatarCount = 244
var randomAvatarMap map[string][]byte
var randomAvatarMapMutex sync.RWMutex
var (
randomAvatarMap map[string][]byte
randomAvatarMapMutex sync.RWMutex
)
func initRandomAvatars() {
randomAvatarMap = map[string][]byte{}

View File

@ -19,8 +19,10 @@ import (
"github.com/casbin/casnode/object"
)
var CasdoorOrganization = ""
var CasdoorApplication = ""
var (
CasdoorOrganization = ""
CasdoorApplication = ""
)
func init() {
object.InitConfig()

View File

@ -14,8 +14,10 @@
package discuzx
var dbName = "ultrax"
var discuzxDomain = "https://www.discuz.net/"
var discuzxAttachmentBaseUrl = "https://attachment.discuz.net/forum/"
var (
dbName = "ultrax"
discuzxDomain = "https://www.discuz.net/"
discuzxAttachmentBaseUrl = "https://attachment.discuz.net/forum/"
)
var avatarPoolBaseUrl = "https://cdn.casbin.com/avatar-pool/"

View File

@ -23,8 +23,10 @@ import (
"github.com/casbin/casnode/object"
)
var AddThreadsConcurrency = 100
var AddThreadsBatchSize = 10000
var (
AddThreadsConcurrency = 100
AddThreadsBatchSize = 10000
)
func addThreads(threads []*Thread, threadPostsMap map[int][]*Post, attachmentMap map[int][]*Attachment, forumMap map[int]*Forum, classMap map[int]*Class) {
arrayMutex := sync.RWMutex{}

View File

@ -25,14 +25,16 @@ import (
"time"
)
var reBold *regexp.Regexp
var reAlign *regexp.Regexp
var reFont *regexp.Regexp
var reUrl *regexp.Regexp
var reSize *regexp.Regexp
var reSize2 *regexp.Regexp
var reSize3 *regexp.Regexp
var reVideo *regexp.Regexp
var (
reBold *regexp.Regexp
reAlign *regexp.Regexp
reFont *regexp.Regexp
reUrl *regexp.Regexp
reSize *regexp.Regexp
reSize2 *regexp.Regexp
reSize3 *regexp.Regexp
reVideo *regexp.Regexp
)
func init() {
reBold, _ = regexp.Compile("\\[b](.*?)\\[/b]")

View File

@ -23,9 +23,11 @@ import (
"xorm.io/xorm"
)
var adapter *Adapter
var CasdoorOrganization string
var CasdoorApplication string
var (
adapter *Adapter
CasdoorOrganization string
CasdoorApplication string
)
type Session struct {
SessionKey string `xorm:"char(64) notnull pk"`

View File

@ -30,8 +30,10 @@ type BasicInfo struct {
Value string `xorm:"mediumtext"`
}
var fileDate, version string
var onlineMemberNum, highestOnlineNum int
var (
fileDate, version string
onlineMemberNum, highestOnlineNum int
)
func InitForumBasicInfo() {
GetForumVersion()

View File

@ -21,8 +21,7 @@ type FrontConf struct {
Tags []string `xorm:"varchar(200)" json:"tags"`
}
var (
Confs = []*FrontConf{
var Confs = []*FrontConf{
{Id: "forumName", Value: "Casnode", Field: "visualConf", Tags: nil},
{Id: "logoImage", Value: "https://cdn.casbin.com/forum/static/img/logo.png", Field: "visualConf", Tags: nil},
{Id: "footerLogoImage", Value: "https://cdn.casbin.com/forum/static/img/logo-footer.png", Field: "visualConf", Tags: nil},
@ -36,7 +35,6 @@ var (
{Id: "advertise", Value: "Not yet", Field: "", Tags: nil},
{Id: "thanks", Value: "Not yet", Field: "", Tags: nil},
}
)
func InitFrontConf() {
var confs []*FrontConf

View File

@ -326,7 +326,7 @@ func createTopicWithMessages(messages []gitter.Message, room gitter.Room, node N
}
}
var mentioned = false // if @user
mentioned := false // if @user
for _, mention := range msg.Mentions {
if mention.ScreenName == lastMsg.From.Username {
mentioned = true

View File

@ -228,7 +228,7 @@ func AddReplyNotification(senderId, content string, objectId, topicId int) {
}
delete(memberMap, receiverId)
for receiverId2, _ := range memberMap {
for receiverId2 := range memberMap {
wg.Add(1)
go func(receiverId2 string) {
defer wg.Done()
@ -278,7 +278,7 @@ func AddTopicNotification(objectId int, author, content string) {
}
}
for k, _ := range memberMap {
for k := range memberMap {
wg.Add(1)
k := k
go func() {

View File

@ -16,8 +16,11 @@ import (
// var chromeCtx ctx.Context
var chromeCtxPool *SsrPool
var isChromeInstalled bool
var isChromeInit bool
var (
isChromeInstalled bool
isChromeInit bool
)
type PageCache struct {
time time.Time

View File

@ -24,8 +24,7 @@ func init() {
}
func initAPI() {
ns :=
beego.NewNamespace("/api",
ns := beego.NewNamespace("/api",
beego.NSInclude(
&controllers.ApiController{},
),

View File

@ -57,7 +57,7 @@ func Keyword(word []string) []string {
for _, v := range word {
wordnum[v] = wordnum[v] + 1
}
for s, _ := range wordnum {
for s := range wordnum {
words = append(words, s)
}
if len(wordnum) < 5 {

View File

@ -45,7 +45,7 @@ func ReadStringFromPath(path string) string {
}
func WriteStringToPath(s string, path string) {
err := ioutil.WriteFile(path, []byte(s), 0644)
err := ioutil.WriteFile(path, []byte(s), 0o644)
if err != nil {
panic(err)
}