| // Copyright 2015 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // xdgCacheDir returns the XDG Base Directory Specification cache |
| func xdgCacheDir() string { |
| cache := os.Getenv("XDG_CACHE_HOME") |
| home := os.Getenv("HOME") |
| // Not XDG but standard for OS X. |
| if runtime.GOOS == "darwin" { |
| return filepath.Join(home, "Library/Caches") |
| cache = filepath.Join(home, ".cache") |
| // xdgCreateDir creates a directory and its parents in accordance with |
| // the XDG Base Directory Specification. |
| func xdgCreateDir(path string) error { |
| return os.MkdirAll(path, 0700) |