aboutsummaryrefslogtreecommitdiffstats
path: root/util.go
blob: 44166961ce39dbbfce7f672415e5669ae4979797 (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
30
31
32
33
34
35
36
package main

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

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

func ConfigFilePath(basePath, name string) string {
    return filepath.Join(basePath, name)
}

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)
}

func checkErr(err error) {
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }
}