File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import (
1212 "go/version"
1313 "os"
1414 "runtime"
15+ "strings"
1516 "time"
1617
1718 "honnef.co/go/tools/config"
@@ -311,11 +312,24 @@ func (prog *program) loadFromSource(spec *PackageSpec) (*Package, error) {
311312 if prog .options .GoVersion == "module" {
312313 if spec .Module != nil && spec .Module .GoVersion != "" {
313314 var our string
314- if version .IsValid (runtime .Version ()) {
315+ rversion := runtime .Version ()
316+ if fields := strings .Fields (rversion ); len (fields ) > 0 {
317+ // When using GOEXPERIMENT, the version returned by
318+ // runtime.Version might look something like "go1.23.0
319+ // X:boringcrypto", which wouldn't be accepted by
320+ // version.IsValid even though it's a proper release.
321+ //
322+ // When using a development build, the version looks like "devel
323+ // go1.24-206df8e7ad Tue Aug 13 16:44:16 2024 +0000", and taking
324+ // the first field of that won't change whether it's accepted as
325+ // valid or not.
326+ rversion = fields [0 ]
327+ }
328+ if version .IsValid (rversion ) {
315329 // Staticcheck was built with a released version of Go.
316330 // runtime.Version() returns something like "go1.22.4" or
317331 // "go1.23rc1".
318- our = runtime . Version ()
332+ our = rversion
319333 } else {
320334 // Staticcheck was built with a development version of Go.
321335 // runtime.Version() returns something like "devel go1.23-e8ee1dc4f9
You can’t perform that action at this time.
0 commit comments