Source File
tokeninternal.go
Belonging Package
golang.org/x/tools/internal/tokeninternal
// Copyright 2023 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 tokeninternal provides access to some internal features of the token
// package.
package tokeninternal
import (
)
// GetLines returns the table of line-start offsets from a token.File.
func ( *token.File) []int {
// token.File has a Lines method on Go 1.21 and later.
if , := (interface{})().(interface{ () []int }); {
return .()
}
// This declaration must match that of token.File.
// This creates a risk of dependency skew.
// For now we check that the size of the two
// declarations is the same, on the (fragile) assumption
// that future changes would add fields.
type struct {
string
int
int
sync.Mutex // we're not complete monsters
[]int
[]struct{}
}
type struct {
*token.FileSet // deleted in go1.19
}
type = unsafe.Pointer
switch unsafe.Sizeof(*) {
case unsafe.Sizeof({}):
var *
*(*)((&)) = ()
..Lock()
defer ..Unlock()
return .
case unsafe.Sizeof({}):
var *
*(*)((&)) = ()
..Lock()
defer ..Unlock()
return .
default:
panic("unexpected token.File size")
}
}
The pages are generated with Golds v0.4.9. (GOOS=linux GOARCH=amd64)