From dcdc121ea62db72bcf0983c841603fc803931a9d Mon Sep 17 00:00:00 2001 From: David Hollinger Date: Fri, 22 Nov 2024 21:09:22 -0600 Subject: [PATCH] replace deprecated ioutil import with io `io/ioutil` has been deprecated since Go 1.16 and this application is now on Go 1.23, so replacing it with `io` the replacement stable package. --- lib/chatops/rcserver/rcserver.go | 4 ++-- lib/parsers/azure-devops.go | 4 ++-- lib/parsers/gitea.go | 4 ++-- lib/parsers/github.go | 4 ++-- lib/parsers/gitlab.go | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/chatops/rcserver/rcserver.go b/lib/chatops/rcserver/rcserver.go index 1e2670b..7ac9645 100644 --- a/lib/chatops/rcserver/rcserver.go +++ b/lib/chatops/rcserver/rcserver.go @@ -3,7 +3,7 @@ package rcserver import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "net/url" @@ -44,7 +44,7 @@ func parseAttachment(data string) []Attachment { } func handlePostMessage(w http.ResponseWriter, r *http.Request) { - body, _ := ioutil.ReadAll(r.Body) + body, _ := io.ReadAll(r.Body) kvs := strings.Split(string(body), "&") m := make(map[string]string) diff --git a/lib/parsers/azure-devops.go b/lib/parsers/azure-devops.go index 8bfc6f7..b1f483f 100644 --- a/lib/parsers/azure-devops.go +++ b/lib/parsers/azure-devops.go @@ -3,7 +3,7 @@ package parsers import ( "encoding/json" "fmt" - "io/ioutil" + "io" "strings" "github.com/gin-gonic/gin" @@ -13,7 +13,7 @@ import ( // parseAzureDevops processes an Azure DevOps webhook, extracting event details such as branch, module name, and repository info. // It handles the PushEvent type and marks the data as completed and successful upon successful parsing. func (d *Data) parseAzureDevops(c *gin.Context) error { - payload, err := ioutil.ReadAll(c.Request.Body) + payload, err := io.ReadAll(c.Request.Body) if err != nil { return err } diff --git a/lib/parsers/gitea.go b/lib/parsers/gitea.go index afbaeb5..1efa4d1 100644 --- a/lib/parsers/gitea.go +++ b/lib/parsers/gitea.go @@ -2,7 +2,7 @@ package parsers import ( "fmt" - "io/ioutil" + "io" "net/http" api "code.gitea.io/gitea/modules/structs" @@ -17,7 +17,7 @@ func giteaWebhookType(r *http.Request) string { // parseGitea processes a Gitea webhook, extracting branch, repository, and user information. // Handles "push" events to set relevant fields based on the payload. func (d *Data) parseGitea(c *gin.Context) error { - payload, err := ioutil.ReadAll(c.Request.Body) + payload, err := io.ReadAll(c.Request.Body) if err != nil { return err } diff --git a/lib/parsers/github.go b/lib/parsers/github.go index 7d1ea81..ece3de9 100644 --- a/lib/parsers/github.go +++ b/lib/parsers/github.go @@ -2,7 +2,7 @@ package parsers import ( "fmt" - "io/ioutil" + "io" "strings" "github.com/gin-gonic/gin" @@ -12,7 +12,7 @@ import ( // parseGithub processes a GitHub webhook, extracting branch, repository, and user information. // Handles both "push" and "workflow_run" events to set relevant fields based on the payload. func (d *Data) parseGithub(c *gin.Context) error { - payload, err := ioutil.ReadAll(c.Request.Body) + payload, err := io.ReadAll(c.Request.Body) if err != nil { return err } diff --git a/lib/parsers/gitlab.go b/lib/parsers/gitlab.go index ab66fa9..7d80275 100644 --- a/lib/parsers/gitlab.go +++ b/lib/parsers/gitlab.go @@ -2,7 +2,7 @@ package parsers import ( "fmt" - "io/ioutil" + "io" "strings" "github.com/gin-gonic/gin" @@ -10,7 +10,7 @@ import ( ) func (d *Data) parseGitlab(c *gin.Context) error { - payload, err := ioutil.ReadAll(c.Request.Body) + payload, err := io.ReadAll(c.Request.Body) if err != nil { return err }