nostrhコマンドをhostrに変更

This commit is contained in:
studiokaiji
2023-09-28 00:44:09 +09:00
parent acbb9280c3
commit b21a838401
14 changed files with 20 additions and 20 deletions

42
hostr/cmd/paths/paths.go Normal file
View File

@@ -0,0 +1,42 @@
package paths
import (
"os"
"path/filepath"
)
const BaseDirName = ".nostr-webhost"
func GetSettingsDirectory() (string, error) {
homeDir, err := os.UserHomeDir()
if err != nil {
return "", err
}
dirPath := filepath.Join(homeDir, BaseDirName)
_, err = os.Stat(dirPath)
if os.IsNotExist(err) {
// ディレクトリが存在しない場合に作成
err = os.Mkdir(dirPath, 0700)
if err != nil {
return "", err
}
} else if err != nil {
return "", nil
}
return dirPath, nil
}
func GetProjectRootDirectory() (string, error) {
// 実行中のバイナリの絶対パスを取得
exePath, err := os.Executable()
if err != nil {
return "", err
}
// ディレクトリパスを取得
dir := filepath.Dir(exePath)
return dir, nil
}