mirror of
https://github.com/appleboy/drone-telegram.git
synced 2026-06-04 18:23:45 +08:00
refactor: refactor file handling and imports
- Change in main.go: Replaced `godotenv.Load(filename)` with `_ = godotenv.Load(filename)`
- Change in main.go: Replaced `godotenv.Overload("/run/drone/env")` with `_ = godotenv.Overload("/run/drone/env")`
- Change in plugin.go: Added import for "io"
- Change in plugin.go: Replaced `ioutil.ReadAll(r)` with `io.ReadAll(r)`
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
@@ -16,11 +16,11 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
// Load env-file if it exists first
|
// Load env-file if it exists first
|
||||||
if filename, found := os.LookupEnv("PLUGIN_ENV_FILE"); found {
|
if filename, found := os.LookupEnv("PLUGIN_ENV_FILE"); found {
|
||||||
godotenv.Load(filename)
|
_ = godotenv.Load(filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat("/run/drone/env"); err == nil {
|
if _, err := os.Stat("/run/drone/env"); err == nil {
|
||||||
godotenv.Overload("/run/drone/env")
|
_ = godotenv.Overload("/run/drone/env")
|
||||||
}
|
}
|
||||||
|
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -216,7 +217,7 @@ func loadTextFromFile(filename string) ([]string, error) {
|
|||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
r := bufio.NewReader(f)
|
r := bufio.NewReader(f)
|
||||||
content, err := ioutil.ReadAll(r)
|
content, err := io.ReadAll(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user