utils

package
v1.3.20 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertPathsToAbsolutePaths

func ConvertPathsToAbsolutePaths(paths []string) ([]string, error)

ConvertPathsToAbsolutePaths converts a slice of paths to a slice of absolute paths

func FileExists

func FileExists(filename string) bool

FileExists checks if a file exists and is not a directory

func IsDirectory

func IsDirectory(path string) (bool, error)

IsDirectory checks if the path is a directory

func IsYaml

func IsYaml(file string) bool

IsYaml checks if the file has YAML extension (does not check file schema, nor validates the file)

func JoinAbsolutePathWithPaths

func JoinAbsolutePathWithPaths(basePath string, paths []string) ([]string, error)

JoinAbsolutePathWithPaths joins a base path with each item in the path slice and returns a slice of absolute paths

func PrintAsJSON

func PrintAsJSON(data interface{}) error

PrintAsJSON prints the provided value as YAML document to the console

func PrintAsYAML

func PrintAsYAML(data interface{}) error

PrintAsYAML prints the provided value as YAML document to the console

func SliceContainsInt

func SliceContainsInt(s []int, i int) bool

SliceContainsInt checks if an int is present in a slice

func SliceContainsString

func SliceContainsString(s []string, str string) bool

SliceContainsString checks if a string is present in a slice

func SliceContainsStringStartsWith

func SliceContainsStringStartsWith(s []string, str string) bool

SliceContainsStringStartsWith checks if a slice contains a string that the given string begins with

func SliceOfStringsToSpaceSeparatedString

func SliceOfStringsToSpaceSeparatedString(s []string) string

SliceOfStringsToSpaceSeparatedString checks if an int is present in a slice

func StringKeysFromMap

func StringKeysFromMap(m map[string]interface{}) []string

StringKeysFromMap returns a slice of sorted string keys from the provided map

func TrimBasePathFromPath

func TrimBasePathFromPath(basePath string, path string) string

TrimBasePathFromPath trims the base path prefix from the path

func UniqueStrings

func UniqueStrings(input []string) []string

UniqueStrings returns a unique subset of the string slice provided

func WriteToFileAsJSON

func WriteToFileAsJSON(filePath string, data interface{}, fileMode os.FileMode) error

WriteToFileAsJSON converts the provided value to YAML and writes it to the provided file

func WriteToFileAsYAML

func WriteToFileAsYAML(filePath string, data interface{}, fileMode os.FileMode) error

WriteToFileAsYAML converts the provided value to YAML and writes it to the provided file

Types

This section is empty.

Jump to

Keyboard shortcuts

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