feat: deprecated ioutil

main
Tran Hau 2021-03-17 05:13:28 +00:00
parent 616b403203
commit fc961796ea
1 changed files with 2 additions and 3 deletions

View File

@ -2,7 +2,6 @@ package main
import ( import (
"fmt" "fmt"
"io/ioutil"
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
@ -220,7 +219,7 @@ func (a *action) getVersion() (string, error) {
func (a *action) generateMarkdownChangelog(output, version string, commits []convention.Commit) error { func (a *action) generateMarkdownChangelog(output, version string, commits []convention.Commit) error {
// If CHANGELOG file already exist // If CHANGELOG file already exist
var oldData string var oldData string
bytes, err := ioutil.ReadFile(output) bytes, err := os.ReadFile(output)
if err == nil { if err == nil {
oldData = string(bytes) oldData = string(bytes)
} }
@ -228,7 +227,7 @@ func (a *action) generateMarkdownChangelog(output, version string, commits []con
markdownGenerator := changelog.NewMarkdownGenerator(oldData, version, time.Now()) markdownGenerator := changelog.NewMarkdownGenerator(oldData, version, time.Now())
newData := markdownGenerator.Generate(commits) newData := markdownGenerator.Generate(commits)
if err := ioutil.WriteFile(output, []byte(newData), 0o644); err != nil { if err := os.WriteFile(output, []byte(newData), 0o644); err != nil {
return fmt.Errorf("failed to write file %s: %w", output, err) return fmt.Errorf("failed to write file %s: %w", output, err)
} }