Documentation
¶
Index ¶
- func ChangeExtension(path, newExt string) string
- func CleanDir(path string) error
- func ComputeFileHash(path string, algo HashAlgorithm) (string, error)
- func ComputeHash(data []byte, algo HashAlgorithm) (string, error)
- func ComputeStringHash(s string, algo HashAlgorithm) (string, error)
- func CopyFile(src, dst string) error
- func EnsureDir(path string) error
- func ExecCommand(name string, args ...string) (string, error)
- func ExpandPath(path string) (string, error)
- func FileExists(path string) bool
- func FindExecutable(name string) (string, error)
- func FromSlash(path string) string
- func GetBaseName(path string) string
- func GetDirName(path string) string
- func GetFileExtension(path string) string
- func GetFileSize(path string) (int64, error)
- func GetRelativePath(base, target string) (string, error)
- func GlobPattern(pattern string) ([]string, error)
- func HasExtension(path string, extensions ...string) bool
- func HasPathPrefix(path, prefix string) bool
- func HashData(data []byte) (string, error)
- func HashFile(path string) (string, error)
- func HashString(s string) (string, error)
- func IsAbsolutePath(path string) bool
- func IsDir(path string) bool
- func IsSubPath(parent, child string) bool
- func IsValidPackageName(name string) bool
- func IsValidProtoFileName(name string) bool
- func JoinPath(elements ...string) string
- func MakeAbsolute(base, path string) (string, error)
- func MakeRelative(base, path string) (string, error)
- func MatchPattern(pattern, name string) (bool, error)
- func NormalizePath(path string) (string, error)
- func ParallelExecute(workerCount int, tasks []Task) (int, []error)
- func ReadFile(path string) ([]byte, error)
- func RemoveDir(path string) error
- func RemoveExtension(path string) string
- func SplitExtension(path string) (name, ext string)
- func SplitPath(path string) (dir, file string)
- func ToSlash(path string) string
- func ValidateFilePattern(pattern string) error
- func ValidateProtoPackageName(packageName string) bool
- func VerifyFileHash(path, expectedHash string, algo HashAlgorithm) (bool, error)
- func WriteFile(path string, data []byte) error
- type FileInfo
- type FileWatcher
- type FindFilesOptions
- type HashAlgorithm
- type Task
- type TaskResult
- type ValidationResult
- type WorkerPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChangeExtension ¶
ChangeExtension changes the extension of a file path.
func ComputeFileHash ¶
func ComputeFileHash(path string, algo HashAlgorithm) (string, error)
ComputeFileHash computes the hash of a file using the specified algorithm.
func ComputeHash ¶
func ComputeHash(data []byte, algo HashAlgorithm) (string, error)
ComputeHash computes the hash of data using the specified algorithm.
func ComputeStringHash ¶
func ComputeStringHash(s string, algo HashAlgorithm) (string, error)
ComputeStringHash computes the hash of a string using the specified algorithm.
func ExecCommand ¶ added in v0.5.0
ExecCommand executes a command and returns its output
func ExpandPath ¶
ExpandPath expands environment variables and home directory in a path.
func FileExists ¶
FileExists checks if a file or directory exists.
func FindExecutable ¶ added in v0.5.0
FindExecutable finds an executable in the system PATH
func GetBaseName ¶
GetBaseName returns the base name of a path (file name without directory).
func GetDirName ¶
GetDirName returns the directory name of a path.
func GetFileExtension ¶
GetFileExtension returns the extension of a file (including the dot).
func GetFileSize ¶
GetFileSize returns the size of a file in bytes.
func GetRelativePath ¶
GetRelativePath returns the relative path from base to target.
func GlobPattern ¶
GlobPattern finds all paths matching a pattern.
func HasExtension ¶
HasExtension checks if a file has one of the specified extensions.
func HasPathPrefix ¶
HasPathPrefix checks if a path starts with the given prefix.
func HashString ¶
HashString is a convenience function that uses SHA256 by default.
func IsAbsolutePath ¶
IsAbsolutePath checks if a path is absolute.
func IsValidPackageName ¶
IsValidPackageName checks if a package name is valid.
func IsValidProtoFileName ¶
IsValidProtoFileName checks if a file name is a valid proto file name.
func MakeAbsolute ¶
MakeAbsolute makes a path absolute relative to a base directory. If the path is already absolute, it returns it unchanged.
func MakeRelative ¶
MakeRelative makes a path relative to a base directory. If the path is already relative, it returns it unchanged.
func MatchPattern ¶
MatchPattern checks if a file name matches a glob pattern.
func NormalizePath ¶
NormalizePath normalizes a file path by cleaning it and converting to absolute path.
func ParallelExecute ¶
ParallelExecute executes tasks in parallel with the specified worker count. Returns the number of successful tasks and any errors that occurred.
func RemoveExtension ¶
RemoveExtension removes the extension from a file path.
func SplitExtension ¶
SplitExtension splits a path into name and extension.
func ToSlash ¶
ToSlash converts path separators to forward slashes (for cross-platform compatibility).
func ValidateFilePattern ¶
ValidateFilePattern validates a file pattern for searching.
func ValidateProtoPackageName ¶
ValidateProtoPackageName validates a proto package name.
func VerifyFileHash ¶
func VerifyFileHash(path, expectedHash string, algo HashAlgorithm) (bool, error)
VerifyFileHash verifies that a file's hash matches the expected hash.
Types ¶
type FileInfo ¶
type FileInfo struct {
Path string // Absolute path to the file
RelPath string // Relative path to the file
Size int64 // File size in bytes
IsDir bool // Whether the path is a directory
ModTime int64 // Modification time (Unix timestamp)
FileInfo os.FileInfo // Original FileInfo from os
}
FileInfo contains information about a file.
type FileWatcher ¶ added in v0.5.0
type FileWatcher struct {
// contains filtered or unexported fields
}
FileWatcher represents a file system watcher
func NewFileWatcher ¶ added in v0.5.0
func NewFileWatcher() (*FileWatcher, error)
NewFileWatcher creates a new file watcher
func (*FileWatcher) Add ¶ added in v0.5.0
func (fw *FileWatcher) Add(path string) error
Add adds a path to watch
func (*FileWatcher) Close ¶ added in v0.5.0
func (fw *FileWatcher) Close() error
Close closes the watcher
func (*FileWatcher) Errors ¶ added in v0.5.0
func (fw *FileWatcher) Errors() <-chan error
Errors returns the channel for watcher errors
func (*FileWatcher) Events ¶ added in v0.5.0
func (fw *FileWatcher) Events() <-chan fsnotify.Event
Events returns the channel for file system events
func (*FileWatcher) Remove ¶ added in v0.5.0
func (fw *FileWatcher) Remove(path string) error
Remove removes a path from watching
type FindFilesOptions ¶
type FindFilesOptions struct {
Pattern string // File pattern to match (e.g., "*.proto")
Recursive bool // Search recursively in subdirectories
IncludeDirs bool // Include directories in results
Exclude []string // Patterns to exclude
}
FindFilesOptions contains options for finding files.
type HashAlgorithm ¶
type HashAlgorithm string
HashAlgorithm represents supported hash algorithms.
const ( MD5 HashAlgorithm = "md5" SHA1 HashAlgorithm = "sha1" SHA256 HashAlgorithm = "sha256" SHA512 HashAlgorithm = "sha512" )
type TaskResult ¶
type TaskResult struct {
Index int // Index of the task in the original queue
Error error // Error if the task failed
}
TaskResult contains the result of a task execution.
func ExecuteAndWait ¶
func ExecuteAndWait(workerCount int, tasks []Task) ([]TaskResult, error)
ExecuteAndWait is a convenience function that creates a pool, executes tasks, and cleans up.
type ValidationResult ¶
type ValidationResult struct {
Valid bool // Whether the validation passed
Errors []string // List of validation errors
Warnings []string // List of validation warnings
}
ValidationResult contains the result of a validation.
func ValidateOutputDir ¶
func ValidateOutputDir(path string) (*ValidationResult, error)
ValidateOutputDir validates an output directory.
func ValidatePath ¶
func ValidatePath(path string) (*ValidationResult, error)
ValidatePath validates a file or directory path.
func ValidateProtoFile ¶
func ValidateProtoFile(path string) (*ValidationResult, error)
ValidateProtoFile validates a proto file.
func (*ValidationResult) AddError ¶
func (vr *ValidationResult) AddError(format string, args ...interface{})
AddError adds an error to the validation result.
func (*ValidationResult) AddWarning ¶
func (vr *ValidationResult) AddWarning(format string, args ...interface{})
AddWarning adds a warning to the validation result.
func (*ValidationResult) HasErrors ¶
func (vr *ValidationResult) HasErrors() bool
HasErrors returns true if there are any errors.
func (*ValidationResult) HasWarnings ¶
func (vr *ValidationResult) HasWarnings() bool
HasWarnings returns true if there are any warnings.
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool manages a pool of workers for concurrent task execution.
func NewWorkerPool ¶
func NewWorkerPool(workerCount int) (*WorkerPool, error)
NewWorkerPool creates a new worker pool with the specified number of workers.
func (*WorkerPool) Close ¶
func (wp *WorkerPool) Close()
Close closes the worker pool (no-op for simplified implementation).
func (*WorkerPool) Execute ¶
func (wp *WorkerPool) Execute(tasks []Task) []TaskResult
Execute executes all tasks and returns the results.