typecover

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: MIT Imports: 8 Imported by: 0

README

typecover

typecover is a go linter that checks if a code block is assigning to all exported fields of a struct or calling all exported methods of an interface.

It is useful in cases where code wants to be aware of any newly added members.

Install

go get -u github.com/kisunji/typecover/cmd/typecover

Usage

typecover [package/file]

Examples

typecover:YourType will check for the existence of all exported members of YourType in the comment's associated code block.

type MyStruct struct {
	MyField1 string
	MyField2 string
	myField3 string
}

// typecover:MyStruct
m := MyStruct{ 
    MyField1: "hello",
}
Type example.MyStruct is missing MyField2

The typecover annotation can be placed at a higher level to cover the whole block.

// typecover:MyStruct
func example() {
    m := MyStruct{}
    m.MyField2 = "world"    
}
Type example.MyStruct is missing MyField1

typecover works with imported structs as well

// typecover:flag.Flag
f := flag.Flag{ 
    Name:  "test",
    Usage: "usage instructions",
    Value: nil,
}
Type flag.Flag is missing DefValue

Credits

https://github.com/mbilski/exhaustivestruct

https://github.com/reillywatson/enumcover

Documentation

Index

Constants

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

Variables

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

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