gosum

package module
v0.0.0-...-1d719db Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2017 License: MIT Imports: 1 Imported by: 0

README

Sum/Union/Variant Type in Go and Static Check Tool of switch-case handling

GoDoc LICENSE

gosumcheck

Installation

$ go get -u github.com/haya14busa/gosum/cmd/gosumcheck

Example

$ gosumcheck go/ast/...
/usr/lib/go/src/go/ast/commentmap.go:233:3: uncovered cases for ast.Node type switch:
        - *ast.ChanType
        - *ast.Ident
        - *ast.SelectorExpr
        - *ast.TypeAssertExpr
        - *ast.CompositeLit
        - *ast.FieldList
        - *ast.Package
        - *ast.ArrayType
        - *ast.ParenExpr
        - *ast.BinaryExpr
        - *ast.UnaryExpr
        - *ast.BadExpr
        - *ast.FuncLit
        - *ast.CommentGroup
        - *ast.IndexExpr
        - *ast.MapType
        - *ast.StructType
        - *ast.BasicLit
        - *ast.Ellipsis
        - *ast.InterfaceType
        - *ast.Comment
        - *ast.FuncType
        - *ast.SliceExpr
        - *ast.StarExpr
        - *ast.CallExpr
        - *ast.KeyValueExpr
/usr/lib/go/src/go/ast/filter.go:158:2: uncovered cases for ast.Spec type switch:
        - *ast.ImportSpec
/usr/lib/go/src/go/ast/filter.go:209:2: uncovered cases for ast.Decl type switch:
        - *ast.BadDecl

See gosumcheck -h and Sum/Union/Variant Type in Go and Static Check Tool of switch-case handling for detail.

Documentation

Overview

Package gosum provides utilities for Sum/Union/Variant like types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsInternalInterface

func IsInternalInterface(iface *types.Interface) bool

IsInternalInterface returns true if the given interface has unexported method.

Types

type SumInterface

type SumInterface struct {
	// underling interface type. It uses types.Named instead of types.Interface
	// for convenience.
	NamedInterface *types.Named

	// is "internal interface" which includes unexported methods, otherwise
	// "public" interface.
	IsInternal bool

	// Implements holds types which implement SumInterface type.
	Implements struct {
		Interfaces []*SumInterface
		Pointers   []*types.Pointer
	}

	// "Implements" only holds types in PkgScope. It's especially for "public"
	// interface.
	PkgScope []*types.Package
}

SumInterface represents Sum type by interface{} type.

func NewSumInterface

func NewSumInterface(namedInterface *types.Named, pkgscope []*types.Package) *SumInterface

NewSumInterface returns SumInterface from given interface type. If the given interface is "public", this function searches implemented types in pkgscope. pkgscope can be nil and it's useful to pass nil if you know the interface is "internal" interface.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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