diff --git a/.gitattributes b/.gitattributes index 4acf6de..9f22417 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,8 @@ +*.sh text eol=lf +*.hex binary +*.rc text eol=crlf +*.manifest text eol=crlf +*.ico binary +testdata/go/*.go text eol=lf go.mod text eol=lf go.sum text eol=lf diff --git a/README.md b/README.md index b3c51c3..13efc20 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ GoVersionInfo ========== -[![Build Status](https://travis-ci.org/josephspurrier/goversioninfo.svg)](https://travis-ci.org/josephspurrier/goversioninfo) [![Coverage Status](https://coveralls.io/repos/josephspurrier/goversioninfo/badge.svg)](https://coveralls.io/r/josephspurrier/goversioninfo) [![GoDoc](https://godoc.org/github.com/josephspurrier/goversioninfo?status.svg)](https://godoc.org/github.com/josephspurrier/goversioninfo) + +[![Go Report Card](https://goreportcard.com/badge/github.com/josephspurrier/goversioninfo)](https://goreportcard.com/report/github.com/josephspurrier/goversioninfo) [![Build Status](https://travis-ci.org/josephspurrier/goversioninfo.svg)](https://travis-ci.org/josephspurrier/goversioninfo) [![Coverage Status](https://coveralls.io/repos/josephspurrier/goversioninfo/badge.svg)](https://coveralls.io/r/josephspurrier/goversioninfo) [![GoDoc](https://godoc.org/github.com/josephspurrier/goversioninfo?status.svg)](https://godoc.org/github.com/josephspurrier/goversioninfo) Microsoft Windows File Properties/Version Info and Icon Resource Generator for the Go Language @@ -40,12 +41,14 @@ Complete list of the flags for goversioninfo: -company="": StringFileInfo.CompanyName -copyright="": StringFileInfo.LegalCopyright -description="": StringFileInfo.FileDescription - -example=false: just dump out an example versioninfo.json to stdout + -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 -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 diff --git a/cmd/goversioninfo/main.go b/cmd/goversioninfo/main.go index 3d558ec..af6e4fd 100644 --- a/cmd/goversioninfo/main.go +++ b/cmd/goversioninfo/main.go @@ -14,8 +14,10 @@ import ( ) func main() { - flagExample := flag.Bool("example", false, "just dump out an example versioninfo.json to stdout") + flagExample := flag.Bool("example", false, "dump out an example versioninfo.json to stdout") flagOut := flag.String("o", "resource.syso", "output file name") + flagGo := flag.String("gofile", "", "Go output file name (optional)") + flagPackage := flag.String("gofilepackage", "main", "Go output package name (optional, requires parameter: 'gofile')") flagPlatformSpecific := flag.Bool("platform-specific", false, "output i386 and amd64 named resource.syso, ignores -o") flagIcon := flag.String("icon", "", "icon file name") flagManifest := flag.String("manifest", "", "manifest file name") @@ -173,6 +175,11 @@ func main() { // Write the data to a buffer. vi.Walk() + // If the flag is set, then generate the optional Go file. + if *flagGo != "" { + vi.WriteGo(*flagGo, *flagPackage) + } + // List of the architectures to output. var archs []string diff --git a/go.mod b/go.mod index ba4008b..c444e34 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,7 @@ module github.com/josephspurrier/goversioninfo go 1.12 -require github.com/akavel/rsrc v0.8.0 +require ( + github.com/akavel/rsrc v0.8.0 + github.com/stretchr/testify v1.6.1 +) diff --git a/go.sum b/go.sum index 26f25bb..48b5e71 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,12 @@ github.com/akavel/rsrc v0.8.0 h1:zjWn7ukO9Kc5Q62DOJCcxGpXC18RawVtYAGdz2aLlfw= github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/goversioninfo.go b/goversioninfo.go index 1a299d2..42701c0 100644 --- a/goversioninfo.go +++ b/goversioninfo.go @@ -11,6 +11,7 @@ import ( "os" "reflect" "strconv" + "strings" "github.com/akavel/rsrc/binutil" "github.com/akavel/rsrc/coff" @@ -160,7 +161,7 @@ func (t Translation) getTranslation() string { // IO Methods // ***************************************************************************** -// Walk writes the data buffer with hexidecimal data from the structs +// Walk writes the data buffer with hexadecimal data from the structs func (vi *VersionInfo) Walk() { // Create a buffer var b bytes.Buffer @@ -192,7 +193,7 @@ func (vi *VersionInfo) WriteSyso(filename string, arch string) error { // Create a new RSRC section rsrc := coff.NewRSRC() - // Set the architechture + // Set the architecture err := rsrc.Arch(arch) if err != nil { return err @@ -232,6 +233,66 @@ func (vi *VersionInfo) WriteHex(filename string) error { return ioutil.WriteFile(filename, vi.Buffer.Bytes(), 0655) } +// WriteGo creates a Go file that contains the version info so you can access +// it in the application +func (vi *VersionInfo) WriteGo(filename, packageName string) error { + if len(packageName) == 0 { + packageName = "main" + } + + out, err := os.Create(filename) + if err != nil { + return err + } + + ffib, err := json.MarshalIndent(vi.FixedFileInfo, "\t", "\t") + if err != nil { + return err + } + + sfib, err := json.MarshalIndent(vi.StringFileInfo, "\t", "\t") + if err != nil { + return err + } + + vfib, err := json.MarshalIndent(vi.VarFileInfo, "\t", "\t") + if err != nil { + return err + } + + replace := "`\" + \"`\" + \"`" + str := "`{\n\t" + str += `"FixedFileInfo":` + str += strings.Replace(string(ffib), "`", replace, -1) + str += ",\n\t" + str += `"StringFileInfo":` + str += strings.Replace(string(sfib), "`", replace, -1) + str += ",\n\t" + str += `"VarFileInfo":` + str += strings.Replace(string(vfib), "`", replace, -1) + str += "\n" + str += "}`" + fmt.Fprintf(out, `// Auto-generated file by goversioninfo. Do not edit. +package %v + +import ( + "encoding/json" + + "github.com/josephspurrier/goversioninfo" +) + +func unmarshalGoVersionInfo(b []byte) goversioninfo.VersionInfo { + vi := goversioninfo.VersionInfo{} + json.Unmarshal(b, &vi) + return vi +} + +var versionInfo = unmarshalGoVersionInfo([]byte(%v)) +`, packageName, string(str)) + + return nil +} + func writeCoff(coff *coff.Coff, fnameout string) error { out, err := os.Create(fnameout) if err != nil { diff --git a/goversioninfo_test.go b/goversioninfo_test.go index b1ee19c..936b0df 100644 --- a/goversioninfo_test.go +++ b/goversioninfo_test.go @@ -7,9 +7,12 @@ import ( "log" "os" "path/filepath" + "runtime" + "strings" "testing" "github.com/akavel/rsrc/coff" + "github.com/stretchr/testify/assert" ) // ***************************************************************************** @@ -27,9 +30,7 @@ func testFile(t *testing.T, filename string) { path, _ := filepath.Abs("./testdata/json/" + filename + ".json") jsonBytes, err := ioutil.ReadFile(path) - if err != nil { - t.Error("Could not load "+filename+".json", err) - } + assert.NoError(t, err) // Create a new container vi := &VersionInfo{} @@ -51,13 +52,35 @@ func testFile(t *testing.T, filename string) { ioutil.WriteFile(path3, vi.Buffer.Bytes(), 0655)*/ expected, err := ioutil.ReadFile(path2) - if err != nil { - t.Error("Could not load "+filename+".hex", err) - } + assert.NoError(t, err) if !bytes.Equal(vi.Buffer.Bytes(), expected) { t.Error("Data does not match " + filename + ".hex") } + + // Test the Go file generation. + tmpdir, err := ioutil.TempDir("", "generate_go") + assert.NoError(t, err) + defer os.RemoveAll(tmpdir) + path4 := filepath.Join(tmpdir, filename+".go") + err = vi.WriteGo(path4, "") + assert.NoError(t, err) + + gen, err := ioutil.ReadFile(path4) + assert.NoError(t, err) + + path5, _ := filepath.Abs("./testdata/gofile/" + filename + ".go") + expected5, err := ioutil.ReadFile(path5) + if err != nil { + t.Error("Could not load "+path5, err) + } + + // Handle newlines. + if runtime.GOOS == "windows" { + expected5 = []byte(strings.ReplaceAll(string(expected5), "\r\n", "\n")) + } + + assert.Equal(t, string(expected5), string(gen)) } func TestWrite32(t *testing.T) { @@ -74,9 +97,7 @@ func doTestWrite(t *testing.T, arch string) { path, _ := filepath.Abs("./testdata/json/" + filename + ".json") jsonBytes, err := ioutil.ReadFile(path) - if err != nil { - t.Error("Could not load "+filename+".json", err) - } + assert.NoError(t, err) // Create a new container vi := &VersionInfo{} @@ -92,21 +113,15 @@ func doTestWrite(t *testing.T, arch string) { vi.Walk() tmpdir, err := ioutil.TempDir("", "resource") - if err != nil { - t.Error("Could not create temp dir", err) - } + assert.NoError(t, err) defer os.RemoveAll(tmpdir) file := filepath.Join(tmpdir, "resource.syso") err = vi.WriteSyso(file, arch) - if err != nil { - t.Errorf("Error writing syso: %v", err) - } + assert.NoError(t, err) _, err = ioutil.ReadFile(file) - if err != nil { - t.Error("Could not load "+file, err) - } + assert.NoError(t, err) } func TestMalformedJSON(t *testing.T) { @@ -115,9 +130,7 @@ func TestMalformedJSON(t *testing.T) { path, _ := filepath.Abs("./testdata/json/" + filename + ".json") jsonBytes, err := ioutil.ReadFile(path) - if err != nil { - t.Error("Could not load "+filename+".json", err) - } + assert.NoError(t, err) // Create a new container vi := &VersionInfo{} @@ -134,9 +147,7 @@ func TestIcon(t *testing.T) { path, _ := filepath.Abs("./testdata/json/" + filename + ".json") jsonBytes, err := ioutil.ReadFile(path) - if err != nil { - t.Error("Could not load "+filename+".json", err) - } + assert.NoError(t, err) // Create a new container vi := &VersionInfo{} @@ -155,21 +166,15 @@ func TestIcon(t *testing.T) { vi.Walk() tmpdir, err := ioutil.TempDir("", "resource") - if err != nil { - t.Error("Could not create temp dir", err) - } + assert.NoError(t, err) defer os.RemoveAll(tmpdir) file := filepath.Join(tmpdir, "resource.syso") err = vi.WriteSyso(file, "386") - if err != nil { - t.Errorf("Error writing syso: %v", err) - } + assert.NoError(t, err) _, err = ioutil.ReadFile(file) - if err != nil { - t.Error("Could not load "+file, err) - } + assert.NoError(t, err) } func TestBadIcon(t *testing.T) { @@ -178,9 +183,7 @@ func TestBadIcon(t *testing.T) { path, _ := filepath.Abs("./testdata/json/" + filename + ".json") jsonBytes, err := ioutil.ReadFile(path) - if err != nil { - t.Error("Could not load "+filename+".json", err) - } + assert.NoError(t, err) // Create a new container vi := &VersionInfo{} @@ -199,9 +202,7 @@ func TestBadIcon(t *testing.T) { vi.Walk() tmpdir, err := ioutil.TempDir("", "resource") - if err != nil { - t.Error("Could not create temp dir", err) - } + assert.NoError(t, err) defer os.RemoveAll(tmpdir) file := filepath.Join(tmpdir, "resource.syso") @@ -222,9 +223,7 @@ func TestTimestamp(t *testing.T) { path, _ := filepath.Abs("./testdata/json/" + filename + ".json") jsonBytes, err := ioutil.ReadFile(path) - if err != nil { - t.Error("Could not load "+filename+".json", err) - } + assert.NoError(t, err) // Create a new container vi := &VersionInfo{} @@ -243,21 +242,15 @@ func TestTimestamp(t *testing.T) { vi.Walk() tmpdir, err := ioutil.TempDir("", "resource") - if err != nil { - t.Error("Could not create temp dir", err) - } + assert.NoError(t, err) defer os.RemoveAll(tmpdir) file := filepath.Join(tmpdir, "resource.syso") err = vi.WriteSyso(file, "386") - if err != nil { - t.Errorf("Error writing syso: %v", err) - } + assert.NoError(t, err) _, err = ioutil.ReadFile(file) - if err != nil { - t.Error("Could not load "+file, err) - } + assert.NoError(t, err) } func TestVersionString(t *testing.T) { @@ -266,9 +259,7 @@ func TestVersionString(t *testing.T) { path, _ := filepath.Abs("./testdata/json/" + filename + ".json") jsonBytes, err := ioutil.ReadFile(path) - if err != nil { - t.Error("Could not load "+filename+".json", err) - } + assert.NoError(t, err) // Create a new container vi := &VersionInfo{} @@ -288,9 +279,7 @@ func TestWriteHex(t *testing.T) { path, _ := filepath.Abs("./testdata/json/" + filename + ".json") jsonBytes, err := ioutil.ReadFile(path) - if err != nil { - t.Error("Could not load "+filename+".json", err) - } + assert.NoError(t, err) // Create a new container vi := &VersionInfo{} @@ -306,21 +295,15 @@ func TestWriteHex(t *testing.T) { vi.Walk() tmpdir, err := ioutil.TempDir("", "resource") - if err != nil { - t.Error("Could not create temp dir", err) - } + assert.NoError(t, err) defer os.RemoveAll(tmpdir) file := filepath.Join(tmpdir, "resource.syso") err = vi.WriteHex(file) - if err != nil { - t.Errorf("Error writing hex: %v", err) - } + assert.NoError(t, err) _, err = ioutil.ReadFile(file) - if err != nil { - t.Error("Could not load "+file, err) - } + assert.NoError(t, err) } func testdatatr2Uint32(t *testing.T) { diff --git a/testdata/bash/build.sh b/testdata/bash/build.sh index 5b81e49..6751525 100755 --- a/testdata/bash/build.sh +++ b/testdata/bash/build.sh @@ -17,4 +17,13 @@ GOOS=windows GOARCH=amd64 go generate GOOS=windows GOARCH=amd64 go build rm example64.exe rm resource.syso +cd ../../ + +# Test Windows 64 with Go output file. +cd testdata/example64-gofile +GOOS=windows GOARCH=amd64 go generate +GOOS=windows GOARCH=amd64 go build +rm example64-gofile.exe +rm resource.syso +rm versioninfo.go cd ../../ \ No newline at end of file diff --git a/testdata/example64-gofile/main.go b/testdata/example64-gofile/main.go new file mode 100644 index 0000000..40d87a3 --- /dev/null +++ b/testdata/example64-gofile/main.go @@ -0,0 +1,9 @@ +//go:generate goversioninfo -icon=../resource/icon.ico -manifest=../resource/goversioninfo.exe.manifest -gofile=versioninfo.go + +package main + +import "fmt" + +func main() { + fmt.Printf("Hello world %v %v %v\n%v", versionInfo.StringFileInfo.ProductName, versionInfo.StringFileInfo.ProductVersion, versionInfo.FixedFileInfo.FileVersion, versionInfo.StringFileInfo.LegalCopyright) +} diff --git a/testdata/example64-gofile/versioninfo.json b/testdata/example64-gofile/versioninfo.json new file mode 100644 index 0000000..fe59b22 --- /dev/null +++ b/testdata/example64-gofile/versioninfo.json @@ -0,0 +1,43 @@ +{ + "FixedFileInfo": { + "FileVersion": { + "Major": 1, + "Minor": 0, + "Patch": 0, + "Build": 0 + }, + "ProductVersion": { + "Major": 1, + "Minor": 0, + "Patch": 0, + "Build": 0 + }, + "FileFlagsMask": "3f", + "FileFlags ": "00", + "FileOS": "040004", + "FileType": "01", + "FileSubType": "00" + }, + "StringFileInfo": { + "Comments": "Test file.", + "CompanyName": "josephspurrier", + "FileDescription": "This is a hello world file.", + "FileVersion": "v1.0.0.0", + "InternalName": "goversioninfo.exe", + "LegalCopyright": "Copyright (c) 2019 Joseph Spurrier", + "LegalTrademarks": "", + "OriginalFilename": "main.go", + "PrivateBuild": "", + "ProductName": "goversioninfo", + "ProductVersion": "v1.0.0.0", + "SpecialBuild": "" + }, + "VarFileInfo": { + "Translation": { + "LangID": "0409", + "CharsetID": "04B0" + } + }, + "IconPath": "", + "ManifestPath": "" +} \ No newline at end of file diff --git a/testdata/gofile/cmd.go b/testdata/gofile/cmd.go new file mode 100644 index 0000000..0559ad7 --- /dev/null +++ b/testdata/gofile/cmd.go @@ -0,0 +1,56 @@ +// Auto-generated file by goversioninfo. Do not edit. +package main + +import ( + "encoding/json" + + "github.com/josephspurrier/goversioninfo" +) + +func unmarshalGoVersionInfo(b []byte) goversioninfo.VersionInfo { + vi := goversioninfo.VersionInfo{} + json.Unmarshal(b, &vi) + return vi +} + +var versionInfo = unmarshalGoVersionInfo([]byte(`{ + "FixedFileInfo":{ + "FileVersion": { + "Major": 6, + "Minor": 3, + "Patch": 9600, + "Build": 16384 + }, + "ProductVersion": { + "Major": 6, + "Minor": 3, + "Patch": 9600, + "Build": 16384 + }, + "FileFlagsMask": "3f", + "FileFlags": "", + "FileOS": "040004", + "FileType": "01", + "FileSubType": "00" + }, + "StringFileInfo":{ + "Comments": "", + "CompanyName": "Microsoft Corporation", + "FileDescription": "Windows Command Processor", + "FileVersion": "6.3.9600.16384 (winblue_rtm.130821-1623)", + "InternalName": "cmd", + "LegalCopyright": "© Microsoft Corporation. All rights reserved.", + "LegalTrademarks": "", + "OriginalFilename": "Cmd.Exe", + "PrivateBuild": "", + "ProductName": "Microsoft® Windows® Operating System", + "ProductVersion": "6.3.9600.16384", + "SpecialBuild": "" + }, + "VarFileInfo":{ + "Translation": { + "LangID": 1033, + "CharsetID": 1200 + } + } +}`)) diff --git a/testdata/gofile/control.go b/testdata/gofile/control.go new file mode 100644 index 0000000..b7801de --- /dev/null +++ b/testdata/gofile/control.go @@ -0,0 +1,56 @@ +// Auto-generated file by goversioninfo. Do not edit. +package main + +import ( + "encoding/json" + + "github.com/josephspurrier/goversioninfo" +) + +func unmarshalGoVersionInfo(b []byte) goversioninfo.VersionInfo { + vi := goversioninfo.VersionInfo{} + json.Unmarshal(b, &vi) + return vi +} + +var versionInfo = unmarshalGoVersionInfo([]byte(`{ + "FixedFileInfo":{ + "FileVersion": { + "Major": 6, + "Minor": 3, + "Patch": 9600, + "Build": 16384 + }, + "ProductVersion": { + "Major": 6, + "Minor": 3, + "Patch": 9600, + "Build": 16384 + }, + "FileFlagsMask": "3f", + "FileFlags": "", + "FileOS": "040004", + "FileType": "01", + "FileSubType": "00" + }, + "StringFileInfo":{ + "Comments": "", + "CompanyName": "Microsoft Corporation", + "FileDescription": "Windows Control Panel", + "FileVersion": "6.3.9600.16384 (winblue_rtm.130821-1623)", + "InternalName": "Control", + "LegalCopyright": "© Microsoft Corporation. All rights reserved.", + "LegalTrademarks": "", + "OriginalFilename": "CONTROL.EXE", + "PrivateBuild": "", + "ProductName": "Microsoft® Windows® Operating System", + "ProductVersion": "6.3.9600.16384", + "SpecialBuild": "" + }, + "VarFileInfo":{ + "Translation": { + "LangID": 1033, + "CharsetID": 1200 + } + } +}`)) diff --git a/testdata/gofile/explorer.go b/testdata/gofile/explorer.go new file mode 100644 index 0000000..c6e2a81 --- /dev/null +++ b/testdata/gofile/explorer.go @@ -0,0 +1,56 @@ +// Auto-generated file by goversioninfo. Do not edit. +package main + +import ( + "encoding/json" + + "github.com/josephspurrier/goversioninfo" +) + +func unmarshalGoVersionInfo(b []byte) goversioninfo.VersionInfo { + vi := goversioninfo.VersionInfo{} + json.Unmarshal(b, &vi) + return vi +} + +var versionInfo = unmarshalGoVersionInfo([]byte(`{ + "FixedFileInfo":{ + "FileVersion": { + "Major": 6, + "Minor": 3, + "Patch": 9600, + "Build": 17284 + }, + "ProductVersion": { + "Major": 6, + "Minor": 3, + "Patch": 9600, + "Build": 17284 + }, + "FileFlagsMask": "3f", + "FileFlags": "", + "FileOS": "040004", + "FileType": "01", + "FileSubType": "00" + }, + "StringFileInfo":{ + "Comments": "", + "CompanyName": "Microsoft Corporation", + "FileDescription": "Windows Explorer", + "FileVersion": "6.3.9600.17284 (winblue_r2.140822-1915)", + "InternalName": "explorer", + "LegalCopyright": "© Microsoft Corporation. All rights reserved.", + "LegalTrademarks": "", + "OriginalFilename": "EXPLORER.EXE", + "PrivateBuild": "", + "ProductName": "Microsoft® Windows® Operating System", + "ProductVersion": "6.3.9600.17284", + "SpecialBuild": "" + }, + "VarFileInfo":{ + "Translation": { + "LangID": 1033, + "CharsetID": 1200 + } + } +}`)) diff --git a/testdata/gofile/simple.go b/testdata/gofile/simple.go new file mode 100644 index 0000000..bc05165 --- /dev/null +++ b/testdata/gofile/simple.go @@ -0,0 +1,56 @@ +// Auto-generated file by goversioninfo. Do not edit. +package main + +import ( + "encoding/json" + + "github.com/josephspurrier/goversioninfo" +) + +func unmarshalGoVersionInfo(b []byte) goversioninfo.VersionInfo { + vi := goversioninfo.VersionInfo{} + json.Unmarshal(b, &vi) + return vi +} + +var versionInfo = unmarshalGoVersionInfo([]byte(`{ + "FixedFileInfo":{ + "FileVersion": { + "Major": 1, + "Minor": 0, + "Patch": 0, + "Build": 0 + }, + "ProductVersion": { + "Major": 1, + "Minor": 0, + "Patch": 0, + "Build": 0 + }, + "FileFlagsMask": "3f", + "FileFlags": "", + "FileOS": "40004", + "FileType": "01", + "FileSubType": "00" + }, + "StringFileInfo":{ + "Comments": "", + "CompanyName": "", + "FileDescription": "", + "FileVersion": "", + "InternalName": "", + "LegalCopyright": "", + "LegalTrademarks": "", + "OriginalFilename": "", + "PrivateBuild": "", + "ProductName": "", + "ProductVersion": "1.0", + "SpecialBuild": "" + }, + "VarFileInfo":{ + "Translation": { + "LangID": 1033, + "CharsetID": 1200 + } + } +}`))