Skip to content

Instantly share code, notes, and snippets.

@syossan27
Last active December 22, 2018 03:12
Show Gist options
  • Select an option

  • Save syossan27/1869a9ce465b70465b1bd707efcb5dd9 to your computer and use it in GitHub Desktop.

Select an option

Save syossan27/1869a9ce465b70465b1bd707efcb5dd9 to your computer and use it in GitHub Desktop.
package foundation
import (
"os"
"github.com/mitchellh/go-homedir"
)
var (
homeDir, _ = homedir.Dir()
ConfigDirPath = homeDir + "/.en"
KeyPath = homeDir + "/.ssh/id_rsa"
// 接続情報管理ファイル
StorePath = homeDir + "/.en/store"
)
func MakeConfig() {
// 接続情報管理ファイルを置くディレクトリの確認、及び生成
if _, err := os.Stat(ConfigDirPath); err != nil {
err := os.Mkdir(ConfigDirPath, 0777)
if err != nil {
PrintError("Failed to create .en directory")
}
}
// 接続情報管理ファイルの確認、及び生成
if _, err := os.Stat(StorePath); err != nil {
_, err := os.Create(StorePath)
if err != nil {
PrintError("Failed to create store file")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment