toolsgolang.org/x/tools/internal/lsp/safetoken Index | Files

package safetoken

import "golang.org/x/tools/internal/lsp/safetoken"

Package safetoken provides wrappers around methods in go/token, that return errors rather than panicking.

Index

Functions

func InRange

func InRange(tf *token.File, pos token.Pos) bool

InRange reports whether the given position is in the given token.File.

func Offset

func Offset(tf *token.File, pos token.Pos) (int, error)

Offset returns tok.Offset(pos), but first checks that the pos is in range for the given file.

func Pos

func Pos(tf *token.File, offset int) (token.Pos, error)

Pos returns tok.Pos(offset), but first checks that the offset is valid for the given file.

Source Files

safetoken.go

Version
v0.1.12
Published
Jul 27, 2022
Platform
darwin/amd64
Imports
2 packages
Last checked
35 seconds ago

Tools for package owners.