• Stars
    star
    824
  • Rank 55,348 (Top 2 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Golang Microsoft Windows File Properties/Version Info and Icon Resource Generator

GoVersionInfo

Go Report Card Build Status Coverage Status GoDoc

Microsoft Windows File Properties/Version Info and Icon Resource Generator for the Go Language

Package creates a syso file which contains Microsoft Windows Version Information and an optional icon. When you run "go build", Go will embed the version information and an optional icon and an optional manifest in the executable. Go will automatically use the syso file if it's in the same directory as the main() function.

Example of the file properties you can set using this package:

Image of File Properties

Usage

To install, run the following command:

go get github.com/josephspurrier/goversioninfo/cmd/goversioninfo

Copy testdata/resource/versioninfo.json into your working directory and then modify the file with your own settings.

Add a similar text to the top of your Go source code (-icon and -manifest are optional, but can also be specified in the versioninfo.json file):

//go:generate goversioninfo -icon=testdata/resource/icon.ico -manifest=testdata/resource/goversioninfo.exe.manifest

Run the Go commands in this order so goversioninfo will create a file called resource.syso in the same directory as the Go source code.

go generate
go build

Command-Line Flags

Complete list of the flags for goversioninfo:

  -charset=0: charset ID
  -comment="": StringFileInfo.Comments
  -company="": StringFileInfo.CompanyName
  -copyright="": StringFileInfo.LegalCopyright
  -description="": StringFileInfo.FileDescription
  -example=false: dump out an example versioninfo.json to stdout
  -file-version="": StringFileInfo.FileVersion
  -icon="": icon file name
  -internal-name="": StringFileInfo.InternalName
  -manifest="": manifest file name
  -skip-versioninfo=false: skip version info reading on true, allows setting just icon
  -o="resource.syso": output file name
  -gofile="": Go output file name (optional) - generates a Go file to access version information internally
  -gofilepackage="main": Go output package name (optional, requires parameter: 'gofile')
  -platform-specific=false: output i386 and amd64 named resource.syso, ignores -o
  -original-name="": StringFileInfo.OriginalFilename
  -private-build="": StringFileInfo.PrivateBuild
  -product-name="": StringFileInfo.ProductName
  -product-version="": StringFileInfo.ProductVersion
  -special-build="": StringFileInfo.SpecialBuild
  -trademark="": StringFileInfo.LegalTrademarks
  -translation=0: translation ID
  -64:false: generate 64-bit binaries on true
  -arm:false: generate ARM binaries on true
  -ver-major=-1: FileVersion.Major
  -ver-minor=-1: FileVersion.Minor
  -ver-patch=-1: FileVersion.Patch
  -ver-build=-1: FileVersion.Build
  -product-ver-major=-1: ProductVersion.Major
  -product-ver-minor=-1: ProductVersion.Minor
  -product-ver-patch=-1: ProductVersion.Patch
  -product-ver-build=-1: ProductVersion.Build

You can look over the Microsoft Resource Information: VERSIONINFO resource

You can look through the Microsoft Version Information structures: Version Information Structures

PowerShell Differences

In PowerShell, the version components are named differently than the fields in the versioninfo.json file:

PowerShell:          versioninfo.json:
-----------          -----------------
FileMajorPart      = FileVersion.Major
FileMinorPart      = FileVersion.Minor
FileBuildPart      = FileVersion.Patch
FilePrivatePart    = FileVersion.Build
ProductMajorPart   = ProductVersion.Major
ProductMinorPart   = ProductVersion.Minor
ProductBuildPart   = ProductVersion.Patch
ProductPrivatePart = ProductVersion.Build

If you find any other differences, let me know.

Alternatives to this Tool

You can also use windres to create the syso file. The windres executable is available in either MinGW or tdm-gcc.

Below is a sample batch file you can use to create a .syso file from a .rc file. There are sample .rc files in the testdata/rc folder.

@ECHO OFF

SET PATH=C:\TDM-GCC-64\bin;%PATH%
REM SET PATH=C:\mingw64\bin;%PATH%

windres -i testdata/rc/versioninfo.rc -O coff -o versioninfo.syso

PAUSE

The information on how to create a .rc file is available here. You can use the testdata/rc/versioninfo.rc file to create a .syso file that contains version info, icon, and manifest.

Issues

The majority of the code for the creation of the syso file is from this package: https://github.com/akavel/rsrc

There is an issue with adding the icon resource that prevents your application from being compressed or modified with a resource editor. Please use with caution.

Major Contributions

Thanks to Tamás Gulácsi for his superb code additions, refactoring, and optimization to make this a solid package.

Thanks to Mateusz Czaplinski for his embedded binary resource package with icon and manifest functionality.

More Repositories

1

gowebapp

Basic MVC Web Application in Go
Go
1,136
star
2

golang-portable-windows

Go Programming Language - Portable Environment for Windows
Batchfile
119
star
3

polarbearblog

Beautifully simple single author blog in Go - derived from Bear Blog.
Go
109
star
4

gowebapi

Testable Web API in Go with Swagger
Go
57
star
5

csrfbanana

Golang CSRF Protection for gorilla/sessions
Go
29
star
6

rove

MySQL Database Migration Tool Inspired by Liquibase in Go/Golang
Go
23
star
7

surfstack-wamp

Preinstalled Windows package with Apache, Nginx, MySQL, MongoDB, PHP, and Memcached
PHP
16
star
8

mithril-template

Sample notepad application template in Mithril with TypeScript showing integrations with modern tools. This project uses Babel, Bulma, Cypress, JSX, ESLint, Mock Service Worker, npm, Sass, Storybook, Prettier, VS Code, webpack, and webpack DevServer.
TypeScript
11
star
9

gocleanarchitecture

Example web application using clean architecture in Go.
Go
10
star
10

goconsole

Golang Command Line Functionality
Go
10
star
11

liteide-material

Material Theme for LiteIDE
9
star
12

gomithrilapp

Sample notepad application in Mithril (JSX) and Go showing good practices and integrations with modern tools. This project uses Bulma, Cypress, Docker, ESLint, gvt, make, Mock Service Worker, Rove, Storybook, Swagger, and Travis-CI.
Go
9
star
13

goappmation

Portable App Creator in Go
Go
9
star
14

h

Advanced Lightweight Go HTTP Handler Adapter
Go
6
star
15

gomithriltsapp

Sample notepad application in Mithril (TypeScript and Hyperscript) and Go showing good practices and integrations with modern tools. This project uses Bulma, Cypress, Docker, ESLint, gvt, make, Mock Service Worker, Rove, Storybook, Swagger, and Travis-CI.
Go
6
star
16

govueapp

Sample notepad application in Vue and Go showing good practices and integrations with modern tools. This project uses Bulma, Cypress, Docker, ESLint, gvt, make, Nuxt.js, Rove, Swagger, and Travis-CI.
Go
4
star
17

surfstack-routing

URL Router and Dispatcher in PHP
PHP
3
star
18

ninja-file-collector

Chrome extension that displays all files a web page uses
JavaScript
3
star
19

sveltekitapp

Sample notepad application in SvelteKit with TypeScript showing good practices and integrations with modern tools. This project uses Bulma, ESLint, and Storybook.
TypeScript
1
star
20

structreflect

Regenerate Struct through Reflection in Go
Go
1
star
21

octane

Template for Go REST API using Echo and Swagger
Go
1
star
22

surfstack-coding-standards

PHP Coding Standards using Allman Style
1
star
23

texman

Simple package for making changes to text files in Go.
Go
1
star
24

mithril-fusion

Mithril with Fusion.js (Uber)
JavaScript
1
star
25

surfstack-templating

PHP Template Engine
PHP
1
star
26

godockertest

Testing Golang Build Constraints with Docker
Shell
1
star
27

goreactapp

Sample notepad application in React and Go showing good practices and integrations with modern tools. This project uses Bulma, Cypress, Docker, ESLint, gvt, make, Rove, Swagger, Mock Service Worker, and Travis-CI.
Go
1
star