mirror of
https://github.com/ivuorinen/gh-action-readme.git
synced 2026-02-24 18:53:27 +00:00
Initial commit
This commit is contained in:
25
internal/validation/path.go
Normal file
25
internal/validation/path.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// 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)
|
||||
}
|
||||
Reference in New Issue
Block a user