thunk

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 14 Imported by: 0

README

thunk

MIT License Test

thunk is a code generator to make interface's wrapper with methods evaluated lazily.

About

thunk generates interface's wrapper for lazy evaluation. Methods of the wrapper returns a thunk of the method call, instead of evaluating indivisually.

// original interface `Hello`
hello := NewHello()
hello.Greet("Tom")

// generated wrapper `LazyHello`
lazyHello := NewLazyHello(hello)
greetThunk := lazyHello.Greet("Bob") // Hello.Greet is not evaluated yet!
greetThunk()                         // Hello.Greet is evaluated here

See /_examples/hello for details.

Install

$ go install github.com/syuparn/thunk/cmd/thunk@latest

Usage

# generate wrapper code to zz_generated.thunk.go
$ thunk -o zz_generated.thunk.go example.com/your/package

Also, you can use go generate to generate thunks.

//go:generate thunk -o zz_generated.thunk.go example.com/your/package

Note

This project uses skeleton to generate the module.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Generator = &codegen.Generator{
	Name: "thunk",
	Doc:  doc,
	Run:  run,
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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