diff --git a/cmd/gf/internal/cmd/cmd_version.go b/cmd/gf/internal/cmd/cmd_version.go index 8ab836f56..10a31eacf 100644 --- a/cmd/gf/internal/cmd/cmd_version.go +++ b/cmd/gf/internal/cmd/cmd_version.go @@ -70,6 +70,8 @@ func (c cVersion) getGFVersionOfCurrentProject() (string, error) { if gfile.Exists(goModPath) { lines := gstr.SplitAndTrim(gfile.GetContents(goModPath), "\n") for _, line := range lines { + line = gstr.Trim(line) + line = gstr.TrimLeftStr(line, "require ") line = gstr.Trim(line) // Version 1. match, err := gregex.MatchString(`^github\.com/gogf/gf\s+(.+)$`, line)