stop using ioutil
Signed-off-by: Naman Sood <mail@nsood.in>
This commit is contained in:
parent
f223051b68
commit
038695d123
2 changed files with 4 additions and 5 deletions
4
page.go
4
page.go
|
@ -3,7 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
|
|
||||||
"github.com/aymerick/raymond"
|
"github.com/aymerick/raymond"
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
|
@ -31,7 +31,7 @@ type Page struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPage(slug string) (*Page, error) {
|
func newPage(slug string) (*Page, error) {
|
||||||
data, err := ioutil.ReadFile("posts/" + slug + ".md")
|
data, err := os.ReadFile("posts/" + slug + ".md")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not read file: %s", err)
|
return nil, fmt.Errorf("could not read file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -47,7 +46,7 @@ func newServer() (*server, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *server) refreshPages() error {
|
func (s *server) refreshPages() error {
|
||||||
files, err := ioutil.ReadDir("posts/")
|
files, err := os.ReadDir("posts/")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -136,7 +135,7 @@ func loadRegularStylesheet(filename string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *server) refreshStyles() error {
|
func (s *server) refreshStyles() error {
|
||||||
styles, err := ioutil.ReadDir("styles/")
|
styles, err := os.ReadDir("styles/")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Could not load styles directory: %s", err)
|
return fmt.Errorf("Could not load styles directory: %s", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue