diff --git a/graph/formats/cytoscapejs/cytoscapejs.go b/graph/formats/cytoscapejs/cytoscapejs.go index 02429f234..f9f9d7677 100644 --- a/graph/formats/cytoscapejs/cytoscapejs.go +++ b/graph/formats/cytoscapejs/cytoscapejs.go @@ -34,7 +34,7 @@ type Element struct { Scratch interface{} `json:"scratch,omitempty"` } -// ElemType is described an Element type. +// ElemType describes an Element type. type ElemType int const ( @@ -46,7 +46,7 @@ const ( // Type returns the element type of the receiver. It returns an error if the Element Group // is invalid or does not match the Element Data, or if the Elelement Data is an incomplete // edge. -func (e Element) Tyoe() (ElemType, error) { +func (e Element) Type() (ElemType, error) { et := InvalidElement switch { case e.Data.Source == "" && e.Data.Target == "": @@ -54,7 +54,7 @@ func (e Element) Tyoe() (ElemType, error) { case e.Data.Source != "" && e.Data.Target != "": et = EdgeElement default: - return et, errors.New("cytoscapejs: invalid element") + return et, errors.New("cytoscapejs: invalid element: incomplete edge") } switch { case e.Group == "": @@ -64,7 +64,7 @@ func (e Element) Tyoe() (ElemType, error) { case e.Group == "edge" && et == EdgeElement: return NodeElement, nil default: - return InvalidElement, errors.New("cytoscapejs: invalid element") + return InvalidElement, errors.New("cytoscapejs: invalid element: mismatched group") } } diff --git a/graph/formats/cytoscapejs/cytoscapejs_test.go b/graph/formats/cytoscapejs/cytoscapejs_test.go index dbaa56057..412178770 100644 --- a/graph/formats/cytoscapejs/cytoscapejs_test.go +++ b/graph/formats/cytoscapejs/cytoscapejs_test.go @@ -63,7 +63,7 @@ func TestUnmarshalElements(t *testing.T) { } var gotNodes, gotEdges int for _, e := range got { - typ, err := e.Tyoe() + typ, err := e.Type() if err != nil { t.Errorf("unexpected error finding element type for %+v: %v", e, err) }