mirror of
https://github.com/foxcpp/maddy.git
synced 2025-04-06 06:27:38 +03:00
Root package now contains only initialization code and 'dummy' module. Each module now got its own package. Module packages are grouped by their main purpose (storage/, target/, auth/, etc). Shared code is placed in these "group" packages. Parser for module references in config is moved into config/module. Code shared by tests (mock modules, etc) is placed in testutils.
24 lines
512 B
Go
24 lines
512 B
Go
package address
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
func Split(addr string) (mailbox, domain string, err error) {
|
|
parts := strings.Split(addr, "@")
|
|
switch len(parts) {
|
|
case 1:
|
|
if strings.EqualFold(parts[0], "postmaster") {
|
|
return parts[0], "", nil
|
|
}
|
|
return "", "", fmt.Errorf("malformed address")
|
|
case 2:
|
|
if len(parts[0]) == 0 || len(parts[1]) == 0 {
|
|
return "", "", fmt.Errorf("malformed address")
|
|
}
|
|
return parts[0], parts[1], nil
|
|
default:
|
|
return "", "", fmt.Errorf("malformed address")
|
|
}
|
|
}
|