filesystem

package
v0.2.22 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 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 GetExecutableGoModPath added in v0.2.22

func GetExecutableGoModPath() (string, error)

GetExecutableGoModPath get the path of the go.mod file relative to the executable (searching upwards in the directory tree)

Returns:

  • string: The path to the go.mod file
  • error: The error if any

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) (
	records [][]string,
	headers []string,
	err 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 slice of string slices containing the CSV records
  • []string: 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