Skip to content

Package config: Add types for common configuration needs. #83

Description

@octo

The "config".Unmarshaler interface can be used to implement unmarshaling behavior that differs from the default. That can be used to support some recurring needs:

  • A type Port uint16 that accepts numeric and string values. If a string, "net".LookupPort is used to convert it to an integer. If the numeric value is outside of the 1–65535 range, an error is returned.
  • A type ServiceName string that is the inverse: a numeric value (in the 1–65535 range) is converted to a string.
  • Control mapping of multiple values onto a scalar type. For example, when mapping ["foo", "bar", "qux"] to a single string, should this result in an error (current behavior), the first value ("foo"), the last value ("qux"), or a random value? Special types could handle that. The "last value wins" / value is overwritten behavior is not uncommon in C plugins.
  • Provide minimum / maximum values for numeric values.
  • Check string values with a regular expression.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions