-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gopls: add a main.version variable to override the version at linktime
As discussed in golang/go#63803, add a version variable to allow package managers to set the gopls version at linktime, thereby avoiding the need to patch source. Fixes golang/go#63803 Change-Id: Ie6696283e1007577e82d96f01c96e16e89cfcb6f Reviewed-on: https://go-review.googlesource.com/c/tools/+/555457 Reviewed-by: Alan Donovan <[email protected]> Auto-Submit: Robert Findley <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
- Loading branch information
Showing
6 changed files
with
62 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2019 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)" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters