mirror of
https://github.com/disposable-email-domains/disposable-email-domains.git
synced 2024-11-22 08:38:12 +08:00
ADD GO CODE!!!!!!!! 🥰😍🔥✨ (#321)
* ADD GO CODE!!!!!!!! * Add Go Code * remove unused import
This commit is contained in:
parent
f3fa1f0720
commit
710a546213
24
README.md
24
README.md
@ -43,6 +43,30 @@ function isDisposableEmail($email, $blocklist_path = null) {
|
||||
return in_array($domain, $disposable_domains);
|
||||
}
|
||||
```
|
||||
|
||||
**Go** contributed by [@pjebs](https://github.com/pjebs)
|
||||
|
||||
```go
|
||||
import ("bufio"; "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