Files
gh-action-readme/internal/validation/path.go
2025-07-30 19:17:36 +03:00

26 lines
624 B
Go

// Package validation provides common utility functions for the gh-action-readme tool.
package validation
import (
"fmt"
"os"
"path/filepath"
)
// GetBinaryDir returns the directory containing the current executable.
func GetBinaryDir() (string, error) {
executable, err := os.Executable()
if err != nil {
return "", fmt.Errorf("failed to get executable path: %w", err)
}
return filepath.Dir(executable), nil
}
// EnsureAbsolutePath converts a relative path to an absolute path.
func EnsureAbsolutePath(path string) (string, error) {
if filepath.IsAbs(path) {
return path, nil
}
return filepath.Abs(path)
}