Merge pull request #5235 from testwill/fmt

chore: fmt modify
This commit is contained in:
Ming Deng 2023-06-08 22:40:24 +08:00 committed by GitHub
commit 444675a2ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 15 additions and 15 deletions

View File

@ -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 {

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -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
}
}

View File

@ -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++ {