Creating components in Go

Beware: Technical topic, best suited for power-users!

If you want to write a component with Go code, but would like to have it work seamlessly with other workflow processes in SciPipe, without reimplementing the whole SciProcess functionality yourself, there is a way to do it: By using the CustomExecute field of SciProcess.

In short, it can be done like this:

// Initiate task from a "shell like" pattern, though here we
// just specify the out-port, and nothing else. We have to
// specify the out-port (and any other ports we plan to use later),
// so that they are correctly initialized.
fooWriter := sci.NewProc("fooer", "{o:foo}")

// Set the output formatter to a static string
fooWriter.SetPathStatic("foo", "foo.txt")

// Create the custom execute function, with pure Go code and
// add it to the CustomExecute field of the fooWriter process
fooWriter.CustomExecute = func(task *sci.SciTask) {
    task.OutTargets["foo"].WriteTempFile([]byte("foo\n"))
}

For a more detailed example, see this example (Have a look at the NewFooer() and NewFoo2Barer() factory functions in particular!)