func (g *Gobot) Start() (errs []error) {
	if rerrs := g.robots.Start(); len(rerrs) > 0 {
		for _, err := range rerrs {
			log.Println("Error:", err)
			errs = append(errs, err)
		}
	}
	if g.AutoStop {
		c := make(chan os.Signal, 1)
		g.trap(c)
		if len(errs) > 0 {
			c <- os.Interrupt
		}
		<-c
		g.Stop()
	}
	return errs
}
Start calls the Start method on each robot in its collection of robots. On
error, call Stop to ensure that all robots are returned to a sane, stopped
state.
package gobot
import (
	"log"
	"os"
	"os/signal"
)
type JSONGobot struct {
	Robots   []*JSONRobot `json:"robots"`
	Commands []string     `json:"commands"`
}
func NewJSONGobot(gobot *Gobot) *JSONGobot {
	jsonGobot := &JSONGobot{
		Robots:   []*JSONRobot{},
		Commands: []string{},
	}
	for command := range gobot.Commands() {
		jsonGobot.Commands = append(jsonGobot.Commands, command)
	}
	gobot.robots.Each(func(r *Robot) {
		jsonGobot.Robots = append(jsonGobot.Robots, NewJSONRobot(r))
	})
	return jsonGobot
}
type Gobot struct {
	robots   *Robots
	trap     func(chan os.Signal)
	AutoStop bool
	Commander
	Eventer
}
func NewGobot() *Gobot {
	return &Gobot{
		robots: &Robots{},
		trap: func(c chan os.Signal) {
			signal.Notify(c, os.Interrupt)
		},
		AutoStop:  true,
		Commander: NewCommander(),
		Eventer:   NewEventer(),
	}
}