pkger/pkging/costello/ref.go

50 lines
709 B
Go
Raw Normal View History

package costello
import (
"os"
"path/filepath"
"runtime"
"github.com/markbates/pkger/here"
)
type Ref struct {
here.Info
}
func NewRef() (*Ref, error) {
her, err := here.Package("github.com/markbates/pkger")
if err != nil {
return nil, err
}
dir := filepath.Join(
2019-10-30 18:31:39 +03:00
her.Module.Dir,
"pkging",
"costello",
"testdata",
"ref")
if _, err := os.Stat(dir); err != nil {
return nil, err
}
ref := &Ref{
Info: here.Info{
ImportPath: "app",
Dir: dir,
Name: "app",
2019-10-30 18:31:39 +03:00
Module: here.Module{
Main: true,
Path: "app",
Dir: dir,
GoMod: filepath.Join(dir, "go.mod"),
GoVersion: runtime.Version(),
2019-10-30 18:31:39 +03:00
},
},
}
return ref, nil
}