mirror of
https://github.com/beego/bee.git
synced 2024-11-23 11:50:55 +00:00
Remove Beego version because when we use GO mod, we can not know specific project's beego version
This commit is contained in:
parent
551d7cb8d3
commit
7b3d1b5f64
@ -23,7 +23,6 @@ type RuntimeInfo struct {
|
|||||||
GOROOT string
|
GOROOT string
|
||||||
Compiler string
|
Compiler string
|
||||||
BeeVersion string
|
BeeVersion string
|
||||||
BeegoVersion string
|
|
||||||
Published string
|
Published string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +60,6 @@ func show(out io.Writer, content string) {
|
|||||||
runtime.GOROOT(),
|
runtime.GOROOT(),
|
||||||
runtime.Compiler,
|
runtime.Compiler,
|
||||||
version,
|
version,
|
||||||
GetBeegoVersion(),
|
|
||||||
utils.GetLastPublishedTime(),
|
utils.GetLastPublishedTime(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1,16 +1,12 @@
|
|||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
path "path/filepath"
|
|
||||||
"regexp"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -30,7 +26,6 @@ const verboseVersionBanner string = `%s%s______
|
|||||||
| |_/ /| __/| __/
|
| |_/ /| __/| __/
|
||||||
\____/ \___| \___| v{{ .BeeVersion }}%s
|
\____/ \___| \___| v{{ .BeeVersion }}%s
|
||||||
%s%s
|
%s%s
|
||||||
├── Beego : {{ .BeegoVersion }}
|
|
||||||
├── GoVersion : {{ .GoVersion }}
|
├── GoVersion : {{ .GoVersion }}
|
||||||
├── GOOS : {{ .GOOS }}
|
├── GOOS : {{ .GOOS }}
|
||||||
├── GOARCH : {{ .GOARCH }}
|
├── GOARCH : {{ .GOARCH }}
|
||||||
@ -83,7 +78,6 @@ func versionCmd(cmd *commands.Command, args []string) int {
|
|||||||
runtime.GOROOT(),
|
runtime.GOROOT(),
|
||||||
runtime.Compiler,
|
runtime.Compiler,
|
||||||
version,
|
version,
|
||||||
GetBeegoVersion(),
|
|
||||||
utils.GetLastPublishedTime(),
|
utils.GetLastPublishedTime(),
|
||||||
}
|
}
|
||||||
switch outputFormat {
|
switch outputFormat {
|
||||||
@ -120,52 +114,6 @@ func ShowShortVersionBanner() {
|
|||||||
InitBanner(output, bytes.NewBufferString(colors.MagentaBold(shortVersionBanner)))
|
InitBanner(output, bytes.NewBufferString(colors.MagentaBold(shortVersionBanner)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBeegoVersion() string {
|
|
||||||
re, err := regexp.Compile(`VERSION = "([0-9.]+)"`)
|
|
||||||
if err != nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
wgopath := utils.GetGOPATHs()
|
|
||||||
if len(wgopath) == 0 {
|
|
||||||
beeLogger.Log.Error("GOPATH environment is empty,may be you use `go module`")
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
for _, wg := range wgopath {
|
|
||||||
wg, _ = path.EvalSymlinks(path.Join(wg, "src", "github.com", "beego", "beego"))
|
|
||||||
filename := path.Join(wg, "beego.go")
|
|
||||||
_, err := os.Stat(filename)
|
|
||||||
if err != nil {
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
beeLogger.Log.Error("Error while getting stats of 'beego.go'")
|
|
||||||
}
|
|
||||||
fd, err := os.Open(filename)
|
|
||||||
if err != nil {
|
|
||||||
beeLogger.Log.Error("Error while reading 'beego.go'")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
reader := bufio.NewReader(fd)
|
|
||||||
for {
|
|
||||||
byteLine, _, er := reader.ReadLine()
|
|
||||||
if er != nil && er != io.EOF {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
if er == io.EOF {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
line := string(byteLine)
|
|
||||||
s := re.FindStringSubmatch(line)
|
|
||||||
if len(s) >= 2 {
|
|
||||||
return s[1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return "Beego is not installed. Please do consider installing it first: https://github.com/beego/beego/v2. " +
|
|
||||||
"If you are using go mod, and you don't install the beego under $GOPATH/src/github.com/beego, just ignore this."
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetGoVersion() string {
|
func GetGoVersion() string {
|
||||||
var (
|
var (
|
||||||
cmdOut []byte
|
cmdOut []byte
|
||||||
|
Loading…
Reference in New Issue
Block a user