fix: make lint

Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
pull/1161/head
Xinwei Xiong(cubxxw) 2 years ago
parent 8dd6a05d38
commit c312a0c22e

@ -361,13 +361,17 @@ linters-settings:
- gorm.io/gorm - gorm.io/gorm
- gorm.io/driver/mysql - gorm.io/driver/mysql
- k8s.io/klog - k8s.io/klog
- github.com/allowed/module
- go.mongodb.org/mongo-driver/mongo
# - gopkg.in/yaml.v2 # - gopkg.in/yaml.v2
domains: # List of allowed module domains domains: # List of allowed module domains
- google.golang.org - google.golang.org
- gopkg.in - gopkg.in
- golang.org - golang.org
- github.com - github.com
- go.mongodb.org
- go.uber.org - go.uber.org
- openim.io
- go.etcd.io - go.etcd.io
blocked: blocked:
versions: versions:

@ -61,11 +61,11 @@ func run(port int) error {
if err != nil { if err != nil {
return err return err
} }
if err := client.CreateRpcRootNodes(config.Config.GetServiceNames()); err != nil { if err = client.CreateRpcRootNodes(config.Config.GetServiceNames()); err != nil {
return err return err
} }
fmt.Println("api register public config to discov") fmt.Println("api register public config to discov")
if err := client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.Config.EncodeConfig()); err != nil { if err = client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.Config.EncodeConfig()); err != nil {
return err return err
} }
fmt.Println("api register public config to discov success") fmt.Println("api register public config to discov success")
@ -82,7 +82,9 @@ func run(port int) error {
err = router.Run(address) err = router.Run(address)
if err != nil { if err != nil {
log.ZError(context.Background(), "api run failed ", err, "address", address) log.ZError(context.Background(), "api run failed ", err, "address", address)
return err return err
} }
return nil return nil
} }

@ -106,7 +106,7 @@ func (o *ThirdApi) ObjectRedirect(c *gin.Context) {
c.Redirect(http.StatusFound, resp.Url) c.Redirect(http.StatusFound, resp.Url)
} }
// #################### logs #################### // #################### logs ####################.
func (o *ThirdApi) UploadLogs(c *gin.Context) { func (o *ThirdApi) UploadLogs(c *gin.Context) {
a2r.Call(third.ThirdClient.UploadLogs, o.Client, c) a2r.Call(third.ThirdClient.UploadLogs, o.Client, c)
} }

