pointerinterface

command module
v0.0.0-...-a10dbd2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

README

pointerinterface

pointerinterface is a linter that warns about the usage of new type declarations with pointer to interface values.

Usage

Installation:

go install code.larus.se/lmas/pointerinterface@latest

Running:

pointerinterface ./...

Testing:

go test -cover ./...

Explanation

You almost never need a pointer to an interface.

An interface is represented by a two-word pair, containing:

  • A pointer to type-specific information (the "type")
  • Another pointer to the associated data (the "data", always as a pointer despite the type of data)

Thus using a pointer to interface is redundant (a pointer to pointers) and makes it harder to use practically. A demonstration of this issue (and a better alternative) can be found inside testdata/.

A related question can be found at Stack Overflow.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL