Defining a Pipeline

At this point, your tool executes the first step in the CI pipeline: Go Build. In its current state, the information to execute this step is hard-coded into the run function. While this is a valid approach, adding more steps to this tool using the same approach would cause extensive code repetition. We want a tool that’s maintainable and easy to extend, so let’s make a change to the program’s structure to make the code more reusable.

To do that, you’ll refactor the part of the run function that executes the external program into its own function. To make it easier to configure, let’s add a custom type step that represents a pipeline step and associate the method execute to it. You’ll also add a constructor function called ...

Get Powerful Command-Line Applications in Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.