|
1
|
|
|
/* |
|
2
|
|
|
* Copyright (c) 2023 Clive Walkden <[email protected]> |
|
3
|
|
|
* |
|
4
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
5
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
|
6
|
|
|
* in the Software without restriction, including without limitation the rights |
|
7
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
8
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
|
9
|
|
|
* furnished to do so, subject to the following conditions: |
|
10
|
|
|
* |
|
11
|
|
|
* The above copyright notice and this permission notice shall be included in all |
|
12
|
|
|
* copies or substantial portions of the Software. |
|
13
|
|
|
* |
|
14
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
15
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
16
|
|
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
17
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
18
|
|
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
19
|
|
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
20
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
21
|
|
|
* OTHER DEALINGS IN THE SOFTWARE. |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
package utils |
|
25
|
|
|
|
|
26
|
|
|
import ( |
|
27
|
|
|
"github.com/spf13/viper" |
|
28
|
|
|
"log" |
|
29
|
|
|
"os" |
|
30
|
|
|
) |
|
31
|
|
|
|
|
32
|
|
|
func UserHome() (homeDir string) { |
|
33
|
|
|
homeDir, err := os.UserHomeDir() |
|
34
|
|
|
if err != nil { |
|
35
|
|
|
log.Fatal(err) |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
if viper.GetBool("verbose") { |
|
39
|
|
|
log.Println("UserHome Directory: ", homeDir) |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
return homeDir |
|
43
|
|
|
} |
|
44
|
|
|
|