file

package
v0.0.0-...-94fa7b2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Copyright © 2025 Oscar Marquez

Copyright © 2025 Oscar Marquez

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseFile

func CloseFile(file *os.File) error

Release the lock on the file descriptor and close the file

func LoadFile

func LoadFile(filename string) (*os.File, error)

Load file with exclusive lock. Check if the file exists, if not create it with read-write permissions

Types

type CSVStorage

type CSVStorage struct {
	// contains filtered or unexported fields
}

func NewCSVStorage

func NewCSVStorage(filepath string) *CSVStorage

func (*CSVStorage) AddTask

func (s *CSVStorage) AddTask(task string) error

func (*CSVStorage) CompleteTask

func (s *CSVStorage) CompleteTask(w io.Writer, id int) error

func (*CSVStorage) DeleteTask

func (s *CSVStorage) DeleteTask(w io.Writer, id int) error

func (*CSVStorage) ListTasks

func (s *CSVStorage) ListTasks(w io.Writer) error

type FileStorage

type FileStorage interface {
	AddTask(task string) error
	ListTasks(w io.Writer) error
	CompleteTask(w io.Writer, id int) error
	DeleteTask(w io.Writer, id int) error
}

func SelectStorage

func SelectStorage(path, storageType string) (FileStorage, error)

type JSONStorage

type JSONStorage struct {
	// contains filtered or unexported fields
}

func NewJSONStorage

func NewJSONStorage(filepath string) *JSONStorage

func (*JSONStorage) AddTask

func (s *JSONStorage) AddTask(task string) error

func (*JSONStorage) CompleteTask

func (s *JSONStorage) CompleteTask(w io.Writer, id int) error

func (*JSONStorage) DeleteTask

func (s *JSONStorage) DeleteTask(w io.Writer, id int) error

func (*JSONStorage) ListTasks

func (s *JSONStorage) ListTasks(w io.Writer) error

type Task

type Task struct {
	ID         int
	Task       string
	CreatedAt  time.Time
	IsComplete bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL