ssh-chat/chat/message/identity.go
Andrey Petrov 4bca1f0294 refactor: Identifier.SetID -> Identifier.SetName
Identifier.ID() is now read-only and derived from name.
2017-04-28 11:43:15 -04:00

27 lines
482 B
Go

package message
// Identifier is an interface that can uniquely identify itself.
type Identifier interface {
ID() string
Name() string
SetName(string)
}
// SimpleID is a simple Identifier implementation used for testing.
type SimpleID string
// ID returns the ID as a string.
func (i SimpleID) ID() string {
return string(i)
}
// Name returns the ID
func (i SimpleID) Name() string {
return i.ID()
}
// SetName is a no-op
func (i SimpleID) SetName(s string) {
// no-op
}