file

package
v2.0.0-...-4b7107c Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 8 Imported by: 0

README

File

Description

Simple file utilities.

Features

  1. GetExtension: Extracts the extension of a given file name and returns it as a string.

  2. HasExtension: Checks if a file has a specific extension and returns a boolean result.

  3. Existsp: Determines whether a given file exists and returns a boolean value.

  4. GetExtension: Extracts the extension of a given file name and returns it as a string.

  5. HasExtensions: Checks if a file has any of the specified extensions from a given list.

  6. IsValidYaml: Validates if a YAML file can be opened and unmarshalled without error.

  7. HasJsonExtension: Checks if a file has a JSON extension (case-insensitive) and returns a boolean result.

  8. HasYamlExtension: Checks if a file has a YAML extension (case-insensitive) and returns a boolean result.

  9. CreateTempFile: Creates a temporary file in a temporary directory using a unique identifier (UUID) and returns the file path. It handles the cleanup of the temporary file after use.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTempFile

func CreateTempFile() (string, error)

CreateTempFile - Create a temporary file in a temporary directory (uses uuid for the context)

func Exists

func Exists(fileName string) bool

Exists - Return boolean value if file exists

func Existsp

func Existsp(name *string) bool

Existsp - Return boolean value if file exists

func GetExtension

func GetExtension(name string) string

GetExtension - return the given file's extension

func HasExtension

func HasExtension(filename, extension string) bool

HasExtension - return boolean result if a YAML extension exists

func HasExtensions

func HasExtensions(filename string, extensions []string) (result bool)

HasExtensions - return boolean if file has any of a list of extensions

func HasJsonExtension

func HasJsonExtension(filename string) bool

HasJsonExtension - return boolean result if JSON extension exists (case-insensitive)

func HasYamlExtension

func HasYamlExtension(filename string) bool

HasYamlExtension - return boolean result if a YAML extension exists

func IsValidYaml

func IsValidYaml(filename string) error

IsValidYaml - Return boolean if YAML can be opened and unmarshalled without error

Types

This section is empty.

Jump to

Keyboard shortcuts

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