There is a detailed article available on how you can write workflows in Go language.
How I develop workflows
I like to write all my workflows in Go language unless the workflow can be done using only Alfred builtin objects and some python/bash code. Here are steps I follow to create my workflows, both Go workflows and non Go.
Using Go and AwGo
- Create a folder in
~/src/alfred. Prefix the folder name with
- Initialize the folder with git as any project.
- Inside the
alfred-..folder I create a
workflowdirectory. This is where the actual workflow will live in as well as the binary file compiled from my Go code.
- Create the workflow I want to make in Alfred Preferences. Add the icon, name and unique bundle ID. And add the workflow to my custom
Minecategory so I can quickly filter out all the workflows I've ever made inside Alfred.
Carry the info.plist and .png file of the logo to this workflow directory I created. I use Alfred's Move To... file action for quickly transferring files. You can find these files by going here.
Delete the workflow I made from Alfred preferences.
- Inside my
alfred-..directory I run
alfred link. That creates a symlink between the workflow directory and where the actual workflow lies. This uses alfred CLI tool.
- Write my Go code inside
alfred-..folder and when I want to compile it to run from Alfred, I run
- Write the code and make a MVP. Not forgetting to add/change version number of my workflow.
- If I want to share the workflow with the world (which is usually always), I create a GitHub repository and push my workflow there, making sure that AwGo updating works so all the users can receive future updates.
Using Alfred builtin objects + some code
- Create a folder in
~/src/alfred/small-workflows. Name the folder by workflow name, lowercased and separated by dashes without
- Inside the folder I create a
- Create the workflow I want to make in Alfred Preferences. Add the icon, name and unique bundle ID. Add the workflow to
- Carry the info.plist and .png file of the logo to
workflowdirectory I just made.
- Delete the workflow I made from Alfred preferences.
- Inside my workflow's folder in small workflows, I run
workflow-install -s workflow.
workflow-installcommand is placed inside my ~/.dotfiles/bin which is added to my $PATH. The script symlinks the
workflowdirectory to Alfred.
- If the workflow is private to me, I prefix it's name with
a.before the workflow name to indicate that I have not released the workflow yet or it contains sensitive information.
- Create the Alfred objects I need to make the workflow does what I want. If the workflow needs something more complex, I sometimes create Python files inside the workflow dir to do what I want and call them from the Script Filters.
- In cases where I want to release the workflow, I strip the
a.prefix from the name. Then go to to my Objects library workflow and transfer a OneUpdater object to my workflow.
readonly workflow_urlvariables in OneUpdater script to point to correct links. Then add a version number to the workflow if I haven't yet. Export the workflow to
~/Desktopwith DirectoryWatches workflow and then viewing
~/Desktopwith Directory Watches workflow, I file action on the workflow in
~/Desktopto move it quickly to the directory in my small workflows.
pushthe directory contents to GitHub.
Updating existing workflows
I first commit and push the changes to my repo.
I then use Workflow Directory workflow to search the workflow I want to export and with a modifier press, export that workflow to
~/Desktop. This action also copies the version number of the workflow.
I then use modified by me wonderful Repos workflow which searches Git projects in directories I specify to open a new release page in my browser on a modifier keypress. You can grab my hacked version of Repos workflow here.
Using the workflow I search the
alfred-.. workflow I want to release an update for and with a modifier press quickly open the new release page. I then add the version number I have copied in my clipboard and add the name to the release and I attach the workflow sitting in my
~/Desktop to the release.
I use Workflow Directory workflow to search the workflow I want to export and with a modifier press, export that workflow to
I delete the original workflow sitting in the directory of the workflow and then with Alfred's
Move to.. transfer the workflow to the directory of the workflow. Commit and push.