-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
138 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Go build | ||
|
||
# 触发事件 含标签v**g | ||
on: | ||
push: | ||
tags: | ||
- "v**g" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
|
||
- name: Change go env | ||
run: go env -w GO111MODULE=on | ||
|
||
- name: Build | ||
env: | ||
GOOS: windows | ||
GOARCH: amd64 | ||
working-directory: ./backup4abap_go | ||
run: go build -o backup.exe ./main.go | ||
|
||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
body: "压缩代码下载器,用于从已配置 backup4abap_interface 的 ICF 服务通过 HTTP 请求下载代码包到本地,并自动解压。目前仅生成 win64 的运行程序" | ||
files: ./backup4abap_go/backup.exe | ||
token: ${{ secrets.RELEASE_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package util | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
type Bar struct { | ||
percent int64 // 百分比 | ||
curr int64 | ||
total int64 | ||
grap string | ||
show string | ||
IsInit bool | ||
} | ||
|
||
func (bar *Bar) Init(total int64, grap string) { | ||
bar.IsInit = true | ||
bar.total = total | ||
if grap == "" { | ||
bar.grap = "#" | ||
} | ||
bar.show = strings.Repeat(bar.grap, 100) | ||
} | ||
|
||
func (bar *Bar) percents() { | ||
bar.percent = int64(float32(bar.curr) / float32(bar.total) * 100) | ||
} | ||
|
||
func (bar *Bar) Add(desc string) { | ||
if !bar.IsInit { | ||
return | ||
} | ||
|
||
bar.curr++ | ||
|
||
bar.percents() | ||
|
||
fmt.Printf("\r[%-50s]%3d%% %8d/%d %-10s", bar.show[:bar.percent/2], bar.percent, bar.curr, bar.total, desc) | ||
} | ||
|
||
func (bar *Bar) End() { | ||
if !bar.IsInit { | ||
return | ||
} | ||
|
||
fmt.Println() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters