Packaging release

To package the data for release, we will embed this metadata into the application binary. Doing so requires creating a binary resource file (ending in .syso) that will encapsulate the manifest and icon files. The easiest way to do this is with the rsrc tool that was used in Chapter 4Walk – Building Graphical Windows Applications. If you have not yet installed rsrc, you can do so with go get github.com/akavel/rsrc. We tell the tool where to find the manifest and icon files and it will output an rsrc.syso file in the current directory, as follows:

rsrc -manifest myapp.exe.manifest -ico myapp.ico

If you are compiling for a 64 bit target, you will need to specify an additional -arch amd64 parameter. It is important that the resource file generated is for the same architecture (either i386 or amd64) as the application you are compiling.

Now that the metadata has been bundled into a resource file, we have to re-build our project. Make sure that, this time, you add the -ldflags="-H windowsgui" parameter, otherwise the resulting application will display a Terminal window when starting:

go build -ldflags="-H windowsgui"

Once the build is complete, we will have created a Windows executable with the icon and metadata included. You can now launch this from the command line or by double-clicking the icon:

Building the application after generating a resource bundle will automatically include the data

Here, we see the same directory in Windows Explorer. The application is on the left in the screenshot that follows, displayed using the icon we included:

Our Windows application with the icon embedded

These processes are slow and can be prone to errors. To avoid doing this process manually, we will explore tools that could automate this.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.35.193