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

Defining the Aggregator interface

The Aggregator interface describes the set of methods that must be implemented by Go types so that they can be used with our graph processing framework for data aggregation purposes:

type Aggregator interface {
    // Type returns the type of this aggregator.
    Type() string

    // Set the aggregator to the specified value.
    Set(val interface{})

    // Get the current aggregator value.
    Get() interface{}

    // Aggregate updates the aggregator's value based on the provided     // value.
    Aggregate(val interface{})

    // Delta returns the change in the aggregator's value since the last     // call to Delta. 
    Delta() interface{}
}

One of my pet peeves is that the methods in the preceding interface definition use interface{} values. Unfortunately, ...

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