1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 03:23:49 +08:00

another way to get version

This commit is contained in:
wdvxdr 2021-03-25 23:33:11 +08:00
parent 03c3af14aa
commit e98e4eef8c
No known key found for this signature in database
GPG Key ID: 55FF1414A69CEBA6
2 changed files with 9 additions and 2 deletions

View File

@ -32,5 +32,4 @@ jobs:
goarch: ${{ matrix.goarch }}
goversion: "https://golang.org/dl/go1.16.linux-amd64.tar.gz"
build_flags: -trimpath
ldflags: -w -s -X "github.com/Mrs4s/go-cqhttp/coolq.Version=${{ env.RELEASE_VERSION }}"
ldflags: -w -s

View File

@ -10,6 +10,7 @@ import (
"path"
"path/filepath"
"runtime"
"runtime/debug"
"strconv"
"strings"
"time"
@ -26,6 +27,13 @@ import (
// Version go-cqhttp的版本信息在编译时使用ldflags进行覆盖
var Version = "unknown"
func init() {
info, ok := debug.ReadBuildInfo()
if ok {
Version = info.Main.Version
}
}
// CQGetLoginInfo 获取登录号信息
//
// https://git.io/Jtz1I