Socket
Socket
Sign inDemoInstall

github.com/carlmjohnson/versioninfo

Package Overview
Dependencies
0
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/carlmjohnson/versioninfo

Package versioninfo uses runtime.ReadBuildInfo() to set global executable revision information if possible.


Version published

Readme

Source

versioninfo GoDoc Go Report Card

Importable package that parses debug.ReadBuildInfo() for inclusion in your Go application.

Requires Go 1.18+ for Git revision information, but compatible with prior versions of Go.

Examples

package main

import (
    "fmt"

    "github.com/carlmjohnson/versioninfo"
)

func main() {
    fmt.Println("Version:", versioninfo.Version)
    fmt.Println("Revision:", versioninfo.Revision)
    fmt.Println("DirtyBuild:", versioninfo.DirtyBuild)
    fmt.Println("LastCommit:", versioninfo.LastCommit)
}

You may use the concatenated information provided by versioninfo.Short():

package main

import (
    "fmt"

    "github.com/carlmjohnson/versioninfo"
)

func main() {
    fmt.Println("ShortInfo:", versioninfo.Short())
}

Add the -v and -version flags:

package main

import (
    "flag"
    "fmt"

    "github.com/carlmjohnson/versioninfo"
)

func main() {
    versioninfo.AddFlag(nil)
    flag.Parse()
    fmt.Println("done")
}

FAQs

Last updated on 02 Aug 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc