helper

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: MIT Imports: 15 Imported by: 0

README

Helper

This is a helper library for common functions used in Apigear.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendChecksum

func AppendChecksum(dst string, src string) error

func ArrayToMap

func ArrayToMap[T any](m map[string]T, e []T, f func(T) string) map[string]T

ArrayToMap converts an array to a map using a key function

func CalcChecksum

func CalcChecksum(src string) (string, error)

func Contains

func Contains(a string, b string) bool

Contains checks if a string contains a substring case insensitive

func CopyDir

func CopyDir(src, dst string) error

func CopyFile

func CopyFile(src, dst string) error

func CreateTarGz

func CreateTarGz(src, dst string) error

CreateTarGz creates a tar.gz file from a source directory.

func CreateZipFromDir

func CreateZipFromDir(src, dst string) error

CreateZipFile creates a zip file from a src directory.

func Ext

func Ext(file string) string

func ExtractTarGz

func ExtractTarGz(src, dest string) error

ExtractTarGz extracts a tar.gz file to a destination directory.

func ExtractZipFile

func ExtractZipFile(zipFile string, dest string) error

ExtractZipFile extracts a zip file to a destination directory.

func FileExists

func FileExists(src string) bool

func FilterDir

func FilterDir(src string, filter func(fs.DirEntry) bool) ([]fs.DirEntry, error)

FilterDir returns a list of files in a directory that match filter

func FindFile

func FindFile(src string, name string) (fs.FileInfo, error)

func GetFreePort

func GetFreePort() (int, error)

func HasExt

func HasExt(src string, ext string) bool

func HttpDownload

func HttpDownload(url, dest string) error

HttpDownload downloads a file from a url to a local file.

func IsDir

func IsDir(src string) bool

IsDir returns true if the path is a directory.

func IsDocument

func IsDocument(path string) bool

func IsFile

func IsFile(src string) bool

IsFile returns true if the path is a file.

func Join

func Join(elem ...string) string

Join joins any number of path elements into a single path. If any element is an absolute path, Join returns the absolute path of that element and ignores previous elements.

func ListDir

func ListDir(src string) ([]fs.DirEntry, error)

func MakeIdGenerator

func MakeIdGenerator(prefix string) func() string

MakeIdGenerator creates a new id generator The id generator is a function that returns a new id on each call

func MapToArray

func MapToArray[T any](m map[string]T) []T

MapToArray converts a map to an array

func MkDir

func MkDir(src string) error

func Must

func Must(err error)

func ReadDocument

func ReadDocument(src string, v any) error

func ReadFile

func ReadFile(src string) ([]byte, error)

func Rename

func Rename(src, dst string) error

Rename renames a file or directory.

func RmDir

func RmDir(src string) error

func RmFile

func RmFile(src string) error

RmFile removes a file.

func WriteDocument

func WriteDocument(dst string, v any) error

func WriteFile

func WriteFile(dst string, data []byte) error

func YamlToJson

func YamlToJson(in []byte) ([]byte, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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