diff --git a/db_test.go b/db_test.go index 4996d5e..6d4632e 100644 --- a/db_test.go +++ b/db_test.go @@ -4,6 +4,7 @@ import ( "database/sql" "log" "os" + "path/filepath" "reflect" "testing" ) @@ -201,16 +202,8 @@ func TestGetTasksByStatus(t *testing.T) { } } -func cleanTempDir() string { - tmp := os.TempDir() - if tmp[len(tmp)-1] != '/' { - return tmp + "/" - } - return tmp -} - func setup() *taskDB { - path := cleanTempDir() + "test.db" + path := filepath.Join(os.TempDir(), "test.db") db, err := sql.Open("sqlite3", path) if err != nil { log.Fatal(err) diff --git a/main.go b/main.go index 90beacf..ff96102 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "os" + "path/filepath" _ "github.com/mattn/go-sqlite3" gap "github.com/muesli/go-app-paths" @@ -38,7 +39,7 @@ func setupPath() string { // openDB opens a SQLite database and stores that database in our special spot. func openDB(path string) (*taskDB, error) { - db, err := sql.Open("sqlite3", fmt.Sprintf("%s/tasks.db", path)) + db, err := sql.Open("sqlite3", filepath.Join(path, "tasks.db")) if err != nil { return nil, err }