Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DirExistAndHasContent ¶
DirExistAndHasContent checks if the given directory exists and has content.
Parameters:
- dirPath: The path to the directory to check.
Returns:
- error: An error if the directory does not exist or if there is any other issue.
Example:
err := DirExistAndHasContent("/path/to/dir") if err != nil { log.Fatalf("Error: %v", err) } else { fmt.Println("The directory exists and has content.")
func FileHasContent ¶
FileHasContent checks if the specified file exists and has content.
Parameters:
- file: The path to the file to check.
Returns:
- error: An error if the file does not exist, is empty, or if there is any other issue.
Example:
err := FileHasContent("/path/to/file.txt") if err != nil { log.Fatalf("Error: %v", err) } else { fmt.Println("The file exists and has content.")
func GetAllEnvVarsFromHost ¶
GetAllEnvVarsFromHost retrieves all environment variables from the host and returns them as a map.
Returns:
- map[string]string: A map containing all environment variables from the host.
Example:
envVars := GetAllEnvVarsFromHost() fmt.Printf("Host environment variables: %v\n", envVars)
func IsValidDirE ¶
IsValidDirE checks if the given path is a valid directory.
Parameters:
- path: The path to check.
Returns:
- error: An error if the path is not a valid directory.
Example:
err := IsValidDirE("/path/to/check") if err != nil { log.Fatalf("Error: %v", err) } else { fmt.Println("The path is a valid directory.")
func MergeSlices ¶ added in v0.0.8
MergeSlices merges multiple slices of strings into a single slice.
Parameters:
- slices: Variadic parameter representing multiple slices of strings to be merged.
Returns:
- []string: A single slice containing all the elements from the input slices.
Example:
slice1 := []string{"a", "b"} slice2 := []string{"c", "d"} merged := MergeSlices(slice1, slice2) fmt.Printf("Merged slice: %v\n", merged)
Types ¶
type EnvVar ¶
EnvVar represents an environment variable with a name and value.
func GetAllEnvVarsFromHostAsStruct ¶
GetAllEnvVarsFromHostAsStruct retrieves the specified environment variables from the host and returns them as a slice of EnvVar structs.
Parameters:
- envVarNames: A list of environment variable names to retrieve.
Returns:
- []EnvVar: A slice of EnvVar structs representing the specified environment variables.
Example:
envVarNames := []string{"PATH", "HOME"} envVars := GetAllEnvVarsFromHostAsStruct(envVarNames) fmt.Printf("Host environment variables as structs: %v\n", envVars)