comparablepanics

package module
v0.0.0-...-baad379 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

README

Background

Go Reference

Go 1.20+ will change the semantics of the comparable constraint will include interfaces. Interfaces in Go have always been comparable and woud panic at runtime, when the type stored in the interface has no comparision defined on it the comparable constraint was the outlier, soo that changed.

So far that makes sense, but some people already wrote type safe generic code that worked with the comparable constraint and may want to know where their code will now have runtime panics.

This analyzer will mark places where Go 1.20+ comparable will panic to document the effect of your upgrade and help Go programmers to workaround it.

Another use case is never allowing this new feature in your own code.

TODO

  • Tests (couldn't publish mine for copyright reasons)
  • CI/CD with github actions
  • Announce it in golang-nuts
  • Be smarter and follow type inference further
  • Ask for integration into golangci-lint

Contribution

It is still work in progress and contributions are welcome. Especially test cases!

Documentation

Overview

Package comparablepanics defines an Analyzer that checks for usage of arguments constrainte by comparable that will panic at runtime at Go 1.20+.

Index

Constants

View Source
const Doc = `` /* 203-byte string literal not displayed */

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "comparablepanics",
	Doc:  Doc,
	Requires: []*analysis.Analyzer{
		inspect.Analyzer,
		usesgenerics.Analyzer,
	},
	Run: run,
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
comparablepanics
The comparablepanics command applies the github.com/nightlyone/comparablepanics analysis to the specified packages of Go source code.
The comparablepanics command applies the github.com/nightlyone/comparablepanics analysis to the specified packages of Go source code.

Jump to

Keyboard shortcuts

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