Files
archived-frankenphp/internal/fastabs/filepath_unix.go
Rob Landers 6d86ea84bc chore: run go fmt (#2211)
A few files were not formatted correctly.

Signed-off-by: Robert Landers <landers.robert@gmail.com>
Co-authored-by: Marc <m@pyc.ac>
2026-02-21 17:38:51 +01:00

42 lines
650 B
Go

//go:build unix
package fastabs
import (
"os"
"path/filepath"
)
var (
wd string
wderr error
)
func init() {
wd, wderr = os.Getwd()
if wderr != nil {
return
}
canonicalWD, err := filepath.EvalSymlinks(wd)
if err == nil {
wd = canonicalWD
}
}
// FastAbs is an optimized version of filepath.Abs for Unix systems,
// since we don't expect the working directory to ever change once
// Caddy is running. Avoid the os.Getwd syscall overhead.
func FastAbs(path string) (string, error) {
if filepath.IsAbs(path) {
return filepath.Clean(path), nil
}
if wderr != nil {
return "", wderr
}
return filepath.Join(wd, path), nil
}