Skip to content

Commit

Permalink
Fix compat with go1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
kivutar committed Nov 14, 2019
1 parent 74b0a51 commit 520ad7f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions history/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"io"
"log"
"os"
"os/user"
"path/filepath"
)

// Game represents a game in the history file
Expand Down Expand Up @@ -46,12 +48,12 @@ func Push(g Game) {

// Load loads history.csv in memory
func Load() error {
homeDir, err := os.UserHomeDir()
usr, err := user.Current()
if err != nil {
return err
}

file, err := os.Open(homeDir + "/.ludo/history.csv")
file, err := os.Open(filepath.Join(usr.HomeDir, ".ludo", "history.csv"))
if err != nil {
return err
}
Expand Down Expand Up @@ -81,12 +83,12 @@ func Load() error {

// Save persists the history as a csv file
func Save() error {
homeDir, err := os.UserHomeDir()
usr, err := user.Current()
if err != nil {
return err
}

file, err := os.Create(homeDir + "/.ludo/history.csv")
file, err := os.Create(filepath.Join(usr.HomeDir, ".ludo", "history.csv"))
if err != nil {
return err
}
Expand Down

0 comments on commit 520ad7f

Please sign in to comment.