Skip to content
/ gocontract Public

golang tool for validating struct initializations in constructors.

License

Notifications You must be signed in to change notification settings

krk/gocontract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

golang tool for validating struct initializations in constructors.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages