blogposts: refactor, create newPost func
This commit is contained in:
parent
6292463e90
commit
dec5f045a7
@ -33,6 +33,12 @@ func getPost(fileSystem fs.FS, f fs.DirEntry) (Post, error) {
|
|||||||
}
|
}
|
||||||
defer postFile.Close()
|
defer postFile.Close()
|
||||||
|
|
||||||
|
return newPost(postFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: Does newPost have to be coupled to an fs.File ?
|
||||||
|
// Do we use all the methods and data from this type? What do we really need?
|
||||||
|
func newPost(postFile fs.File) (Post, error) {
|
||||||
postData, err := io.ReadAll(postFile)
|
postData, err := io.ReadAll(postFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Post{}, err
|
return Post{}, err
|
||||||
|
Loading…
Reference in New Issue
Block a user