diff --git a/config/legacy.go b/config/legacy.go index d7973d36a..78f2ad478 100644 --- a/config/legacy.go +++ b/config/legacy.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -45,7 +45,7 @@ func MigrateCredentials(path string) (conf *Configuration, err error) { conf = &Configuration{} ini, err := ini.Load(path) if err != nil { - err = fmt.Errorf(" parse failed: %v\n", err) + err = fmt.Errorf(" parse failed: %v", err) return } @@ -81,7 +81,7 @@ func MigrateCredentials(path string) (conf *Configuration, err error) { func MigrateConfigure(path string, conf *Configuration) (err error) { ini, err := ini.Load(path) if err != nil { - err = fmt.Errorf("parse failed: %s\n", err) + err = fmt.Errorf("parse failed: %s", err) return } diff --git a/config/legacy_test.go b/config/legacy_test.go index 91d7c2043..405850f29 100644 --- a/config/legacy_test.go +++ b/config/legacy_test.go @@ -25,10 +25,9 @@ func TestMigrateCredentials(t *testing.T) { conf, err := MigrateCredentials("http://nicai") assert.Empty(t, conf) if runtime.GOOS == "windows" { - assert.EqualError(t, err, " parse failed: open http://nicai: The filename, directory name, or volume label syntax is incorrect.\n") + assert.EqualError(t, err, " parse failed: open http://nicai: The filename, directory name, or volume label syntax is incorrect.") } else { - assert.EqualError(t, err, " parse failed: open http://nicai: no such file or directory\n") - + assert.EqualError(t, err, " parse failed: open http://nicai: no such file or directory") } test, err := os.Create("test.ini") @@ -68,9 +67,9 @@ func TestMigrateConfigure(t *testing.T) { {Name: "aaa", Mode: AK, AccessKeyId: "sdf", AccessKeySecret: "ddf", OutputFormat: "json"}}} err := MigrateConfigure("http://nici", conf) if runtime.GOOS == "windows" { - assert.Equal(t, "parse failed: open http://nici: The filename, directory name, or volume label syntax is incorrect.\n", err.Error()) + assert.Equal(t, "parse failed: open http://nici: The filename, directory name, or volume label syntax is incorrect.", err.Error()) } else { - assert.Equal(t, "parse failed: open http://nici: no such file or directory\n", err.Error()) + assert.Equal(t, "parse failed: open http://nici: no such file or directory", err.Error()) } test, err := os.Create("testconf.ini") diff --git a/config/profile.go b/config/profile.go index 1846859d4..139c16cf6 100644 --- a/config/profile.go +++ b/config/profile.go @@ -422,7 +422,7 @@ func (cp *Profile) GetClientByCredentialsURI(config *sdk.Config, ctx *cli.Contex } if res.StatusCode != 200 { - return nil, fmt.Errorf("Get Credentials from %s failed, status code %d", uri, res.StatusCode) + return nil, fmt.Errorf("get credentials from %s failed, status code %d", uri, res.StatusCode) } body, err := io.ReadAll(res.Body) @@ -441,11 +441,11 @@ func (cp *Profile) GetClientByCredentialsURI(config *sdk.Config, ctx *cli.Contex var response Response err = json.Unmarshal(body, &response) if err != nil { - return nil, fmt.Errorf("Unmarshal credentials failed, the body %s", string(body)) + return nil, fmt.Errorf("unmarshal credentials failed, the body %s", string(body)) } if response.Code != "Success" { - return nil, fmt.Errorf("Get sts token err, Code is not Success") + return nil, fmt.Errorf("get sts token err, Code is not Success") } cred := credentials.NewStsTokenCredential(response.AccessKeyId, response.AccessKeySecret, response.SecurityToken)