options-gen icon indicating copy to clipboard operation
options-gen copied to clipboard

Provide a way to mark options as deprecated

Open kazhuravlev opened this issue 1 year ago • 0 comments

In a real world we change our software sometimes, but is some cases - we would like to have an option to provide a smooth way to migrate from old options to a new one.

example:

// Old options that contains a logger
type Options struct {
  logger *zap.Logger `option:"mandatory"`
}

// For example we would like to migrate from zap to slog. So we want to migrate to a new options struct like:
type Options struct {
  logger *slog.Logger `option:""mandatory"`
}

Options:

  • We can just mark this logger field with // Deprecated: ... and create a new field. But in example above (when we have mandatory mark) we will not see a deprecation marker, because this field will have no setter like WithLogger.
  • ???

kazhuravlev avatar Jun 24 '23 16:06 kazhuravlev