File: version.go

package info (click to toggle)
golang-github-cue-lang-cue 0.12.0.-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,072 kB
  • sloc: sh: 57; makefile: 17
file content (29 lines) | stat: -rw-r--r-- 737 bytes parent folder | download | duplicates (3)
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
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Package version manages the gopls version.
//
// The VersionOverride variable may be used to set the gopls version at link
// time.
package version

import "runtime/debug"

var VersionOverride = ""

// Version returns the gopls version.
//
// By default, this is read from runtime/debug.ReadBuildInfo, but may be
// overridden by the [VersionOverride] variable.
func Version() string {
	if VersionOverride != "" {
		return VersionOverride
	}
	if info, ok := debug.ReadBuildInfo(); ok {
		if info.Main.Version != "" {
			return info.Main.Version
		}
	}
	return "(unknown)"
}