@@ -14,17 +14,14 @@ package main
14
14
import (
15
15
"flag"
16
16
"fmt"
17
- "go/types"
18
17
"log"
19
18
"os"
20
19
"os/exec"
21
20
"path/filepath"
22
- "strconv"
23
21
"strings"
24
22
25
23
"golang.org/x/mod/modfile"
26
24
"golang.org/x/mod/semver"
27
- "golang.org/x/tools/go/packages"
28
25
)
29
26
30
27
var versionFlag = flag .String ("version" , "" , "version to tag" )
@@ -52,10 +49,6 @@ func main() {
52
49
if filepath .Base (wd ) != "gopls" {
53
50
log .Fatalf ("must run from the gopls module" )
54
51
}
55
- // Confirm that they have updated the hardcoded version.
56
- if err := validateHardcodedVersion (* versionFlag ); err != nil {
57
- log .Fatal (err )
58
- }
59
52
// Confirm that the versions in the go.mod file are correct.
60
53
if err := validateGoModFile (wd ); err != nil {
61
54
log .Fatal (err )
@@ -64,47 +57,6 @@ func main() {
64
57
os .Exit (0 )
65
58
}
66
59
67
- // validateHardcodedVersion reports whether the version hardcoded in the gopls
68
- // binary is equivalent to the version being published. It reports an error if
69
- // not.
70
- func validateHardcodedVersion (version string ) error {
71
- const debugPkg = "golang.org/x/tools/gopls/internal/debug"
72
- pkgs , err := packages .Load (& packages.Config {
73
- Mode : packages .NeedName | packages .NeedFiles |
74
- packages .NeedCompiledGoFiles | packages .NeedImports |
75
- packages .NeedTypes | packages .NeedTypesSizes ,
76
- }, debugPkg )
77
- if err != nil {
78
- return err
79
- }
80
- if len (pkgs ) != 1 {
81
- return fmt .Errorf ("expected 1 package, got %v" , len (pkgs ))
82
- }
83
- pkg := pkgs [0 ]
84
- if len (pkg .Errors ) > 0 {
85
- return fmt .Errorf ("failed to load %q: first error: %w" , debugPkg , pkg .Errors [0 ])
86
- }
87
- obj := pkg .Types .Scope ().Lookup ("Version" )
88
- c , ok := obj .(* types.Const )
89
- if ! ok {
90
- return fmt .Errorf ("no constant named Version" )
91
- }
92
- hardcodedVersion , err := strconv .Unquote (c .Val ().ExactString ())
93
- if err != nil {
94
- return err
95
- }
96
- if semver .Prerelease (hardcodedVersion ) != "" {
97
- return fmt .Errorf ("unexpected pre-release for hardcoded version: %s" , hardcodedVersion )
98
- }
99
- // Don't worry about pre-release tags and expect that there is no build
100
- // suffix.
101
- version = strings .TrimSuffix (version , semver .Prerelease (version ))
102
- if hardcodedVersion != version {
103
- return fmt .Errorf ("expected version to be %s, got %s" , * versionFlag , hardcodedVersion )
104
- }
105
- return nil
106
- }
107
-
108
60
func validateGoModFile (goplsDir string ) error {
109
61
filename := filepath .Join (goplsDir , "go.mod" )
110
62
data , err := os .ReadFile (filename )
0 commit comments