Skip to content

Golang | Method Sets (values, pointers) #99

@atc0005

Description

@atc0005

Scratch notes

Rules in the Go spec that define what methods, for a particular type, get bound to the value of that type:

  • value types, require value semantics (value receivers)

    • only those methods implemented with value semantics are attached to values
  • pointer types, allow pointer or value semantics (value or pointer receivers)

    • all methods defined using pointer semantics or value semantics
    • the full method set of behavior is attached to pointers or addresses

Relevant to method sets for implementing interfaces.

Values of type user do not implement the interface because pointer receivers don't belong to the method set of a value.

References

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions