Skip to content

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

 
 
 

Contributors

Languages