| // Copyright 2019 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| |
| package internal |
| |
| import ( |
| "strings" |
| |
| "golang.org/x/mod/semver" |
| ) |
| |
| // TopLevelDomains contains all of the top level domains in the discovery |
| // database. |
| var TopLevelDomains = map[string]bool{ |
| "af": true, |
| "africa": true, |
| "ag": true, |
| "agency": true, |
| "ai": true, |
| "app": true, |
| "ar": true, |
| "as": true, |
| "at": true, |
| "au": true, |
| "beer": true, |
| "berlin": true, |
| "biz": true, |
| "blue": true, |
| "br": true, |
| "build": true, |
| "by": true, |
| "ca": true, |
| "cafe": true, |
| "casa": true, |
| "cc": true, |
| "ch": true, |
| "ci": true, |
| "city": true, |
| "cl": true, |
| "click": true, |
| "cloud": true, |
| "club": true, |
| "cn": true, |
| "co": true, |
| "codes": true, |
| "coffee": true, |
| "com": true, |
| "computer": true, |
| "consulting": true, |
| "coop": true, |
| "cx": true, |
| "cz": true, |
| "de": true, |
| "design": true, |
| "dev": true, |
| "digital": true, |
| "direct": true, |
| "dk": true, |
| "dog": true, |
| "download": true, |
| "earth": true, |
| "edu": true, |
| "ee": true, |
| "engineer": true, |
| "engineering": true, |
| "es": true, |
| "eu": true, |
| "farm": true, |
| "fi": true, |
| "fm": true, |
| "fr": true, |
| "fun": true, |
| "fyi": true, |
| "ga": true, |
| "gay": true, |
| "gg": true, |
| "gmbh": true, |
| "gov": true, |
| "gq": true, |
| "gt": true, |
| "haus": true, |
| "host": true, |
| "ht": true, |
| "hu": true, |
| "icu": true, |
| "id": true, |
| "ie": true, |
| "im": true, |
| "in": true, |
| "info": true, |
| "ink": true, |
| "io": true, |
| "ir": true, |
| "is": true, |
| "it": true, |
| "jp": true, |
| "ke": true, |
| "kr": true, |
| "kz": true, |
| "la": true, |
| "land": true, |
| "lgbt": true, |
| "li": true, |
| "life": true, |
| "link": true, |
| "london": true, |
| "lt": true, |
| "lv": true, |
| "me": true, |
| "media": true, |
| "mil": true, |
| "ml": true, |
| "mn": true, |
| "moe": true, |
| "ms": true, |
| "name": true, |
| "nc": true, |
| "net": true, |
| "network": true, |
| "ninja": true, |
| "nl": true, |
| "no": true, |
| "nu": true, |
| "nz": true, |
| "one": true, |
| "online": true, |
| "org": true, |
| "pe": true, |
| "pl": true, |
| "pm": true, |
| "pro": true, |
| "pub": true, |
| "pw": true, |
| "re": true, |
| "red": true, |
| "ren": true, |
| "rip": true, |
| "ro": true, |
| "rocks": true, |
| "ru": true, |
| "run": true, |
| "school": true, |
| "science": true, |
| "se": true, |
| "services": true, |
| "sh": true, |
| "site": true, |
| "sm": true, |
| "software": true, |
| "solutions": true, |
| "space": true, |
| "st": true, |
| "std": true, |
| "studio": true, |
| "study": true, |
| "su": true, |
| "supply": true, |
| "systems": true, |
| "taxi": true, |
| "team": true, |
| "tech": true, |
| "technology": true, |
| "tf": true, |
| "th": true, |
| "tickets": true, |
| "tk": true, |
| "tm": true, |
| "to": true, |
| "today": true, |
| "tools": true, |
| "top": true, |
| "town": true, |
| "trade": true, |
| "tv": true, |
| "tw": true, |
| "ua": true, |
| "uk": true, |
| "us": true, |
| "uz": true, |
| "ve": true, |
| "vip": true, |
| "vn": true, |
| "wang": true, |
| "website": true, |
| "work": true, |
| "works": true, |
| "wtf": true, |
| "xyz": true, |
| "yandex": true, |
| "zone": true, |
| } |
| |
| // IsGoPkgInPathElement reports whether p is an element of a gopkg.in path. |
| // It returns true if p has "gopkg.in" as a prefix, or the suffix is a major |
| // version, for example "yaml.v2". |
| func IsGoPkgInPathElement(p string) bool { |
| if strings.HasPrefix(strings.ToLower(p), "gopkg.in") { |
| return true |
| } |
| parts := strings.Split(p, ".") |
| if len(parts) <= 1 { |
| return false |
| } |
| maj := parts[len(parts)-1] |
| return semver.Major(maj) == maj |
| } |