concept behavior in category go

This is an excerpt from Manning's book Get Programming with Go.
To remove the duplication and simplify the code, the variables in listing 4.6 should be declared in the wider function scope, making them available after the switch statement for later work. It’s time to refactor! Refactoring means modifying the code without modifying the code’s behavior. The code in the following listing still displays a random date.
Before you start on this lesson, look around and consider the types around you and the behaviors they each have.

This is an excerpt from Manning's book Go in Action.
In addition Go has a unique interface implementation that allows you to model behavior, rather than model types. You don’t need to declare that you’re implementing an interface in Go; the compiler does the work of determining whether values of your types satisfy the interfaces you’re using. Many interfaces in Go’s standard library are very small, exposing only a few functions. In practice this takes some time to get used to, especially if you’ve been writing in object-oriented languages like Java.
Listing 2.34. search/match.go: lines 01–17
01 package search 02 03 import ( 04 "log" 05 ) 06 07 // Result contains the result of a search. 08 type Result struct { 09 Field string 10 Content string 11 } 12 13 // Matcher defines the behavior required by types that want 14 // to implement a new search type. 15 type Matcher interface { 16 Search(feed *Feed, searchTerm string) ([]*Result, error) 17 }
Methods provide a way to add behavior to user-defined types. Methods are really functions that contain an extra parameter that’s declared between the keyword func and the function name.