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

Class Field

A struct field.

Note that field identity is determined by type identity: if two struct types are identical in the sense of the Go language specification (https://golang.org/ref/spec#Type_identity), then any of their fields that have the same name are also identical. This, in turn, means that a field can have two or more declarations.

For example, consider the following two type declarations:

type T1 struct { x int }
type T2 struct { x int }

Types T1 and T2 are different, but their underlying struct types are identical. Hence the two declarations of x refer to the same field.

Import path

import semmle.go.Scopes

Direct supertypes

Indirect supertypes

Known direct subtypes

Fields

Predicates

getDeclaringType

Gets the struct type declaring this field.

getPackage

Gets the package in which this entity is declared, if any.

hasQualifiedName

Holds if this field has name f and it belongs to a type with qualified name tp.

hasQualifiedName

Holds if this field has name f and it belongs to a type tp declared in package pkg.

Inherited predicates

getARead

Gets a data-flow node that reads the value of this entity.

from ValueEntity
getAReference

Gets a reference to this entity.

from Entity
getAWrite

Gets a control-flow node that updates the value of this entity.

from ValueEntity
getDeclaration

Gets the declaring identifier for this entity.

from Entity
getName

Gets the name of this entity.

from Entity
getQualifiedName

Gets the qualified name of this entity, if any.

from Entity
getScope

Gets the scope in which this entity is declared, if any.

from Entity
getType

Gets the type of this entity.

from Entity
hasLocationInfo

Holds if this element is at the specified location. The location spans column startcolumn of line startline to column endcolumn of line endline in file filepath. For more information, see Locations.

from Entity
toString

Gets a textual representation of this entity.

from Entity

Charpred