just use gofumpt instead to fmt source code

pull/699/head
alimy 8 months ago
parent 24f35a18d5
commit 4fb7beb25d
No known key found for this signature in database
GPG Key ID: 6964A0C5FE15145A

@ -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 PROJECT = paopao-ce
TARGET = paopao TARGET = paopao
@ -22,6 +22,7 @@ BUILD_VERSION := $(shell git describe --tags --always)
BUILD_DATE := $(shell date +'%Y-%m-%d %H:%M:%S %Z') BUILD_DATE := $(shell date +'%Y-%m-%d %H:%M:%S %Z')
SHA_SHORT := $(shell git rev-parse --short HEAD) SHA_SHORT := $(shell git rev-parse --short HEAD)
GOFMT ?= gofumpt -l -w
MOD_NAME = github.com/rocboss/paopao-ce MOD_NAME = github.com/rocboss/paopao-ce
LDFLAGS = -X "${MOD_NAME}/pkg/version.version=${BUILD_VERSION}" \ LDFLAGS = -X "${MOD_NAME}/pkg/version.version=${BUILD_VERSION}" \
-X "${MOD_NAME}/pkg/version.buildDate=${BUILD_DATE}" \ -X "${MOD_NAME}/pkg/version.buildDate=${BUILD_DATE}" \
@ -84,18 +85,18 @@ generate: gen-mir gen-rpc gen-enum
.PHONY: gen-mir .PHONY: gen-mir
gen-mir: gen-mir:
@go generate mirc/gen.go @go generate mirc/gen.go
@go fmt ./auto/api/... $(GOFMT) ./auto/api
.PHONY: gen-rpc .PHONY: gen-rpc
gen-rpc: gen-rpc:
@rm -rf auto/rpc @rm -rf auto/rpc
@buf generate proto buf generate proto
@go fmt ./auto/rpc/... $(GOFMT) ./auto/rpc
.PHONY: gen-enum .PHONY: gen-enum
gen-enum: gen-enum:
@go generate ./internal/model/enum/... @go generate ./internal/model/enum/...
go fmt ./internal/model/enum/... $(GOFMT) ./internal/model/enum
.PHONY: proto-mod .PHONY: proto-mod
proto-mod: proto-mod:
@ -111,8 +112,9 @@ clean:
fmt: fmt:
@echo Formatting... @echo Formatting...
@go fmt ./internal/... $(GOFMT) .
@go fmt ./pkg/...
vet:
@go vet -composites=false ./internal/... @go vet -composites=false ./internal/...
@go vet -composites=false ./pkg/... @go vet -composites=false ./pkg/...
@ -125,6 +127,7 @@ pre-commit: fmt
.PHONY: install-tools .PHONY: install-tools
install-tools: install-protobuf-plugins install-tools: install-protobuf-plugins
@go install github.com/abice/go-enum@latest @go install github.com/abice/go-enum@latest
@go install mvdan.cc/gofumpt@latest
.PHONY: install-protobuf-plugins .PHONY: install-protobuf-plugins
install-protobuf-plugins: install-protobuf-plugins:

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.36.6 // protoc-gen-go v1.36.11
// protoc (unknown) // protoc (unknown)
// source: core/v1/auth.proto // source: core/v1/auth.proto

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT. // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions: // versions:
// - protoc-gen-go-grpc v1.5.1 // - protoc-gen-go-grpc v1.6.0
// - protoc (unknown) // - protoc (unknown)
// source: core/v1/auth.proto // source: core/v1/auth.proto
@ -89,13 +89,13 @@ type AuthenticateServiceServer interface {
type UnimplementedAuthenticateServiceServer struct{} type UnimplementedAuthenticateServiceServer struct{}
func (UnimplementedAuthenticateServiceServer) PreLogin(context.Context, *User) (*ActionReply, error) { 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) { 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) { 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) mustEmbedUnimplementedAuthenticateServiceServer() {}
func (UnimplementedAuthenticateServiceServer) testEmbeddedByValue() {} func (UnimplementedAuthenticateServiceServer) testEmbeddedByValue() {}
@ -108,7 +108,7 @@ type UnsafeAuthenticateServiceServer interface {
} }
func RegisterAuthenticateServiceServer(s grpc.ServiceRegistrar, srv AuthenticateServiceServer) { 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 // embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization // unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O. // time to prevent it from happening at runtime later due to I/O.

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.36.6 // protoc-gen-go v1.36.11
// protoc (unknown) // protoc (unknown)
// source: greet/v1/greet.proto // source: greet/v1/greet.proto

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT. // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions: // versions:
// - protoc-gen-go-grpc v1.5.1 // - protoc-gen-go-grpc v1.6.0
// - protoc (unknown) // - protoc (unknown)
// source: greet/v1/greet.proto // source: greet/v1/greet.proto
@ -63,7 +63,7 @@ type GreetServiceServer interface {
type UnimplementedGreetServiceServer struct{} type UnimplementedGreetServiceServer struct{}
func (UnimplementedGreetServiceServer) Greet(context.Context, *GreetRequest) (*GreetResponse, error) { 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) mustEmbedUnimplementedGreetServiceServer() {}
func (UnimplementedGreetServiceServer) testEmbeddedByValue() {} func (UnimplementedGreetServiceServer) testEmbeddedByValue() {}
@ -76,7 +76,7 @@ type UnsafeGreetServiceServer interface {
} }
func RegisterGreetServiceServer(s grpc.ServiceRegistrar, srv GreetServiceServer) { 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 // embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization // unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O. // time to prevent it from happening at runtime later due to I/O.

@ -8,13 +8,11 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var ( var rootCmd = &cobra.Command{
rootCmd = &cobra.Command{
Use: "paopao", Use: "paopao",
Short: `an artistic "twitter like" community`, Short: `an artistic "twitter like" community`,
Long: `an artistic "twitter like" community`, Long: `an artistic "twitter like" community`,
} }
)
// Setup set root command name,short-describe, long-describe // Setup set root command name,short-describe, long-describe
// return &cobra.Command to custom other options // return &cobra.Command to custom other options

@ -9,9 +9,7 @@ import (
"github.com/allegro/bigcache/v3" "github.com/allegro/bigcache/v3"
) )
var ( var _ tweetsCache = (*bigCacheTweetsCache)(nil)
_ tweetsCache = (*bigCacheTweetsCache)(nil)
)
type bigCacheTweetsCache struct { type bigCacheTweetsCache struct {
bc *bigcache.BigCache bc *bigcache.BigCache

@ -15,9 +15,7 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var ( var _onceInit sync.Once
_onceInit sync.Once
)
func NewRedisCache() core.RedisCache { func NewRedisCache() core.RedisCache {
return &redisCache{ return &redisCache{

@ -12,9 +12,7 @@ import (
"gorm.io/gorm" "gorm.io/gorm"
) )
var ( var _ core.AuthorizationManageService = (*authorizationManageSrv)(nil)
_ core.AuthorizationManageService = (*authorizationManageSrv)(nil)
)
type authorizationManageSrv struct { type authorizationManageSrv struct {
db *gorm.DB db *gorm.DB

@ -14,9 +14,7 @@ import (
"gorm.io/gorm" "gorm.io/gorm"
) )
var ( var _ core.ContactManageService = (*contactManageSrv)(nil)
_ core.ContactManageService = (*contactManageSrv)(nil)
)
type contactManageSrv struct { type contactManageSrv struct {
db *gorm.DB db *gorm.DB

@ -20,8 +20,10 @@ type Model struct {
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag" json:"is_del"` IsDel soft_delete.DeletedAt `gorm:"softDelete:flag" json:"is_del"`
} }
type ConditionsT map[string]any type (
type Predicates map[string][]any ConditionsT map[string]any
Predicates map[string][]any
)
func (m *Model) BeforeCreate(tx *gorm.DB) (err error) { func (m *Model) BeforeCreate(tx *gorm.DB) (err error) {
nowTime := time.Now().Unix() nowTime := time.Now().Unix()

@ -24,15 +24,13 @@ const (
ContentTypeChargeAttachment ContentTypeChargeAttachment
) )
var ( var mediaContentType = []PostContentT{
mediaContentType = []PostContentT{
ContentTypeImage, ContentTypeImage,
ContentTypeVideo, ContentTypeVideo,
ContentTypeAudio, ContentTypeAudio,
ContentTypeAttachment, ContentTypeAttachment,
ContentTypeChargeAttachment, ContentTypeChargeAttachment,
} }
)
type PostContent struct { type PostContent struct {
*Model *Model

@ -12,9 +12,7 @@ import (
"gorm.io/gorm" "gorm.io/gorm"
) )
var ( var _ core.FollowingManageService = (*followingManageSrv)(nil)
_ core.FollowingManageService = (*followingManageSrv)(nil)
)
type followingManageSrv struct { type followingManageSrv struct {
db *gorm.DB db *gorm.DB

@ -12,9 +12,7 @@ import (
"gorm.io/gorm" "gorm.io/gorm"
) )
var ( var _ core.MessageService = (*messageSrv)(nil)
_ core.MessageService = (*messageSrv)(nil)
)
type messageSrv struct { type messageSrv struct {
db *gorm.DB db *gorm.DB

@ -15,9 +15,7 @@ import (
"gorm.io/gorm" "gorm.io/gorm"
) )
var ( var _ core.SecurityService = (*securitySrv)(nil)
_ core.SecurityService = (*securitySrv)(nil)
)
type securitySrv struct { type securitySrv struct {
db *gorm.DB db *gorm.DB

@ -250,7 +250,6 @@ func (s *tweetManageSrv) DeletePost(post *ms.Post) ([]string, error) {
return nil return nil
}, },
) )
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -15,9 +15,7 @@ import (
"gorm.io/gorm" "gorm.io/gorm"
) )
var ( var _ core.UserManageService = (*userManageSrv)(nil)
_ core.UserManageService = (*userManageSrv)(nil)
)
type userManageSrv struct { type userManageSrv struct {
db *gorm.DB db *gorm.DB

@ -12,9 +12,7 @@ import (
"gorm.io/gorm" "gorm.io/gorm"
) )
var ( var _ core.WalletService = (*walletSrv)(nil)
_ core.WalletService = (*walletSrv)(nil)
)
type walletSrv struct { type walletSrv struct {
db *gorm.DB db *gorm.DB
@ -35,6 +33,7 @@ func (s *walletSrv) GetRechargeByID(id int64) (*ms.WalletRecharge, error) {
return recharge.Get(s.db) return recharge.Get(s.db)
} }
func (s *walletSrv) CreateRecharge(userId, amount int64) (*ms.WalletRecharge, error) { func (s *walletSrv) CreateRecharge(userId, amount int64) (*ms.WalletRecharge, error) {
recharge := &dbr.WalletRecharge{ recharge := &dbr.WalletRecharge{
UserID: userId, UserID: userId,

@ -12,9 +12,7 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var ( var _ core.TweetSearchService = (*bridgeTweetSearchServant)(nil)
_ core.TweetSearchService = (*bridgeTweetSearchServant)(nil)
)
type documents struct { type documents struct {
primaryKey []string primaryKey []string

@ -12,9 +12,7 @@ import (
"github.com/rocboss/paopao-ce/internal/core" "github.com/rocboss/paopao-ce/internal/core"
) )
var ( var _ core.AttachmentCheckService = (*attachmentCheckServant)(nil)
_ core.AttachmentCheckService = (*attachmentCheckServant)(nil)
)
type attachmentCheckServant struct { type attachmentCheckServant struct {
domain string domain string

@ -12,9 +12,7 @@ import (
"gopkg.in/resty.v1" "gopkg.in/resty.v1"
) )
var ( var _ core.PhoneVerifyService = (*juheSmsServant)(nil)
_ core.PhoneVerifyService = (*juheSmsServant)(nil)
)
type juhePhoneCaptchaRsp struct { type juhePhoneCaptchaRsp struct {
ErrorCode int `json:"error_code"` ErrorCode int `json:"error_code"`

@ -120,7 +120,6 @@ func (s *cosServant) IsObjectExist(objectKey string) (bool, error) {
func (s *cosServant) SignURL(objectKey string, expiredInSec int64) (string, error) { func (s *cosServant) SignURL(objectKey string, expiredInSec int64) (string, error) {
signedURL, err := s.client.Object.GetPresignedURL(context.Background(), signedURL, err := s.client.Object.GetPresignedURL(context.Background(),
http.MethodGet, objectKey, conf.COSSetting.SecretID, conf.COSSetting.SecretKey, time.Second*time.Duration(expiredInSec), nil) http.MethodGet, objectKey, conf.COSSetting.SecretID, conf.COSSetting.SecretKey, time.Second*time.Duration(expiredInSec), nil)
if err != nil { if err != nil {
logrus.Errorf("client.SignURL err: %v", err) logrus.Errorf("client.SignURL err: %v", err)
return "", err return "", err

@ -45,7 +45,7 @@ type localossServant struct {
func (s *localossCreateServant) PutObject(objectKey string, reader io.Reader, objectSize int64, contentType string, _persistance bool) (string, error) { func (s *localossCreateServant) PutObject(objectKey string, reader io.Reader, objectSize int64, contentType string, _persistance bool) (string, error) {
saveDir := s.savePath + filepath.Dir(objectKey) saveDir := s.savePath + filepath.Dir(objectKey)
err := os.MkdirAll(saveDir, 0750) err := os.MkdirAll(saveDir, 0o750)
if err != nil && !os.IsExist(err) { if err != nil && !os.IsExist(err) {
return "", err return "", err
} }
@ -80,7 +80,7 @@ func (s *localossCreateTempDirServant) PutObject(objectKey string, reader io.Rea
objectName = s.tempDir + objectKey objectName = s.tempDir + objectKey
} }
saveDir := s.savePath + filepath.Dir(objectName) saveDir := s.savePath + filepath.Dir(objectName)
err := os.MkdirAll(saveDir, 0750) err := os.MkdirAll(saveDir, 0o750)
if err != nil && !os.IsExist(err) { if err != nil && !os.IsExist(err) {
return "", err return "", err
} }
@ -112,7 +112,7 @@ func (s *localossCreateTempDirServant) PersistObject(objectKey string) error {
} }
saveDir := s.savePath + filepath.Dir(objectKey) 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 return err
} }

@ -1,8 +1,8 @@
// Code generated by go-enum DO NOT EDIT. // Code generated by go-enum DO NOT EDIT.
// Version: v0.7.0 // Version: 0.9.2
// Revision: 03ade876e762757c985a1cde66576bd63f75d7cd // Revision: 9d73c76728916582359433d1eb0b27340a8268b7
// Build Date: 2025-04-20T09:27:58+0000 // Build Date: 2025-10-17T20:10:48Z
// Built By: alimy // Built By: goreleaser
package enum package enum
@ -112,6 +112,14 @@ func (x *Boolean) UnmarshalText(text []byte) error {
return nil 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 var errBooleanNilPtr = errors.New("value pointer is nil") // one per type for package clashes
// Scan implements the Scanner interface. // Scan implements the Scanner interface.

@ -69,11 +69,15 @@ type SendWhisperReq struct {
Content string `json:"content" binding:"required"` Content string `json:"content" binding:"required"`
} }
type GetCollectionsReq BasePageReq type (
type GetCollectionsResp base.PageResp GetCollectionsReq BasePageReq
GetCollectionsResp base.PageResp
)
type GetStarsReq BasePageReq type (
type GetStarsResp base.PageResp GetStarsReq BasePageReq
GetStarsResp base.PageResp
)
type UserPhoneBindReq struct { type UserPhoneBindReq struct {
BaseInfo `json:"-" binding:"-"` BaseInfo `json:"-" binding:"-"`

@ -13,9 +13,7 @@ import (
"github.com/rocboss/paopao-ce/pkg/xerror" "github.com/rocboss/paopao-ce/pkg/xerror"
) )
var ( var bindAny = base.NewBindAnyFn()
bindAny = base.NewBindAnyFn()
)
type BaseInfo struct { type BaseInfo struct {
User *ms.User User *ms.User

@ -9,9 +9,7 @@ import (
"github.com/rocboss/paopao-ce/internal/servants/base" "github.com/rocboss/paopao-ce/internal/servants/base"
) )
var ( var _ api.User = (*userSrv)(nil)
_ api.User = (*userSrv)(nil)
)
type userSrv struct { type userSrv struct {
*base.BaseServant *base.BaseServant

@ -137,7 +137,6 @@ func bindAnySentry(c *gin.Context, obj any) error {
setter.SetPageInfo(page, pageSize) setter.SetPageInfo(page, pageSize)
} }
return nil return nil
} }
func RenderAny(c *gin.Context, data any, err error) { func RenderAny(c *gin.Context, data any, err error) {

@ -9,9 +9,7 @@ import (
"github.com/rocboss/paopao-ce/internal/servants/base" "github.com/rocboss/paopao-ce/internal/servants/base"
) )
var ( var _ api.User = (*userSrv)(nil)
_ api.User = (*userSrv)(nil)
)
type userSrv struct { type userSrv struct {
*base.BaseServant *base.BaseServant

@ -9,9 +9,7 @@ import (
"github.com/rocboss/paopao-ce/internal/servants/base" "github.com/rocboss/paopao-ce/internal/servants/base"
) )
var ( var _ api.User = (*userSrv)(nil)
_ api.User = (*userSrv)(nil)
)
type userSrv struct { type userSrv struct {
*base.BaseServant *base.BaseServant

@ -8,9 +8,7 @@ import (
api "github.com/rocboss/paopao-ce/auto/rpc/greet/v1" api "github.com/rocboss/paopao-ce/auto/rpc/greet/v1"
) )
var ( var _ api.GreetServiceServer = (*greetServiceSrv)(nil)
_ api.GreetServiceServer = (*greetServiceSrv)(nil)
)
type greetServiceSrv struct { type greetServiceSrv struct {
api.UnimplementedGreetServiceServer api.UnimplementedGreetServiceServer

@ -9,9 +9,7 @@ import (
"github.com/rocboss/paopao-ce/internal/servants/base" "github.com/rocboss/paopao-ce/internal/servants/base"
) )
var ( var _ api.User = (*userSrv)(nil)
_ api.User = (*userSrv)(nil)
)
type userSrv struct { type userSrv struct {
*base.BaseServant *base.BaseServant

@ -18,9 +18,7 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var ( var _ api.Admin = (*adminSrv)(nil)
_ api.Admin = (*adminSrv)(nil)
)
type adminSrv struct { type adminSrv struct {
api.UnimplementedAdminServant api.UnimplementedAdminServant

@ -7,7 +7,6 @@ package web
import ( import (
"context" "context"
"fmt" "fmt"
"time" "time"
"unicode/utf8" "unicode/utf8"
@ -30,9 +29,7 @@ var (
_maxCaptchaTimes int = 2 _maxCaptchaTimes int = 2
) )
var ( var _ api.Core = (*coreSrv)(nil)
_ api.Core = (*coreSrv)(nil)
)
type coreSrv struct { type coreSrv struct {
api.UnimplementedCoreServant api.UnimplementedCoreServant

@ -15,9 +15,7 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var ( var _ api.Followship = (*followshipSrv)(nil)
_ api.Followship = (*followshipSrv)(nil)
)
type followshipSrv struct { type followshipSrv struct {
api.UnimplementedFollowshipServant api.UnimplementedFollowshipServant

@ -14,9 +14,7 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var ( var _ api.Friendship = (*friendshipSrv)(nil)
_ api.Friendship = (*friendshipSrv)(nil)
)
type friendshipSrv struct { type friendshipSrv struct {
api.UnimplementedFriendshipServant api.UnimplementedFriendshipServant

@ -21,9 +21,7 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var ( var _ api.Loose = (*looseSrv)(nil)
_ api.Loose = (*looseSrv)(nil)
)
type looseSrv struct { type looseSrv struct {
api.UnimplementedLooseServant api.UnimplementedLooseServant

@ -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, func (s *privSrv) createPostPreHandler(commentID int64, userID, atUserID int64) (*ms.Post, *ms.Comment, int64,
error) { error,
) {
// 加载Comment // 加载Comment
comment, err := s.Ds.GetCommentByID(commentID) comment, err := s.Ds.GetCommentByID(commentID)
if err != nil { if err != nil {

@ -27,9 +27,7 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var ( var _ api.Pub = (*pubSrv)(nil)
_ api.Pub = (*pubSrv)(nil)
)
const ( const (
_MaxLoginErrTimes = 10 _MaxLoginErrTimes = 10

@ -15,9 +15,7 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var ( var _ api.Relax = (*relaxSrv)(nil)
_ api.Relax = (*relaxSrv)(nil)
)
type relaxSrv struct { type relaxSrv struct {
api.UnimplementedRelaxServant api.UnimplementedRelaxServant

@ -12,9 +12,7 @@ import (
"github.com/rocboss/paopao-ce/pkg/version" "github.com/rocboss/paopao-ce/pkg/version"
) )
var ( var _ api.Site = (*siteSrv)(nil)
_ api.Site = (*siteSrv)(nil)
)
type siteSrv struct { type siteSrv struct {
api.UnimplementedSiteServant api.UnimplementedSiteServant

@ -18,9 +18,7 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var ( var _ api.Trends = (*trendsSrv)(nil)
_ api.Trends = (*trendsSrv)(nil)
)
type trendsSrv struct { type trendsSrv struct {
api.UnimplementedTrendsServant api.UnimplementedTrendsServant

@ -16,9 +16,7 @@ import (
"github.com/rocboss/paopao-ce/internal/servants" "github.com/rocboss/paopao-ce/internal/servants"
) )
var ( var _ Service = (*adminService)(nil)
_ Service = (*adminService)(nil)
)
type adminService struct { type adminService struct {
*baseHttpService *baseHttpService

@ -16,9 +16,7 @@ import (
"github.com/rocboss/paopao-ce/internal/servants" "github.com/rocboss/paopao-ce/internal/servants"
) )
var ( var _ Service = (*botService)(nil)
_ Service = (*botService)(nil)
)
type botService struct { type botService struct {
*baseHttpService *baseHttpService

@ -14,9 +14,7 @@ import (
"github.com/rocboss/paopao-ce/internal/servants" "github.com/rocboss/paopao-ce/internal/servants"
) )
var ( var _ Service = (*docsService)(nil)
_ Service = (*docsService)(nil)
)
type docsService struct { type docsService struct {
*baseHttpService *baseHttpService

@ -14,9 +14,7 @@ import (
"github.com/rocboss/paopao-ce/internal/servants" "github.com/rocboss/paopao-ce/internal/servants"
) )
var ( var _ Service = (*frontendWebService)(nil)
_ Service = (*frontendWebService)(nil)
)
type frontendWebService struct { type frontendWebService struct {
*baseHttpService *baseHttpService

@ -10,9 +10,7 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
) )
var ( var _ server = (*grpcServer)(nil)
_ server = (*grpcServer)(nil)
)
// grpcServer wraper for grpc.Server // grpcServer wraper for grpc.Server
type grpcServer struct { type grpcServer struct {

@ -11,9 +11,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
var ( var _ server = (*httpServer)(nil)
_ server = (*httpServer)(nil)
)
// httpServer wraper for gin.engine and http.Server // httpServer wraper for gin.engine and http.Server
type httpServer struct { type httpServer struct {

@ -15,9 +15,7 @@ import (
"github.com/rocboss/paopao-ce/internal/servants" "github.com/rocboss/paopao-ce/internal/servants"
) )
var ( var _ Service = (*localossService)(nil)
_ Service = (*localossService)(nil)
)
type localossService struct { type localossService struct {
*baseHttpService *baseHttpService

@ -17,9 +17,7 @@ import (
"github.com/rocboss/paopao-ce/internal/infra/metrics/statistics" "github.com/rocboss/paopao-ce/internal/infra/metrics/statistics"
) )
var ( var _ Service = (*metricsService)(nil)
_ Service = (*metricsService)(nil)
)
type metricsService struct { type metricsService struct {
*baseHttpService *baseHttpService

@ -16,9 +16,7 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
) )
var ( var _ Service = (*mobileService)(nil)
_ Service = (*mobileService)(nil)
)
type mobileService struct { type mobileService struct {
*baseGRPCService *baseGRPCService

@ -13,9 +13,7 @@ import (
"github.com/rocboss/paopao-ce/internal/conf" "github.com/rocboss/paopao-ce/internal/conf"
) )
var ( var _ Service = (*pprofService)(nil)
_ Service = (*pprofService)(nil)
)
type pprofService struct { type pprofService struct {
*baseHttpService *baseHttpService

@ -16,9 +16,7 @@ import (
"github.com/rocboss/paopao-ce/internal/servants" "github.com/rocboss/paopao-ce/internal/servants"
) )
var ( var _ Service = (*spaceXService)(nil)
_ Service = (*spaceXService)(nil)
)
type spaceXService struct { type spaceXService struct {
*baseHttpService *baseHttpService

@ -17,9 +17,7 @@ import (
"github.com/rocboss/paopao-ce/internal/servants" "github.com/rocboss/paopao-ce/internal/servants"
) )
var ( var _ Service = (*webService)(nil)
_ Service = (*webService)(nil)
)
type webService struct { type webService struct {
*baseHttpService *baseHttpService

@ -8,6 +8,4 @@ import (
"errors" "errors"
) )
var ( var ErrNotImplemented = errors.New("not implemented")
ErrNotImplemented = errors.New("not implemented")
)

@ -11,9 +11,7 @@ import (
gp "github.com/alimy/tryst/pool" gp "github.com/alimy/tryst/pool"
) )
var ( var _ AsyncClient = (*wormClient)(nil)
_ AsyncClient = (*wormClient)(nil)
)
const ( const (
_minRequestBuf = 10 _minRequestBuf = 10

@ -62,7 +62,8 @@ func NewSnakeNamingStrategy() NamingStrategy {
"API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP",
"HTTPS", "ID", "IP", "JSON", "LHS", "QPS", "RAM", "RHS", "RPC", "SLA", "HTTPS", "ID", "IP", "JSON", "LHS", "QPS", "RAM", "RHS", "RPC", "SLA",
"SMTP", "SSH", "TLS", "TTL", "UID", "UI", "UUID", "URI", "URL", "UTF8", "SMTP", "SSH", "TLS", "TTL", "UID", "UI", "UUID", "URI", "URL", "UTF8",
"VM", "XML", "XSRF", "XSS"} "VM", "XML", "XSRF", "XSS",
}
var oldnews []string var oldnews []string
for _, initialism := range initialisms { for _, initialism := range initialisms {

@ -12,9 +12,7 @@ import (
hx "github.com/rocboss/paopao-ce/pkg/http" hx "github.com/rocboss/paopao-ce/pkg/http"
) )
var ( var _ OpenObserveClient = (*obxClient)(nil)
_ OpenObserveClient = (*obxClient)(nil)
)
const ( 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" _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"

@ -47,7 +47,6 @@ func (j *JsonBox[T]) UnmarshalJSON(data []byte) error {
return errors.New("JsonBox.UnmarshalJSON: on nil pointer") return errors.New("JsonBox.UnmarshalJSON: on nil pointer")
} }
return json.Unmarshal(data, &j.data) return json.Unmarshal(data, &j.data)
} }
func (j *JsonBox[T]) Value() (driver.Value, error) { func (j *JsonBox[T]) Value() (driver.Value, error) {

@ -11,7 +11,6 @@ import (
) )
func PrintHelloBanner(text string) { func PrintHelloBanner(text string) {
fmt.Println(" ____ __ __ ____ __ __ ") fmt.Println(" ____ __ __ ____ __ __ ")
fmt.Println("( _ \\ / _\\ / \\( _ \\ / _\\ / \\ ") fmt.Println("( _ \\ / _\\ / \\( _ \\ / _\\ / \\ ")
fmt.Println(" ) __// \\( O )) __// \\( O )") fmt.Println(" ) __// \\( O )) __// \\( O )")

@ -20,8 +20,10 @@ const (
CLEAR // 去除部分易混淆的字符 CLEAR // 去除部分易混淆的字符
) )
var fontKinds = [][]int{{10, 48}, {26, 97}, {26, 65}} var (
var letters = []byte("34578acdefghjkmnpqstwxyABCDEFGHJKMNPQRSVWXY") fontKinds = [][]int{{10, 48}, {26, 97}, {26, 65}}
letters = []byte("34578acdefghjkmnpqstwxyABCDEFGHJKMNPQRSVWXY")
)
// 生成随机字符串 // 生成随机字符串
// size 个数 kind 模式 // size 个数 kind 模式

@ -10,9 +10,7 @@ import (
"time" "time"
) )
var ( var BuildTime = time.Now()
BuildTime = time.Now()
)
func init() { func init() {
exe, err := os.Executable() exe, err := os.Executable()

@ -12,11 +12,9 @@ import (
"github.com/alimy/mir/v5" "github.com/alimy/mir/v5"
) )
var ( var _ mir.Error = (*Error)(nil)
_ mir.Error = (*Error)(nil)
// codes = map[int]string{} // codes = map[int]string{}
)
type Error struct { type Error struct {
code int code int

@ -126,7 +126,6 @@ func (c *ZincClient) ExistIndex(name string) bool {
// 新增/更新文档 // 新增/更新文档
func (c *ZincClient) PutDoc(name string, id int64, doc any) (bool, error) { 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)) resp, err := c.request().SetBody(doc).Put(fmt.Sprintf("/api/%s/_doc/%d", name, id))
if err != nil { if err != nil {
return false, err return false, err
} }

Loading…
Cancel
Save