From 310b09e95bb8755263c85888602fcee5a7331310 Mon Sep 17 00:00:00 2001 From: spiritlhl <103393591+spiritLHLS@users.noreply.github.com> Date: Mon, 24 Jun 2024 09:02:28 +0000 Subject: [PATCH] =?UTF-8?q?v0.0.4=20-=20=E5=A2=9E=E5=8A=A0=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BAIP=E4=BF=A1=E6=81=AF=E7=9A=84=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yaml | 2 +- bk/version.go | 4 ++-- cmd/main.go | 23 +++++++++++++---------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7f1ab37..f617fab 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,7 +24,7 @@ jobs: run: | git config --global user.name 'github-actions' 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 push origin $TAG env: diff --git a/bk/version.go b/bk/version.go index e49a52d..2e35ec4 100644 --- a/bk/version.go +++ b/bk/version.go @@ -1,4 +1,4 @@ package backtrace -const BackTraceVersion = "v0.0.3" // git tag v0.0.3 -var EnableLoger bool \ No newline at end of file +const BackTraceVersion = "v0.0.4" // git tag v0.0.4 +var EnableLoger bool diff --git a/cmd/main.go b/cmd/main.go index df8fa64..cc6c379 100644 --- a/cmd/main.go +++ b/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") }() 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(&showIpInfo, "s", true, "diabel show ip info") flag.BoolVar(&backtrace.EnableLoger, "e", false, "Enable logging") flag.Parse() if showVersion { fmt.Println(backtrace.BackTraceVersion) return } - rsp, err := http.Get("http://ipinfo.io") - if err != nil { - fmt.Errorf("Get ip info err %v \n", err.Error()) - } else { - info := IpInfo{} - err = json.NewDecoder(rsp.Body).Decode(&info) + if showIpInfo { + rsp, err := http.Get("http://ipinfo.io") if err != nil { - fmt.Errorf("json decode err %v \n", err.Error()) + fmt.Errorf("Get ip info err %v \n", err.Error()) } else { - fmt.Println(Green("国家: ") + White(info.Country) + Green(" 城市: ") + White(info.City) + - Green(" 服务商: ") + Blue(info.Org)) + info := IpInfo{} + 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()