From db7c837bfa822c1cba93ccc9620b96bd0e6d44f6 Mon Sep 17 00:00:00 2001 From: comp500 Date: Sat, 27 Apr 2019 14:22:59 +0100 Subject: [PATCH] Switch to DecodeFile because it's cleaner --- core/index.go | 7 +------ core/pack.go | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/core/index.go b/core/index.go index 3ae34f1..38dc22f 100644 --- a/core/index.go +++ b/core/index.go @@ -4,7 +4,6 @@ import ( "crypto/sha256" "encoding/hex" "io" - "io/ioutil" "os" "path/filepath" "sort" @@ -33,12 +32,8 @@ type IndexFile struct { // LoadIndex attempts to load the index file from a path func LoadIndex(indexFile string, flags Flags) (Index, error) { - data, err := ioutil.ReadFile(indexFile) - if err != nil { - return Index{}, err - } var index Index - if _, err := toml.Decode(string(data), &index); err != nil { + if _, err := toml.DecodeFile(indexFile, &index); err != nil { return Index{}, err } index.flags = flags diff --git a/core/pack.go b/core/pack.go index f80b26a..c3290f0 100644 --- a/core/pack.go +++ b/core/pack.go @@ -3,7 +3,6 @@ import ( "crypto/sha256" "encoding/hex" "io" - "io/ioutil" "os" "path/filepath" @@ -27,12 +26,8 @@ type Pack struct { // LoadPack loads the modpack metadata to a Pack struct func LoadPack(flags Flags) (Pack, error) { - data, err := ioutil.ReadFile(flags.PackFile) - if err != nil { - return Pack{}, err - } var modpack Pack - if _, err := toml.Decode(string(data), &modpack); err != nil { + if _, err := toml.DecodeFile(flags.PackFile, &modpack); err != nil { return Pack{}, err }