gosha

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 4 Imported by: 0

README ΒΆ

Gosha: Go SHA256 Hash Generator for Packages

Go Report Card GoDoc License

Gosha is a versatile Go package and accompanying CLI tool designed to generate SHA256 hashes for Go packages and their dependencies. This becomes invaluable for integrity checks in CI/CD pipelines, automated workflows, or even managing monorepos.

🌟 Key Features

  • πŸ“¦ Package Hashing: Generate SHA256 hashes for any Go package.
  • πŸ› οΈ CLI & Library Support: Both command-line and programmatic interfaces are available.
  • βš™οΈ Fine-grained Control: Optionally include standard library and test files in the hash generation.
  • πŸš€ Use-cases:
    • Efficiently manage monorepo builds by rebuilding only when a service source code has changed.
    • Use the generated SHA as a tag for Docker images, ensuring Kubernetes Deployments are updated only when necessary.

πŸ“₯ Installation

Install the package and CLI tool using go get:

go get -u github.com/draganm/gosha

πŸ“˜ Usage

CLI Interface

Use the following command syntax:

gosha [OPTIONS] [PACKAGE_PATH]

Options:

  • --include-stdlib: Include Go's standard libraries in the hash generation.
    • Environment variable: INCLUDE_STDLIB
  • --include-testfiles: Include test files in the hash generation.
    • Environment variable: INCLUDE_TESTFILES
Examples:

To generate a SHA256 hash for the package in the current directory:

gosha

To include standard libraries for a specific package:

gosha --include-stdlib <path to your main package>
Programmatic Interface

To use Gosha programmatically, import the gosha package and call the CalculatePackageSHA() function.

import "github.com/draganm/gosha/gosha"

finalSHA, err := gosha.CalculatePackageSHA("<path to your main package>", false, false)
if err != nil {
    fmt.Println("Error:", err)
    return
}
// Use the finalSHA as needed...

πŸ‘₯ Contributing

Contributions are welcome! Feel free to submit issues for bug reports, feature requests, or even pull requests.

πŸ“œ License

This project is licensed under the MIT License.

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL