mirror of
https://github.com/oneclickvirt/backtrace.git
synced 2025-02-22 17:05:41 +08:00
v0.0.4 - 增加不显示IP信息的参数
This commit is contained in:
parent
9c658fb118
commit
310b09e95b
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
@ -24,7 +24,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
git config --global user.name 'github-actions'
|
git config --global user.name 'github-actions'
|
||||||
git config --global user.email 'github-actions@github.com'
|
git config --global user.email 'github-actions@github.com'
|
||||||
TAG="v0.0.3-$(date +'%Y%m%d%H%M%S')"
|
TAG="v0.0.4-$(date +'%Y%m%d%H%M%S')"
|
||||||
git tag $TAG
|
git tag $TAG
|
||||||
git push origin $TAG
|
git push origin $TAG
|
||||||
env:
|
env:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package backtrace
|
package backtrace
|
||||||
|
|
||||||
const BackTraceVersion = "v0.0.3" // git tag v0.0.3
|
const BackTraceVersion = "v0.0.4" // git tag v0.0.4
|
||||||
var EnableLoger bool
|
var EnableLoger bool
|
||||||
|
23
cmd/main.go
23
cmd/main.go
@ -23,25 +23,28 @@ func main() {
|
|||||||
http.Get("https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Foneclickvirt%2Fbacktrace&count_bg=%2323E01C&title_bg=%23555555&icon=sonarcloud.svg&icon_color=%23E7E7E7&title=hits&edge_flat=false")
|
http.Get("https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Foneclickvirt%2Fbacktrace&count_bg=%2323E01C&title_bg=%23555555&icon=sonarcloud.svg&icon_color=%23E7E7E7&title=hits&edge_flat=false")
|
||||||
}()
|
}()
|
||||||
fmt.Println(Green("项目地址:"), Yellow("https://github.com/oneclickvirt/backtrace"))
|
fmt.Println(Green("项目地址:"), Yellow("https://github.com/oneclickvirt/backtrace"))
|
||||||
var showVersion bool
|
var showVersion, showIpInfo bool
|
||||||
flag.BoolVar(&showVersion, "v", false, "show version")
|
flag.BoolVar(&showVersion, "v", false, "show version")
|
||||||
|
flag.BoolVar(&showIpInfo, "s", true, "diabel show ip info")
|
||||||
flag.BoolVar(&backtrace.EnableLoger, "e", false, "Enable logging")
|
flag.BoolVar(&backtrace.EnableLoger, "e", false, "Enable logging")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if showVersion {
|
if showVersion {
|
||||||
fmt.Println(backtrace.BackTraceVersion)
|
fmt.Println(backtrace.BackTraceVersion)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rsp, err := http.Get("http://ipinfo.io")
|
if showIpInfo {
|
||||||
if err != nil {
|
rsp, err := http.Get("http://ipinfo.io")
|
||||||
fmt.Errorf("Get ip info err %v \n", err.Error())
|
|
||||||
} else {
|
|
||||||
info := IpInfo{}
|
|
||||||
err = json.NewDecoder(rsp.Body).Decode(&info)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Errorf("json decode err %v \n", err.Error())
|
fmt.Errorf("Get ip info err %v \n", err.Error())
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(Green("国家: ") + White(info.Country) + Green(" 城市: ") + White(info.City) +
|
info := IpInfo{}
|
||||||
Green(" 服务商: ") + Blue(info.Org))
|
err = json.NewDecoder(rsp.Body).Decode(&info)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Errorf("json decode err %v \n", err.Error())
|
||||||
|
} else {
|
||||||
|
fmt.Println(Green("国家: ") + White(info.Country) + Green(" 城市: ") + White(info.City) +
|
||||||
|
Green(" 服务商: ") + Blue(info.Org))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
backtrace.BackTrace()
|
backtrace.BackTrace()
|
||||||
|
Loading…
Reference in New Issue
Block a user