// checkFilePath checks if the todo.txt is created under root folder
// Create it if it doesnt exist
checkFilePath checks if the todo.txt is created under root folder
Create it if it doesnt exist
// checkFilePath checks if the todo . txt is created under root folder // Create it if it doesnt exist
func checkFilePath() (string, error) {
	home, err := homedir.Dir()
	if err != nil {
		return "", err
	}
	path := filepath.Join(home, "todo.txt")
	if _, err := os.Stat(path); os.IsNotExist(err) {
		file, err := os.Create(path)
		if err != nil {
			return "", err
		}
		defer file.Close()
		fmt.Printf("\nNo existing TODO file. \nNew TODO file created  - %s \n\n", path)
		return "", err
	} else {
	}
	return path, nil
}
func checkFilePath ( ) ( string , error ) { home , err := homedir . Dir ( ) if err != nil { return " " , err } path := filepath . Join ( home , " " ) if _ , err := os . Stat ( path ) ; os . IsNotExist ( err ) { file , err := os . Create ( path ) if err != nil { return " " , err } defer file . Close ( ) fmt . Printf ( " \n \n \n \n " , path ) return " " , err } else { } return path , nil }
checkFilePath checks if the todo.txt is created under root folder
Create it if it doesnt exist
checkFilePath checks if the todo . txt is created under root folder Create it if it doesnt exist
// Create file // Normal case // fmt.Printf("\nUsing TODO file  - %s \n\n", path)