You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
438 B
Go
27 lines
438 B
Go
4 years ago
|
package gen
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"os"
|
||
|
"path/filepath"
|
||
|
|
||
|
"github.com/tal-tech/go-zero/tools/goctl/util"
|
||
|
)
|
||
|
|
||
|
func getFilePath(file string) (string, error) {
|
||
|
wd, err := os.Getwd()
|
||
|
if err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
|
||
|
projPath, ok := util.FindGoModPath(filepath.Join(wd, file))
|
||
|
if !ok {
|
||
|
projPath, err = util.PathFromGoSrc()
|
||
|
if err != nil {
|
||
|
return "", errors.New("no go.mod found, or not in GOPATH")
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return projPath, nil
|
||
|
}
|