27 lines
380 B
Go
27 lines
380 B
Go
|
package board
|
||
|
|
||
|
type Identity struct {
|
||
|
ID int
|
||
|
}
|
||
|
|
||
|
// SetID updates the ID value with a valid ID value
|
||
|
// only if the ID is unset (i.e. < 1).
|
||
|
func (i *Identity) SetID(id int) error {
|
||
|
if id < 1 {
|
||
|
return InvalidIDError{id}
|
||
|
}
|
||
|
|
||
|
if i.ID > 0 {
|
||
|
return IDAlreadySetError{}
|
||
|
}
|
||
|
|
||
|
i.ID = id
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// GetID returns the ID value.
|
||
|
func (i *Identity) GetID() int {
|
||
|
return i.ID
|
||
|
}
|