diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index f32ca8da1..e0c25f2c7 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -164,10 +164,10 @@ func init() { // it will panic cannot find config/config.yaml bytes, err := ioutil.ReadFile(Root + "/config/config.yaml") if err != nil { - panic(err) + panic(err.Error()) } if err = yaml.Unmarshal(bytes, &Config); err != nil { - panic(err) + panic(err.Error()) } } diff --git a/pkg/common/db/model.go b/pkg/common/db/model.go index 494f8ffaf..becdd71b6 100644 --- a/pkg/common/db/model.go +++ b/pkg/common/db/model.go @@ -35,14 +35,14 @@ func init() { } mgoSession, err := mgo.DialWithInfo(mgoDailInfo) if err != nil { - panic(err) + panic(err.Error()) } DB.mgoSession = mgoSession DB.mgoSession.SetMode(mgo.Monotonic, true) c := DB.mgoSession.DB(config.Config.Mongo.DBDatabase).C(cChat) err = c.EnsureIndexKey("uid") if err != nil { - panic(err) + panic(err.Error()) } // redis pool init diff --git a/pkg/common/db/mysql.go b/pkg/common/db/mysql.go index 17370e15f..865571b7f 100644 --- a/pkg/common/db/mysql.go +++ b/pkg/common/db/mysql.go @@ -23,14 +23,14 @@ func initMysqlDB() { db, err := gorm.Open("mysql", dsn) if err != nil { log.Error("", "", dsn) - panic(err) + panic(err.Error()) } //Check the database and table during initialization sql := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s ;", config.Config.Mysql.DBDatabaseName) err = db.Exec(sql).Error if err != nil { - panic(err) + panic(err.Error()) } db.Close() @@ -38,7 +38,7 @@ func initMysqlDB() { config.Config.Mysql.DBUserName, config.Config.Mysql.DBPassword, config.Config.Mysql.DBAddress[0], config.Config.Mysql.DBDatabaseName) db, err = gorm.Open("mysql", dsn) if err != nil { - panic(err) + panic(err.Error()) } sqlTable := "CREATE TABLE IF NOT EXISTS `user` (" + @@ -56,7 +56,7 @@ func initMysqlDB() { " ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;" err = db.Exec(sqlTable).Error if err != nil { - panic(err) + panic(err.Error()) } sqlTable = "CREATE TABLE IF NOT EXISTS `friend` (" + @@ -69,7 +69,7 @@ func initMysqlDB() { " ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;" err = db.Exec(sqlTable).Error if err != nil { - panic(err) + panic(err.Error()) } sqlTable = "CREATE TABLE IF NOT EXISTS `friend_request` (" + @@ -82,7 +82,7 @@ func initMysqlDB() { " ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;" err = db.Exec(sqlTable).Error if err != nil { - panic(err) + panic(err.Error()) } sqlTable = "CREATE TABLE IF NOT EXISTS `black_list` (" + @@ -94,7 +94,7 @@ func initMysqlDB() { " ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;" err = db.Exec(sqlTable).Error if err != nil { - panic(err) + panic(err.Error()) } sqlTable = "CREATE TABLE IF NOT EXISTS `user_black_list` (" + @@ -105,7 +105,7 @@ func initMysqlDB() { " ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;" err = db.Exec(sqlTable).Error if err != nil { - panic(err) + panic(err.Error()) } sqlTable = "CREATE TABLE IF NOT EXISTS `group` (" + @@ -120,7 +120,7 @@ func initMysqlDB() { " ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;" err = db.Exec(sqlTable).Error if err != nil { - panic(err) + panic(err.Error()) } sqlTable = "CREATE TABLE IF NOT EXISTS `group_member` (" + @@ -134,7 +134,7 @@ func initMysqlDB() { " ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;" err = db.Exec(sqlTable).Error if err != nil { - panic(err) + panic(err.Error()) } sqlTable = "CREATE TABLE IF NOT EXISTS `group_request` (" + @@ -155,7 +155,7 @@ func initMysqlDB() { " ) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8mb4;" err = db.Exec(sqlTable).Error if err != nil { - panic(err) + panic(err.Error()) } sqlTable = "CREATE TABLE IF NOT EXISTS `chat_log` (" + @@ -173,7 +173,7 @@ func initMysqlDB() { " ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;" err = db.Exec(sqlTable).Error if err != nil { - panic(err) + panic(err.Error()) } } diff --git a/pkg/common/kafka/consumer.go b/pkg/common/kafka/consumer.go index eed6ef142..771145906 100644 --- a/pkg/common/kafka/consumer.go +++ b/pkg/common/kafka/consumer.go @@ -20,14 +20,14 @@ func NewKafkaConsumer(addr []string, topic string) *Consumer { consumer, err := sarama.NewConsumer(p.addr, nil) if err != nil { - panic(err) + panic(err.Error()) return nil } p.Consumer = consumer partitionList, err := consumer.Partitions(p.Topic) if err != nil { - panic(err) + panic(err.Error()) return nil } p.PartitionList = partitionList diff --git a/pkg/common/kafka/consumer_group.go b/pkg/common/kafka/consumer_group.go index 4c4af5033..3af714373 100644 --- a/pkg/common/kafka/consumer_group.go +++ b/pkg/common/kafka/consumer_group.go @@ -30,11 +30,11 @@ func NewMConsumerGroup(consumerConfig *MConsumerGroupConfig, topics, addr []stri config.Consumer.Return.Errors = consumerConfig.IsReturnErr client, err := sarama.NewClient(addr, config) if err != nil { - panic(err) + panic(err.Error()) } consumerGroup, err := sarama.NewConsumerGroupFromClient(groupID, client) if err != nil { - panic(err) + panic(err.Error()) } return &MConsumerGroup{ consumerGroup, @@ -47,7 +47,7 @@ func (mc *MConsumerGroup) RegisterHandleAndConsumer(handler sarama.ConsumerGroup for { err := mc.ConsumerGroup.Consume(ctx, mc.topics, handler) if err != nil { - panic(err) + panic(err.Error()) } } } diff --git a/pkg/common/kafka/producer.go b/pkg/common/kafka/producer.go index c82df975f..98ad92209 100644 --- a/pkg/common/kafka/producer.go +++ b/pkg/common/kafka/producer.go @@ -25,7 +25,7 @@ func NewKafkaProducer(addr []string, topic string) *Producer { producer, err := sarama.NewSyncProducer(p.addr, p.config) //Initialize the client if err != nil { - panic(err) + panic(err.Error()) return nil } p.producer = producer diff --git a/pkg/common/log/logrus.go b/pkg/common/log/logrus.go index b88a6f6d3..03b768eca 100644 --- a/pkg/common/log/logrus.go +++ b/pkg/common/log/logrus.go @@ -34,7 +34,7 @@ func loggerInit(moduleName string) *Logger { //Close std console output src, err := os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, os.ModeAppend) if err != nil { - panic(err) + panic(err.Error()) } writer := bufio.NewWriter(src) logger.SetOutput(writer) @@ -82,7 +82,7 @@ func initRotateLogs(rotationTime time.Duration, maxRemainNum uint, level string, rotatelogs.WithRotationCount(maxRemainNum), ) if err != nil { - panic(err) + panic(err.Error()) } else { return writer } diff --git a/pkg/utils/get_server_ip.go b/pkg/utils/get_server_ip.go index b7f6076c2..239c75a19 100644 --- a/pkg/utils/get_server_ip.go +++ b/pkg/utils/get_server_ip.go @@ -17,7 +17,7 @@ func init() { // see https://gist.github.com/jniltinho/9787946#gistcomment-3019898 conn, err := net.Dial("udp", "8.8.8.8:80") if err != nil { - panic(err) + panic(err.Error()) } defer conn.Close()