Categorygithub.com/theplant/testingutils
modulepackage
0.0.2
Repository: https://github.com/theplant/testingutils.git
Documentation: pkg.go.dev

# README

Pretty Json Diff

func PrettyJsonDiff(expected interface{}, actual interface{}) (r string)

It convert the two objects into pretty json, and diff them, output the result.

	type Company struct {
	    Name string
	}
	type People struct {
	    Name    string
	    Age     int
	    Company Company
	}
	
	p1 := People{
	    Name: "Felix",
	    Age:  20,
	    Company: Company{
	        Name: "The Plant",
	    },
	}
	p2 := People{
	    Name: "Tom",
	    Age:  21,
	    Company: Company{
	        Name: "Microsoft",
	    },
	}
	
	fmt.Println(PrettyJsonDiff(p1, p2))
	//Output:
	// --- Expected
	// +++ Actual
	// @@ -1,7 +1,7 @@
	//  {
	// -	"Name": "Felix",
	// -	"Age": 20,
	// +	"Name": "Tom",
	// +	"Age": 21,
	//  	"Company": {
	// -		"Name": "The Plant"
	// +		"Name": "Microsoft"
	//  	}
	//  }

Println Json

func PrintlnJson(vals ...interface{})

# Packages

go:generate stringer -output stringers.go -type "HandleType".
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

It convert the two objects into pretty json, and diff them, output the result.
No description provided by the author