go-humanize Documentation

Go Humans! (formatters for units to human friendly sizes)

4,844 stars Go Go 1 file ยท ~1,183 tokens
RAW Doc

File: SECURITY.md

Security Policy

To report a security issue, please disclose it at security advisory.

We will respond within 7 working days of your submission. If the issue is confirmed as a vulnerability, we will open a Security Advisory and acknowledge your contributions as part of it. This project follows a 90 day disclosure timeline.


File: .github/dependabot.yml

version: 2
updates:

  • package-ecosystem: "github-actions"
    directory: "/"
    schedule:

    Check for updates to GitHub Actions every week

    interval: "weekly"

File: .github/workflows/coverage.yml

Generates an HTML test coverage report and publishes it to GitHub

Pages, served at https://dustin.github.io/go-humanize/

name: Coverage

on:
push:
branches: [ "master" ]

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
coverage:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

text
- name: Set up Go
  uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
  with:
    go-version: "1.27"

- name: Generate coverage report
  run: |
    go test -coverprofile=coverage.out ./...
    mkdir -p public
    go tool cover -html=coverage.out -o public/index.html

- name: Configure Pages
  uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0

- name: Upload coverage report
  uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
  with:
    path: public

- name: Deploy to GitHub Pages
  id: deployment
  uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1

File: .github/workflows/fuzz.yml

Runs fuzz targets. Fuzzing is expensive, so this only runs on pushes to

master (i.e. once per merge) rather than on every commit or pull request.

It can also be triggered manually via workflow_dispatch.

name: Fuzz

on:
push:
branches: [ "master" ]
workflow_dispatch:

permissions:
contents: read

jobs:

discover-fuzz-targets:
runs-on: ubuntu-latest
outputs:
targets: ${{ steps.discover.outputs.targets }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

text
- name: Set up Go
  uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
  with:
    go-version: "1.27"

- name: Discover fuzz tests
  id: discover
  run: |
    targets=$(go list ./... | while read -r pkg; do
      go test -list '^Fuzz' "$pkg" | grep '^Fuzz' | while read -r name; do
        jq -n --arg pkg "$pkg" --arg name "$name" '{package: $pkg, name: $name}'
      done
    done | jq -s -c .)
    echo "targets=$targets" >> "$GITHUB_OUTPUT"

fuzz:
needs: discover-fuzz-targets
if: needs.discover-fuzz-targets.outputs.targets != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: ${{ fromJson(needs.discover-fuzz-targets.outputs.targets) }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

text
- name: Set up Go
  uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
  with:
    go-version: "1.27"

- name: Fuzz ${{ matrix.target.name }}
  run: go test -run=${{ matrix.target.name }} -fuzz=^${{ matrix.target.name }}$ -fuzztime=30s ${{ matrix.target.package }}

- name: Upload failing corpus entry
  if: failure()
  uses: actions/upload-artifact@v7
  with:
    name: fuzz-failure-${{ matrix.target.name }}
    path: testdata/fuzz/${{ matrix.target.name }}
    if-no-files-found: ignore

File: .github/workflows/go.yml

This workflow will build a golang project

For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:

build:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ["1.21", "1.27"]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

text
- name: Set up Go
  uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
  with:
    go-version: ${{ matrix.go-version }}

- name: Build
  run: go build -v ./...

- name: Test
  run: go test -v ./...