mirror of
https://github.com/directorz/mailfull-go.git
synced 2025-12-17 17:47:04 +00:00
Implement sort.Interface to required struct slice
This commit is contained in:
@@ -6,6 +6,13 @@ type AliasDomain struct {
|
|||||||
target string
|
target string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AliasDomainSlice attaches the methods of sort.Interface to []*AliasDomain.
|
||||||
|
type AliasDomainSlice []*AliasDomain
|
||||||
|
|
||||||
|
func (p AliasDomainSlice) Len() int { return len(p) }
|
||||||
|
func (p AliasDomainSlice) Less(i, j int) bool { return p[i].Name() < p[j].Name() }
|
||||||
|
func (p AliasDomainSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||||
|
|
||||||
// NewAliasDomain creates a new AliasDomain instance.
|
// NewAliasDomain creates a new AliasDomain instance.
|
||||||
func NewAliasDomain(name, target string) (*AliasDomain, error) {
|
func NewAliasDomain(name, target string) (*AliasDomain, error) {
|
||||||
if !validAliasDomainName(name) {
|
if !validAliasDomainName(name) {
|
||||||
|
|||||||
@@ -13,6 +13,13 @@ type AliasUser struct {
|
|||||||
targets []string
|
targets []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AliasUserSlice attaches the methods of sort.Interface to []*AliasUser.
|
||||||
|
type AliasUserSlice []*AliasUser
|
||||||
|
|
||||||
|
func (p AliasUserSlice) Len() int { return len(p) }
|
||||||
|
func (p AliasUserSlice) Less(i, j int) bool { return p[i].Name() < p[j].Name() }
|
||||||
|
func (p AliasUserSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||||
|
|
||||||
// NewAliasUser creates a new AliasUser instance.
|
// NewAliasUser creates a new AliasUser instance.
|
||||||
func NewAliasUser(name string, targets []string) (*AliasUser, error) {
|
func NewAliasUser(name string, targets []string) (*AliasUser, error) {
|
||||||
if !validAliasUserName(name) {
|
if !validAliasUserName(name) {
|
||||||
|
|||||||
@@ -8,6 +8,13 @@ type Domain struct {
|
|||||||
CatchAllUser *CatchAllUser
|
CatchAllUser *CatchAllUser
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DomainSlice attaches the methods of sort.Interface to []*Domain.
|
||||||
|
type DomainSlice []*Domain
|
||||||
|
|
||||||
|
func (p DomainSlice) Len() int { return len(p) }
|
||||||
|
func (p DomainSlice) Less(i, j int) bool { return p[i].Name() < p[j].Name() }
|
||||||
|
func (p DomainSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||||
|
|
||||||
// NewDomain creates a new Domain instance.
|
// NewDomain creates a new Domain instance.
|
||||||
func NewDomain(name string) (*Domain, error) {
|
func NewDomain(name string) (*Domain, error) {
|
||||||
if !validDomainName(name) {
|
if !validDomainName(name) {
|
||||||
|
|||||||
7
user.go
7
user.go
@@ -7,6 +7,13 @@ type User struct {
|
|||||||
forwards []string
|
forwards []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UserSlice attaches the methods of sort.Interface to []*User.
|
||||||
|
type UserSlice []*User
|
||||||
|
|
||||||
|
func (p UserSlice) Len() int { return len(p) }
|
||||||
|
func (p UserSlice) Less(i, j int) bool { return p[i].Name() < p[j].Name() }
|
||||||
|
func (p UserSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||||
|
|
||||||
// NewUser creates a new User instance.
|
// NewUser creates a new User instance.
|
||||||
func NewUser(name, hashedPassword string, forwards []string) (*User, error) {
|
func NewUser(name, hashedPassword string, forwards []string) (*User, error) {
|
||||||
if !validUserName(name) {
|
if !validUserName(name) {
|
||||||
|
|||||||
Reference in New Issue
Block a user