Skip to content

sentenz/percent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Percent

GoDoc Go Report Card Coverage License

Percent is a Go package that provides utility functions for calculating percentages and performing related operations.

1. Module

1.1. Prerequisites

  • Go

    Go programming language environment for building and running Go applications.

1.2. Installation

  • Install

    Install the package via go get.

    go get github.com/sentenz/percent
  • Import

    Import the package in a called Go source file.

    import "github.com/sentenz/percent/pkg/percent"

1.3. Usage

  • Examples

    Examples of how to use the Percent package.

    package main
    
    import (
        "fmt"
        "log"
        
        "github.com/sentenz/percent/pkg/percent"
    )
    
    func main() {
        // Example 1: Calculate what percentage of a value is
        // What is 25% of 200?
        result, err := percent.Percent(25, 200.0)
        if err != nil {
            log.Fatalf("Error calculating percent: %v", err)
        }
        fmt.Printf("25%% of 200 = %.2f\n", result) // Output: 25% of 200 = 50.00
    
        // Example 2: Calculate what percentage a value is of a total
        // What percentage is 50 of 200?
        pct, err := percent.Of(50.0, 200.0)
        if err != nil {
            log.Fatalf("Error calculating percentage: %v", err)
        }
        fmt.Printf("50 is %.2f%% of 200\n", pct) // Output: 50 is 25.00% of 200
    }

2. Contribute

Contribution guidelines and project management tools.

2.1. Task Runner

2.1.1. Make

Make is a automation tool that defines and manages tasks to streamline development workflows.

  1. Insights and Details

    • Makefile

      Makefile defining tasks for building, testing, and managing the project.

  2. Usage and Instructions

    • Tasks

      make help

      [!NOTE]

      • Each task description must begin with ## to be included in the task list.
      $ make help
      
      Tasks
              A collection of tasks used in the current project.
      
      Usage
              make <task>
      
              bootstrap         Initialize a software development workspace with requisites
              setup             Install and configure all dependencies essential for development
              teardown          Remove development artifacts and restore the host to its pre-setup state
      

2.2. Bootstrap

2.2.1. Scripts

scripts/ provides scripts to bootstrap, setup, and teardown a software development workspace with requisites.

  1. Insights and Details

    • bootstrap.sh

      Initializes a software development workspace with requisites.

    • setup.sh

      Installs and configures all dependencies essential for development.

    • teardown.sh

      Removes development artifacts and restores the host to its pre-setup state.

  2. Usage and Instructions

    • Tasks

      make bootstrap
      make setup
      make teardown

2.3. Dev Containers

.devcontainer/ provides Dev Containers as a consistent development environment using Docker containers.

  1. Insights and Details

    • go/

      Dev Container configuration for Go development environment.

      // ...
      "postCreateCommand": "sudo make bootstrap && sudo make setup",
      // ...

      [!NOTE] The devcontainer.json runs the bootstrap and setup tasks to initialize and configure the development environment.

  2. Usage and Instructions

    • Tasks

      # TODO
      # make devcontainer-go

2.4. Dependency Manager

2.4.1. Go Modules

Go Modules is the dependency management system for Go that simplifies the process of managing dependencies and libraries.

  1. Insights and Details

    • go.mod

      Go module file defining the module path and dependencies.

    • go.sum

      Go checksum file containing expected cryptographic checksums of module dependencies.

    • vendor/

      Directory containing vendored dependencies.

  2. Usage and Instructions

    • Tasks

      make go-mod-tidy
      make go-mod-vendor

2.5. Software Testing

2.5.1. Unit Testing

Go testing is the standard library package for unit testing in Go.

  1. Insights and Details

    • testing.T

      Unit tests use the standard Go testing package with testing.T.

    • AGENTS.md

      Automate unit test generation using Large Language Models (LLMs) Agents.

  2. Usage and Instructions

    • CI/CD

      uses: sentenz/actions/go-tests@latest
    • Tasks

      make go-test-unit

2.5.2. Fuzz Testing

Go fuzzing is a testing technique that uses randomized inputs to find bugs and security vulnerabilities.

  1. Insights and Details

    • testing.F

      Fuzz tests use the standard Go testing package with testing.F.

    • AGENTS.md

      Automate fuzz test generation using Large Language Models (LLMs) Agents.

  2. Usage and Instructions

    • CI/CD

      uses: sentenz/actions/go-tests@latest
    • Tasks

      make go-test-fuzz

2.5.3. Benchmarks

Go benchmarks measure the performance of code and track performance regressions.

  1. Insights and Details

    • testing.B

      Benchmark tests use the standard Go testing package with testing.B.

    • AGENTS.md

      Automate benchmark test generation using Large Language Models (LLMs) Agents.

  2. Usage and Instructions

    • Tasks

      make go-test-bench

2.5.4. Code Coverage

go tool cover provides code coverage analysis for Go tests.

  1. Insights and Details

    • Code coverage reports are generated in HTML and XML formats.
  2. Usage and Instructions

    • CI/CD

      uses: sentenz/actions/go-tests@latest
    • Tasks

      make go-test-coverage

2.6. Release Manager

2.6.1. Semantic-Release

Semantic-Release automates the release process by analyzing commit messages to determine the next version number, generating changelog and release notes, and publishing the release.

  1. Insights and Details

    • .releaserc.json

      Configuration file for Semantic-Release specifying release rules and plugins.

  2. Usage and Instructions

    • CI/CD

      uses: sentenz/actions/semantic-release@latest

2.7. Update Manager

2.7.1. Renovate

Renovate automates dependency updates by creating merge requests for outdated dependencies, libraries and packages.

  1. Insights and Details

    • renovate.json

      Configuration file for Renovate specifying update rules and schedules.

  2. Usage and Instructions

    • CI/CD

      uses: sentenz/actions/renovate@latest

2.7.2. Dependabot

Dependabot automates dependency updates by creating pull requests for outdated dependencies, libraries and packages.

  1. Insights and Details

2.8. Policy Manager

2.8.1. Conftest

Conftest is a Policy as Code (PaC) tool to streamline policy management for improved development, security and audit capability.

  1. Insights and Details

    • conftest.toml

      Configuration file for Conftest specifying policy paths and output formats.

    • tests/policy

      Directory contains Rego policies for Conftest to enforce best practices and compliance standards.

  2. Usage and Instructions

    • CI/CD

      uses: sentenz/actions/regal@latest
      uses: sentenz/actions/conftest@latest
    • Tasks

      make policy-lint-regal <filepath>
      make policy-analysis-conftest <filepath>

2.9. Supply Chain Manager

2.9.1. Trivy

Trivy is a comprehensive security scanner for vulnerabilities, misconfigurations, and compliance issues in container images, filesystems, and source code.

  1. Insights and Details

    • trivy.yaml

      Configuration file for Trivy specifying scan settings and options.

    • .trivyignore

      File specifying vulnerabilities to ignore during Trivy scans.

  2. Usage and Instructions

    • CI/CD

      uses: sentenz/actions/trivy@latest
    • Tasks

      make sast-trivy-fs <path>
      make sast-trivy-sbom-cyclonedx-fs <path>
      make sast-trivy-sbom <sbom_path>
      make sast-trivy-sbom-license <sbom_path>

3. References

About

A percentage module for Go.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •