CodeQL library for Go
codeql/go-all 2.1.3 (changelog, source)
Search

Member predicate GoModLine::getToken

Gets the ith token of line, including the token in the line block declaration, if it there is one, 0-based.

This compensates for the fact that lines in line blocks have their 0th token in the line block declaration, and makes dealing with lines more uniform.

For example, .getToken(1) will result in the dependency path (github.com/github/codeql-go) for both lines for normal require lines like require "github.com/github/codeql-go" v1.2.3 and in a line block like

require (
  "github.com/github/codeql-go" v1.2.3
  ...
)

As a special case, when i is 0 and the line is in a line block, the result will be the token from the line block.

string getToken(int i)