files

package
v2.1.93 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGettingFileFromURL = errors.New("error getting file from url")
)

Functions

func CleanupServiceFileStructure

func CleanupServiceFileStructure(servicePath string) error

CleanupServiceFileStructure removes empty directories from the service directory.

func CopyDirectory

func CopyDirectory(src, dest string) error

CopyDirectory copies a directory recursively.

func CopyFile

func CopyFile(srcPath, destPath string) error

CopyFile copies a file from srcPath to destPath. If the destination directory doesn't exist, it will be created. File permissions are preserved from the source file.

func GetFileContentsFromURL

func GetFileContentsFromURL(client *http.Client, url string) ([]byte, string, error)

GetFileContentsFromURL fetches file contents from a URL.

func GetFileHash

func GetFileHash(file io.Reader) string

GetFileHash gets the SHA256 hash of a file.

func GetModuleInfo

func GetModuleInfo(startDir string) (string, string, error)

GetModuleInfo walks up the directory tree to find go.mod and returns both the module name and the module root directory path

func IsEmptyDir

func IsEmptyDir(path string) bool

IsEmptyDir checks if a directory is empty.

func IsJsonType

func IsJsonType(content []byte) bool

IsJsonType checks if the content is a valid JSON document.

func IsURL

func IsURL(path string) bool

IsURL checks if a path is a URL (starts with http:// or https://).

func IsYamlType

func IsYamlType(content []byte) bool

IsYamlType checks if the content is a valid YAML document.

func ReadFileOrURL

func ReadFileOrURL(path string) ([]byte, error)

ReadFileOrURL reads content from either a local file path or a URL. If the path starts with http:// or https://, it fetches from the URL. Otherwise, it reads from the local file system. Returns the file contents and an error if any.

func SaveFile

func SaveFile(filePath string, data []byte) error

SaveFile saves a file to the specified path. If the destination directory doesn't exist, it will be created.

Types

This section is empty.

Jump to

Keyboard shortcuts

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