remove ioutil

master
Niko Abeler 2 months ago
parent 0a3af85b02
commit a42da82516
  1. 4
      post.go
  2. 3
      repository.go
  3. 3
      user.go
  4. 5
      user_test.go

@ -3,8 +3,8 @@ package owl
import (
"bytes"
"errors"
"io/ioutil"
"net/url"
"os"
"path"
"sort"
"sync"
@ -155,7 +155,7 @@ func (post *Post) Meta() PostMeta {
func (post *Post) Content() []byte {
// read file
data, _ := ioutil.ReadFile(post.ContentFile())
data, _ := os.ReadFile(post.ContentFile())
return data
}

@ -3,7 +3,6 @@ package owl
import (
_ "embed"
"fmt"
"io/ioutil"
"os"
"path"
)
@ -102,7 +101,7 @@ func (repo Repository) FullUrl() string {
func (repo Repository) Template() (string, error) {
// load base.html
path := path.Join(repo.Dir(), "base.html")
base_html, err := ioutil.ReadFile(path)
base_html, err := os.ReadFile(path)
if err != nil {
return "", err
}

@ -2,7 +2,6 @@ package owl
import (
"fmt"
"io/ioutil"
"net/url"
"os"
"path"
@ -187,7 +186,7 @@ func (user User) CreateNewPost(title string, draft bool) (Post, error) {
func (user User) Template() (string, error) {
// load base.html
path := path.Join(user.Dir(), "meta", "base.html")
base_html, err := ioutil.ReadFile(path)
base_html, err := os.ReadFile(path)
if err != nil {
return "", err
}

@ -3,7 +3,6 @@ package owl_test
import (
"fmt"
"h4kor/owl-blogs"
"io/ioutil"
"os"
"path"
"testing"
@ -15,7 +14,7 @@ func TestCreateNewPostCreatesEntryInPublic(t *testing.T) {
user, _ := repo.CreateUser(randomUserName())
// Create a new post
user.CreateNewPost("testpost", false)
files, err := ioutil.ReadDir(path.Join(user.Dir(), "public"))
files, err := os.ReadDir(path.Join(user.Dir(), "public"))
if err != nil {
t.Error("Error reading directory")
}
@ -55,7 +54,7 @@ func TestCreateNewPostMultipleCalls(t *testing.T) {
user.CreateNewPost("testpost", false)
user.CreateNewPost("testpost", false)
user.CreateNewPost("testpost", false)
files, err := ioutil.ReadDir(path.Join(user.Dir(), "public"))
files, err := os.ReadDir(path.Join(user.Dir(), "public"))
if err != nil {
t.Error("Error reading directory")
}

Loading…
Cancel
Save