Skip to Content
Hands-On Software Engineering with Golang
book

Hands-On Software Engineering with Golang

by Achilleas Anagnostopoulos
January 2020
Intermediate to advanced
640 pages
16h 56m
English
Packt Publishing
Content preview from Hands-On Software Engineering with Golang

Iterating Links and Edges

Since there is no upper bound in the number of links or edges that can be potentially returned by calls to the Links and Edges methods, we will be implementing the iterator design pattern and lazily fetch Link and Edge models on demand. The LinkIterator and EdgeIterator types, which are returned by these methods, are interfaces themselves. This is intentional as their internal implementation details will obviously depend on the database technology that we select for the link graph persistence layer. Here is how they are defined:

// LinkIterator is implemented by objects that can iterate the graph links.
type LinkIterator interface {
    Iterator

    // Link returns the currently fetched link object.
    Link() *Link
}

// EdgeIterator ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Software Architecture with Golang

Hands-On Software Architecture with Golang

Jyotiswarup Raiturkar

Publisher Resources

ISBN: 9781838554491Supplemental Content