irgen

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2017 License: MPL-2.0 Imports: 7 Imported by: 0

README

irgen is a code generator for the visitees (elements) in the visitor pattern.

Given a file option.go in the directory $GOPATH/src/some-domain.org/option containing

package option

//go:generate irgen Option OptionConsumer

type Option interface {
    FeedTo(consumer OptionConsumer)
}

type OptionConsumer interface {
    Some(X interface{})
    None()
}

running go generate some-domain.org/option will generate a file named option_impl.go containing something like

package option

type Some struct {
    X interface{}
}
type None struct {
}

func (option Some) FeedTo(consumer OptionConsumer) { consumer.Some(Option.X) }
func (option None) FeedTo(consumer OptionConsumer) { consumer.None() }

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Path to the directory containing the code.
	Directory string
	//
	PackageName string

	TypeNames struct {
		Composite string
		Consumer  string
	}
}

A configuration object specifying what to generate based on what.

func (Config) Generate

func (cfg Config) Generate(out io.Writer) error

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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