Using the Go in Flogo

Flynn has a new friend… a proper gopher 🙂

Not too long ago Flogo introduced a new Go API that allows you to build event-driven apps by simply embedding the Flogo engine in your existing Go code. Now you can use the event-driven engine of Flogo to build Go apps while using the activities and triggers that already exist and combining that with “regular” Go code. In one of my other posts, I built an app that could receive messages from PubNub and for this post, I’ll walk through building the exact same using the Go API.

Note: I realize that certain pieces of the code aren’t as optimized as they could be, but I wanted to keep the flow similar to what I did with the Web UI

https://medium.com/media/64cef8e47401e448f42b523573a30a6c/href

To run this example you’ll need to have Go installed and execute these commands from where you created the file with the source code (which will have to be in your $GOPATH)

Get all the dependencies

#If you already have Flogo or the Flogo CLI, you can skip these
go get -u github.com/TIBCOSoftware/flogo-contrib/activity/log
go get -u github.com/TIBCOSoftware/flogo-lib/core/data
go get -u github.com/TIBCOSoftware/flogo-lib/engine
go get -u github.com/TIBCOSoftware/flogo-lib/flogo
go get -u github.com/TIBCOSoftware/flogo-lib/logger
# You will need to go get these :)
go get -u github.com/retgits/flogo-components/activity/writetofile
go get -u github.com/retgits/flogo-components/trigger/pubnubsubscriber

Generate the metadata

The Flogo engine needs a bit of metadata, and to generate that the line at the top of the file needs to be executed. To do that, simply run the command below:

go generate

Build and run

Now that the “hard” part is done, you can build the app like you would do for any Go app:

go build
./pubnub-app

Testing it out

If you’re testing it out in the same way as I did in my last post, you’ll see the same the same status messages come by as in the example with the Web UI and when you test the app in the exact same way, you’ll see that both apps will receive the same message!

No matter if you’re a Go developer or someone who builds microservices visually (through a very cool Web UI), you can do it using Flogo! If you’re trying out Flogo and have any questions, feel free to join our Gitter channel, create an issue on GitHub or even drop me a note on Twitter. I’d also love to get your feedback if you thought this was helpful (or not).


Using the Go in Flogo was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: