notreturninterface

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 7 Imported by: 0

README

notreturninterface

notreturninterface is a static code analyzer which detects function returns interface.

Install

You can install notreturninterface by go install command.

go install github.com/ksrnnb/notreturninterface/cmd/notreturninterface@latest

How to use

You can run notreturninterface by go vet command.

go vet -vettool=$(which notreturninterface) ./...

# When you want to ignore some interfaces, you can pass them separated by comma
go vet -vettool=$(which notreturninterface) -notreturninterface.ignore=any,someInterface ./...

Example

type Hoge interface{}

type Foo struct{}

func f() Hoge { // NG: return value is interface
	return nil
}

func g() Foo { // OK: return value is struct
	return Foo{}
}

func x() error { // OK: error is allowed
	return nil
}

You can ignore notreturninterface check by comment like//lint:ignore notreturninterface reason. Note that reason is required.

//lint:ignore notreturninterface hoge is special
func h() Hoge { // OK: you can ignore
	return nil
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "notreturninterface",
	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