From ca44b13a9bf78f3ef5a4d67214dba1e8c1dfab6b Mon Sep 17 00:00:00 2001 From: devhindo Date: Mon, 30 Dec 2024 23:09:41 +0200 Subject: [PATCH] Update Go version to 1.23 and replace ioutil with os package functions Signed-off-by: devhindo --- .github/workflows/add-catalog.yml | 2 +- assets/artifact-hub-pkg/go.mod | 2 +- assets/artifact-hub-pkg/package.go | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/add-catalog.yml b/.github/workflows/add-catalog.yml index cae5e77d18..9a18679d60 100644 --- a/.github/workflows/add-catalog.yml +++ b/.github/workflows/add-catalog.yml @@ -27,7 +27,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: '1.23' - name: Set env run: | diff --git a/assets/artifact-hub-pkg/go.mod b/assets/artifact-hub-pkg/go.mod index 84cec9c5bd..0a602fcb2e 100644 --- a/assets/artifact-hub-pkg/go.mod +++ b/assets/artifact-hub-pkg/go.mod @@ -1,6 +1,6 @@ module package.go -go 1.21.0 +go 1.23 require ( github.com/Masterminds/semver/v3 v3.2.1 diff --git a/assets/artifact-hub-pkg/package.go b/assets/artifact-hub-pkg/package.go index bf97617827..0608d05ec9 100644 --- a/assets/artifact-hub-pkg/package.go +++ b/assets/artifact-hub-pkg/package.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "os" @@ -114,7 +114,7 @@ func fetchCatalogPatterns() ([]byte, error) { } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, ErrReadRespBody(err) } @@ -209,11 +209,11 @@ func decodeURIComponent(encodedURI string) (string, error) { func writePatternFile(pattern CatalogPattern, versionDir, patternType, patternInfo, patternCaveats, compatibility, patternImageURL string) error { designFilePath := filepath.Join(versionDir, "design.yml") - if err := ioutil.WriteFile(designFilePath, []byte(pattern.PatternFile), 0644); err != nil { + if err := os.WriteFile(designFilePath, []byte(pattern.PatternFile), 0644); err != nil { return utils.ErrWriteFile(err, designFilePath) } - contenttemp, err := ioutil.ReadFile(designFilePath) + contenttemp, err := os.ReadFile(designFilePath) if err != nil { return utils.ErrReadFile(err, designFilePath) } @@ -299,7 +299,7 @@ URL: 'https://raw.githubusercontent.com/meshery/meshery.io/master/%s/%s/%s/desig downloadLink: %s/design.yml ---`, strings.TrimSpace(string(nameYAML)), version, pattern.UserID, userFullName, userInfo.AvatarURL, patternType, compatibility, pattern.ID, patternImageURL, patternInfo, patternCaveats, patternType, slugify(pattern.Name), pattern.ID, mesheryCatalogFilesDir, pattern.ID, version, pattern.ID) - if err := ioutil.WriteFile(fmt.Sprintf(filepath.Join("..", "..", "collections", "_catalog", patternType, pattern.ID+".md")), []byte(content), 0644); err != nil { + if err := os.WriteFile(fmt.Sprintf(filepath.Join("..", "..", "collections", "_catalog", patternType, pattern.ID+".md")), []byte(content), 0644); err != nil { return utils.ErrWriteFile(err, filepath.Join("..", "..", "collections", "_catalog", patternType, pattern.ID+".md")) } @@ -314,7 +314,7 @@ func fetchUserInfo(userID string) (UserInfo, error) { defer resp.Body.Close() var userInfo UserInfo - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return UserInfo{}, ErrReadRespBody(err) }