notes blog about

// Stringer.go shows the use of Stringer interface.
package main

import "fmt"

// Pair is a sample custom type.
type Pair struct {
	x, y string

// String method implements the Stringer interface
// (
func (p *Pair) String() string {
	return fmt.Sprintf("x: %s, y: %s", p.x, p.y)

func main() {
	p := &Pair{x: "XXX", y: "YYY"}
	fmt.Println(p) // String method used here

See for more.