🌱
Sprout
Github
  • About
  • Roadmap to Sprout v1.0
  • Migration from Sprig
  • Introduction
    • Getting Started
    • Templating Conventions
  • Features
    • Loader System (Registry)
    • Loader System (Registry Group)
    • Function Aliases
    • Function Notices
    • Safe Functions
  • Registries
    • List of all registries
    • Backward
    • Checksum
    • Conversion
    • Crypto
    • Encoding
    • Env
    • Filesystem
    • Maps
    • Numeric
    • Network
    • Random
    • Reflect
    • Regexp
    • SemVer
    • Slices
    • Std
    • Strings
    • Time
    • Uniqueid
  • Groups
    • List of all registry groups
    • All
    • Hermetic
  • Advanced
    • How to create a handler
    • How to create a registry
    • How to create a registry group
  • Links
    • GitHub repository
Powered by GitBook
On this page
  • File Naming Conventions
  • Creating a Registry Group
Edit on GitHub
  1. Advanced

How to create a registry group

File Naming Conventions

  • {{registry_group_name}}.go: This file defines the registry group, including key components like structs, interfaces, constants, and variables.

  • {{registry_group_name}}_test.go: Includes tests for the registry group to ensure it functions as expected.

This structure ensures consistency and maintainability across different registries, making it easier for developers to contribute and collaborate effectively. For the rest of conventions please read Templating Conventions.

Creating a Registry Group

  1. New Repository: You can start by creating a new repository on your GitHub account or organization. This will house your registry group functions.

  2. Contributing to Official Registry: To add a new registry group to the official registry, submit a pull request (PR) after a discussion inside an issue. The official registry groups are organized under the group/ folder.

To start, in your {{registry_group_name}}.go file, create a function called RegistryGroup respecting the following signature:

func RegistryGroup() *sprout.RegistryGroup {
  return sprout.NewRegistryGroup(
    // Add your registries here
    // registry.NewRegistry(),
  )
}

You can also create a group directly in your codebase without the need to create a new package. This is useful when you want to group registries that are specific to a project or a use case.

group := sprout.NewRegistryGroup(registry.NewRegistry())

handler.AddGroups(group)

Once your group is defined, you can start using it in your projects. 🎉

PreviousHow to create a registry

Last updated 6 months ago