GG修改器破解版下载地址:https://ghb2023zs.bj.bcebos.com/gg/xgq/ggxgq?GGXGQ
大家好,今天小编为大家分享关于gg修改器怎么用无root_Gg修改器怎么用无root的内容,赶快来一起来看看吧。
大家好,我是 polarisxu。
项目中,特别是开源项目,会特别重视项目的版本号。有些项目,会把版本号写入源码中,每次升级都修改源码号。不过这不是特别好的方式。本文通过学习 Go 语言源码的处理方式来掌握它,并应用于自己的项目中。
本文基于 Go1.17,不同版本的实现细节可能有所不同
在 Go 语言项目中,如果要获取当前 Go 语言版本,只需要调用 runtime.Version:
package main
import (
"fmt"
"runtime"
)
func main() {
fmt.Println("Go Version:", runtime.Version())
}
查看 runtime.Version 的源码:
// buildVersion is the Go tree’s version string at build time.
//
// If any GOEXPERIMENTs are set to non-default values, it will include
// "X:<GOEXPERIMENT>".
//
// This is set by the linker.
//
// This is accessed by "go version <binary>".
var buildVersion string
// Version returns the Go tree’s version string.
// It is either mit hash and date at the time of the build or,
// when possible, a release tag like "go1.3".
func Version() string {
return buildVersion
}
根据注释提示,在 Go 仓库源码中,找到 src/cmd/link,这是 Go 链接器的实现。在其中的 internal/ld/main.go 文件找到了如下代码:
buildVersion := buildcfg.Version
if goexperiment := buildcfg.GOEXPERIMENT(); goexperiment != "" {
buildVersion += " X:" + goexperiment
}
addstrdata1(ctxt, "runtime.buildVersion="+buildVersion)
buildVersion 值从 buildcfg.Version 获取,如果设置了 GOEXPERIMENT(环境变量值),则用该值。
着重看 buildcfg.Version 如何得到的:
var (
defaultGOROOT string // set by linker
GOROOT = envOr("GOROOT", defaultGOROOT)
GOARCH = envOr("GOARCH", defaultGOARCH)
GOOS = envOr("GOOS", defaultGOOS)
GO386 = envOr("GO386", defaultGO386)
GOARM = goarm()
GOMIPS = gomips()
GOMIPS64 = gomips64()
GOPPC64 = goppc64()
GOWASM = gowasm()
GO_LDSO = defaultGO_LDSO
Version = version
)
很奇怪,Version 的值,直接用 version 赋值的。但 version 的值是什么?在 src/cmd/dist/buildruntime.go 文件中,有一个函数 mkbuildcfg,用于生成 buildcfg:
// mkbuildcfg writes internal/buildcfg/zbootstrap.go:
//
// package buildcfg
//
// const defaultGOROOT = <goroot>
// const defaultGO386 = <go386>
// ...
// const defaultGOOS = runtime.GOOS
// const defaultGOARCH = runtime.GOARCH
//
// The use of runtime.GOOS and runtime.GOARCH makes sure that
// a piler expects pile for its own target
// system. That is, if on a Mac you do:
//
// GOOS=linux GOARCH=ppc64 go build pile
//
// the piler will default to generating linux/ppc64 object files.
// This is more useful than having it default to generating objects for the
// original target (in this example, a Mac).
func mkbuildcfg(file string) {
var buf bytes.Buffer
fmt.Fprintf(&buf, "// Code generated by go tool dist; DO NOT EDIT.
")
fmt.Fprintln(&buf)
fmt.Fprintf(&buf, "package buildcfg
")
fmt.Fprintln(&buf)
fmt.Fprintf(&buf, "import "runtime"
")
fmt.Fprintln(&buf)
fmt.Fprintf(&buf, "const defaultGO386 = `%s`
", go386)
fmt.Fprintf(&buf, "const defaultGOARM = `%s`
", goarm)
fmt.Fprintf(&buf, "const defaultGOMIPS = `%s`
", gomips)
fmt.Fprintf(&buf, "const defaultGOMIPS64 = `%s`
", gomips64)
fmt.Fprintf(&buf, "const defaultGOPPC64 = `%s`
", goppc64)
fmt.Fprintf(&buf, "const defaultGOEXPERIMENT = `%s`
", goexperiment)
fmt.Fprintf(&buf, "const defaultGO_EXTLINK_ENABLED = `%s`
", goextlinkenabled)
fmt.Fprintf(&buf, "const defaultGO_LDSO = `%s`
", defaultldso)
fmt.Fprintf(&buf, "const version = `%s`
", findgoversion())
fmt.Fprintf(&buf, "const defaultGOOS = runtime.GOOS
")
fmt.Fprintf(&buf, "const defaultGOARCH = runtime.GOARCH
")
writefile(buf.String(), file, writeSkipSame)
}
其中 version 的值是通过 findgoversion() 得到,该函数定义在 src/cmd/dist/build.go 中:(省略了部分细节)
// findgoversion determines the Go version to use in the version string.
func findgoversion() string {
// The $GOROOT/VERSION file takes priority, for distributions
// without the source repo.
path := pathf("%s/VERSION", goroot)
if isfile(path) {
...
}
// The $GOROOT/VERSION.cache file is a cache to avoid invoking
// git every time we run mand. Unlike VERSION, it gets
// deleted by the mand.
path = pathf("%s/VERSION.cache", goroot)
if isfile(path) {
return chomp(readfile(path))
}
// Show a nicer error message if this isn’t a Git repo.
if !isGitRepo() {
fatalf("FAILED: not a Git repo; must put a VERSION file in $GOROOT")
}
// Otherwise, use Git.
// What is the current branch?
branch := chomp(run(goroot, CheckExit, "git", "rev-parse", "--abbrev-ref", "HEAD"))
...
// Cache version.
writefile(tag, path, 0)
return tag
}
按一下顺序获得 Version(如果前面的获取不到,则依次执行后续获取步骤)
通过前文分析,总结下 Go 版本是如何写入 Go 源码的:
最后,可以通过一个 API 把版本信息公开给用户。
对于我们自己的 Go 项目,通过 Git 获得版本信息,可以通过 shell 脚本实现,最后编译 Go 项目时,将版本信息通过 -X 传递进去。
现在我们通过脚本来实现这个功能。
项目代码如下:
// main.go
package main
import (
"fmt"
)
var Version string
func main() {
fmt.Println("Version:", Version)
}
现在写一个 shell 脚本,通过该脚本对以上代码进行编译:
#!/bin/sh
version=""
if [ -f "VERSION" ]; then
version=`cat VERSION`
fi
if [[ -z $version ]]; then
if [ -d ".git" ]; then
version=`git symbolic-ref HEAD | cut -b 12-`-`git rev-parse HEAD`
else
version="unknown"
fi
fi
go build -ldflags "-X main.Version=$version" main.go
这样项目中的 Version 就设置上正确的值了。
本文通过对 Go 源码中版本信息的学习研究,掌握了优秀开源项目设置版本信息的做法。最后,演示了如何在自己的项目中用上该技能。
本文没有演示环境变量,一般用的比较少。
以上就是关于gg修改器怎么用无root_Gg修改器怎么用无root的全部内容,感谢大家的浏览观看,如果你喜欢本站的文章可以CTRL+D收藏哦。
gg修改器最新版本连接,GG修改器最新版本介绍 大小:11.41MB7,045人安装 GG修改器是目前Android游戏中最为流行,功能最为全面的游戏修改工具之一。它可以无……
下载最新免root用GG修改器,最新免root用GG修改器,让你的游戏体验更自由舒适 大小:16.68MB7,010人安装 在手机游戏盛行的今天,很多游戏都有着非常严格的防修改机制,让玩家无法轻松地自由……
下载gg游戏修改器根和无根,GG游戏修改器:根和无根版本的完美融合 大小:17.32MB6,763人安装 玩游戏对于许多玩家而言,最重要的是游戏体验!然而,有时候游戏的难度过高,或者游……
下载gg游戏修改器源,赞美gg游戏修改器源 大小:4.37MB6,799人安装 现代人对于游戏已经不单单是一种娱乐方式,更是一种生活方式。游戏开发者们不断推出……
下载gg修改器无root运行_gg修改器无root安装使用方法 大小:8.34MB8,105人安装 大家好,今天小编为大家分享关于gg修改器无root运行_gg修改器无root安装使用方法的……
下载gg修改器网站怎么设置中文,GG修改器网站怎么设置中文? 大小:18.75MB6,926人安装 GG修改器是一款非常实用的游戏修改器,在游戏中使用它可以让您轻松获得游戏中的各种……
下载gg修改器中文官网下载什么用_gg修改器中文版官网 大小:17.18MB7,911人安装 大家好,今天小编为大家分享关于gg修改器中文官网下载什么用_gg修改器中文版官网的……
下载64位GG修改器免root版,64位GG修改器免root版:从此改变游戏体验 大小:13.82MB7,023人安装 对于很多游戏爱好者来说,游戏体验是至关重要的。而在玩游戏过程中,可能会出现一些……
下载GG游戏修改器工作模式,GG游戏修改器工作模式:为游戏爱好者带来无限可能 大小:14.44MB6,719人安装 游戏修改器是游戏爱好者们必不可少的一款工具,而GG游戏修改器则成为了越来越多玩家……
下载gg修改器最新版本,GG修改器最新版怎么使用 大小:11.22MB8,020人安装 只要玩家拥有足够多的金钱,你就可以购买自己想要的任何食物! 华丽的画面设计让你……
下载