Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use go generate for TLD generation #12

Merged
merged 5 commits into from
Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore

This file was deleted.

1 change: 1 addition & 0 deletions .gx/lastpubver
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.2: QmNv3umRGdwwWAuJeF2X2BnKisqmzWSAKFtSLdtCh9ehb1
17 changes: 0 additions & 17 deletions gen.sh

This file was deleted.

2 changes: 2 additions & 0 deletions is_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"strings"
)

//go:generate bash regenerate-tlds.sh

// IsICANNTLD returns whether the given string is a TLD (Top Level Domain),
// according to ICANN. Well, really according to the TLDs listed in this
// package.
Expand Down
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"author": "jbenet",
"bugs": {
"URL": "https://github.com/jbenet/go-is-domain/issues",
"url": "https://github.com/jbenet/go-is-domain/issues"
},
"gx": {
"dvcsimport": "github.com/jbenet/go-is-domain"
},
"gxVersion": "0.7.0",
"language": "go",
"license": "MIT",
"name": "go-is-domain",
"version": "1.0.2"
}

24 changes: 24 additions & 0 deletions regenerate-tlds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

out=${1-tlds_iana.go}

list=$(mktemp)

wget https://data.iana.org/TLD/tlds-alpha-by-domain.txt -O $list

header=$(head -1 $list)

cat > $out <<EOF
package isdomain

// $header
var TLDs = map[string]bool{
EOF

grep -v '^#' $list | while read tld; do
echo -e "\t\"$tld\": true,"
done >> $out

echo '}' >> $out

gofmt -w $out
Loading