ptrparam

package module
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 7 Imported by: 0

README

yze-go-ptrparam

A yze analyzer (group go, category immutability) enforcing the gomatic Go immutability standard: function parameters are passed by value, never by pointer, unless the pointed-to type is a standard-library type where a pointer is the idiomatic calling convention (*slog.Logger, *testing.T, *http.Request, *sql.DB, …).

  • Rule: yze/go/ptrparam
  • Binary: cmd/yze-go-ptrparam runs it standalone (text/-json, and as a go vet -vettool).

Built on the go-yze framework. The allow-list is baked in for v1; a configurable -allow flag is planned.

Documentation

Overview

Foreign-convention detection: the analyzed module's own types are its design responsibility, but a foreign type follows its library's conventions.

Package ptrparam provides a go/analysis analyzer enforcing the gomatic Go immutability standard: function parameters are passed by value, never by pointer, unless a pointer is the pointed-to type's idiomatic calling convention — a standard-library type conventionally passed by pointer (the generated allowlist_std.go, discovered from the toolchain by discover.go: uncopyable types, pointer-only method sets, and types the stdlib's own API passes as *T), the sanctioned CLI framework's *cli.Command (urfave/cli/v3 imposes it in every Action/Before/After signature), or a type parameter (a generic seam whose instantiations the analyzer cannot judge).

Semantic pointer-idiomatic detection: the discovery criteria applied live to any package's types.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = newAnalyzer()

Analyzer reports pointer parameters that are not idiomatic standard-library types.

View Source
var Registration = goyze.Registration{
	Name:       "ptrparam",
	Categories: []goyze.Category{"immutability"},
	URL:        "https://docs.gomatic.dev/yze/go/ptrparam",
	Analyzer:   Analyzer,
}

Registration declares this analyzer to the yze framework.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
yze-go-ptrparam command
Command yze-go-ptrparam runs the ptrparam analyzer as a standalone go/analysis checker (text, -json, and -fix output, and as a `go vet -vettool`).
Command yze-go-ptrparam runs the ptrparam analyzer as a standalone go/analysis checker (text, -json, and -fix output, and as a `go vet -vettool`).

Jump to

Keyboard shortcuts

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