diff --git a/out/main.go b/out/main.go index 7733b09..5e0cd5f 100644 --- a/out/main.go +++ b/out/main.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" "log" "os" "path/filepath" @@ -23,7 +22,7 @@ func buildMessage(alert Alert, m concourse.BuildMetadata, path string) *slack.Me // Open and read message file if set if alert.MessageFile != "" { file := filepath.Join(path, alert.MessageFile) - f, err := ioutil.ReadFile(file) + f, err := os.ReadFile(file) if err != nil { fmt.Fprintf(os.Stderr, "error reading message_file: %v\nwill default to message instead\n", err) @@ -35,7 +34,7 @@ func buildMessage(alert Alert, m concourse.BuildMetadata, path string) *slack.Me // Open and read channel file if set if alert.ChannelFile != "" { file := filepath.Join(path, alert.ChannelFile) - f, err := ioutil.ReadFile(file) + f, err := os.ReadFile(file) if err != nil { fmt.Fprintf(os.Stderr, "error reading channel_file: %v\nwill default to channel instead\n", err) @@ -47,7 +46,7 @@ func buildMessage(alert Alert, m concourse.BuildMetadata, path string) *slack.Me // Open and read text file if set if alert.TextFile != "" { file := filepath.Join(path, alert.TextFile) - f, err := ioutil.ReadFile(file) + f, err := os.ReadFile(file) if err != nil { fmt.Fprintf(os.Stderr, "error reading text_file: %v\nwill default to text instead\n", err) diff --git a/out/main_test.go b/out/main_test.go index a4501c6..8931fc5 100644 --- a/out/main_test.go +++ b/out/main_test.go @@ -1,7 +1,6 @@ package main import ( - "io/ioutil" "net/http" "net/http/httptest" "os" @@ -354,14 +353,9 @@ func TestBuildMessage(t *testing.T) { t.Run(name, func(t *testing.T) { path := "" if c.alert.MessageFile != "" || c.alert.ChannelFile != "" { - dir, err := ioutil.TempDir("", "example") - if err != nil { - t.Fatal(err) - } - path = dir + path = t.TempDir() - defer os.RemoveAll(dir) - if err := ioutil.WriteFile(filepath.Join(dir, "test_file"), []byte("filecontents"), 0666); err != nil { + if err := os.WriteFile(filepath.Join(path, "test_file"), []byte("filecontents"), 0666); err != nil { t.Fatal(err) } }