// ComparePublicEquals compare two public methods od object, return true if equels func ComparePublicEquals(obj1 interface{}, obj2 interface{}) (bool, error) { json1, err := varutil.ObjectToJSON(obj1) if err != nil { return false, err } json2, err := varutil.ObjectToJSON(obj2) if err != nil { return false, err } return json1 == json2, nil }
// WriteJSON write data from object to json file func WriteJSON(fs filesystem.Filespace, path string, object interface{}) error { json, err := varutil.ObjectToJSON(object) if err != nil { return err } dir := filepath.Dir(path) if !fs.IsDir(dir) { if err := fs.MkdirAll(dir, 0777); err != nil { return err } } return fs.WriteFile(path, []byte(json), 0777) }
// ToString change object to string func (obt *ObjectConverter) ToString(ival interface{}) (string, error) { return varutil.ObjectToJSON(ival) }