diff --git a/casdoor/adapter.go b/casdoor/adapter.go
index 316156e8..3345c884 100644
--- a/casdoor/adapter.go
+++ b/casdoor/adapter.go
@@ -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"`
diff --git a/controllers/balance.go b/controllers/balance.go
index 60ca34d3..d228b3de 100644
--- a/controllers/balance.go
+++ b/controllers/balance.go
@@ -35,7 +35,7 @@ func (c *ApiController) AddThanks() {
user := c.GetSessionUser()
id := util.ParseInt(c.Input().Get("id"))
- thanksType := c.Input().Get("thanksType") //1 means topic, 2 means reply
+ thanksType := c.Input().Get("thanksType") // 1 means topic, 2 means reply
var author *auth.User
if thanksType == "2" {
@@ -160,7 +160,7 @@ func (c *ApiController) GetCheckinBonus() {
bonus := rand.Intn(maxBonus)
record := object.ConsumptionRecord{
- //Id: util.IntToString(object.GetConsumptionRecordId() + 1),
+ // Id: util.IntToString(object.GetConsumptionRecordId() + 1),
Amount: bonus,
Balance: object.GetMemberBalance(user) + bonus,
ReceiverId: GetUserName(user),
diff --git a/controllers/base.go b/controllers/base.go
index f1d21aa7..2dc202ee 100644
--- a/controllers/base.go
+++ b/controllers/base.go
@@ -67,7 +67,7 @@ func (c *ApiController) GetSessionUser() *auth.User {
func (c *ApiController) SetSessionUser(user *auth.User) {
if user == nil {
- //c.DelSession("user")
+ // c.DelSession("user")
return
}
diff --git a/controllers/favorites.go b/controllers/favorites.go
index 1886ebc1..232205c1 100644
--- a/controllers/favorites.go
+++ b/controllers/favorites.go
@@ -43,7 +43,7 @@ func (c *ApiController) AddFavorites() {
username := c.GetSessionUsername()
favorites := object.Favorites{
- //Id: util.IntToString(object.GetFavoritesCount()) + username,
+ // Id: util.IntToString(object.GetFavoritesCount()) + username,
FavoritesType: favoritesType,
ObjectId: objectId,
CreatedTime: util.GetCurrentTime(),
@@ -74,7 +74,7 @@ func (c *ApiController) AddFavorites() {
if favoritesType == object.FavorTopic {
topicId := util.ParseInt(objectId)
notification := object.Notification{
- //Id: util.IntToString(object.GetNotificationId()),
+ // Id: util.IntToString(object.GetNotificationId()),
NotificationType: 4,
ObjectId: topicId,
CreatedTime: util.GetCurrentTime(),
@@ -226,7 +226,7 @@ func (c *ApiController) GetAccountFavoriteNum() {
var res [6]int
var wg sync.WaitGroup
- //favorite type set,5 object.favorTopic...
+ // favorite type set,5 object.favorTopic...
typeSet := []string{object.FavorTopic, object.FollowUser, object.FavorNode, object.SubscribeTopic}
for i := 1; i <= len(typeSet); i++ {
diff --git a/controllers/file.go b/controllers/file.go
index b1e04fac..250daab2 100644
--- a/controllers/file.go
+++ b/controllers/file.go
@@ -191,7 +191,7 @@ func (c *ApiController) UpdateFileDescribe() {
}
// @Title UploadFile
-// @Tag File API
+// @Tag File API
// @router /upload-file [post]
func (c *ApiController) UploadFile() {
if c.RequireSignedIn() {
@@ -213,7 +213,7 @@ func (c *ApiController) UploadFile() {
}
// @Title ModeratorUpload
-// @Tag File API
+// @Tag File API
// @router /upload-moderator [post]
func (c *ApiController) ModeratorUpload() {
if c.RequireSignedIn() {
@@ -236,5 +236,5 @@ func (c *ApiController) ModeratorUpload() {
timeStamp := fmt.Sprintf("?time=%d", time.Now().UnixNano())
c.ResponseOk(fileUrl + timeStamp)
- //resp := Response{Status: "ok", Msg: fileName, Data: fileUrl + timeStamp}
+ // resp := Response{Status: "ok", Msg: fileName, Data: fileUrl + timeStamp}
}
diff --git a/controllers/frontConf.go b/controllers/frontConf.go
index 00a779e4..15563c28 100644
--- a/controllers/frontConf.go
+++ b/controllers/frontConf.go
@@ -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())
}
diff --git a/controllers/node.go b/controllers/node.go
index 8525bbe7..16aefb5d 100644
--- a/controllers/node.go
+++ b/controllers/node.go
@@ -58,7 +58,6 @@ func (c *ApiController) GetNode() {
c.ServeJSON()
}
-
// @Title UpdateNode
// @router /update-node [post]
// @Tag Node API
diff --git a/controllers/notifications.go b/controllers/notifications.go
index 31f3303e..f2386c83 100644
--- a/controllers/notifications.go
+++ b/controllers/notifications.go
@@ -30,7 +30,7 @@ func (c *ApiController) AddNotification() {
memberId := c.GetSessionUsername()
notification := object.Notification{
- //Id: util.IntToString(object.GetNotificationId()),
+ // Id: util.IntToString(object.GetNotificationId()),
NotificationType: tempNotification.NotificationType,
ObjectId: tempNotification.ObjectId,
CreatedTime: util.GetCurrentTime(),
diff --git a/controllers/sensitive.go b/controllers/sensitive.go
index a211202f..beaed654 100644
--- a/controllers/sensitive.go
+++ b/controllers/sensitive.go
@@ -74,4 +74,4 @@ func (c *ApiController) DelSensitive() {
func (c *ApiController) GetSensitive() {
c.Data["json"] = object.GetSensitiveWords()
c.ServeJSON()
-}
\ No newline at end of file
+}
diff --git a/controllers/tab.go b/controllers/tab.go
index b168eb14..6f7943fb 100644
--- a/controllers/tab.go
+++ b/controllers/tab.go
@@ -115,7 +115,7 @@ func (c *ApiController) UpdateTab() {
}
tab := object.Tab{
- //Id: tabInfo.Id,
+ // Id: tabInfo.Id,
Name: tabInfo.Name,
Sorter: tabInfo.Sorter,
CreatedTime: tabInfo.CreatedTime,
diff --git a/controllers/topic.go b/controllers/topic.go
index baa42899..0fb25929 100644
--- a/controllers/topic.go
+++ b/controllers/topic.go
@@ -143,7 +143,7 @@ func (c *ApiController) GetTopic() {
// @Title GetTopicAdmin
// @Description get topic for admin by id
-//@Param id query string true "id"
+// @Param id query string true "id"
// @Success 200 {object} object.AdminTopicInfo The Response object
// @router /get-topic-admin [get]
// @Tag Topic API
@@ -216,7 +216,7 @@ func (c *ApiController) AddTopic() {
}
topic := object.Topic{
- //Id: util.IntToString(object.GetTopicId()),
+ // Id: util.IntToString(object.GetTopicId()),
Author: GetUserName(user),
NodeId: node.Id,
NodeName: node.Name,
@@ -242,9 +242,9 @@ func (c *ApiController) AddTopic() {
c.ResponseError("You don't have enough balance.")
return
}
- //payRes := object.CreateTopicConsumption(c.GetSessionUser(), topic.Id)
+ // payRes := object.CreateTopicConsumption(c.GetSessionUser(), topic.Id)
- //object.AddTopicNotification(topic.Id, c.GetSessionUser(), body)
+ // object.AddTopicNotification(topic.Id, c.GetSessionUser(), body)
err = json.Unmarshal(c.Ctx.Input.RequestBody, &topic)
if err != nil {
@@ -545,7 +545,6 @@ func (c *ApiController) GetHotTopic() {
res := object.GetHotTopic(limit)
c.ResponseOk(res)
-
}
// @Title GetSortedTopics
@@ -618,7 +617,7 @@ func (c *ApiController) UpdateTopicNode() {
}
topic := object.Topic{
- //Id: id,
+ // Id: id,
NodeId: node.Id,
NodeName: node.Name,
TabId: node.TabId,
@@ -702,7 +701,7 @@ func (c *ApiController) TranslateTopic() {
topicIdStr := c.Input().Get("id")
targetLang := c.Input().Get("target")
- //ISO/IEC 15897 to ISO 639-1
+ // ISO/IEC 15897 to ISO 639-1
targetLang = targetLang[0:2]
topicId := util.ParseInt(topicIdStr)
@@ -741,10 +740,10 @@ func (c *ApiController) TopTopic() {
var res bool
nodeId := object.GetTopicNodeId(id)
if object.CheckIsAdmin(user) || object.CheckNodeModerator(user, nodeId) {
- //timeStr := c.Input().Get("time")
- //time := util.ParseInt(timeStr)
- //date := util.GetTimeMinute(time)
- //res = object.ChangeTopicTopExpiredTime(id, date)
+ // timeStr := c.Input().Get("time")
+ // time := util.ParseInt(timeStr)
+ // date := util.GetTimeMinute(time)
+ // res = object.ChangeTopicTopExpiredTime(id, date)
topType := c.Input().Get("topType")
date := util.GetTimeYear(100)
res = object.ChangeTopicTopExpiredTime(id, date, topType)
diff --git a/discuzx/avatat_cached.go b/discuzx/avatat_cached.go
index dc8d3f69..825908b9 100644
--- a/discuzx/avatat_cached.go
+++ b/discuzx/avatat_cached.go
@@ -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{}
diff --git a/discuzx/casdoor_init.go b/discuzx/casdoor_init.go
index cf9787cd..bea3ccb7 100644
--- a/discuzx/casdoor_init.go
+++ b/discuzx/casdoor_init.go
@@ -19,8 +19,10 @@ import (
"github.com/casbin/casnode/object"
)
-var CasdoorOrganization = ""
-var CasdoorApplication = ""
+var (
+ CasdoorOrganization = ""
+ CasdoorApplication = ""
+)
func init() {
object.InitConfig()
diff --git a/discuzx/conf.go b/discuzx/conf.go
index 3f654eaa..2a773ce3 100644
--- a/discuzx/conf.go
+++ b/discuzx/conf.go
@@ -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/"
diff --git a/discuzx/post.go b/discuzx/post.go
index 10f7f57b..ef0f9a0d 100644
--- a/discuzx/post.go
+++ b/discuzx/post.go
@@ -33,7 +33,7 @@ type Post struct {
func getPosts() []*Post {
posts := []*Post{}
err := adapter.Engine.Table("pre_forum_post").Find(&posts)
- //err := adapter.Engine.Table("pre_forum_post").Where("tid = ?", threadId).Find(&posts)
+ // err := adapter.Engine.Table("pre_forum_post").Where("tid = ?", threadId).Find(&posts)
if err != nil {
panic(err)
}
diff --git a/discuzx/thread.go b/discuzx/thread.go
index bafa2b49..dcf63a54 100644
--- a/discuzx/thread.go
+++ b/discuzx/thread.go
@@ -80,7 +80,7 @@ func addThread(thread *Thread, threadPostsMap map[int][]*Post, attachments []*At
thread.Posts = posts
- //deleteWholeTopic(thread)
+ // deleteWholeTopic(thread)
mutex := sync.RWMutex{}
diff --git a/discuzx/thread_other_test.go b/discuzx/thread_other_test.go
index 70ca11ef..31da6e2e 100644
--- a/discuzx/thread_other_test.go
+++ b/discuzx/thread_other_test.go
@@ -34,11 +34,11 @@ func TestGetThreads(t *testing.T) {
if thread, ok := threadMap[post.Tid]; ok {
thread.Posts = append(thread.Posts, post)
} else {
- //fmt.Printf("Failed to find thread: %d for post: %s\n", post.Tid, post.Message)
+ // fmt.Printf("Failed to find thread: %d for post: %s\n", post.Tid, post.Message)
}
}
- //thread := threadMap[126152]
+ // thread := threadMap[126152]
thread := threadMap[126239]
println(thread)
diff --git a/discuzx/thread_test.go b/discuzx/thread_test.go
index 07591cda..023477a0 100644
--- a/discuzx/thread_test.go
+++ b/discuzx/thread_test.go
@@ -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{}
diff --git a/discuzx/user.go b/discuzx/user.go
index bf161757..6c04804c 100644
--- a/discuzx/user.go
+++ b/discuzx/user.go
@@ -28,27 +28,27 @@ func getUserFromMember(memberEx *MemberEx) *auth.User {
CreatedTime: getTimeFromUnixSeconds(memberEx.Member.Regdate),
Id: strconv.Itoa(memberEx.Member.Uid),
Type: "normal-user",
- //Password: memberEx.UcenterMember.Password,
- //PasswordSalt: memberEx.UcenterMember.Salt,
- //DisplayName: displayName,
+ // Password: memberEx.UcenterMember.Password,
+ // PasswordSalt: memberEx.UcenterMember.Salt,
+ // DisplayName: displayName,
Avatar: "",
PermanentAvatar: "*",
Email: memberEx.Member.Email,
- //Phone: memberEx.Profile.Mobile,
- //Location: memberEx.Profile.Residecity,
+ // Phone: memberEx.Profile.Mobile,
+ // Location: memberEx.Profile.Residecity,
Address: []string{},
- //Affiliation: memberEx.Profile.Occupation,
- //Title: memberEx.Profile.Position,
- //IdCardType: idCardType,
- //IdCard: idCard,
- //Homepage: memberEx.Profile.Site,
- //Bio: memberEx.Profile.Bio,
- //Tag: memberEx.Profile.Interest,
+ // Affiliation: memberEx.Profile.Occupation,
+ // Title: memberEx.Profile.Position,
+ // IdCardType: idCardType,
+ // IdCard: idCard,
+ // Homepage: memberEx.Profile.Site,
+ // Bio: memberEx.Profile.Bio,
+ // Tag: memberEx.Profile.Interest,
Region: "CN",
Language: "zh",
- //Gender: gender,
- //Birthday: birthday,
- //Education: memberEx.Profile.Education,
+ // Gender: gender,
+ // Birthday: birthday,
+ // Education: memberEx.Profile.Education,
Score: memberEx.Member.Credits,
Ranking: memberEx.Member.Uid,
IsOnline: false,
@@ -57,8 +57,8 @@ func getUserFromMember(memberEx *MemberEx) *auth.User {
IsForbidden: false,
IsDeleted: false,
SignupApplication: CasdoorApplication,
- //CreatedIp: memberEx.UcenterMember.Regip,
- //LastSigninTime: getTimeFromUnixSeconds(memberEx.UcenterMember.Lastlogintime),
+ // CreatedIp: memberEx.UcenterMember.Regip,
+ // LastSigninTime: getTimeFromUnixSeconds(memberEx.UcenterMember.Lastlogintime),
LastSigninIp: "",
Properties: map[string]string{},
}
diff --git a/discuzx/util.go b/discuzx/util.go
index fc818b4c..353a075b 100644
--- a/discuzx/util.go
+++ b/discuzx/util.go
@@ -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]")
@@ -42,7 +44,7 @@ func init() {
reSize, _ = regexp.Compile("\\[[a-z]+(=[^]]+)?]")
reSize2, _ = regexp.Compile("\\[/align]")
reSize3, _ = regexp.Compile("\\[/[a-z]+]")
- //reSize, _ = regexp.Compile("\\[size=\\d+\\].*\\[/size\\]")
+ // reSize, _ = regexp.Compile("\\[size=\\d+\\].*\\[/size\\]")
reVideo, _ = regexp.Compile("\\[media=x,(\\d+),(\\d+)\\].*/id_(.*)\\.html\\[/media\\]")
}
diff --git a/main.go b/main.go
index 90bd4e40..974da00f 100644
--- a/main.go
+++ b/main.go
@@ -43,7 +43,7 @@ func main() {
AllowCredentials: true,
}))
- //beego.DelStaticPath("/static")
+ // beego.DelStaticPath("/static")
beego.SetStaticPath("/static", "web/build/static")
beego.SetStaticPath("/swagger", "swagger")
beego.BConfig.WebConfig.DirectoryIndex = true
diff --git a/object/adapter.go b/object/adapter.go
index 28701066..24c7c8bf 100644
--- a/object/adapter.go
+++ b/object/adapter.go
@@ -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"`
diff --git a/object/balance.go b/object/balance.go
index b6255173..8bef5e79 100644
--- a/object/balance.go
+++ b/object/balance.go
@@ -176,7 +176,7 @@ func GetThanksStatus(memberId string, id, recordType int) bool {
func CreateTopicConsumption(user *auth.User, id int) bool {
record := ConsumptionRecord{
- //Id: util.IntToString(GetConsumptionRecordId()),
+ // Id: util.IntToString(GetConsumptionRecordId()),
ReceiverId: GetUserName(user),
ObjectId: id,
CreatedTime: util.GetCurrentTime(),
@@ -199,7 +199,7 @@ func CreateTopicConsumption(user *auth.User, id int) bool {
func CreateReplyConsumption(user *auth.User, id int) bool {
record := ConsumptionRecord{
- //Id: util.IntToString(GetConsumptionRecordId()),
+ // Id: util.IntToString(GetConsumptionRecordId()),
ReceiverId: GetUserName(user),
ObjectId: id,
CreatedTime: util.GetCurrentTime(),
@@ -226,7 +226,7 @@ func GetReplyBonus(author *auth.User, consumer *auth.User, id int) {
}
record := ConsumptionRecord{
- //Id: util.IntToString(GetConsumptionRecordId()),
+ // Id: util.IntToString(GetConsumptionRecordId()),
ConsumerId: consumer.Name,
ReceiverId: author.Name,
ObjectId: id,
diff --git a/object/basic.go b/object/basic.go
index f8c85c16..99a49140 100644
--- a/object/basic.go
+++ b/object/basic.go
@@ -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()
@@ -68,7 +70,7 @@ func GetForumVersion() string {
return ""
}
- //Convert to full length
+ // Convert to full length
temp := string(content)
version = strings.ReplaceAll(temp, "\n", "")
diff --git a/object/cron.go b/object/cron.go
index 81ac53e9..02c1831c 100755
--- a/object/cron.go
+++ b/object/cron.go
@@ -117,7 +117,7 @@ func refreshCronTasks() bool {
}
schedule := fmt.Sprintf("%s %s * * *", minutes, hours)
- //schedule := "* * * * *"
+ // schedule := "* * * * *"
err := ctab.AddJob(schedule, schedulePost, post.Id)
if err != nil {
panic(err)
diff --git a/object/favorites.go b/object/favorites.go
index 70091e46..548646e9 100644
--- a/object/favorites.go
+++ b/object/favorites.go
@@ -35,7 +35,7 @@ const (
)
func IsFavoritesExist(Type string) bool {
- //check the if the string is in the enum
+ // check the if the string is in the enum
if Type == FavorTopic || Type == FollowUser || Type == FavorNode || Type == SubscribeTopic {
return true
}
diff --git a/object/frontConf.go b/object/frontConf.go
index 8ea09d41..babf5517 100644
--- a/object/frontConf.go
+++ b/object/frontConf.go
@@ -21,22 +21,20 @@ type FrontConf struct {
Tags []string `xorm:"varchar(200)" json:"tags"`
}
-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},
- {Id: "footerLogoUrl", Value: "https://www.digitalocean.com/", Field: "visualConf", Tags: nil},
- {Id: "signinBoxStrong", Value: "Casbin = way to authorization", Field: "visualConf", Tags: nil},
- {Id: "signinBoxSpan", Value: "A place for Casbin developers and users", Field: "visualConf", Tags: nil},
- {Id: "footerDeclaration", Value: "World is powered by code", Field: "visualConf", Tags: nil},
- {Id: "footerAdvise", Value: "♥ Do have faith in what you're doing.", Field: "visualConf", Tags: nil},
- {Id: "faq", Value: "Not yet", Field: "", Tags: nil},
- {Id: "mission", Value: "Not yet", Field: "", Tags: nil},
- {Id: "advertise", Value: "Not yet", Field: "", Tags: nil},
- {Id: "thanks", Value: "Not yet", Field: "", Tags: nil},
- }
-)
+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},
+ {Id: "footerLogoUrl", Value: "https://www.digitalocean.com/", Field: "visualConf", Tags: nil},
+ {Id: "signinBoxStrong", Value: "Casbin = way to authorization", Field: "visualConf", Tags: nil},
+ {Id: "signinBoxSpan", Value: "A place for Casbin developers and users", Field: "visualConf", Tags: nil},
+ {Id: "footerDeclaration", Value: "World is powered by code", Field: "visualConf", Tags: nil},
+ {Id: "footerAdvise", Value: "♥ Do have faith in what you're doing.", Field: "visualConf", Tags: nil},
+ {Id: "faq", Value: "Not yet", Field: "", Tags: nil},
+ {Id: "mission", Value: "Not yet", Field: "", Tags: nil},
+ {Id: "advertise", Value: "Not yet", Field: "", Tags: nil},
+ {Id: "thanks", Value: "Not yet", Field: "", Tags: nil},
+}
func InitFrontConf() {
var confs []*FrontConf
diff --git a/object/gitter.go b/object/gitter.go
index a1edf64b..3f19b0a0 100644
--- a/object/gitter.go
+++ b/object/gitter.go
@@ -305,7 +305,7 @@ func createTopicWithMessages(messages []gitter.Message, room gitter.Room, node N
// create if user is not exist
user, err := auth.GetUser(msg.From.Username)
- //fmt.Println("user:", user)
+ // fmt.Println("user:", user)
if err != nil {
panic(err)
}
@@ -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
diff --git a/object/hot.go b/object/hot.go
index 619a287f..7f635ea4 100644
--- a/object/hot.go
+++ b/object/hot.go
@@ -14,7 +14,7 @@
package object
-//RecordType: 1 means node hit record
+// RecordType: 1 means node hit record
type BrowseRecord struct {
Id int `xorm:"int notnull pk autoincr" json:"id"`
MemberId string `xorm:"varchar(100)" json:"memberId"`
diff --git a/object/member.go b/object/member.go
index 432781cf..3084cbc8 100644
--- a/object/member.go
+++ b/object/member.go
@@ -29,7 +29,7 @@ func GetRankingRich() ([]*auth.User, error) {
}
func GetRankingPlayer() ([]*auth.User, error) {
- return casdoor.GetSortedUsers("karma", 25), nil
+ return casdoor.GetSortedUsers("karma", 25), nil
}
func GetUser(id string) *auth.User {
diff --git a/object/node.go b/object/node.go
index 66762dfe..992425f4 100644
--- a/object/node.go
+++ b/object/node.go
@@ -93,7 +93,7 @@ func UpdateNode(id string, node *Node) bool {
panic(err)
}
- //return affected != 0
+ // return affected != 0
return true
}
diff --git a/object/notification.go b/object/notification.go
index 259539aa..15833e2f 100644
--- a/object/notification.go
+++ b/object/notification.go
@@ -34,7 +34,7 @@ type Notification struct {
SenderId string `xorm:"varchar(100)" json:"senderId"`
ReceiverId string `xorm:"varchar(100) index" json:"receiverId"`
Status int `xorm:"tinyint" json:"-"`
- //Deleted bool `xorm:"bool" json:"-"`
+ // Deleted bool `xorm:"bool" json:"-"`
}
func AddNotification(notification *Notification) bool {
@@ -207,7 +207,7 @@ func AddReplyNotification(senderId, content string, objectId, topicId int) {
if senderId != receiverId {
notification := Notification{
- //Id: memberMap[receiverId],
+ // Id: memberMap[receiverId],
NotificationType: 1,
ObjectId: objectId,
CreatedTime: util.GetCurrentTime(),
@@ -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() {
diff --git a/object/reply.go b/object/reply.go
index 6cae4695..3785ec8c 100644
--- a/object/reply.go
+++ b/object/reply.go
@@ -83,34 +83,34 @@ func GetReplies(topicId int, user *auth.User, limit int, page int) ([]*ReplyWith
if enableNestedReply {
replies = bulidReplies(replies)
- //Use limit to calculate offset
- //If limit is 2, but the first reply have 2 child replies(3 replies)
- //We need put these replies to offset, so cannot use (page * limit) to calculate offset
+ // Use limit to calculate offset
+ // If limit is 2, but the first reply have 2 child replies(3 replies)
+ // We need put these replies to offset, so cannot use (page * limit) to calculate offset
pageLimit := limit
for index, reply := range replies {
replyLen := getReplyLen(reply)
- //Ignore replies until page == 1
+ // Ignore replies until page == 1
if page > 1 {
- //Calculate limit in every ignore page
+ // Calculate limit in every ignore page
pageLimit -= replyLen
- //Get replices for init == true(get the latest replies)
+ // Get replices for init == true(get the latest replies)
resultReplies = append(resultReplies, reply)
if pageLimit <= 0 {
page--
pageLimit = limit
if index+1 < len(replies) {
- //If the page is a usable value when we get the latest replies, clear the result
+ // If the page is a usable value when we get the latest replies, clear the result
resultReplies = nil
}
}
} else if limit > 0 {
- //if page == 1, prove that we are processing current page now
- //So we can only calculate the limit and put replies to result slice
+ // if page == 1, prove that we are processing current page now
+ // So we can only calculate the limit and put replies to result slice
limit -= replyLen
resultReplies = append(resultReplies, reply)
page--
} else {
- //if page == 1, and limit < 0, prove that we get all replies in this page now
+ // if page == 1, and limit < 0, prove that we get all replies in this page now
break
}
}
@@ -290,7 +290,7 @@ func UpdateReply(id int, reply *Reply) bool {
panic(err)
}
- //return affected != 0
+ // return affected != 0
return true
}
@@ -305,13 +305,13 @@ func UpdateReplyWithLimitCols(id int, reply *Reply) bool {
panic(err)
}
- //return affected != 0
+ // return affected != 0
return true
}
// AddReply returns add reply result and reply id.
func AddReply(reply *Reply) (bool, int) {
- //reply.Content = strings.ReplaceAll(reply.Content, "\n", "
")
+ // reply.Content = strings.ReplaceAll(reply.Content, "\n", "
")
reply.Content = FilterUnsafeHTML(reply.Content)
affected, err := adapter.Engine.Insert(reply)
if err != nil {
diff --git a/object/sensitive_word.go b/object/sensitive_word.go
index d75879d7..4532bafb 100644
--- a/object/sensitive_word.go
+++ b/object/sensitive_word.go
@@ -18,7 +18,7 @@ import "strings"
type SensitiveWord struct {
Word string `xorm:"varchar(64) notnull"`
- Id int64
+ Id int64
}
var sensitiveWords []SensitiveWord
@@ -86,4 +86,4 @@ func ContainsSensitiveWord(str string) bool {
}
}
return false
-}
\ No newline at end of file
+}
diff --git a/object/tab.go b/object/tab.go
index 854b9484..3d2bd063 100644
--- a/object/tab.go
+++ b/object/tab.go
@@ -69,7 +69,7 @@ func UpdateTab(id string, tab *Tab) bool {
panic(err)
}
- //return affected != 0
+ // return affected != 0
return true
}
diff --git a/object/topic.go b/object/topic.go
index b07199a1..940cee90 100644
--- a/object/topic.go
+++ b/object/topic.go
@@ -414,7 +414,7 @@ func UpdateTopic(id int, topic *Topic) bool {
panic(err)
}
- //return affected != 0
+ // return affected != 0
return true
}
@@ -437,7 +437,7 @@ func UpdateTopicWithLimitCols(id int, topic *Topic) bool {
panic(err)
}
- //return affected != 0
+ // return affected != 0
return true
}
@@ -639,7 +639,7 @@ func GetHotTopic(limit int) []*TopicWithAvatar {
func GetSortedTopics(lastReplySort, hotSort, favCountSort, createdTimeSort string, limit int, offset int) []*TopicWithAvatar {
var topics []*Topic
db := adapter.Engine.Table("topic")
- //last reply time sort
+ // last reply time sort
switch lastReplySort {
case "1":
db = db.Asc("last_reply_time")
diff --git a/routers/filter_ssr.go b/routers/filter_ssr.go
index 6e7cff9a..a3e7351e 100644
--- a/routers/filter_ssr.go
+++ b/routers/filter_ssr.go
@@ -14,10 +14,13 @@ import (
"github.com/astaxie/beego/context"
)
-//var chromeCtx ctx.Context
+// var chromeCtx ctx.Context
var chromeCtxPool *SsrPool
-var isChromeInstalled bool
-var isChromeInit bool
+
+var (
+ isChromeInstalled bool
+ isChromeInit bool
+)
type PageCache struct {
time time.Time
diff --git a/routers/router.go b/routers/router.go
index 947dafe7..cc95cfb4 100644
--- a/routers/router.go
+++ b/routers/router.go
@@ -24,12 +24,11 @@ func init() {
}
func initAPI() {
- ns :=
- beego.NewNamespace("/api",
- beego.NSInclude(
- &controllers.ApiController{},
- ),
- )
+ ns := beego.NewNamespace("/api",
+ beego.NSInclude(
+ &controllers.ApiController{},
+ ),
+ )
beego.AddNamespace(ns)
beego.Router("/api/get-topics", &controllers.ApiController{}, "GET:GetTopics")
@@ -37,7 +36,7 @@ func initAPI() {
beego.Router("/api/get-topic", &controllers.ApiController{}, "GET:GetTopic")
beego.Router("/api/get-topic-admin", &controllers.ApiController{}, "GET:GetTopicAdmin")
beego.Router("/api/get-topic-by-urlpath-and-title", &controllers.ApiController{}, "GET:GetTopicByUrlPathAndTitle")
- //beego.Router("/api/update-topic", &controllers.ApiController{}, "POST:UpdateTopic") // no necessary to explore this api.
+ // beego.Router("/api/update-topic", &controllers.ApiController{}, "POST:UpdateTopic") // no necessary to explore this api.
beego.Router("/api/add-topic", &controllers.ApiController{}, "POST:AddTopic")
beego.Router("/api/delete-topic", &controllers.ApiController{}, "POST:DeleteTopic")
beego.Router("/api/translate-topic", &controllers.ApiController{}, "POST:TranslateTopic")
@@ -80,12 +79,12 @@ func initAPI() {
beego.Router("/api/get-ranking-rich", &controllers.ApiController{}, "GET:GetRankingRich")
beego.Router("/api/get-ranking-player", &controllers.ApiController{}, "GET:GetRankingPlayer")
- beego.Router("/api/update-poster", &controllers.ApiController{}, "POST:UpdatePoster") //Update poster api just for admin.
+ beego.Router("/api/update-poster", &controllers.ApiController{}, "POST:UpdatePoster") // Update poster api just for admin.
beego.Router("/api/read-poster", &controllers.ApiController{}, "GET:ReadPoster")
- beego.Router("/api/update-translator", &controllers.ApiController{}, "POST:UpdateTranslator") //Update translator api just for admin.
- beego.Router("/api/add-translator", &controllers.ApiController{}, "POST:AddTranslator") //Add translator api just for admin.
- beego.Router("/api/del-translator", &controllers.ApiController{}, "POST:DelTranslator") //Delete translator api just for admin.
+ beego.Router("/api/update-translator", &controllers.ApiController{}, "POST:UpdateTranslator") // Update translator api just for admin.
+ beego.Router("/api/add-translator", &controllers.ApiController{}, "POST:AddTranslator") // Add translator api just for admin.
+ beego.Router("/api/del-translator", &controllers.ApiController{}, "POST:DelTranslator") // Delete translator api just for admin.
beego.Router("/api/get-translator", &controllers.ApiController{}, "GET:GetTranslator")
beego.Router("/api/visible-translator", &controllers.ApiController{}, "GET:VisibleTranslator")
@@ -130,7 +129,7 @@ func initAPI() {
beego.Router("/api/get-plane", &controllers.ApiController{}, "GET:GetPlane")
beego.Router("/api/get-plane-admin", &controllers.ApiController{}, "GET:GetPlaneAdmin")
- //beego.Router("/api/get-planes", &controllers.ApiController{}, "GET:GetPlanes")
+ // beego.Router("/api/get-planes", &controllers.ApiController{}, "GET:GetPlanes")
beego.Router("/api/add-plane", &controllers.ApiController{}, "POST:AddPlane") // Add plane api just for admin.
beego.Router("/api/get-plane-list", &controllers.ApiController{}, "GET:GetPlaneList")
beego.Router("/api/update-plane", &controllers.ApiController{}, "POST:UpdatePlane") // Update plane api just for admin.
diff --git a/routers/ssr_pool.go b/routers/ssr_pool.go
index 7899d6f6..f1591b20 100644
--- a/routers/ssr_pool.go
+++ b/routers/ssr_pool.go
@@ -90,10 +90,10 @@ func render(chromeCtx ctx.Context, url string) (string, error) {
}
func (pool *SsrPool) worker() {
- //chromeCtx, _ := chromedp.NewExecAllocator(ctx.Background(), append(
+ // chromeCtx, _ := chromedp.NewExecAllocator(ctx.Background(), append(
// chromedp.DefaultExecAllocatorOptions[:],
// chromedp.Flag("headless", false))...)
- //chromeCtx, _ = chromedp.NewContext(chromeCtx)
+ // chromeCtx, _ = chromedp.NewContext(chromeCtx)
chromeCtx, _ := chromedp.NewContext(ctx.Background()) // set default context with headless mode
for task := range pool.JobsChannel {
cancel := func() bool {
diff --git a/service/tokenizer.go b/service/tokenizer.go
index 52f5dd57..738f2d20 100644
--- a/service/tokenizer.go
+++ b/service/tokenizer.go
@@ -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 {
diff --git a/util/log.go b/util/log.go
index e699f50f..ab717625 100644
--- a/util/log.go
+++ b/util/log.go
@@ -36,7 +36,7 @@ func GetIPInfo(clientIP string) string {
ip := strings.TrimSpace(ips[i])
desc := "" // GetDescFromIP(ip)
ipstr := fmt.Sprintf("%s: %s", ip, desc)
- if i != len(ips) - 1 {
+ if i != len(ips)-1 {
res += ipstr + " -> "
} else {
res += ipstr
@@ -65,12 +65,12 @@ func getIPFromRequest(req *http.Request) string {
func LogInfo(ctx *context.Context, f string, v ...interface{}) {
ipString := fmt.Sprintf("(%s) ", getIPFromRequest(ctx.Request))
- logs.Info(ipString + f, v...)
+ logs.Info(ipString+f, v...)
}
func LogWarning(ctx *context.Context, f string, v ...interface{}) {
ipString := fmt.Sprintf("(%s) ", getIPFromRequest(ctx.Request))
- logs.Warning(ipString + f, v...)
+ logs.Warning(ipString+f, v...)
}
func ReadLog() []string {
diff --git a/util/string.go b/util/string.go
index 5b7eb203..02d56e81 100644
--- a/util/string.go
+++ b/util/string.go
@@ -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)
}