diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..de63877 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,45 @@ +name: build + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + name: Build + strategy: + fail-fast: false + matrix: + go-version: [~1.16] + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + env: + GO111MODULE: "on" + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: Cache-Go + uses: actions/cache@v1 + with: + path: | + ~/go/pkg/mod # Module download cache + ~/.cache/go-build # Build cache (Linux) + ~/Library/Caches/go-build # Build cache (Mac) + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Download Go modules + run: go mod download + + - name: Build project + id: makefile + run: make \ No newline at end of file diff --git a/utils/utils.go b/utils/utils.go index 6c7aec0..2b26edc 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -47,24 +47,24 @@ func DecorateText(s string, msgType MessageType) string { // FormatTime formats time.Duration output to a human readable value. func FormatTime(d time.Duration) string { if d.Seconds() < 60.0 { - return fmt.Sprintf("%ds", int64(d.Seconds())) + return fmt.Sprintf("%.2fs", d.Seconds()) } if d.Minutes() < 60.0 { remainingSeconds := math.Mod(d.Seconds(), 60) - return fmt.Sprintf("%dm:%ds", int64(d.Minutes()), int64(remainingSeconds)) + return fmt.Sprintf("%dm %.2fs", int64(d.Minutes()), remainingSeconds) } if d.Hours() < 24.0 { remainingMinutes := math.Mod(d.Minutes(), 60) remainingSeconds := math.Mod(d.Seconds(), 60) - return fmt.Sprintf("%dh:%dm:%ds", - int64(d.Hours()), int64(remainingMinutes), int64(remainingSeconds)) + return fmt.Sprintf("%dh %dm %.2fs", + int64(d.Hours()), int64(remainingMinutes), remainingSeconds) } remainingHours := math.Mod(d.Hours(), 24) remainingMinutes := math.Mod(d.Minutes(), 60) remainingSeconds := math.Mod(d.Seconds(), 60) - return fmt.Sprintf("%dd:%dh:%dm:%ds", + return fmt.Sprintf("%dd %dh %dm %.2fs", int64(d.Hours()/24), int64(remainingHours), - int64(remainingMinutes), int64(remainingSeconds)) + int64(remainingMinutes), remainingSeconds) } // DetectFileContentType detects the file type by reading MIME type information of the file content.