mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
style: move coolq.Version into internal/base
This commit is contained in:
parent
87754111ce
commit
f2ed46d6ce
@ -27,7 +27,7 @@ builds:
|
|||||||
flags:
|
flags:
|
||||||
- -trimpath
|
- -trimpath
|
||||||
ldflags:
|
ldflags:
|
||||||
- -s -w -X github.com/Mrs4s/go-cqhttp/coolq.Version=v{{.Version}}
|
- -s -w -X github.com/Mrs4s/go-cqhttp/internal/base.Version=v{{.Version}}
|
||||||
- id: win
|
- id: win
|
||||||
env:
|
env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
|
21
coolq/api.go
21
coolq/api.go
@ -10,7 +10,6 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/debug"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -23,21 +22,9 @@ import (
|
|||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
|
|
||||||
"github.com/Mrs4s/go-cqhttp/global"
|
"github.com/Mrs4s/go-cqhttp/global"
|
||||||
|
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Version go-cqhttp的版本信息,在编译时使用ldflags进行覆盖
|
|
||||||
var Version = "unknown"
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
if Version != "unknown" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
info, ok := debug.ReadBuildInfo()
|
|
||||||
if ok {
|
|
||||||
Version = info.Main.Version
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CQGetLoginInfo 获取登录号信息
|
// CQGetLoginInfo 获取登录号信息
|
||||||
//
|
//
|
||||||
// https://git.io/Jtz1I
|
// https://git.io/Jtz1I
|
||||||
@ -1388,8 +1375,8 @@ func (bot *CQBot) CQGetVersionInfo() global.MSG {
|
|||||||
wd, _ := os.Getwd()
|
wd, _ := os.Getwd()
|
||||||
return OK(global.MSG{
|
return OK(global.MSG{
|
||||||
"app_name": "go-cqhttp",
|
"app_name": "go-cqhttp",
|
||||||
"app_version": Version,
|
"app_version": base.Version,
|
||||||
"app_full_name": fmt.Sprintf("go-cqhttp-%s_%s_%s-%s", Version, runtime.GOOS, runtime.GOARCH, runtime.Version()),
|
"app_full_name": fmt.Sprintf("go-cqhttp-%s_%s_%s-%s", base.Version, runtime.GOOS, runtime.GOARCH, runtime.Version()),
|
||||||
"protocol_version": "v11",
|
"protocol_version": "v11",
|
||||||
"coolq_directory": wd,
|
"coolq_directory": wd,
|
||||||
"coolq_edition": "pro",
|
"coolq_edition": "pro",
|
||||||
@ -1399,7 +1386,7 @@ func (bot *CQBot) CQGetVersionInfo() global.MSG {
|
|||||||
"plugin_build_configuration": "release",
|
"plugin_build_configuration": "release",
|
||||||
"runtime_version": runtime.Version(),
|
"runtime_version": runtime.Version(),
|
||||||
"runtime_os": runtime.GOOS,
|
"runtime_os": runtime.GOOS,
|
||||||
"version": Version,
|
"version": base.Version,
|
||||||
"protocol": func() int {
|
"protocol": func() int {
|
||||||
switch client.SystemDeviceInfo.Protocol {
|
switch client.SystemDeviceInfo.Protocol {
|
||||||
case client.IPad:
|
case client.IPad:
|
||||||
|
16
internal/base/version.go
Normal file
16
internal/base/version.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package base
|
||||||
|
|
||||||
|
import "runtime/debug"
|
||||||
|
|
||||||
|
// Version go-cqhttp的版本信息,在编译时使用ldflags进行覆盖
|
||||||
|
var Version = "unknown"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if Version != "unknown" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
info, ok := debug.ReadBuildInfo()
|
||||||
|
if ok {
|
||||||
|
Version = info.Main.Version
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user