filesystem

package
v0.2.18 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrUnableToReadFile = "unable to read file: %v"
)

Variables

View Source
var (
	ErrNilFile = errors.New("file cannot be nil")
)

Functions

func CloseFile added in v0.2.15

func CloseFile(file *os.File) error

CloseFile closes the file

Parameters:

  • file: The file to close

Returns:

  • error: An error if something went wrong

func GetCurrentDirectory

func GetCurrentDirectory() (string, error)

GetCurrentDirectory gets the current directory of the executable

Returns:

  • string: the current directory path
  • error: error if any occurred while retrieving the directory

func OpenFile added in v0.2.15

func OpenFile(path string) (*os.File, error)

OpenFile opens the file from the given path

Parameters:

  • path: The path to the file

Returns:

  • *os.File: The opened file
  • error: An error if something went wrong

func ReadCSVFile added in v0.2.15

func ReadCSVFile(file *os.File, readHeaders bool) (
	*[][]string,
	*[]string,
	error,
)

ReadCSVFile reads a CSV file and returns a slice of string slices

Parameters:

  • file: The file to read
  • readHeaders: Whether to read the first line as headers

Returns:

  • *[][]string: A pointer to a slice of string slices containing the CSV records
  • *[]string: A pointer to a slice of strings containing the headers (if readHeaders is true)
  • error: An error if something went wrong

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile reads the file from the given path

Parameters:

  • path: The path to the file

Returns:

  • []byte: The content of the file
  • error: An error if something went wrong

Types

This section is empty.

Jump to

Keyboard shortcuts

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