aboutsummaryrefslogtreecommitdiffstats
path: root/util.go
blob: f5cec715dd8f2b9bd447dff68d34243971a8a14b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package main

import (
    "runtime"
    "path/filepath"
    "fmt"
    "os"
)

func GetDefaultConfigDir() string {
    return filepath.Join(Homedir(), ".gdrive")
}

func GetDefaultTokenFilePath() string {
    return filepath.Join(GetDefaultConfigDir(), "token_v2.json")
}

func Homedir() string {
	if runtime.GOOS == "windows" {
		return os.Getenv("APPDATA")
	}
	return os.Getenv("HOME")
}

func ExitF(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
	fmt.Println("")
	os.Exit(1)
}