mirror of
https://github.com/appleboy/drone-discord.git
synced 2026-06-04 10:23:47 +08:00
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:
@@ -6,7 +6,6 @@ linters:
|
||||
- durationcheck
|
||||
- errcheck
|
||||
- errorlint
|
||||
- exportloopref
|
||||
- gci
|
||||
- gofmt
|
||||
- goimports
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user