Adding Custom Golang Code or Dependencies to the App
You can use custom Golang code with your extensions. You can also use custom Golang code in your Flogo apps directly without using it in any extension. Your custom extensions and apps may also have dependencies. In the case of both, the custom Golang code and the dependencies, you have the option to either dynamically pull the latest version of the packages from github.com during build time, or to pull a specific version of the package and store it locally in <FLOGO_HOME>/lib/ext/src folder ahead of time. Storing a specific version of the package locally reduces your build time. Since the packages will be available locally, the build process saves the time it takes to pull them from an external source. Keep in mind that when the packages are pulled from the github.com repository during build time, the absolute latest version of the packages get pulled. So, if you want a specific version of the package, you must pull the package ahead of time and store it locally.
When you build the app binary, the build process first searches for the packages locally. If it does not find a package locally, it attempts to pull the package from github.com repository.
Adding custom Golang code to your app
- Pull the package from the Git repository ahead of time. This is not required if you want the package pulled dynamically during build time.
- Create a
deps.go file under
<FLOGO_HOME>/lib/ext/src folder if it does not already exist and add an entry for the package pointing to its public URL.
Here are two examples of the deps.go file content:
package main import _ "github.com/<username>/contrib/eventlistener"
package main import ( _ "github.com/<username>/contrib/eventlistener" _ "github.com/<username>/contrib/example" )
Add the public github.com URLs for all your custom Golang code packages here.The build process uses the package URL stated in the deps.go file to look for the package on github.com if the package is not found locally. Once the code package is pulled, deps.go initializes the package.
Adding versioned dependencies to your custom extension
If your custom extension uses a third party library over which you have no control, you might want the extension to always use a specific version of the library. You can download the specific version of the library and place it under <FLOGO_HOME>/lib/ext/src folder. You must not add an entry in the deps.go file for dependency packages. Build the app binary.