godel-refreshables-plugin

command module
v0.213.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

README

Autorelease

godel-refreshables-plugin

A godel plugin for generating strongly-typed refreshable wrappers for arbitrary types.

For each target type, and the types required to construct it, the plugin will generate an interface definition (and implementation) which provides typed variants of the Current, Map, and Subscribe methods from the refreshable.Refreshable interface. Struct types additionally have generated methods to access each field as a Refreshable.

Plugin Configuration

The plugin reads a configuration file at godel/config/refreshables-plugin.yml which specifies the types for which Refreshable wrappers will be generated.

Example:

refreshables:
  # Relative path to local package
  ./pkg/mypackage:
    types:
      - MyType
  # Absolute path to local package
  github.com/user/project/pkg/mypackage:
    types:
      - MyType
  # Absolute path to remote package
  # In this case, an output path is required.
  github.com/otheruser/otherpackage:
    output: ./generated/otherpackage/zz_generated_refreshables.go
    types:
      - MyType
Excluding Fields From Code Generation

There are some cases where you may want to exclude specific fields in a struct from generation (for example if the field type is a third-party library struct that contains unexported fields). Fields can be excluded from generation by adding a refreshables tag with the value ",exclude". For example:

package mypackage

type MyType struct {
	FieldA string `yaml:"field-a"`
	// FieldB will not have refreshable methods/types generated for it
	FieldB string `yaml:"field-b" refreshables:",exclude"`
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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