21 lines
478 B
Go
21 lines
478 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
)
|
|
|
|
func DefaultCacheRoot(userCacheDir func() (string, error)) (string, error) {
|
|
if userCacheDir == nil {
|
|
return "", fmt.Errorf("user cache directory resolver must not be nil")
|
|
}
|
|
root, err := userCacheDir()
|
|
if err != nil {
|
|
return "", fmt.Errorf("resolve user cache directory: %w", err)
|
|
}
|
|
if root == "" {
|
|
return "", fmt.Errorf("user cache directory must not be empty")
|
|
}
|
|
return filepath.Join(root, "notarius"), nil
|
|
}
|