1// Copyright 2023 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package versions
6
7import (
8	"go/types"
9)
10
11// GoVersion returns the Go version of the type package.
12// It returns zero if no version can be determined.
13func GoVersion(pkg *types.Package) string {
14	// TODO(taking): x/tools can call GoVersion() [from 1.21] after 1.25.
15	if pkg, ok := any(pkg).(interface{ GoVersion() string }); ok {
16		return pkg.GoVersion()
17	}
18	return ""
19}
20