Documentation ¶
Overview ¶
Package version provides functions to build a VERSIONINFO structure for Windows applications.
This what Windows displays in the Details tab of file properties.
Index ¶
- Constants
- type Info
- func (vi *Info) Bytes() []byte
- func (vi *Info) MarshalJSON() ([]byte, error)
- func (vi *Info) Set(langID uint16, key string, value string) error
- func (vi *Info) SetFileVersion(fileVersion string)
- func (vi *Info) SetProductVersion(productVersion string)
- func (vi *Info) SplitTranslations() map[uint16]*Info
- func (vi *Info) Table() LangTable
- func (vi *Info) UnmarshalJSON(b []byte) error
- type LangTable
- type StringTable
Examples ¶
Constants ¶
const ( Comments = "Comments" CompanyName = "CompanyName" FileDescription = "FileDescription" FileVersion = "FileVersion" InternalName = "InternalName" LegalCopyright = "LegalCopyright" LegalTrademarks = "LegalTrademarks" OriginalFilename = "OriginalFilename" PrivateBuild = "PrivateBuild" ProductName = "ProductName" ProductVersion = "ProductVersion" SpecialBuild = "SpecialBuild" )
const ( App fileType = iota DLL Unknown )
const ( // LangNeutral is the LCID for language agnostic data. LangNeutral = 0 // LangDefault is the LCID for en-US, and it is the default in many tools and APIs. LangDefault = 0x409 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct { FileVersion [4]uint16 ProductVersion [4]uint16 Flags versionFlags Type fileType Timestamp time.Time // contains filtered or unexported fields }
Info is the main struct of this package. Create one as Info{}, use Info.Set() to add key/value pairs, set other members, then add it to the resource set with Info.AddTo.
Example ¶
vi := Info{} // Set some info in the fixed structure vi.ProductVersion = [4]uint16{1, 0, 0, 1} // Set some info in the string table vi.Set(0x409, ProductName, "Good Product") vi.Set(0x40C, ProductName, "Bon Produit") // Once it's complete, make a resource // resourceData := vi.Bytes() // ...
Output:
func MergeTranslations ¶
MergeTranslations merges several VERSIONINFO structs into one multilingual struct.
The fixed part will be taken in priority from:
- The neutral language (zero)
- The default language (en-US)
- The first language ID in ascending order
Each struct corresponds to one translation, and its language ID will be the one it is mapped to.
This means that each struct is supposed to contain exactly one translation, either neutral or of same language ID as it is mapped to.
If a struct contains several translations, those that don't correspond to the map key will be ignored.
If a struct contains one translation with a different language ID, it will be imported as if it had been the same value as the map key.
func (*Info) MarshalJSON ¶
func (*Info) Set ¶
Set sets a key/value pair in the Info structure for a specific locale.
Standard keys are defined as constants in this package: version.ProductName, version.CompanyName, ...
Strings must not contain NUL characters.
Language Code Identifiers (LCID) are listed there: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/
langID may also be 0 for neutral.
Example ¶
vi := Info{} // 0x409 is en-US, and the default language vi.Set(0x409, ProductName, "Good Product") // 0x40C is fr-FR vi.Set(0x40C, ProductName, "Bon Produit") // 0 is neutral vi.Set(0, "Smile", "😀")
Output:
func (*Info) SetFileVersion ¶
SetFileVersion sets the file version, ensuring this is the only one in the structure.
This should be called after json.Unmarshal to override the version.
func (*Info) SetProductVersion ¶
SetProductVersion sets the product version, ensuring this is the only one in the structure.
This should be called after json.Unmarshal to override the version.
func (*Info) SplitTranslations ¶
SplitTranslations splits the Info struct by language. It returns a map indexed by language ID.
Windows Explorer doesn't seem to search for a proper translation inside the VERSIONINFO struct. So one has to embed a whole VERSIONINFO for each language as a resource translation.
func (*Info) Table ¶ added in v0.3.0
Table returns a copy of the language and containing string tables, which hold key/value metadata.
func (*Info) UnmarshalJSON ¶
type LangTable ¶ added in v0.3.0
type LangTable map[uint16]*StringTable
LangTable holds different languages.
func (LangTable) GetMainTranslation ¶ added in v0.3.0
func (lt LangTable) GetMainTranslation() StringTable
GetMainTranslation returns the main translation.
type StringTable ¶ added in v0.3.0
StringTable holds key/value metadata.