package folderPaths import ( "os" "runtime" ) func InitFolders() { dirs := []string{rootFolder(), buildPath(rootFolder(), "Chats"), buildPath(rootFolder(), "DirectMessages"), buildPath(rootFolder(), "Users")} for _, v := range dirs { if _, err := os.Stat(v); os.IsNotExist(err) { os.Mkdir(v, 0775) } } } func FileAtChatsFolder(fileName string) string { return buildPath(rootFolder(), "Chats", fileName+".txt") } func FileAtDirectMessagesFolder(fileName string) string { return buildPath(rootFolder(), "DirectMessages", fileName+".txt") } func FileAtUsersFolder(fileName string) string { return buildPath(rootFolder(), "Users", fileName+".txt") } func rootFolder() string { if runtime.GOOS == "windows" { return "C:\\Users\\username\\AppData\\Roaming\\ctfc" } home, _ := os.UserHomeDir() return home + "/Desktop/ctfc" } func buildPath(folders ...string) (path string) { sep := "/" if runtime.GOOS == "windows" { sep = "\\" } for i, v := range folders { path += v if i < len(folders)-1 { path += sep } } return }