Git Product home page Git Product logo

go-fileversion's Introduction

go-fileversion

GoDoc Go Report Card

Package fileversion provides wrapper for querying properties from windows version-information resource.

Using the package you can extract the following info:

properties example

If you are looking how to add this info to your go binary - look at josephspurrier/goversioninfo.

Examples

Print version info from input file

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/bi-zone/go-fileversion"
)

func main() {
	if len(os.Args) < 2 {
		log.Fatalf("Usage: %s <image-path>", os.Args[0])
	}
	f, err := fileversion.New(os.Args[1])
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("ProductName:", f.ProductName())
	fmt.Println("LegalCopyright:", f.LegalCopyright())
	fmt.Println("Version:", f.FixedInfo().FileVersion)
}

All string properties in file version-information resource by-design has multiple translations. go-fileversion allows you to query that translations in a 2 ways.

You can create an Info object with "preferred" locale:

germanLocale := fileversion.Locale{
    LangID: 0x0407, // langID German
    CharsetID: fileversion.CSUnicode,
}
f, err := fileversion.NewWithLocale(os.Args[1], germanLocale)
if err != nil {
    log.Fatal(err)
}
fmt.Println("ProductName:", f.ProductName())

Here "German-Unicode" locale will be used to query string properties (like ProductName), but if the german translation will be missing - go-fileversion would try to fetch a property with default translation. (The idea of locales handling was copied from .NET Framework 4.8)

The only way to get necessary translation without any heuristics is to use GetPropertyWithLocale manualy:

f, err := fileversion.New(os.Args[1])
if err != nil {
    log.Fatal(err)
}
germanLocale := fileversion.Locale{
    LangID: 0x0407, // langID German
    CharsetID: fileversion.CSUnicode,
}
fmt.Println(f.GetPropertyWithLocale("ProductName", germanLocale))

Versioning

Project uses semantic versioning for version numbers, which is similar to the version contract of the Go language. Which means that the major version will always maintain backwards compatibility with minor versions. Minor versions will only add new additions and changes. Fixes will always be in patch.

This contract should allow you to upgrade to new minor and patch versions without breakage or modifications to your existing code. Leave a ticket, if there is breakage, so that it could be fixed.

go-fileversion's People

Contributors

mshsmlv avatar yalegko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

go-fileversion's Issues

FixedInfo().FileVersion.String() Generates Version in the Wrong Order

When a Windows application is built and I look at the file's Properties, and then the Details tab, the file version values are in the order I would expect, Mahor, Minor, Build, Revision (what you call Patch). For example: 5.0.0.19

However when I use go-fileversion to retrieve the same file's version info and then use FixedInfo().FileVersion.String() to display it, it displays in the wrong order: 5.0.19.0

It appears to be putting Revision/Patch in front of Build instead of after.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.