diff --git a/client/orm/migration/ddl.go b/client/orm/migration/ddl.go index ab452b49..bcbfdd5a 100644 --- a/client/orm/migration/ddl.go +++ b/client/orm/migration/ddl.go @@ -274,7 +274,7 @@ func (m *Migration) GetSQL() (sql string) { } if len(m.Primary) > 0 { - sql += fmt.Sprintf(",\n PRIMARY KEY( ") + sql += ",\n PRIMARY KEY( " } for index, column := range m.Primary { sql += fmt.Sprintf(" `%s`", column.Name) @@ -284,7 +284,7 @@ func (m *Migration) GetSQL() (sql string) { } if len(m.Primary) > 0 { - sql += fmt.Sprintf(")") + sql += ")" } for _, unique := range m.Uniques { @@ -295,7 +295,7 @@ func (m *Migration) GetSQL() (sql string) { sql += "," } } - sql += fmt.Sprintf(")") + sql += ")" } for _, foreign := range m.Foreigns { sql += fmt.Sprintf(",\n `%s` %s %s %s %s %s", foreign.Name, foreign.DataType, foreign.Unsign, foreign.Null, foreign.Inc, foreign.Default) @@ -356,7 +356,7 @@ func (m *Migration) GetSQL() (sql string) { } if len(m.Primary) > 0 { - sql += fmt.Sprintf("\n DROP PRIMARY KEY,") + sql += "\n DROP PRIMARY KEY," } for index, unique := range m.Uniques { diff --git a/core/config/json/json.go b/core/config/json/json.go index 098f0308..36ab6a75 100644 --- a/core/config/json/json.go +++ b/core/config/json/json.go @@ -99,12 +99,12 @@ func (c *JSONConfigContainer) sub(key string) (map[string]interface{}, error) { } value, ok := c.data[key] if !ok { - return nil, errors.New(fmt.Sprintf("key is not found: %s", key)) + return nil, fmt.Errorf("key is not found: %s", key) } res, ok := value.(map[string]interface{}) if !ok { - return nil, errors.New(fmt.Sprintf("the type of value is invalid, key: %s", key)) + return nil, fmt.Errorf("the type of value is invalid, key: %s", key) } return res, nil } diff --git a/core/config/xml/xml.go b/core/config/xml/xml.go index 1d7494b4..cd9d4e00 100644 --- a/core/config/xml/xml.go +++ b/core/config/xml/xml.go @@ -120,11 +120,11 @@ func (c *ConfigContainer) sub(key string) (map[string]interface{}, error) { } value, ok := c.data[key] if !ok { - return nil, errors.New(fmt.Sprintf("the key is not found: %s", key)) + return nil, fmt.Errorf("the key is not found: %s", key) } res, ok := value.(map[string]interface{}) if !ok { - return nil, errors.New(fmt.Sprintf("the value of this key is not a structure: %s", key)) + return nil, fmt.Errorf("the value of this key is not a structure: %s", key) } return res, nil } diff --git a/core/logs/alils/log_project.go b/core/logs/alils/log_project.go index f993003e..63200ece 100755 --- a/core/logs/alils/log_project.go +++ b/core/logs/alils/log_project.go @@ -45,7 +45,7 @@ func (p *LogProject) ListLogStore() (storeNames []string, err error) { "x-sls-bodyrawsize": "0", } - uri := fmt.Sprintf("/logstores") + uri := "/logstores" r, err := request(p, "GET", uri, h, nil) if err != nil { return diff --git a/core/logs/es/es.go b/core/logs/es/es.go index a07ee83c..d1ba452d 100644 --- a/core/logs/es/es.go +++ b/core/logs/es/es.go @@ -81,7 +81,7 @@ func (el *esLogger) Init(config string) error { if len(el.Formatter) > 0 { fmtr, ok := logs.GetFormatter(el.Formatter) if !ok { - return errors.New(fmt.Sprintf("the formatter with name: %s not found", el.Formatter)) + return fmt.Errorf("the formatter with name: %s not found", el.Formatter) } el.formatter = fmtr } diff --git a/core/utils/mail.go b/core/utils/mail.go index e685c449..0f1f95cc 100644 --- a/core/utils/mail.go +++ b/core/utils/mail.go @@ -120,7 +120,7 @@ func (e *Email) Bytes() ([]byte, error) { } // Create the body sections if e.Text != "" { - header.Set("Content-Type", fmt.Sprintf("text/plain; charset=UTF-8")) + header.Set("Content-Type", "text/plain; charset=UTF-8") header.Set("Content-Transfer-Encoding", "quoted-printable") if _, err := subWriter.CreatePart(header); err != nil { return nil, err @@ -131,7 +131,7 @@ func (e *Email) Bytes() ([]byte, error) { } } if e.HTML != "" { - header.Set("Content-Type", fmt.Sprintf("text/html; charset=UTF-8")) + header.Set("Content-Type", "text/html; charset=UTF-8") header.Set("Content-Transfer-Encoding", "quoted-printable") if _, err := subWriter.CreatePart(header); err != nil { return nil, err diff --git a/server/web/config.go b/server/web/config.go index 006201a6..b164f0df 100644 --- a/server/web/config.go +++ b/server/web/config.go @@ -505,7 +505,7 @@ func defaultRecoverPanic(ctx *context.Context, cfg *Config) { break } logs.Critical(fmt.Sprintf("%s:%d", file, line)) - stack = stack + fmt.Sprintln(fmt.Sprintf("%s:%d", file, line)) + stack += fmt.Sprintf("%s:%d\n", file, line) } if ctx.Output.Status != 0 { @@ -629,7 +629,7 @@ func assignConfig(ac config.Configer) error { for adaptor, cfg := range BConfig.Log.Outputs { err := logs.SetLogger(adaptor, cfg) if err != nil { - fmt.Fprintln(os.Stderr, fmt.Sprintf("%s with the config %q got err:%s", adaptor, cfg, err.Error())) + fmt.Fprintf(os.Stderr, "%s with the config %q got err:%s\n", adaptor, cfg, err.Error()) return err } } diff --git a/task/task_test.go b/task/task_test.go index 1fdfd4b9..98a3a059 100644 --- a/task/task_test.go +++ b/task/task_test.go @@ -147,7 +147,7 @@ func TestTask_Run(t *testing.T) { task := func(ctx context.Context) error { cnt++ fmt.Printf("Hello, world! %d \n", cnt) - return errors.New(fmt.Sprintf("Hello, world! %d", cnt)) + return fmt.Errorf("Hello, world! %d", cnt) } tk := NewTask("taska", "0/30 * * * * *", task) for i := 0; i < 200; i++ {