@ -120,6 +120,7 @@ func (d *GWebSocket) SetReadLimit(limit int64) {
func (d *GWebSocket) SetPongHandler(handler PingPongHandler) { func (d *GWebSocket) SetPongHandler(handler PingPongHandler) {
d.conn.SetPongHandler(handler) d.conn.SetPongHandler(handler)
} }
func (d *GWebSocket) SetPingHandler(handler PingPongHandler) { func (d *GWebSocket) SetPingHandler(handler PingPongHandler) {
d.conn.SetPingHandler(handler) d.conn.SetPingHandler(handler)
} }

@ -69,7 +69,6 @@ func (t *thirdServer) UploadLogs(ctx context.Context, req *third.UploadLogsReq)
} }
func (t *thirdServer) DeleteLogs(ctx context.Context, req *third.DeleteLogsReq) (*third.DeleteLogsResp, error) { func (t *thirdServer) DeleteLogs(ctx context.Context, req *third.DeleteLogsReq) (*third.DeleteLogsResp, error) {
if err := authverify.CheckAdmin(ctx); err != nil { if err := authverify.CheckAdmin(ctx); err != nil {
return nil, err return nil, err
} }

@ -414,7 +414,8 @@ func (c *ConversationRedisCache) GetUserAllHasReadSeqs(
} }
func (c *ConversationRedisCache) DelUserAllHasReadSeqs(ownerUserID string, func (c *ConversationRedisCache) DelUserAllHasReadSeqs(ownerUserID string,
conversationIDs ...string) ConversationCache { conversationIDs ...string,
) ConversationCache {
cache := c.NewCache() cache := c.NewCache()
for _, conversationID := range conversationIDs { for _, conversationID := range conversationIDs {
cache.AddKeys(c.getConversationHasReadSeqKey(ownerUserID, conversationID)) cache.AddKeys(c.getConversationHasReadSeqKey(ownerUserID, conversationID))

@ -60,7 +60,6 @@ func (t *thirdDatabase) GetLogs(ctx context.Context, LogIDs []string, userID str
// SearchLogs implements ThirdDatabase. // SearchLogs implements ThirdDatabase.
func (t *thirdDatabase) SearchLogs(ctx context.Context, keyword string, start time.Time, end time.Time, pageNumber int32, showNumber int32) (uint32, []*relation.Log, error) { func (t *thirdDatabase) SearchLogs(ctx context.Context, keyword string, start time.Time, end time.Time, pageNumber int32, showNumber int32) (uint32, []*relation.Log, error) {
return t.logdb.Search(ctx, keyword, start, end, pageNumber, showNumber) return t.logdb.Search(ctx, keyword, start, end, pageNumber, showNumber)
} }
// UploadLogs implements ThirdDatabase. // UploadLogs implements ThirdDatabase.

@ -41,6 +41,7 @@ func (l *LogGorm) Get(ctx context.Context, logIDs []string, userID string) ([]*r
} }
return logs, errs.Wrap(l.db.WithContext(ctx).Where("log_id in ? and user_id=?", logIDs, userID).Find(&logs).Error) return logs, errs.Wrap(l.db.WithContext(ctx).Where("log_id in ? and user_id=?", logIDs, userID).Find(&logs).Error)
} }
func NewLogGorm(db *gorm.DB) relationtb.LogInterface { func NewLogGorm(db *gorm.DB) relationtb.LogInterface {
db.AutoMigrate(&relationtb.Log{}) db.AutoMigrate(&relationtb.Log{})
return &LogGorm{db: db} return &LogGorm{db: db}

@ -46,7 +46,7 @@ import (
) )
const ( const (
// defaultCfgPath is the default path of the configuration file // defaultCfgPath is the default path of the configuration file.
defaultCfgPath = "../../../../../config/config.yaml" defaultCfgPath = "../../../../../config/config.yaml"
minioHealthCheckDuration = 1 minioHealthCheckDuration = 1
maxRetry = 100 maxRetry = 100
@ -66,6 +66,7 @@ func initCfg() error {
if err != nil { if err != nil {
return err return err
} }
return yaml.Unmarshal(data, &config.Config) return yaml.Unmarshal(data, &config.Config)
} }
@ -79,6 +80,7 @@ func main() {
if err := initCfg(); err != nil { if err := initCfg(); err != nil {
fmt.Printf("Read config failed: %v\n", err) fmt.Printf("Read config failed: %v\n", err)
return return
} }
@ -111,22 +113,29 @@ func main() {
if allSuccess { if allSuccess {
successPrint("All components started successfully!") successPrint("All components started successfully!")
return return
} }
} }
os.Exit(1) os.Exit(1)
} }
func exactIP(urll string) string { func extractHost(urlStr string) (string, error) {
u, _ := url.Parse(urll) u, err := url.Parse(urlStr)
if err != nil {
return "", fmt.Errorf("unable to parse URL: %w", err)
}
host, _, err := net.SplitHostPort(u.Host) host, _, err := net.SplitHostPort(u.Host)
if err != nil { if err != nil {
host = u.Host host = u.Host
} }
if strings.HasSuffix(host, ":") { if strings.HasSuffix(host, ":") {
host = host[0 : len(host)-1] host = host[:len(host)-1]
} }
return host
return host, nil
} }
func checkMysql() error { func checkMysql() error {
@ -148,6 +157,7 @@ func checkMysql() error {
return errs.Wrap(err) return errs.Wrap(err)
} }
} }
return nil return nil
} }
@ -177,6 +187,7 @@ func checkMongo() error {
return errs.Wrap(err) return errs.Wrap(err)
} }
} }
return nil return nil
} }
@ -209,6 +220,7 @@ func checkMinio() error {
return ErrConfig.Wrap("apiURL or Minio SignEndpoint endpoint contain 127.0.0.1") return ErrConfig.Wrap("apiURL or Minio SignEndpoint endpoint contain 127.0.0.1")
} }
} }
return nil return nil
} }
@ -236,6 +248,7 @@ func checkRedis() error {
if err != nil { if err != nil {
return errs.Wrap(err) return errs.Wrap(err)
} }
return nil return nil
} }
@ -260,6 +273,7 @@ func checkZookeeper() error {
return errs.Wrap(err) return errs.Wrap(err)
} }
} }
return nil return nil
} }
@ -295,6 +309,7 @@ func checkKafka() error {
return ErrComponentStart.Wrap(fmt.Sprintf("kafka doesn't contain topic:%v", config.Config.Kafka.LatestMsgToRedis.Topic)) return ErrComponentStart.Wrap(fmt.Sprintf("kafka doesn't contain topic:%v", config.Config.Kafka.LatestMsgToRedis.Topic))
} }
} }
return nil return nil
} }

Loading…
Cancel
Save