Chore: use iife replace init in some cases
This commit is contained in:
@ -9,21 +9,19 @@ import (
|
||||
const Name = "clash"
|
||||
|
||||
// Path is used to get the configuration path
|
||||
var Path *path
|
||||
|
||||
type path struct {
|
||||
homeDir string
|
||||
configFile string
|
||||
}
|
||||
|
||||
func init() {
|
||||
var Path = func() *path {
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
homeDir, _ = os.Getwd()
|
||||
}
|
||||
|
||||
homeDir = P.Join(homeDir, ".config", Name)
|
||||
Path = &path{homeDir: homeDir, configFile: "config.yaml"}
|
||||
return &path{homeDir: homeDir, configFile: "config.yaml"}
|
||||
}()
|
||||
|
||||
type path struct {
|
||||
homeDir string
|
||||
configFile string
|
||||
}
|
||||
|
||||
// SetHomeDir is used to set the configuration path
|
||||
|
Reference in New Issue
Block a user