From 7c2d9d084f2f607e3d4a0bbc9660e3a1e478d5b5 Mon Sep 17 00:00:00 2001 From: Allen Date: Fri, 14 Feb 2020 18:05:28 +0530 Subject: [PATCH] Fix some quality issues, add .deepsource.toml Signed-off-by: Allen --- .deepsource.toml | 13 +++++++++++++ cmd/sachet/main.go | 2 +- provider/aliyun/aliyun.go | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .deepsource.toml diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 0000000..8a8f402 --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,13 @@ +version = 1 +test_patterns = [ + "*_test.go" +] +exclude_patterns = [ + "examples/**", + "vendor/**" +] +[[analyzers]] +name = "go" +enabled = true + [analyzers.meta] + import_path = "github.com/messagebird/sachet" diff --git a/cmd/sachet/main.go b/cmd/sachet/main.go index eb07f74..af322a0 100644 --- a/cmd/sachet/main.go +++ b/cmd/sachet/main.go @@ -218,7 +218,7 @@ func errorHandler(w http.ResponseWriter, status int, err error, provider string) } // respond json bytes, _ := json.Marshal(data) - json := string(bytes[:]) + json := string(bytes) fmt.Fprint(w, json) log.Println("Error: " + json) diff --git a/provider/aliyun/aliyun.go b/provider/aliyun/aliyun.go index d66bbb2..6f76b1d 100644 --- a/provider/aliyun/aliyun.go +++ b/provider/aliyun/aliyun.go @@ -52,7 +52,7 @@ func (aliyun *Aliyun) Send(message sachet.Message) error { var response *dysmsapi.SendSmsResponse response, err = aliyun.client.SendSms(request) if err == nil && (!response.IsSuccess() || response.Code != "OK") { - err = fmt.Errorf(response.String()) + return fmt.Errorf(response.String()) } } default: