diff options
| author | Petter Rasmussen | 2016-02-21 21:03:26 +0100 | 
|---|---|---|
| committer | Petter Rasmussen | 2016-02-21 21:03:26 +0100 | 
| commit | 1973512dd8edca24df4124fb3dfac4a432a0d481 (patch) | |
| tree | c61daefa5cf24eb2211ac816862697f9e0676d86 /util.go | |
| parent | 701c7f1991ae765a51b0b7404d1edbb2dc523055 (diff) | |
| download | gdrive-1973512dd8edca24df4124fb3dfac4a432a0d481.tar.bz2 | |
go fmt
Diffstat (limited to 'util.go')
| -rw-r--r-- | util.go | 102 | 
1 files changed, 51 insertions, 51 deletions
| @@ -1,21 +1,21 @@  package main  import ( -    "runtime" -    "path/filepath" -    "fmt" -    "encoding/json" -    "os" -    "io" -    "crypto/md5" +	"crypto/md5" +	"encoding/json" +	"fmt" +	"io" +	"os" +	"path/filepath" +	"runtime"  )  func GetDefaultConfigDir() string { -    return filepath.Join(Homedir(), ".gdrive") +	return filepath.Join(Homedir(), ".gdrive")  }  func ConfigFilePath(basePath, name string) string { -    return filepath.Join(basePath, name) +	return filepath.Join(basePath, name)  }  func Homedir() string { @@ -26,25 +26,25 @@ func Homedir() string {  }  func equal(a, b []string) bool { -    if a == nil && b == nil { -        return true; -    } +	if a == nil && b == nil { +		return true +	} -    if a == nil || b == nil { -        return false; -    } +	if a == nil || b == nil { +		return false +	} -    if len(a) != len(b) { -        return false -    } +	if len(a) != len(b) { +		return false +	} -    for i := range a { -        if a[i] != b[i] { -            return false -        } -    } +	for i := range a { +		if a[i] != b[i] { +			return false +		} +	} -    return true +	return true  }  func ExitF(format string, a ...interface{}) { @@ -54,37 +54,37 @@ func ExitF(format string, a ...interface{}) {  }  func checkErr(err error) { -    if err != nil { -        fmt.Println(err) -        os.Exit(1) -    } +	if err != nil { +		fmt.Println(err) +		os.Exit(1) +	}  }  func writeJson(path string, data interface{}) error { -    tmpFile := path + ".tmp" -    f, err := os.Create(tmpFile) -    if err != nil { -        return err -    } - -    err = json.NewEncoder(f).Encode(data) -    f.Close() -    if err != nil { -        os.Remove(tmpFile) -        return err -    } - -    return os.Rename(tmpFile, path) +	tmpFile := path + ".tmp" +	f, err := os.Create(tmpFile) +	if err != nil { +		return err +	} + +	err = json.NewEncoder(f).Encode(data) +	f.Close() +	if err != nil { +		os.Remove(tmpFile) +		return err +	} + +	return os.Rename(tmpFile, path)  }  func md5sum(path string) string { -    h := md5.New() -    f, err := os.Open(path) -    if err != nil { -        return "" -    } -    defer f.Close() - -    io.Copy(h, f) -    return fmt.Sprintf("%x", h.Sum(nil)) +	h := md5.New() +	f, err := os.Open(path) +	if err != nil { +		return "" +	} +	defer f.Close() + +	io.Copy(h, f) +	return fmt.Sprintf("%x", h.Sum(nil))  } | 
