Package version provides a home for metadata about the program, how it's running, what it's name is, and so forth. It should not depend upon any non-stdlib packages, so that it's safe for import anywhere in the project.



    View Source
    const Program = "dummyapp"

      Program is our idea of the persistent name of the program, for use where we don't want to use argv[0]. It's exported so that this doesn't have to be repeated. Customize this if copying this code for use elsewhere!


      View Source
      var BuildTime string

        BuildTime is potentially set at link-time. It should be used to record the timestamp (date+time) of the build.


        func CurrentVersion

        func CurrentVersion() string

          CurrentVersion provides the single-string derivation of what we consider our current version to be. It might be derived from multiple pieces of information, whatever we think makes sense. It probably fits on one line.

          func PrintTo

          func PrintTo(w io.Writer)

            PrintTo is used to write multiple whole lines of version information to an io.Writer. Contrast with LogPairs.


            type LogPair

            type LogPair struct {
            	Key, Value string

              A LogPair is a simple Key,Value pair of strings, suitable for using in structured logging as one item.

              func LogPairs

              func LogPairs() []LogPair

                LogPairs returns a slice of items suitable for logging. It's roughly equivalent to PrintTo, but it's the caller's responsibility to iterate the slice and add each pair to the logging call.

                Source Files