Skip to content

Commit

Permalink
Merge pull request #55 from josephspurrier/52-allow-empty-versioninfo
Browse files Browse the repository at this point in the history
Ability to skip version info with: -skip-versioninfo. Closes #52
  • Loading branch information
josephspurrier authored Jan 6, 2022
2 parents a887831 + 7f1d431 commit 233067e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Complete list of the flags for goversioninfo:
-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')
Expand Down
45 changes: 25 additions & 20 deletions cmd/goversioninfo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func main() {
flagPlatformSpecific := flag.Bool("platform-specific", false, "output i386, amd64, arm and arm64 named resource.syso, ignores -o")
flagIcon := flag.String("icon", "", "icon file name")
flagManifest := flag.String("manifest", "", "manifest file name")
flagSkipVersion := flag.Bool("skip-versioninfo", false, "skip version info")

flagComment := flag.String("comment", "", "StringFileInfo.Comments")
flagCompany := flag.String("company", "", "StringFileInfo.CompanyName")
Expand Down Expand Up @@ -65,30 +66,34 @@ func main() {
if configFile == "" {
configFile = "versioninfo.json"
}
var err error
var input = io.ReadCloser(os.Stdin)
if configFile != "-" {
if input, err = os.Open(configFile); err != nil {
log.Printf("Cannot open %q: %v", configFile, err)
os.Exit(1)
}
}

// Read the config file.
jsonBytes, err := ioutil.ReadAll(input)
input.Close()
if err != nil {
log.Printf("Error reading %q: %v", configFile, err)
os.Exit(1)
}

// Create a new container.
vi := &goversioninfo.VersionInfo{}

// Parse the config.
if err := vi.ParseJSON(jsonBytes); err != nil {
log.Printf("Could not parse the .json file: %v", err)
os.Exit(2)
if !*flagSkipVersion {
var err error
var input = io.ReadCloser(os.Stdin)
if configFile != "-" {
if input, err = os.Open(configFile); err != nil {
log.Printf("Cannot open %q: %v", configFile, err)
os.Exit(1)
}
}

// Read the config file.
jsonBytes, err := ioutil.ReadAll(input)
input.Close()
if err != nil {
log.Printf("Error reading %q: %v", configFile, err)
os.Exit(1)
}

// Parse the config.
if err := vi.ParseJSON(jsonBytes); err != nil {
log.Printf("Could not parse the .json file: %v", err)
os.Exit(2)
}

}

// Override from flags.
Expand Down

0 comments on commit 233067e

Please sign in to comment.