How to run a Go program before building?

I’m trying to build a rather complex Go program that requires multiple steps before it’s built.

One of the steps is to install a Go command and run it. In bash, it’s literally a two-liner.

go get -u -v
rice embed-go

How can I achieve that during the build process of a Snap?

You can use the override-build section in your part. This lets you add additional commands to the default build process for your part.

The simplest no change override-build section is:

    override-build: |
      snapcraftctl build

This is replacing the build step of the part with a request for Snapcraft to run the default build step. If you place some additional commands before snapcraftctl build, then they will be run before the default build commands.

1 Like

Thanks, that worked!