mirror of
https://github.com/disposable-email-domains/disposable-email-domains.git
synced 2024-11-22 08:38:12 +08:00
ADD GO CODE
This commit is contained in:
parent
2258b1b6f9
commit
6c4bf4b771
23
README.md
23
README.md
@ -43,6 +43,29 @@ function isDisposableEmail($email, $blocklist_path = null) {
|
||||
return in_array($domain, $disposable_domains);
|
||||
}
|
||||
```
|
||||
|
||||
**Go** contributed by [@pjebs](https://github.com/pjebs)
|
||||
|
||||
```go
|
||||
import ("bufio"; "fmt"; "os"; "strings";)
|
||||
var disposableList = make(map[string]struct{}, 3500)
|
||||
func init() {
|
||||
f, _ := os.Open("disposable_email_blocklist.conf")
|
||||
for scanner := bufio.NewScanner(f); scanner.Scan(); {
|
||||
disposableList[scanner.Text()] = struct{}{}
|
||||
}
|
||||
f.Close()
|
||||
}
|
||||
|
||||
func isDisposableEmail(email string) (disposable bool) {
|
||||
segs := strings.Split(email, "@")
|
||||
_, disposable = disposableList[strings.ToLower(segs[len(segs)-1])]
|
||||
return
|
||||
}
|
||||
```
|
||||
|
||||
Alternatively, [anti-disposable-email](https://github.com/rocketlaunchr/anti-disposable-email) which auto-updates based on this repo.
|
||||
|
||||
**Ruby on Rails** contributed by [@MitsunChieh](https://github.com/MitsunChieh)
|
||||
|
||||
In the resource model, usually it is `user.rb`:
|
||||
|
Loading…
Reference in New Issue
Block a user