04-simple-mock-gen

command
v0.0.0-...-52405dd Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: MIT Imports: 12 Imported by: 0

README

Simple Mock Generator

This shows a really simple implementation of a mock generator. It uses AST and go/packages to read in an interface and output a mock object based on it.

Install the generator

Ensure you are in the 04-simple-mock-gen dir on your command line.

If you are running on GitPod, then you can skip this part as it will be setup when you open the repo, if you are running this fresh on your machine, run the below command from the repo root to install the generator to your path:

    cd 04-simple-mock-gen && go install && cd ../

Running the generator

If you open airplane.go you will see the go:generate statement there, run it and you'll get a mock object generated.

Have a look through the code in main.go to see how it works.

When you make changes either run with go run main.go -type=AirplaneReader or re-run the go install command and execute the inline go:generate command.

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