filex

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateYAML

func ValidateYAML(filename string, out interface{}) error

ValidateYAML performs all YAML validations: extension, existence, content, and structure. It returns an error if any of the validations fail.

Example usage:

var config Config
err := ValidateYAML("config.yaml", &config)
if err != nil {
    log.Fatal(err)
}

func ValidateYAMLExists

func ValidateYAMLExists(filename string) bool

ValidateYAMLExists checks if the given YAML file exists. It returns true if the file exists, otherwise false.

Example usage:

exists := ValidateYAMLExists("config.yaml")
fmt.Println(exists) // Output: true

func ValidateYAMLExtension

func ValidateYAMLExtension(filename string) bool

ValidateYAMLExtension checks if the given file has a .yaml or .yml extension. It returns true if the file has a valid YAML extension, otherwise false.

Example usage:

valid := ValidateYAMLExtension("config.yaml")
fmt.Println(valid) // Output: true

func ValidateYAMLHasContent

func ValidateYAMLHasContent(filename string) (bool, error)

ValidateYAMLHasContent checks if the given YAML file is not empty. It returns a boolean indicating whether the file has content and an error if any occurred during reading the file.

Example usage:

hasContent, err := ValidateYAMLHasContent("config.yaml")
if err != nil {
    log.Fatal(err)
}
fmt.Println(hasContent) // Output: true

func ValidateYAMLStructure

func ValidateYAMLStructure(filename string, out interface{}) error

ValidateYAMLStructure checks if the given YAML file can be properly unmarshaled into the provided struct. It returns an error if the file cannot be read or if the content cannot be unmarshaled into the provided struct.

Example usage:

var config Config
err := ValidateYAMLStructure("config.yaml", &config)
if err != nil {
    log.Fatal(err)
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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