refactor: refactor HTTP request handling and improve linter settings

- Remove the `exportloopref` linter from the golangci configuration
- Add the `strconv` package import in `main.go`
- Replace the `fmt.Sprintf` for the year with `strconv.Itoa` to convert the year to a string
- Update the HTTP request method to use `http.MethodPost` instead of a string literal in `plugin.go`

Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
appleboy
2025-03-08 16:36:43 +08:00
parent 4d1d86d8c2
commit f2bd7836ef
3 changed files with 3 additions and 5 deletions
-1
View File
@@ -6,7 +6,6 @@ linters:
- durationcheck
- errcheck
- errorlint
- exportloopref
- gci
- gofmt
- goimports
+2 -3
View File
@@ -1,9 +1,9 @@
package main
import (
"fmt"
"log"
"os"
"strconv"
"time"
"github.com/joho/godotenv"
@@ -23,11 +23,10 @@ func main() {
_ = godotenv.Overload("/run/drone/env")
}
year := fmt.Sprintf("%v", time.Now().Year())
app := cli.NewApp()
app.Name = "Drone Discord"
app.Usage = "Sending message to Discord channel using Webhook"
app.Copyright = "Copyright (c) " + year + " Bo-Yi Wu"
app.Copyright = "Copyright (c) " + strconv.Itoa(time.Now().Year()) + " Bo-Yi Wu"
app.Authors = []*cli.Author{
{
Name: "Bo-Yi Wu",
+1 -1
View File
@@ -163,7 +163,7 @@ func newfileUploadRequest(uri string, params map[string]string, paramName, path
return nil, err
}
req, err := http.NewRequest("POST", uri, body)
req, err := http.NewRequest(http.MethodPost, uri, body)
req.Header.Set("Content-Type", writer.FormDataContentType())
return req, err
}