Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] many: add types.Option generic and use in customizations #860

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Commits on Sep 10, 2024

  1. internal: add new types.Option generic for primitive types

    This is heavily inspired by https://github.com/moznion/go-optional
    with is super nice. However we cannot use it as is because it
    lacks support for toml unmarshal and go makes it really hard to
    extend existing types. Submiting toml unmarshal upstream would
    also be an option but it's difficult in the general case because
    the toml unmarshal interface is very limited for complex types
    (it only passes `data any` with the full decoded complex struct
    into map[string]inteface{} for example which leaves it to the
    user of the library to convert to the actual type struct which
    is a pain with reflect). I really whish go was more expressive
    here.
    
    So this commit defines a subset of https://github.com/moznion/go-optional
    in our own internal types lib.
    mvo5 committed Sep 10, 2024
    Configuration menu
    Copy the full SHA
    fc3af96 View commit details
    Browse the repository at this point in the history
  2. blueprint: use new internal/types to avoid pointers for unset

    It seems we are currently using *bool a lot to distinguish between
    {unset,true,false}. This commit instead uses the new `interal/types`
    library to distinguish between unset/undefined and the value.
    
    It uses generics to works on all primitive toml type.
    mvo5 committed Sep 10, 2024
    Configuration menu
    Copy the full SHA
    932e095 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    dd3212c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    74823a6 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    07741d4 View commit details
    Browse the repository at this point in the history