Documentation
¶
Index ¶
- Constants
- Variables
- func CloseFile(file *os.File) error
- func GetCurrentDirectory() (string, error)
- func GetExecutableGoModPath() (string, error)
- func OpenFile(path string) (*os.File, error)
- func ReadCSVFile(file *os.File, readHeaders bool) (records [][]string, headers []string, err error)
- func ReadFile(path string) ([]byte, error)
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
CloseFile closes the file
Parameters:
- file: The file to close
Returns:
- error: An error if something went wrong
func GetCurrentDirectory ¶
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
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
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
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.