Documentation ¶
Overview ¶
Package instant provides instant answers
Index ¶
- Constants
- Variables
- type Age
- type Answer
- type Answerer
- type BirthStone
- type Birthday
- type Breach
- type Calculator
- type CamelCase
- type Characters
- type Clock
- type Coin
- type Congress
- type CountryCode
- type CountryCodeResponse
- type Currency
- type CurrencyResponse
- type Data
- type Death
- type DigitalStorage
- type Discography
- type FedEx
- type Frequency
- type GDP
- type GDPResponse
- type Hash
- type HashAlgo
- type HashResponse
- type Instant
- type Length
- type Map
- type Maps
- type Minify
- type MortgageCalculator
- type Nutrient
- type NutritionResponse
- type POTUS
- type Person
- type Population
- type PopulationResponse
- type Potus
- type Power
- type Prime
- type Random
- type Reverse
- type SOAnswer
- type Shortener
- type Speed
- type StackOverflow
- type StackOverflowAnswer
- type Stats
- type Status
- type StockQuote
- type Temperature
- type Triggerer
- type Type
- type UPS
- type URLDecode
- type URLEncode
- type USPS
- type UserAgent
- type WHOIS
- type Weather
- type Wikipedia
Constants ¶
const ISO3166 = "ISO 3166-1 alpha-2"
ISO3166 is the ISO 3166-1 alpha-2 country code format
Variables ¶
var ErrInvalidCurrency = fmt.Errorf("invalid currency")
ErrInvalidCurrency indicates the currency was invalid
var ErrInvalidURL = fmt.Errorf("unable to parse url")
ErrInvalidURL indicates an invalid url
var Nutrients = []Nutrient{
{
Name: calcium,
Code: "301",
Units: "mg",
},
{
Name: calories,
Code: "208",
Units: "calories",
Aliases: []nutrient{
energy,
},
},
{
Name: carbohydrates,
Code: "205",
Units: "g",
Aliases: []nutrient{
carbs,
},
},
{
Name: cholesterol,
Code: "601",
Units: "mg",
},
{
Name: saturatedFat,
Code: "606",
Units: "g",
},
{
Name: fat,
Code: "204",
Units: "g",
},
{
Name: fiber,
Code: "291",
Units: "g",
},
{
Name: iron,
Code: "303",
Units: "mg",
},
{
Name: lipid,
Code: "204",
Units: "g",
},
{
Name: magnesium,
Code: "304",
Units: "mg",
},
{
Name: potassium,
Code: "306",
Units: "mg",
},
{
Name: protein,
Code: "203",
Units: "g",
},
{
Name: sodium,
Code: "307",
Units: "mg",
},
{
Name: sugars,
Code: "269",
Units: "g",
Aliases: []nutrient{
sugar,
},
},
{
Name: vitaminA,
Code: "318",
Units: "IU",
},
{
Name: vitaminB,
Code: "418",
Units: "\u00b5g",
Aliases: []nutrient{
vitaminB12, vitaminBB12, vitaminBBB12,
},
},
{
Name: vitaminC,
Code: "401",
Units: "mg",
},
{
Name: vitaminD,
Code: "328",
Units: "\u00b5g",
},
{
Name: zinc,
Code: "309",
Units: "mg",
},
}
Nutrients maps the USDA's codes with names and aliases
Functions ¶
This section is empty.
Types ¶
type Answer ¶
type Answer struct { Data // contains filtered or unexported fields }
Answer holds an instant answer when triggered
type Answerer ¶
type Answerer interface {
// contains filtered or unexported methods
}
Answerer outlines methods for an instant answer
type Clock ¶
type Clock struct { Time time.Time `json:"time"` Location struct { City string `json:"city"` State string `json:"state"` Country string `json:"country"` } }
Clock is a current time for a location TODO: make Location a map/struct of different languages, not just 1
type CountryCodeResponse ¶
CountryCodeResponse is a response to the instant answer
type Currency ¶
type Currency struct { FXFetcher curr.FXFetcher CryptoFetcher curr.CryptoFetcher Answer }
Currency is an instant answer
type CurrencyResponse ¶
type CurrencyResponse struct { *curr.Response Notional float64 From curr.Currency To curr.Currency ForexCurrencies []curr.Currency CryptoCurrencies []curr.Currency Currencies []curr.Currency }
CurrencyResponse is an instant answer response
type Data ¶
type Data struct { Type `json:"type,omitempty"` Triggered bool `json:"triggered"` Solution interface{} `json:"answer,omitempty"` Err error `json:"-"` }
Data holds the returned data of an answer
type GDPResponse ¶
GDPResponse is an instant answer response
type HashResponse ¶
HashResponse is the response to the instant answer
type Instant ¶
type Instant struct { QueryVar string BreachFetcher breach.Fetcher CongressFetcher congress.Fetcher DiscographyFetcher disc.Fetcher FedExFetcher parcel.Fetcher Currency GDPFetcher ggdp.Fetcher LinkShortener shortener.Service LocationFetcher location.Fetcher NutritionFetcher nutrition.Fetcher PopulationFetcher pop.Fetcher StackOverflowFetcher so.Fetcher StatusFetcher status.Fetcher StockQuoteFetcher stock.Fetcher TimeZoneFetcher timezone.Fetcher UPSFetcher parcel.Fetcher USPSFetcher parcel.Fetcher WeatherFetcher weather.Fetcher WHOISFetcher whois.Fetcher WikipediaFetcher wikipedia.Fetcher }
Instant holds config information for the instant answers
type MortgageCalculator ¶
type MortgageCalculator struct {
Answer
}
MortgageCalculator is an instant answer
type NutritionResponse ¶
NutritionResponse is a food's nutrition content
type Population ¶
Population is an instant answer
type PopulationResponse ¶
PopulationResponse is an instant answer response
type StackOverflow ¶
StackOverflow is an instant answer Alternative (but out-of-date): http://archive.org/download/stackexchange/
type StackOverflowAnswer ¶
StackOverflowAnswer is a question and answer
type Stats ¶
type Stats struct {
Answer
}
Stats is an instant answer that returns the average, median, etc.
type StockQuote ¶
StockQuote is an instant answer
type Triggerer ¶
type Triggerer interface {
Trigger()
}
Triggerer detects if the answer has been triggered
type Type ¶
type Type string
Type is the answer type
const ( WikipediaType Type = "wikipedia" WikidataAgeType Type = "wikidata age" WikidataBirthdayType Type = "wikidata birthday" WikidataClockType Type = "wikidata clock" WikidataDeathType Type = "wikidata death" WikidataHeightType Type = "wikidata height" WikidataNutritionType Type = "wikidata nutrition" WikidataWeightType Type = "wikidata weight" WikiquoteType Type = "wikiquote" WiktionaryType Type = "wiktionary" )
WikipediaType is a Wikipedia answer Type
const BirthStoneType Type = "birthstone"
BirthStoneType is an answer Type
const BreachType Type = "breach"
BreachType is an answer Type
const CalculatorType Type = "calculator"
CalculatorType is an answer Type
const CamelCaseType Type = "camelcase"
CamelCaseType is an answer Type
const CharactersType Type = "characters"
CharactersType is an answer Type
const CoinTossType Type = "coin toss"
CoinTossType is an answer Type
const CongressType Type = "congress"
CongressType is an answer Type
const CountryCodeType Type = "country code"
CountryCodeType is an answer Type
const CurrencyType Type = "currency"
CurrencyType is an answer Type
const DiscographyType Type = "discography"
DiscographyType is an answer Type
const FedExType Type = "fedex"
FedExType is an answer Type
const FrequencyType Type = "frequency"
FrequencyType is an answer Type
const GDPType Type = "gdp"
GDPType is an answer Type
const HashType Type = "hash"
HashType is an answer Type
const LocalWeatherType Type = "local weather"
LocalWeatherType is an answer Type
const MapsType Type = "maps"
MapsType is an answer Type
const MinifyType Type = "minify"
MinifyType is an answer Type
const MortageCalculatorType Type = "mortgage calculator"
MortageCalculatorType is an answer Type
const PopulationType Type = "population"
PopulationType is an answer Type
const PotusType Type = "potus"
PotusType is an answer Type
const PrimeType Type = "prime"
PrimeType is an answer Type
const RandomType Type = "random"
RandomType is an answer Type
const ReverseType Type = "reverse"
ReverseType is an answer Type
const StackOverflowType Type = "stackoverflow"
StackOverflowType is an answer Type
const StatsType Type = "stats"
StatsType is an answer Type
const StatusType Type = "status"
StatusType is an answer Type
const StockQuoteType Type = "stock quote"
StockQuoteType is an answer Type
const UPSType Type = "ups"
UPSType is an answer Type
const URLDecodeType Type = "urldecode"
URLDecodeType is an answer Type
const URLEncodeType Type = "urlencode"
URLEncodeType is an answer Type
const URLShortenerType Type = "url shortener"
URLShortenerType is an answer Type
const USPSType Type = "usps"
USPSType is an answer Type
const UnitConverterType Type = "unit converter"
UnitConverterType is an answer Type
const UserAgentType Type = "user agent"
UserAgentType is an answer Type
const WHOISType Type = "whois"
WHOISType is an answer Type
const WeatherType Type = "weather"
WeatherType is an answer Type
Source Files ¶
- answers.go
- birthstone.go
- breach.go
- calculator.go
- camelcase.go
- characters.go
- coin.go
- congress.go
- country_codes.go
- currency.go
- digital_storage.go
- discography.go
- fedex.go
- frequency.go
- gdp.go
- hash.go
- length.go
- maps.go
- minify.go
- mortgage_calculator.go
- population.go
- potus.go
- power.go
- prime.go
- random.go
- reverse.go
- shortener.go
- speed.go
- stackoverflow.go
- stats.go
- status.go
- stock.go
- temperature.go
- ups.go
- urldecode.go
- urlencode.go
- useragent.go
- usps.go
- weather.go
- whois.go
- wikipedia.go
Directories ¶
Path | Synopsis |
---|---|
Package breach checks for data breaches for a given account
|
Package breach checks for data breaches for a given account |
Package congress retrieves members of the United States Congress
|
Package congress retrieves members of the United States Congress |
Package currency fetches foreign exchange quotes
|
Package currency fetches foreign exchange quotes |
Package discography fetches artist discography
|
Package discography fetches artist discography |
gdp
Package gdp retrieves gdp data
|
Package gdp retrieves gdp data |
population
Package population retrieves population data
|
Package population retrieves population data |
Package location fetches geolocation data
|
Package location fetches geolocation data |
Package nutrition provides food nutrition information
|
Package nutrition provides food nutrition information |
Package parcel shows package status for UPS, Fedex and others
|
Package parcel shows package status for UPS, Fedex and others |
Package shortener shortens urls
|
Package shortener shortens urls |
Package stackoverflow fetches stackoverflow data
|
Package stackoverflow fetches stackoverflow data |
Package status checks if a website is down
|
Package status checks if a website is down |
Package stock fetches stock quote data
|
Package stock fetches stock quote data |
Package timezone retrieves timezone info from lat/lon coordinates
|
Package timezone retrieves timezone info from lat/lon coordinates |
Package weather fetches weather data
|
Package weather fetches weather data |
Package whois fetchers WHOIS information for a domain
|
Package whois fetchers WHOIS information for a domain |
Package wikipedia fetches Wikipedia articles Package wikipedia fetches Wikipedia articles
|
Package wikipedia fetches Wikipedia articles Package wikipedia fetches Wikipedia articles |
cmd/dumper
Dumper downloads and dumps wikipedia/wikidata/wikiquotes data to a postgresql database.
|
Dumper downloads and dumps wikipedia/wikidata/wikiquotes data to a postgresql database. |