Skip to content

Commit

Permalink
tool: stdpkgprogress
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Aug 7, 2024
1 parent e0db408 commit 3c32b84
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions chore/stdpkgprogress/go_stdpkg_progress.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package main

import (
"fmt"
"math"
"strconv"
"strings"

"github.com/goplus/hdq/fetcher"
"github.com/goplus/hdq/fetcher/githubisstask"
_ "github.com/goplus/hdq/stream/http/nocache"
)

const importedBy = "Imported By: "

// Usage: stdpkgprogress
func main() {
doc, err := fetcher.FromInput("githubisstask", "goplus/llgo#642")
if err != nil {
panic(err)
}
var done, total float64
ret := doc.(githubisstask.Result)

Check warning on line 23 in chore/stdpkgprogress/go_stdpkg_progress.go

View check run for this annotation

qiniu-x / golangci-lint

chore/stdpkgprogress/go_stdpkg_progress.go#L23

unchecked-type-assertion: type cast result is unchecked in doc.(githubisstask.Result) - type assertion will panic if not matched (revive)
for _, task := range ret.Tasks {
desc := task.Desc // fmt* (Imported By: 4513111)
if pos := strings.Index(desc, "Imported By: "); pos > 0 {
ntext := strings.TrimSuffix(desc[pos+len(importedBy):], ")")
if n, e := strconv.Atoi(ntext); e == nil {
w := math.Log2(float64(n) + 1)
total += w
if task.Done {
done += w
}
}
}
}
fmt.Printf("Progress: %.2f%%\n", done/total*100)

Check warning on line 37 in chore/stdpkgprogress/go_stdpkg_progress.go

View check run for this annotation

qiniu-x / golangci-lint

chore/stdpkgprogress/go_stdpkg_progress.go#L37

use of `fmt.Printf` forbidden by pattern `^(fmt\.Print(|f|ln)|print|println)$` (forbidigo)
}

0 comments on commit 3c32b84

Please sign in to comment.