From 710a546213bd6577ef204b8ba7aefd1a1f7e50ec Mon Sep 17 00:00:00 2001 From: pj Date: Sat, 13 Aug 2022 08:24:10 +1000 Subject: [PATCH] =?UTF-8?q?ADD=20GO=20CODE!!!!!!!!=20=F0=9F=A5=B0?= =?UTF-8?q?=F0=9F=98=8D=F0=9F=94=A5=E2=9C=A8=20(#321)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ADD GO CODE!!!!!!!! * Add Go Code * remove unused import --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 672abca..20ee554 100644 --- a/README.md +++ b/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`: