Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 561 Bytes

README.md

File metadata and controls

40 lines (28 loc) · 561 Bytes

gocontract

gocontract is a very simple utility which detects uninitialized and struct fields in a Go file. Detection is opt-in.

Usage

gocontract [file]

    file    Go source file.

Example

Input file: example.go

package example

type Abc struct {
	val *int `json:"config" require:"assignment,NewAbc ,  NewAbcOther"`
}

func NewAbc() Abc {
	val := 42
	return Abc{
		val: &val}
}

func NewAbcOther() *Abc {
	return &Abc{}
}

Output:

./gocontract example.go
example.go uninitialized struct field Abc.val in NewAbcOther