Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
// An example that shows how to create a sub-network / sub-workflow that can be
// used as a component
package main
import sp ""
func main() {
// Main workflow
wfl := sp.NewWorkflow("foobar_wf", 4)
// Sub-workflow
NewFooBarSubWorkflow(wfl, "foobar_subwf")
// Run
// ------------------------------------------------
// FooBarSubWorkflow
// ------------------------------------------------
type FooBarSubWorkflow struct {
name string
Procs map[string]*sp.Process
Out *sp.OutPort
func NewFooBarSubWorkflow(wf *sp.Workflow, name string) *FooBarSubWorkflow {
fbn := &FooBarSubWorkflow{
name: name,
Procs: make(map[string]*sp.Process),
fbn.Procs["foo"] = sp.NewProc(wf, "foo", "echo foo > {o:foo}")
fbn.Procs["foo"].SetOut("foo", "foo.txt")
fbn.Procs["f2b"] = sp.NewProc(wf, "f2b", "sed 's/foo/bar/g' {i:foo} > {o:bar}")
fbn.Procs["f2b"].SetOut("bar", "{i:foo|%.txt}.bar.txt")
// Connect together inner processes
// Connect last port of inner process to subnetwork out-port
fbn.Out = fbn.Procs["f2b"].Out("bar")
return fbn
func (wf *FooBarSubWorkflow) Name() string {
func (wf *FooBarSubWorkflow) Run() {
for _, proc := range wf.Procs {
go proc.Run()
func (wf *FooBarSubWorkflow) Ready() bool {
return wf.Out.Ready()