Operator overloading

There is no operator overloading in Go, so you can't add to structs together with the + sign, but you can easily define an Add() function on the type and then call something like dataSet1.Add(dataSet2). By omitting operator overloading from the language, we can confidently use the operators without worrying about unexpected behavior due to operator behavior being overloaded somewhere else in code without realizing it.

Get Security with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.