simpleinterface

package module
v0.0.0-...-2cced25 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: MIT Imports: 5 Imported by: 0

README

Simple Interface Go Reference

Simple interface is static analysis tool for Go1.18. The purpose of this tool is to warn complected or unintended definitions of interfaces. For instance, following code is legal Go program and compiled without any warning.

type addable interface {
        int | int32 | int64 | float32 | float64 | string
}

type mulable interface {
        int | int32 | int64 | float32 | float64
}

// XXX the type set is same as addable...
type X interface {
        addable | mulable
        addable
}

func id[T X](elem T) T {
        return elem
}

func main() {
        id(1)
}

Simple Interface will detect redundant interface definitions like of X and possibly (suggest?) modify it to simpler one (like X0). The scope of this tool will be gradually extended.

Installation

go install github.com/naoyafurudono/simpleinterface/cmd/simpleinterface@latest

Usage

go vet -vettool=`which simpleinterface` target-name
sample

You can see the current ability at the test code.

Discussion about implementation

see memo.md.

Documentation

Index

Constants

This section is empty.

Variables

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

Analyzer is ...

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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