File: version.go

package info (click to toggle)
golang-github-linode-linodego 1.47.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 10,032 kB
  • sloc: makefile: 95; sh: 52; python: 24
file content (34 lines) | stat: -rw-r--r-- 690 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package linodego

import (
	"fmt"
	"runtime/debug"
)

const packagePath = "github.com/linode/linodego"

var (
	Version = "dev"

	// DefaultUserAgent is the default User-Agent sent in HTTP request headers
	DefaultUserAgent string
)

// init attempts to source the version from the build info injected
// at runtime and sets the DefaultUserAgent.
func init() {
	buildInfo, ok := debug.ReadBuildInfo()
	if ok {
		for _, dep := range buildInfo.Deps {
			if dep.Path == packagePath {
				if dep.Replace != nil {
					Version = dep.Replace.Version
				}
				Version = dep.Version
				break
			}
		}
	}

	DefaultUserAgent = fmt.Sprintf("linodego/%s https://github.com/linode/linodego", Version)
}