From 4fb7beb25d32c01cae0fcdaba3001bc235dd8544 Mon Sep 17 00:00:00 2001 From: alimy Date: Fri, 6 Feb 2026 11:52:00 +0800 Subject: [PATCH] just use gofumpt instead to fmt source code --- Makefile | 17 ++++++++++------- auto/rpc/core/v1/auth.pb.go | 2 +- auto/rpc/core/v1/auth_grpc.pb.go | 10 +++++----- auto/rpc/greet/v1/greet.pb.go | 2 +- auto/rpc/greet/v1/greet_grpc.pb.go | 6 +++--- cmd/root.go | 12 +++++------- internal/dao/cache/bigcache.go | 4 +--- internal/dao/cache/cache.go | 4 +--- internal/dao/jinzhu/authority.go | 4 +--- internal/dao/jinzhu/contacts.go | 4 +--- internal/dao/jinzhu/dbr/model.go | 6 ++++-- internal/dao/jinzhu/dbr/post_content.go | 16 +++++++--------- internal/dao/jinzhu/following.go | 4 +--- internal/dao/jinzhu/messages.go | 4 +--- internal/dao/jinzhu/security.go | 4 +--- internal/dao/jinzhu/tweets.go | 3 +-- internal/dao/jinzhu/user.go | 4 +--- internal/dao/jinzhu/wallet.go | 5 ++--- internal/dao/search/bridge.go | 4 +--- internal/dao/security/attachment_check.go | 4 +--- internal/dao/security/phone_verify_juhe.go | 4 +--- internal/dao/storage/cos.go | 1 - internal/dao/storage/localoss.go | 6 +++--- internal/model/enum/builtin_enum.go | 16 ++++++++++++---- internal/model/web/core.go | 12 ++++++++---- internal/model/web/web.go | 4 +--- internal/servants/admin/user.go | 4 +--- internal/servants/base/base.go | 1 - internal/servants/bot/user.go | 4 +--- internal/servants/localoss/user.go | 4 +--- internal/servants/mobile/greet.go | 4 +--- internal/servants/space/user.go | 4 +--- internal/servants/web/admin.go | 4 +--- internal/servants/web/core.go | 5 +---- internal/servants/web/events.go | 2 +- internal/servants/web/followship.go | 4 +--- internal/servants/web/friendship.go | 4 +--- internal/servants/web/loose.go | 4 +--- internal/servants/web/priv.go | 3 ++- internal/servants/web/pub.go | 4 +--- internal/servants/web/relax.go | 4 +--- internal/servants/web/site.go | 4 +--- internal/servants/web/trends.go | 4 +--- internal/service/admin.go | 4 +--- internal/service/bot.go | 4 +--- internal/service/docs.go | 4 +--- internal/service/frontend_web.go | 4 +--- internal/service/grpc_server.go | 4 +--- internal/service/http_server.go | 4 +--- internal/service/localoss.go | 4 +--- internal/service/metrics.go | 4 +--- internal/service/mobile.go | 4 +--- internal/service/pprof.go | 4 +--- internal/service/space.go | 4 +--- internal/service/web.go | 4 +--- pkg/debug/errors.go | 4 +--- pkg/http/client.go | 4 +--- pkg/naming/snake_ns.go | 3 ++- pkg/obx/obx.go | 4 +--- pkg/types/json_box.go | 1 - pkg/utils/banner.go | 1 - pkg/utils/str.go | 6 ++++-- pkg/version/build.go | 4 +--- pkg/xerror/xerror.go | 6 ++---- pkg/zinc/zinc.go | 1 - 65 files changed, 115 insertions(+), 192 deletions(-) diff --git a/Makefile b/Makefile index 1b103821..9e05128c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all build build-web run test clean fmt pre-commit help +.PHONY: all build build-web run test clean fmt vet pre-commit help PROJECT = paopao-ce TARGET = paopao @@ -22,6 +22,7 @@ BUILD_VERSION := $(shell git describe --tags --always) BUILD_DATE := $(shell date +'%Y-%m-%d %H:%M:%S %Z') SHA_SHORT := $(shell git rev-parse --short HEAD) +GOFMT ?= gofumpt -l -w MOD_NAME = github.com/rocboss/paopao-ce LDFLAGS = -X "${MOD_NAME}/pkg/version.version=${BUILD_VERSION}" \ -X "${MOD_NAME}/pkg/version.buildDate=${BUILD_DATE}" \ @@ -84,18 +85,18 @@ generate: gen-mir gen-rpc gen-enum .PHONY: gen-mir gen-mir: @go generate mirc/gen.go - @go fmt ./auto/api/... + $(GOFMT) ./auto/api .PHONY: gen-rpc gen-rpc: @rm -rf auto/rpc - @buf generate proto - @go fmt ./auto/rpc/... + buf generate proto + $(GOFMT) ./auto/rpc .PHONY: gen-enum gen-enum: @go generate ./internal/model/enum/... - go fmt ./internal/model/enum/... + $(GOFMT) ./internal/model/enum .PHONY: proto-mod proto-mod: @@ -111,8 +112,9 @@ clean: fmt: @echo Formatting... - @go fmt ./internal/... - @go fmt ./pkg/... + $(GOFMT) . + +vet: @go vet -composites=false ./internal/... @go vet -composites=false ./pkg/... @@ -125,6 +127,7 @@ pre-commit: fmt .PHONY: install-tools install-tools: install-protobuf-plugins @go install github.com/abice/go-enum@latest + @go install mvdan.cc/gofumpt@latest .PHONY: install-protobuf-plugins install-protobuf-plugins: diff --git a/auto/rpc/core/v1/auth.pb.go b/auto/rpc/core/v1/auth.pb.go index b5779cc4..1adae5d3 100644 --- a/auto/rpc/core/v1/auth.pb.go +++ b/auto/rpc/core/v1/auth.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.11 // protoc (unknown) // source: core/v1/auth.proto diff --git a/auto/rpc/core/v1/auth_grpc.pb.go b/auto/rpc/core/v1/auth_grpc.pb.go index ea3b07bf..0d58a38a 100644 --- a/auto/rpc/core/v1/auth_grpc.pb.go +++ b/auto/rpc/core/v1/auth_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.5.1 +// - protoc-gen-go-grpc v1.6.0 // - protoc (unknown) // source: core/v1/auth.proto @@ -89,13 +89,13 @@ type AuthenticateServiceServer interface { type UnimplementedAuthenticateServiceServer struct{} func (UnimplementedAuthenticateServiceServer) PreLogin(context.Context, *User) (*ActionReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method PreLogin not implemented") + return nil, status.Error(codes.Unimplemented, "method PreLogin not implemented") } func (UnimplementedAuthenticateServiceServer) Login(context.Context, *User) (*LoginReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") + return nil, status.Error(codes.Unimplemented, "method Login not implemented") } func (UnimplementedAuthenticateServiceServer) Logout(context.Context, *User) (*ActionReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method Logout not implemented") + return nil, status.Error(codes.Unimplemented, "method Logout not implemented") } func (UnimplementedAuthenticateServiceServer) mustEmbedUnimplementedAuthenticateServiceServer() {} func (UnimplementedAuthenticateServiceServer) testEmbeddedByValue() {} @@ -108,7 +108,7 @@ type UnsafeAuthenticateServiceServer interface { } func RegisterAuthenticateServiceServer(s grpc.ServiceRegistrar, srv AuthenticateServiceServer) { - // If the following call pancis, it indicates UnimplementedAuthenticateServiceServer was + // If the following call panics, it indicates UnimplementedAuthenticateServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. diff --git a/auto/rpc/greet/v1/greet.pb.go b/auto/rpc/greet/v1/greet.pb.go index ed3d3cce..af7a938d 100644 --- a/auto/rpc/greet/v1/greet.pb.go +++ b/auto/rpc/greet/v1/greet.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.11 // protoc (unknown) // source: greet/v1/greet.proto diff --git a/auto/rpc/greet/v1/greet_grpc.pb.go b/auto/rpc/greet/v1/greet_grpc.pb.go index be277a6b..29786031 100644 --- a/auto/rpc/greet/v1/greet_grpc.pb.go +++ b/auto/rpc/greet/v1/greet_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.5.1 +// - protoc-gen-go-grpc v1.6.0 // - protoc (unknown) // source: greet/v1/greet.proto @@ -63,7 +63,7 @@ type GreetServiceServer interface { type UnimplementedGreetServiceServer struct{} func (UnimplementedGreetServiceServer) Greet(context.Context, *GreetRequest) (*GreetResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Greet not implemented") + return nil, status.Error(codes.Unimplemented, "method Greet not implemented") } func (UnimplementedGreetServiceServer) mustEmbedUnimplementedGreetServiceServer() {} func (UnimplementedGreetServiceServer) testEmbeddedByValue() {} @@ -76,7 +76,7 @@ type UnsafeGreetServiceServer interface { } func RegisterGreetServiceServer(s grpc.ServiceRegistrar, srv GreetServiceServer) { - // If the following call pancis, it indicates UnimplementedGreetServiceServer was + // If the following call panics, it indicates UnimplementedGreetServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. diff --git a/cmd/root.go b/cmd/root.go index e0e59974..cc1af061 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -8,13 +8,11 @@ import ( "github.com/spf13/cobra" ) -var ( - rootCmd = &cobra.Command{ - Use: "paopao", - Short: `an artistic "twitter like" community`, - Long: `an artistic "twitter like" community`, - } -) +var rootCmd = &cobra.Command{ + Use: "paopao", + Short: `an artistic "twitter like" community`, + Long: `an artistic "twitter like" community`, +} // Setup set root command name,short-describe, long-describe // return &cobra.Command to custom other options diff --git a/internal/dao/cache/bigcache.go b/internal/dao/cache/bigcache.go index 259ab660..1fb5130f 100644 --- a/internal/dao/cache/bigcache.go +++ b/internal/dao/cache/bigcache.go @@ -9,9 +9,7 @@ import ( "github.com/allegro/bigcache/v3" ) -var ( - _ tweetsCache = (*bigCacheTweetsCache)(nil) -) +var _ tweetsCache = (*bigCacheTweetsCache)(nil) type bigCacheTweetsCache struct { bc *bigcache.BigCache diff --git a/internal/dao/cache/cache.go b/internal/dao/cache/cache.go index 2cee6684..29dbba57 100644 --- a/internal/dao/cache/cache.go +++ b/internal/dao/cache/cache.go @@ -15,9 +15,7 @@ import ( "github.com/sirupsen/logrus" ) -var ( - _onceInit sync.Once -) +var _onceInit sync.Once func NewRedisCache() core.RedisCache { return &redisCache{ diff --git a/internal/dao/jinzhu/authority.go b/internal/dao/jinzhu/authority.go index 9921f214..caef4438 100644 --- a/internal/dao/jinzhu/authority.go +++ b/internal/dao/jinzhu/authority.go @@ -12,9 +12,7 @@ import ( "gorm.io/gorm" ) -var ( - _ core.AuthorizationManageService = (*authorizationManageSrv)(nil) -) +var _ core.AuthorizationManageService = (*authorizationManageSrv)(nil) type authorizationManageSrv struct { db *gorm.DB diff --git a/internal/dao/jinzhu/contacts.go b/internal/dao/jinzhu/contacts.go index 6d415be3..349c605d 100644 --- a/internal/dao/jinzhu/contacts.go +++ b/internal/dao/jinzhu/contacts.go @@ -14,9 +14,7 @@ import ( "gorm.io/gorm" ) -var ( - _ core.ContactManageService = (*contactManageSrv)(nil) -) +var _ core.ContactManageService = (*contactManageSrv)(nil) type contactManageSrv struct { db *gorm.DB diff --git a/internal/dao/jinzhu/dbr/model.go b/internal/dao/jinzhu/dbr/model.go index 75e66561..c8339be6 100644 --- a/internal/dao/jinzhu/dbr/model.go +++ b/internal/dao/jinzhu/dbr/model.go @@ -20,8 +20,10 @@ type Model struct { IsDel soft_delete.DeletedAt `gorm:"softDelete:flag" json:"is_del"` } -type ConditionsT map[string]any -type Predicates map[string][]any +type ( + ConditionsT map[string]any + Predicates map[string][]any +) func (m *Model) BeforeCreate(tx *gorm.DB) (err error) { nowTime := time.Now().Unix() diff --git a/internal/dao/jinzhu/dbr/post_content.go b/internal/dao/jinzhu/dbr/post_content.go index 5f257630..79c279b1 100644 --- a/internal/dao/jinzhu/dbr/post_content.go +++ b/internal/dao/jinzhu/dbr/post_content.go @@ -24,15 +24,13 @@ const ( ContentTypeChargeAttachment ) -var ( - mediaContentType = []PostContentT{ - ContentTypeImage, - ContentTypeVideo, - ContentTypeAudio, - ContentTypeAttachment, - ContentTypeChargeAttachment, - } -) +var mediaContentType = []PostContentT{ + ContentTypeImage, + ContentTypeVideo, + ContentTypeAudio, + ContentTypeAttachment, + ContentTypeChargeAttachment, +} type PostContent struct { *Model diff --git a/internal/dao/jinzhu/following.go b/internal/dao/jinzhu/following.go index a71ee2d6..19787008 100644 --- a/internal/dao/jinzhu/following.go +++ b/internal/dao/jinzhu/following.go @@ -12,9 +12,7 @@ import ( "gorm.io/gorm" ) -var ( - _ core.FollowingManageService = (*followingManageSrv)(nil) -) +var _ core.FollowingManageService = (*followingManageSrv)(nil) type followingManageSrv struct { db *gorm.DB diff --git a/internal/dao/jinzhu/messages.go b/internal/dao/jinzhu/messages.go index 105618e9..0eb83cf3 100644 --- a/internal/dao/jinzhu/messages.go +++ b/internal/dao/jinzhu/messages.go @@ -12,9 +12,7 @@ import ( "gorm.io/gorm" ) -var ( - _ core.MessageService = (*messageSrv)(nil) -) +var _ core.MessageService = (*messageSrv)(nil) type messageSrv struct { db *gorm.DB diff --git a/internal/dao/jinzhu/security.go b/internal/dao/jinzhu/security.go index 18a8ccae..4980763e 100644 --- a/internal/dao/jinzhu/security.go +++ b/internal/dao/jinzhu/security.go @@ -15,9 +15,7 @@ import ( "gorm.io/gorm" ) -var ( - _ core.SecurityService = (*securitySrv)(nil) -) +var _ core.SecurityService = (*securitySrv)(nil) type securitySrv struct { db *gorm.DB diff --git a/internal/dao/jinzhu/tweets.go b/internal/dao/jinzhu/tweets.go index 8139b1c1..8074d28e 100644 --- a/internal/dao/jinzhu/tweets.go +++ b/internal/dao/jinzhu/tweets.go @@ -250,7 +250,6 @@ func (s *tweetManageSrv) DeletePost(post *ms.Post) ([]string, error) { return nil }, ) - if err != nil { return nil, err } @@ -472,7 +471,7 @@ func (s *tweetSrv) ListFollowingTweets(userId int64, limit, offset int) (res []* } beFriendCount, beFollowCount := len(beFriendIds), len(beFollowIds) db := s.db.Model(&dbr.Post{}) - //可见性: 0私密 10充电可见 20订阅可见 30保留 40保留 50好友可见 60关注可见 70保留 80保留 90公开', + // 可见性: 0私密 10充电可见 20订阅可见 30保留 40保留 50好友可见 60关注可见 70保留 80保留 90公开', switch { case beFriendCount > 0 && beFollowCount > 0: db = db.Where("user_id=? OR (visibility>=50 AND user_id IN(?)) OR (visibility>=60 AND user_id IN(?))", userId, beFriendIds, beFollowIds) diff --git a/internal/dao/jinzhu/user.go b/internal/dao/jinzhu/user.go index 6f5c2c71..66e6d158 100644 --- a/internal/dao/jinzhu/user.go +++ b/internal/dao/jinzhu/user.go @@ -15,9 +15,7 @@ import ( "gorm.io/gorm" ) -var ( - _ core.UserManageService = (*userManageSrv)(nil) -) +var _ core.UserManageService = (*userManageSrv)(nil) type userManageSrv struct { db *gorm.DB diff --git a/internal/dao/jinzhu/wallet.go b/internal/dao/jinzhu/wallet.go index e657deca..e479bc92 100644 --- a/internal/dao/jinzhu/wallet.go +++ b/internal/dao/jinzhu/wallet.go @@ -12,9 +12,7 @@ import ( "gorm.io/gorm" ) -var ( - _ core.WalletService = (*walletSrv)(nil) -) +var _ core.WalletService = (*walletSrv)(nil) type walletSrv struct { db *gorm.DB @@ -35,6 +33,7 @@ func (s *walletSrv) GetRechargeByID(id int64) (*ms.WalletRecharge, error) { return recharge.Get(s.db) } + func (s *walletSrv) CreateRecharge(userId, amount int64) (*ms.WalletRecharge, error) { recharge := &dbr.WalletRecharge{ UserID: userId, diff --git a/internal/dao/search/bridge.go b/internal/dao/search/bridge.go index 6c9ed164..43028c95 100644 --- a/internal/dao/search/bridge.go +++ b/internal/dao/search/bridge.go @@ -12,9 +12,7 @@ import ( "github.com/sirupsen/logrus" ) -var ( - _ core.TweetSearchService = (*bridgeTweetSearchServant)(nil) -) +var _ core.TweetSearchService = (*bridgeTweetSearchServant)(nil) type documents struct { primaryKey []string diff --git a/internal/dao/security/attachment_check.go b/internal/dao/security/attachment_check.go index aa077aca..591554e8 100644 --- a/internal/dao/security/attachment_check.go +++ b/internal/dao/security/attachment_check.go @@ -12,9 +12,7 @@ import ( "github.com/rocboss/paopao-ce/internal/core" ) -var ( - _ core.AttachmentCheckService = (*attachmentCheckServant)(nil) -) +var _ core.AttachmentCheckService = (*attachmentCheckServant)(nil) type attachmentCheckServant struct { domain string diff --git a/internal/dao/security/phone_verify_juhe.go b/internal/dao/security/phone_verify_juhe.go index c213d380..25dfd553 100644 --- a/internal/dao/security/phone_verify_juhe.go +++ b/internal/dao/security/phone_verify_juhe.go @@ -12,9 +12,7 @@ import ( "gopkg.in/resty.v1" ) -var ( - _ core.PhoneVerifyService = (*juheSmsServant)(nil) -) +var _ core.PhoneVerifyService = (*juheSmsServant)(nil) type juhePhoneCaptchaRsp struct { ErrorCode int `json:"error_code"` diff --git a/internal/dao/storage/cos.go b/internal/dao/storage/cos.go index 3c2ea65f..bb2790f4 100644 --- a/internal/dao/storage/cos.go +++ b/internal/dao/storage/cos.go @@ -120,7 +120,6 @@ func (s *cosServant) IsObjectExist(objectKey string) (bool, error) { func (s *cosServant) SignURL(objectKey string, expiredInSec int64) (string, error) { signedURL, err := s.client.Object.GetPresignedURL(context.Background(), http.MethodGet, objectKey, conf.COSSetting.SecretID, conf.COSSetting.SecretKey, time.Second*time.Duration(expiredInSec), nil) - if err != nil { logrus.Errorf("client.SignURL err: %v", err) return "", err diff --git a/internal/dao/storage/localoss.go b/internal/dao/storage/localoss.go index 10131d29..d110b371 100644 --- a/internal/dao/storage/localoss.go +++ b/internal/dao/storage/localoss.go @@ -45,7 +45,7 @@ type localossServant struct { func (s *localossCreateServant) PutObject(objectKey string, reader io.Reader, objectSize int64, contentType string, _persistance bool) (string, error) { saveDir := s.savePath + filepath.Dir(objectKey) - err := os.MkdirAll(saveDir, 0750) + err := os.MkdirAll(saveDir, 0o750) if err != nil && !os.IsExist(err) { return "", err } @@ -80,7 +80,7 @@ func (s *localossCreateTempDirServant) PutObject(objectKey string, reader io.Rea objectName = s.tempDir + objectKey } saveDir := s.savePath + filepath.Dir(objectName) - err := os.MkdirAll(saveDir, 0750) + err := os.MkdirAll(saveDir, 0o750) if err != nil && !os.IsExist(err) { return "", err } @@ -112,7 +112,7 @@ func (s *localossCreateTempDirServant) PersistObject(objectKey string) error { } saveDir := s.savePath + filepath.Dir(objectKey) - if err = os.MkdirAll(saveDir, 0750); err != nil && !os.IsExist(err) { + if err = os.MkdirAll(saveDir, 0o750); err != nil && !os.IsExist(err) { return err } diff --git a/internal/model/enum/builtin_enum.go b/internal/model/enum/builtin_enum.go index 149a747f..05e4134a 100644 --- a/internal/model/enum/builtin_enum.go +++ b/internal/model/enum/builtin_enum.go @@ -1,8 +1,8 @@ // Code generated by go-enum DO NOT EDIT. -// Version: v0.7.0 -// Revision: 03ade876e762757c985a1cde66576bd63f75d7cd -// Build Date: 2025-04-20T09:27:58+0000 -// Built By: alimy +// Version: 0.9.2 +// Revision: 9d73c76728916582359433d1eb0b27340a8268b7 +// Build Date: 2025-10-17T20:10:48Z +// Built By: goreleaser package enum @@ -112,6 +112,14 @@ func (x *Boolean) UnmarshalText(text []byte) error { return nil } +// AppendText appends the textual representation of itself to the end of b +// (allocating a larger slice if necessary) and returns the updated slice. +// +// Implementations must not retain b, nor mutate any bytes within b[:len(b)]. +func (x *Boolean) AppendText(b []byte) ([]byte, error) { + return append(b, x.String()...), nil +} + var errBooleanNilPtr = errors.New("value pointer is nil") // one per type for package clashes // Scan implements the Scanner interface. diff --git a/internal/model/web/core.go b/internal/model/web/core.go index 63ab1939..9a07a515 100644 --- a/internal/model/web/core.go +++ b/internal/model/web/core.go @@ -69,11 +69,15 @@ type SendWhisperReq struct { Content string `json:"content" binding:"required"` } -type GetCollectionsReq BasePageReq -type GetCollectionsResp base.PageResp +type ( + GetCollectionsReq BasePageReq + GetCollectionsResp base.PageResp +) -type GetStarsReq BasePageReq -type GetStarsResp base.PageResp +type ( + GetStarsReq BasePageReq + GetStarsResp base.PageResp +) type UserPhoneBindReq struct { BaseInfo `json:"-" binding:"-"` diff --git a/internal/model/web/web.go b/internal/model/web/web.go index 513da35e..01ee4cc8 100644 --- a/internal/model/web/web.go +++ b/internal/model/web/web.go @@ -13,9 +13,7 @@ import ( "github.com/rocboss/paopao-ce/pkg/xerror" ) -var ( - bindAny = base.NewBindAnyFn() -) +var bindAny = base.NewBindAnyFn() type BaseInfo struct { User *ms.User diff --git a/internal/servants/admin/user.go b/internal/servants/admin/user.go index 5713a205..1233e715 100644 --- a/internal/servants/admin/user.go +++ b/internal/servants/admin/user.go @@ -9,9 +9,7 @@ import ( "github.com/rocboss/paopao-ce/internal/servants/base" ) -var ( - _ api.User = (*userSrv)(nil) -) +var _ api.User = (*userSrv)(nil) type userSrv struct { *base.BaseServant diff --git a/internal/servants/base/base.go b/internal/servants/base/base.go index 3c381487..0489846a 100644 --- a/internal/servants/base/base.go +++ b/internal/servants/base/base.go @@ -137,7 +137,6 @@ func bindAnySentry(c *gin.Context, obj any) error { setter.SetPageInfo(page, pageSize) } return nil - } func RenderAny(c *gin.Context, data any, err error) { diff --git a/internal/servants/bot/user.go b/internal/servants/bot/user.go index 5ea239bd..714f299b 100644 --- a/internal/servants/bot/user.go +++ b/internal/servants/bot/user.go @@ -9,9 +9,7 @@ import ( "github.com/rocboss/paopao-ce/internal/servants/base" ) -var ( - _ api.User = (*userSrv)(nil) -) +var _ api.User = (*userSrv)(nil) type userSrv struct { *base.BaseServant diff --git a/internal/servants/localoss/user.go b/internal/servants/localoss/user.go index 2d45f5b9..d0cfe93e 100644 --- a/internal/servants/localoss/user.go +++ b/internal/servants/localoss/user.go @@ -9,9 +9,7 @@ import ( "github.com/rocboss/paopao-ce/internal/servants/base" ) -var ( - _ api.User = (*userSrv)(nil) -) +var _ api.User = (*userSrv)(nil) type userSrv struct { *base.BaseServant diff --git a/internal/servants/mobile/greet.go b/internal/servants/mobile/greet.go index 1d714a9d..0e5a1f10 100644 --- a/internal/servants/mobile/greet.go +++ b/internal/servants/mobile/greet.go @@ -8,9 +8,7 @@ import ( api "github.com/rocboss/paopao-ce/auto/rpc/greet/v1" ) -var ( - _ api.GreetServiceServer = (*greetServiceSrv)(nil) -) +var _ api.GreetServiceServer = (*greetServiceSrv)(nil) type greetServiceSrv struct { api.UnimplementedGreetServiceServer diff --git a/internal/servants/space/user.go b/internal/servants/space/user.go index 505b6f30..c83b98d1 100644 --- a/internal/servants/space/user.go +++ b/internal/servants/space/user.go @@ -9,9 +9,7 @@ import ( "github.com/rocboss/paopao-ce/internal/servants/base" ) -var ( - _ api.User = (*userSrv)(nil) -) +var _ api.User = (*userSrv)(nil) type userSrv struct { *base.BaseServant diff --git a/internal/servants/web/admin.go b/internal/servants/web/admin.go index 6810e89a..f38d4aaf 100644 --- a/internal/servants/web/admin.go +++ b/internal/servants/web/admin.go @@ -18,9 +18,7 @@ import ( "github.com/sirupsen/logrus" ) -var ( - _ api.Admin = (*adminSrv)(nil) -) +var _ api.Admin = (*adminSrv)(nil) type adminSrv struct { api.UnimplementedAdminServant diff --git a/internal/servants/web/core.go b/internal/servants/web/core.go index d3c0ef4a..d0fbeb79 100644 --- a/internal/servants/web/core.go +++ b/internal/servants/web/core.go @@ -7,7 +7,6 @@ package web import ( "context" "fmt" - "time" "unicode/utf8" @@ -30,9 +29,7 @@ var ( _maxCaptchaTimes int = 2 ) -var ( - _ api.Core = (*coreSrv)(nil) -) +var _ api.Core = (*coreSrv)(nil) type coreSrv struct { api.UnimplementedCoreServant diff --git a/internal/servants/web/events.go b/internal/servants/web/events.go index 0e129fdd..6834f744 100644 --- a/internal/servants/web/events.go +++ b/internal/servants/web/events.go @@ -273,7 +273,7 @@ func (e *messageActionEvent) Action() (err error) { default: // TODO } - //清除该用户所有消息缓存 + // 清除该用户所有消息缓存 err = e.wc.DelAny(fmt.Sprintf("%s%d:*", conf.PrefixMessages, userId)) } return diff --git a/internal/servants/web/followship.go b/internal/servants/web/followship.go index a66bac0d..bd9caf34 100644 --- a/internal/servants/web/followship.go +++ b/internal/servants/web/followship.go @@ -15,9 +15,7 @@ import ( "github.com/sirupsen/logrus" ) -var ( - _ api.Followship = (*followshipSrv)(nil) -) +var _ api.Followship = (*followshipSrv)(nil) type followshipSrv struct { api.UnimplementedFollowshipServant diff --git a/internal/servants/web/friendship.go b/internal/servants/web/friendship.go index 68ab7953..1851fc21 100644 --- a/internal/servants/web/friendship.go +++ b/internal/servants/web/friendship.go @@ -14,9 +14,7 @@ import ( "github.com/sirupsen/logrus" ) -var ( - _ api.Friendship = (*friendshipSrv)(nil) -) +var _ api.Friendship = (*friendshipSrv)(nil) type friendshipSrv struct { api.UnimplementedFriendshipServant diff --git a/internal/servants/web/loose.go b/internal/servants/web/loose.go index e8ca4b63..66f9335d 100644 --- a/internal/servants/web/loose.go +++ b/internal/servants/web/loose.go @@ -21,9 +21,7 @@ import ( "github.com/sirupsen/logrus" ) -var ( - _ api.Loose = (*looseSrv)(nil) -) +var _ api.Loose = (*looseSrv)(nil) type looseSrv struct { api.UnimplementedLooseServant diff --git a/internal/servants/web/priv.go b/internal/servants/web/priv.go index 0c8cc199..9835bf24 100644 --- a/internal/servants/web/priv.go +++ b/internal/servants/web/priv.go @@ -748,7 +748,8 @@ func (s *privSrv) deletePostCommentReply(reply *ms.CommentReply) error { } func (s *privSrv) createPostPreHandler(commentID int64, userID, atUserID int64) (*ms.Post, *ms.Comment, int64, - error) { + error, +) { // 加载Comment comment, err := s.Ds.GetCommentByID(commentID) if err != nil { diff --git a/internal/servants/web/pub.go b/internal/servants/web/pub.go index fa81cae5..59bbff04 100644 --- a/internal/servants/web/pub.go +++ b/internal/servants/web/pub.go @@ -27,9 +27,7 @@ import ( "github.com/sirupsen/logrus" ) -var ( - _ api.Pub = (*pubSrv)(nil) -) +var _ api.Pub = (*pubSrv)(nil) const ( _MaxLoginErrTimes = 10 diff --git a/internal/servants/web/relax.go b/internal/servants/web/relax.go index b92f167d..468c033c 100644 --- a/internal/servants/web/relax.go +++ b/internal/servants/web/relax.go @@ -15,9 +15,7 @@ import ( "github.com/sirupsen/logrus" ) -var ( - _ api.Relax = (*relaxSrv)(nil) -) +var _ api.Relax = (*relaxSrv)(nil) type relaxSrv struct { api.UnimplementedRelaxServant diff --git a/internal/servants/web/site.go b/internal/servants/web/site.go index 1dbc1832..54636afa 100644 --- a/internal/servants/web/site.go +++ b/internal/servants/web/site.go @@ -12,9 +12,7 @@ import ( "github.com/rocboss/paopao-ce/pkg/version" ) -var ( - _ api.Site = (*siteSrv)(nil) -) +var _ api.Site = (*siteSrv)(nil) type siteSrv struct { api.UnimplementedSiteServant diff --git a/internal/servants/web/trends.go b/internal/servants/web/trends.go index 0b5ccf66..bf04fd1a 100644 --- a/internal/servants/web/trends.go +++ b/internal/servants/web/trends.go @@ -18,9 +18,7 @@ import ( "github.com/sirupsen/logrus" ) -var ( - _ api.Trends = (*trendsSrv)(nil) -) +var _ api.Trends = (*trendsSrv)(nil) type trendsSrv struct { api.UnimplementedTrendsServant diff --git a/internal/service/admin.go b/internal/service/admin.go index 451a551f..47ac6659 100644 --- a/internal/service/admin.go +++ b/internal/service/admin.go @@ -16,9 +16,7 @@ import ( "github.com/rocboss/paopao-ce/internal/servants" ) -var ( - _ Service = (*adminService)(nil) -) +var _ Service = (*adminService)(nil) type adminService struct { *baseHttpService diff --git a/internal/service/bot.go b/internal/service/bot.go index ff2bd615..62d245e6 100644 --- a/internal/service/bot.go +++ b/internal/service/bot.go @@ -16,9 +16,7 @@ import ( "github.com/rocboss/paopao-ce/internal/servants" ) -var ( - _ Service = (*botService)(nil) -) +var _ Service = (*botService)(nil) type botService struct { *baseHttpService diff --git a/internal/service/docs.go b/internal/service/docs.go index 86983dbd..013ecec1 100644 --- a/internal/service/docs.go +++ b/internal/service/docs.go @@ -14,9 +14,7 @@ import ( "github.com/rocboss/paopao-ce/internal/servants" ) -var ( - _ Service = (*docsService)(nil) -) +var _ Service = (*docsService)(nil) type docsService struct { *baseHttpService diff --git a/internal/service/frontend_web.go b/internal/service/frontend_web.go index 2ed1e116..7873c8a5 100644 --- a/internal/service/frontend_web.go +++ b/internal/service/frontend_web.go @@ -14,9 +14,7 @@ import ( "github.com/rocboss/paopao-ce/internal/servants" ) -var ( - _ Service = (*frontendWebService)(nil) -) +var _ Service = (*frontendWebService)(nil) type frontendWebService struct { *baseHttpService diff --git a/internal/service/grpc_server.go b/internal/service/grpc_server.go index 6b8589db..23d92da5 100644 --- a/internal/service/grpc_server.go +++ b/internal/service/grpc_server.go @@ -10,9 +10,7 @@ import ( "google.golang.org/grpc" ) -var ( - _ server = (*grpcServer)(nil) -) +var _ server = (*grpcServer)(nil) // grpcServer wraper for grpc.Server type grpcServer struct { diff --git a/internal/service/http_server.go b/internal/service/http_server.go index 1a412ce9..f34eef2a 100644 --- a/internal/service/http_server.go +++ b/internal/service/http_server.go @@ -11,9 +11,7 @@ import ( "github.com/gin-gonic/gin" ) -var ( - _ server = (*httpServer)(nil) -) +var _ server = (*httpServer)(nil) // httpServer wraper for gin.engine and http.Server type httpServer struct { diff --git a/internal/service/localoss.go b/internal/service/localoss.go index 0a561ed4..b0789acc 100644 --- a/internal/service/localoss.go +++ b/internal/service/localoss.go @@ -15,9 +15,7 @@ import ( "github.com/rocboss/paopao-ce/internal/servants" ) -var ( - _ Service = (*localossService)(nil) -) +var _ Service = (*localossService)(nil) type localossService struct { *baseHttpService diff --git a/internal/service/metrics.go b/internal/service/metrics.go index 57c7c625..fb81bfb6 100644 --- a/internal/service/metrics.go +++ b/internal/service/metrics.go @@ -17,9 +17,7 @@ import ( "github.com/rocboss/paopao-ce/internal/infra/metrics/statistics" ) -var ( - _ Service = (*metricsService)(nil) -) +var _ Service = (*metricsService)(nil) type metricsService struct { *baseHttpService diff --git a/internal/service/mobile.go b/internal/service/mobile.go index 8d88056e..8b74b06f 100644 --- a/internal/service/mobile.go +++ b/internal/service/mobile.go @@ -16,9 +16,7 @@ import ( "google.golang.org/grpc" ) -var ( - _ Service = (*mobileService)(nil) -) +var _ Service = (*mobileService)(nil) type mobileService struct { *baseGRPCService diff --git a/internal/service/pprof.go b/internal/service/pprof.go index 97501c32..731c70c1 100644 --- a/internal/service/pprof.go +++ b/internal/service/pprof.go @@ -13,9 +13,7 @@ import ( "github.com/rocboss/paopao-ce/internal/conf" ) -var ( - _ Service = (*pprofService)(nil) -) +var _ Service = (*pprofService)(nil) type pprofService struct { *baseHttpService diff --git a/internal/service/space.go b/internal/service/space.go index 989defe1..f4c7ae0b 100644 --- a/internal/service/space.go +++ b/internal/service/space.go @@ -16,9 +16,7 @@ import ( "github.com/rocboss/paopao-ce/internal/servants" ) -var ( - _ Service = (*spaceXService)(nil) -) +var _ Service = (*spaceXService)(nil) type spaceXService struct { *baseHttpService diff --git a/internal/service/web.go b/internal/service/web.go index ec1c353e..3c1ec97e 100644 --- a/internal/service/web.go +++ b/internal/service/web.go @@ -17,9 +17,7 @@ import ( "github.com/rocboss/paopao-ce/internal/servants" ) -var ( - _ Service = (*webService)(nil) -) +var _ Service = (*webService)(nil) type webService struct { *baseHttpService diff --git a/pkg/debug/errors.go b/pkg/debug/errors.go index 04a404ca..bed99e4a 100644 --- a/pkg/debug/errors.go +++ b/pkg/debug/errors.go @@ -8,6 +8,4 @@ import ( "errors" ) -var ( - ErrNotImplemented = errors.New("not implemented") -) +var ErrNotImplemented = errors.New("not implemented") diff --git a/pkg/http/client.go b/pkg/http/client.go index 150b23b1..feb12c16 100644 --- a/pkg/http/client.go +++ b/pkg/http/client.go @@ -11,9 +11,7 @@ import ( gp "github.com/alimy/tryst/pool" ) -var ( - _ AsyncClient = (*wormClient)(nil) -) +var _ AsyncClient = (*wormClient)(nil) const ( _minRequestBuf = 10 diff --git a/pkg/naming/snake_ns.go b/pkg/naming/snake_ns.go index 0c870931..5316d3f6 100644 --- a/pkg/naming/snake_ns.go +++ b/pkg/naming/snake_ns.go @@ -62,7 +62,8 @@ func NewSnakeNamingStrategy() NamingStrategy { "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "LHS", "QPS", "RAM", "RHS", "RPC", "SLA", "SMTP", "SSH", "TLS", "TTL", "UID", "UI", "UUID", "URI", "URL", "UTF8", - "VM", "XML", "XSRF", "XSS"} + "VM", "XML", "XSRF", "XSS", + } var oldnews []string for _, initialism := range initialisms { diff --git a/pkg/obx/obx.go b/pkg/obx/obx.go index 0a6b2c0f..661b0ad2 100644 --- a/pkg/obx/obx.go +++ b/pkg/obx/obx.go @@ -12,9 +12,7 @@ import ( hx "github.com/rocboss/paopao-ce/pkg/http" ) -var ( - _ OpenObserveClient = (*obxClient)(nil) -) +var _ OpenObserveClient = (*obxClient)(nil) const ( _userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" diff --git a/pkg/types/json_box.go b/pkg/types/json_box.go index 7a83e950..8d8b7478 100644 --- a/pkg/types/json_box.go +++ b/pkg/types/json_box.go @@ -47,7 +47,6 @@ func (j *JsonBox[T]) UnmarshalJSON(data []byte) error { return errors.New("JsonBox.UnmarshalJSON: on nil pointer") } return json.Unmarshal(data, &j.data) - } func (j *JsonBox[T]) Value() (driver.Value, error) { diff --git a/pkg/utils/banner.go b/pkg/utils/banner.go index 6862273d..2e4d6195 100644 --- a/pkg/utils/banner.go +++ b/pkg/utils/banner.go @@ -11,7 +11,6 @@ import ( ) func PrintHelloBanner(text string) { - fmt.Println(" ____ __ __ ____ __ __ ") fmt.Println("( _ \\ / _\\ / \\( _ \\ / _\\ / \\ ") fmt.Println(" ) __// \\( O )) __// \\( O )") diff --git a/pkg/utils/str.go b/pkg/utils/str.go index 199ad092..c5943283 100644 --- a/pkg/utils/str.go +++ b/pkg/utils/str.go @@ -20,8 +20,10 @@ const ( CLEAR // 去除部分易混淆的字符 ) -var fontKinds = [][]int{{10, 48}, {26, 97}, {26, 65}} -var letters = []byte("34578acdefghjkmnpqstwxyABCDEFGHJKMNPQRSVWXY") +var ( + fontKinds = [][]int{{10, 48}, {26, 97}, {26, 65}} + letters = []byte("34578acdefghjkmnpqstwxyABCDEFGHJKMNPQRSVWXY") +) // 生成随机字符串 // size 个数 kind 模式 diff --git a/pkg/version/build.go b/pkg/version/build.go index 6f156cc6..69e435bf 100644 --- a/pkg/version/build.go +++ b/pkg/version/build.go @@ -10,9 +10,7 @@ import ( "time" ) -var ( - BuildTime = time.Now() -) +var BuildTime = time.Now() func init() { exe, err := os.Executable() diff --git a/pkg/xerror/xerror.go b/pkg/xerror/xerror.go index 6f575732..c7295164 100644 --- a/pkg/xerror/xerror.go +++ b/pkg/xerror/xerror.go @@ -12,11 +12,9 @@ import ( "github.com/alimy/mir/v5" ) -var ( - _ mir.Error = (*Error)(nil) +var _ mir.Error = (*Error)(nil) - // codes = map[int]string{} -) +// codes = map[int]string{} type Error struct { code int diff --git a/pkg/zinc/zinc.go b/pkg/zinc/zinc.go index 4f44bb78..76c6ad8e 100644 --- a/pkg/zinc/zinc.go +++ b/pkg/zinc/zinc.go @@ -126,7 +126,6 @@ func (c *ZincClient) ExistIndex(name string) bool { // 新增/更新文档 func (c *ZincClient) PutDoc(name string, id int64, doc any) (bool, error) { resp, err := c.request().SetBody(doc).Put(fmt.Sprintf("/api/%s/_doc/%d", name, id)) - if err != nil { return false, err }