Skip to content

Commit

Permalink
Update inline.go
Browse files Browse the repository at this point in the history
Removed io/ioutil and updated
  • Loading branch information
zeushammer committed Mar 18, 2024
1 parent 66d98df commit 5453eda
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tools/inline.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ package tools

import (
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -55,32 +54,32 @@ func Inline(bs []byte, f func(string) ([]byte, error)) ([]byte, error) {
// '%inline("NAME")' is replaced with ReadFile(NAME).
func ReadFileWithInlines(filename string) ([]byte, error) {

bs, err := ioutil.ReadFile(filename)
bs, err := os.ReadFile(filename)
if err != nil {
return nil, err
}

dir := filepath.Dir(filename)
f := func(name string) ([]byte, error) {
return ioutil.ReadFile(dir + string(os.PathSeparator) + name)
return os.ReadFile(dir + string(os.PathSeparator) + name)
}

return Inline(bs, f)
}

// ReadFileWithInlines is a replacement for ioutil.ReadAll that adds
// ReadFileWithInlines is a replacement for io.ReadAll that adds
// automation Inline()ing based on the given directory.
//
// '%inline("NAME")' is replaced with ReadFile(NAME).
func ReadAllWithInlines(in io.Reader, dir string) ([]byte, error) {

bs, err := ioutil.ReadAll(in)
bs, err := io.ReadAll(in)
if err != nil {
return nil, err
}

f := func(name string) ([]byte, error) {
return ioutil.ReadFile(dir + string(os.PathSeparator) + name)
return os.ReadFile(dir + string(os.PathSeparator) + name)
}

return Inline(bs, f)
Expand Down

0 comments on commit 5453eda

Please sign in to comment.