mirror of
https://github.com/cheat/cheat.git
synced 2024-12-18 10:45:05 +01:00
e5114a3e76
- Re-implemented the project in Golang, and deprecated Python entirely - Implemented several new, long-requested features - Refactored cheatsheets into a separate repository
30 lines
493 B
Go
30 lines
493 B
Go
package mock
|
|
|
|
import (
|
|
"fmt"
|
|
"path"
|
|
"path/filepath"
|
|
"runtime"
|
|
)
|
|
|
|
// Path returns the absolute path to the specified mock file.
|
|
func Path(filename string) string {
|
|
|
|
// determine the path of this file during runtime
|
|
_, thisfile, _, _ := runtime.Caller(0)
|
|
|
|
// compute the config path
|
|
file, err := filepath.Abs(
|
|
path.Join(
|
|
filepath.Dir(thisfile),
|
|
"../../mocks",
|
|
filename,
|
|
),
|
|
)
|
|
if err != nil {
|
|
panic(fmt.Errorf("failed to resolve config path: %v", err))
|
|
}
|
|
|
|
return file
|
|
}
|