Skip to content

Commit

Permalink
chore: move off deprecated io/ioutil pkg funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
tjhop committed May 20, 2024
1 parent 8406683 commit 224bffa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
3 changes: 1 addition & 2 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package cmd

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -75,7 +74,7 @@ func init() {
func writeTemplateFile(filename string) error {
// create template file if it doesn't exist
if _, err := os.Stat(filename); os.IsNotExist(err) {
err := ioutil.WriteFile(filename, []byte(baseTemplateFileString), 0644)
err := os.WriteFile(filename, []byte(baseTemplateFileString), 0644)
if err != nil {
return fmt.Errorf("Failed to create template file: %v\n", err)
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package cmd

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -55,7 +54,7 @@ func showClipTemplate(filename string) error {
if _, err := os.Stat(filename); os.IsNotExist(err) {
fmt.Printf("Couldn't find a clip template with the name: '%s'\n", strings.TrimSuffix(filepath.Base(filename), filepath.Ext(filename)))
} else {
buf, err := ioutil.ReadFile(filename)
buf, err := os.ReadFile(filename)
if err != nil {
return fmt.Errorf("Failed to read template file: %v\n", err)
}
Expand Down
6 changes: 3 additions & 3 deletions helpers/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package helpers

import (
"fmt"
"io/ioutil"
"os"

"gopkg.in/yaml.v2"
)
Expand All @@ -38,7 +38,7 @@ type TemplateFile struct {
}

func LoadTemplateFile(filename string) (TemplateFile, error) {
bytes, err := ioutil.ReadFile(filename)
bytes, err := os.ReadFile(filename)
if err != nil {
return TemplateFile{}, err
}
Expand All @@ -58,7 +58,7 @@ func WriteConfigFile(filename string, data interface{}) error {
return fmt.Errorf("Could not marshal data:\n%#v\n...to yaml: %v", data, err)
}

err = ioutil.WriteFile(filename, bytes, 0644)
err = os.WriteFile(filename, bytes, 0644)
if err != nil {
return fmt.Errorf("Could not open file '%s' to write data: %v", filename, err)
}
Expand Down

0 comments on commit 224bffa

Please sign in to comment.