// ReadTasks reads all the tasks from the todofile
ReadTasks reads all the tasks from the todofile
// ReadTasks reads all the tasks from the todofile
func ReadTasks(path string) ([]Task, error) {
	var tasks []Task
	file, err := os.Open(path)
	if err != nil {
		return tasks, err
	}
	defer file.Close()
	if err != nil {
		return tasks, err
	}
	scanner := bufio.NewScanner(file)
	for scanner.Scan() {
		line := scanner.Text()
		splits := strings.Split(line, ",")
		if len(splits) == 3 {
			date := strings.TrimSpace(splits[0])
			name := strings.TrimSpace(splits[1])
			done := strings.TrimSpace(splits[2])
			if done != "x" {
				done = " "
			}
			task := Task{
				Date: date,
				Name: name,
				Done: done,
			}
			tasks = append(tasks, task)
		} else {
		}
	}
	if err := scanner.Err(); err != nil {
		return tasks, err
	}
	return tasks, nil
}
func ReadTasks ( path string ) ( [ ] Task , error ) { var tasks [ ] Task file , err := os . Open ( path ) if err != nil { return tasks , err } defer file . Close ( ) if err != nil { return tasks , err } scanner := bufio . NewScanner ( file ) for scanner . Scan ( ) { line := scanner . Text ( ) splits := strings . Split ( line , " " ) if len ( splits ) == 3 { date := strings . TrimSpace ( splits [ 0 ] ) name := strings . TrimSpace ( splits [ 1 ] ) done := strings . TrimSpace ( splits [ 2 ] ) if done != " " { done = " " } task := Task { Date : date , Name : name , Done : done , } tasks = append ( tasks , task ) } else { } } if err := scanner . Err ( ) ; err != nil { return tasks , err } return tasks , nil }
ReadTasks reads all the tasks from the todofile
ReadTasks reads all the tasks from the todofile
// Read file and construct struct // handle done // continue