mirror of https://github.com/markbates/pkger.git
30 lines
398 B
Go
30 lines
398 B
Go
package here
|
|
|
|
import (
|
|
"path/filepath"
|
|
"sync"
|
|
)
|
|
|
|
var curOnce sync.Once
|
|
var curErr error
|
|
var current Info
|
|
|
|
func Current() (Info, error) {
|
|
(&curOnce).Do(func() {
|
|
b, err := run("go", "env", "GOMOD")
|
|
if err != nil {
|
|
curErr = err
|
|
return
|
|
}
|
|
root := filepath.Dir(string(b))
|
|
i, err := Dir(root)
|
|
if err != nil {
|
|
curErr = err
|
|
return
|
|
}
|
|
current = i
|
|
})
|
|
|
|
return current, curErr
|
|
}
|