Migrate leak related structs to leak package

This commit is contained in:
2018-07-11 16:32:19 +01:00
parent 32ebda931e
commit d239c011b0
7 changed files with 19 additions and 20 deletions

26
leak/object.go Normal file
View File

@@ -0,0 +1,26 @@
package leak
import "encoding/json"
//go:generate easyjson -all object.go
// NewObject returns a new *Object instance with it's attributes populated from
// the given input JSON data.
func NewObject(inputJSON []byte) (*Object, error) {
var obj Object
err := json.Unmarshal(inputJSON, &obj)
return &obj, err
}
// Object is a minimal representation of a Ruby heap object as exported from
// Ruby via `ObjectSpace.dump_all`.
type Object struct {
Address string `json:"address"`
Type string `json:"type"`
}
// Index returns a unique index for the given Object.
func (s *Object) Index() string {
return s.Address + ":" + s.Type
}