Behavioral Patterns in Go
1. Strategy Pattern (Pluggable Payment Processing)
package strategy
// PaymentStrategy defines the interface for payment strategies
type PaymentStrategy interface {
Pay(amount float64) string
}
2. Observer Pattern (Event Broadcasting)
package observer
// FitnessDataSubject defines the interface for the subject
type FitnessDataSubject interface {
RegisterObserver(observer FitnessDataObserver)
RemoveObserver(observer FitnessDataObserver)
NotifyObservers()
}