// Copyright 2021 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 typesimport ()// langCompat reports an error if the representation of a numeric// literal is not compatible with the current language version.func ( *Checker) ( *ast.BasicLit) { := .Valueiflen() <= 2 || .allowVersion(.pkg, 1, 13) {return }// len(s) > 2ifstrings.Contains(, "_") { .errorf(, _InvalidLit, "underscores in numeric literals requires go1.13 or later")return }if [0] != '0' {return } := [1]if == 'b' || == 'B' { .errorf(, _InvalidLit, "binary literals requires go1.13 or later")return }if == 'o' || == 'O' { .errorf(, _InvalidLit, "0o/0O-style octal literals requires go1.13 or later")return }if .Kind != token.INT && ( == 'x' || == 'X') { .errorf(, _InvalidLit, "hexadecimal floating-point literals requires go1.13 or later") }}// allowVersion reports whether the given package// is allowed to use version major.minor.func ( *Checker) ( *Package, , int) bool {// We assume that imported packages have all been checked, // so we only have to check for the local package.if != .pkg {returntrue } , := .version.major, .version.minorreturn == 0 && == 0 || > || == && >= }typeversionstruct {major, minorint}// parseGoVersion parses a Go version string (such as "go1.12")// and returns the version, or an error. If s is the empty// string, the version is 0.0.func ( string) ( version, error) {if == "" {return } := goVersionRx.FindStringSubmatch()if == nil { = fmt.Errorf(`should be something like "go1.12"`)return } .major, = strconv.Atoi([1])if != nil {return } .minor, = strconv.Atoi([2])return}// goVersionRx matches a Go version string, e.g. "go1.12".vargoVersionRx = regexp.MustCompile(`^go([1-9][0-9]*)\.(0|[1-9][0-9]*)$`)
The pages are generated with Goldsv0.4.9. (GOOS=linux GOARCH=amd64)