Ensure all exported functions and types have descriptive comments

This commit is contained in:
2018-07-08 18:38:35 +01:00
parent 2b9fece77f
commit a6cc988f5e
4 changed files with 26 additions and 0 deletions

View File

@@ -4,6 +4,8 @@ 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)
@@ -11,11 +13,14 @@ func NewObject(inputJSON []byte) (*Object, error) {
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
}