id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
11,700
briandowns/openweathermap
current.go
NewCurrent
func NewCurrent(unit, lang, key string, options ...Option) (*CurrentWeatherData, error) { unitChoice := strings.ToUpper(unit) langChoice := strings.ToUpper(lang) c := &CurrentWeatherData{ Settings: NewSettings(), } if ValidDataUnit(unitChoice) { c.Unit = DataUnits[unitChoice] } else { return nil, errUnitUnavailable } if ValidLangCode(langChoice) { c.Lang = langChoice } else { return nil, errLangUnavailable } var err error c.Key, err = setKey(key) if err != nil { return nil, err } if err := setOptions(c.Settings, options); err != nil { return nil, err } return c, nil }
go
func NewCurrent(unit, lang, key string, options ...Option) (*CurrentWeatherData, error) { unitChoice := strings.ToUpper(unit) langChoice := strings.ToUpper(lang) c := &CurrentWeatherData{ Settings: NewSettings(), } if ValidDataUnit(unitChoice) { c.Unit = DataUnits[unitChoice] } else { return nil, errUnitUnavailable } if ValidLangCode(langChoice) { c.Lang = langChoice } else { return nil, errLangUnavailable } var err error c.Key, err = setKey(key) if err != nil { return nil, err } if err := setOptions(c.Settings, options); err != nil { return nil, err } return c, nil }
[ "func", "NewCurrent", "(", "unit", ",", "lang", ",", "key", "string", ",", "options", "...", "Option", ")", "(", "*", "CurrentWeatherData", ",", "error", ")", "{", "unitChoice", ":=", "strings", ".", "ToUpper", "(", "unit", ")", "\n", "langChoice", ":=",...
// NewCurrent returns a new CurrentWeatherData pointer with the supplied parameters
[ "NewCurrent", "returns", "a", "new", "CurrentWeatherData", "pointer", "with", "the", "supplied", "parameters" ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/current.go#L47-L76
11,701
briandowns/openweathermap
current.go
CurrentByName
func (w *CurrentWeatherData) CurrentByName(location string) error { response, err := w.client.Get(fmt.Sprintf(fmt.Sprintf(baseURL, "appid=%s&q=%s&units=%s&lang=%s"), w.Key, url.QueryEscape(location), w.Unit, w.Lang)) if err != nil { return err } defer response.Body.Close() if err := json.NewDecoder(response.Body).Decode(&w); err != nil { return err } return nil }
go
func (w *CurrentWeatherData) CurrentByName(location string) error { response, err := w.client.Get(fmt.Sprintf(fmt.Sprintf(baseURL, "appid=%s&q=%s&units=%s&lang=%s"), w.Key, url.QueryEscape(location), w.Unit, w.Lang)) if err != nil { return err } defer response.Body.Close() if err := json.NewDecoder(response.Body).Decode(&w); err != nil { return err } return nil }
[ "func", "(", "w", "*", "CurrentWeatherData", ")", "CurrentByName", "(", "location", "string", ")", "error", "{", "response", ",", "err", ":=", "w", ".", "client", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "fmt", ".", "Sprintf", "(", "baseURL", ",", ...
// CurrentByName will provide the current weather with the provided // location name.
[ "CurrentByName", "will", "provide", "the", "current", "weather", "with", "the", "provided", "location", "name", "." ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/current.go#L80-L92
11,702
briandowns/openweathermap
current.go
CurrentByCoordinates
func (w *CurrentWeatherData) CurrentByCoordinates(location *Coordinates) error { response, err := w.client.Get(fmt.Sprintf(fmt.Sprintf(baseURL, "appid=%s&lat=%f&lon=%f&units=%s&lang=%s"), w.Key, location.Latitude, location.Longitude, w.Unit, w.Lang)) if err != nil { return err } defer response.Body.Close() if err = json.NewDecoder(response.Body).Decode(&w); err != nil { return err } return nil }
go
func (w *CurrentWeatherData) CurrentByCoordinates(location *Coordinates) error { response, err := w.client.Get(fmt.Sprintf(fmt.Sprintf(baseURL, "appid=%s&lat=%f&lon=%f&units=%s&lang=%s"), w.Key, location.Latitude, location.Longitude, w.Unit, w.Lang)) if err != nil { return err } defer response.Body.Close() if err = json.NewDecoder(response.Body).Decode(&w); err != nil { return err } return nil }
[ "func", "(", "w", "*", "CurrentWeatherData", ")", "CurrentByCoordinates", "(", "location", "*", "Coordinates", ")", "error", "{", "response", ",", "err", ":=", "w", ".", "client", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "fmt", ".", "Sprintf", "(", ...
// CurrentByCoordinates will provide the current weather with the // provided location coordinates.
[ "CurrentByCoordinates", "will", "provide", "the", "current", "weather", "with", "the", "provided", "location", "coordinates", "." ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/current.go#L96-L108
11,703
briandowns/openweathermap
current.go
CurrentByID
func (w *CurrentWeatherData) CurrentByID(id int) error { response, err := w.client.Get(fmt.Sprintf(fmt.Sprintf(baseURL, "appid=%s&id=%d&units=%s&lang=%s"), w.Key, id, w.Unit, w.Lang)) if err != nil { return err } defer response.Body.Close() if err = json.NewDecoder(response.Body).Decode(&w); err != nil { return err } return nil }
go
func (w *CurrentWeatherData) CurrentByID(id int) error { response, err := w.client.Get(fmt.Sprintf(fmt.Sprintf(baseURL, "appid=%s&id=%d&units=%s&lang=%s"), w.Key, id, w.Unit, w.Lang)) if err != nil { return err } defer response.Body.Close() if err = json.NewDecoder(response.Body).Decode(&w); err != nil { return err } return nil }
[ "func", "(", "w", "*", "CurrentWeatherData", ")", "CurrentByID", "(", "id", "int", ")", "error", "{", "response", ",", "err", ":=", "w", ".", "client", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "fmt", ".", "Sprintf", "(", "baseURL", ",", "\"", "...
// CurrentByID will provide the current weather with the // provided location ID.
[ "CurrentByID", "will", "provide", "the", "current", "weather", "with", "the", "provided", "location", "ID", "." ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/current.go#L112-L124
11,704
briandowns/openweathermap
current.go
CurrentByZip
func (w *CurrentWeatherData) CurrentByZip(zip int, countryCode string) error { response, err := w.client.Get(fmt.Sprintf(fmt.Sprintf(baseURL, "appid=%s&zip=%d,%s&units=%s&lang=%s"), w.Key, zip, countryCode, w.Unit, w.Lang)) if err != nil { return err } defer response.Body.Close() if err = json.NewDecoder(response.Body).Decode(&w); err != nil { return err } return nil }
go
func (w *CurrentWeatherData) CurrentByZip(zip int, countryCode string) error { response, err := w.client.Get(fmt.Sprintf(fmt.Sprintf(baseURL, "appid=%s&zip=%d,%s&units=%s&lang=%s"), w.Key, zip, countryCode, w.Unit, w.Lang)) if err != nil { return err } defer response.Body.Close() if err = json.NewDecoder(response.Body).Decode(&w); err != nil { return err } return nil }
[ "func", "(", "w", "*", "CurrentWeatherData", ")", "CurrentByZip", "(", "zip", "int", ",", "countryCode", "string", ")", "error", "{", "response", ",", "err", ":=", "w", ".", "client", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "fmt", ".", "Sprintf", ...
// CurrentByZip will provide the current weather for the // provided zip code.
[ "CurrentByZip", "will", "provide", "the", "current", "weather", "for", "the", "provided", "zip", "code", "." ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/current.go#L128-L139
11,705
briandowns/openweathermap
forecast.go
NewForecast
func NewForecast(forecastType, unit, lang, key string, options ...Option) (*ForecastWeatherData, error) { unitChoice := strings.ToUpper(unit) langChoice := strings.ToUpper(lang) if forecastType != "16" && forecastType != "5" { return nil, errForecastUnavailable } if !ValidDataUnit(unitChoice) { return nil, errUnitUnavailable } if !ValidLangCode(langChoice) { return nil, errLangUnavailable } settings := NewSettings() if err := setOptions(settings, options); err != nil { return nil, err } var err error k, err := setKey(key) if err != nil { return nil, err } forecastData := ForecastWeatherData{ Unit: DataUnits[unitChoice], Lang: langChoice, Key: k, Settings: settings, } if forecastType == "16" { forecastData.baseURL = forecast16Base forecastData.ForecastWeatherJson = &Forecast16WeatherData{} } else { forecastData.baseURL = forecast5Base forecastData.ForecastWeatherJson = &Forecast5WeatherData{} } return &forecastData, nil }
go
func NewForecast(forecastType, unit, lang, key string, options ...Option) (*ForecastWeatherData, error) { unitChoice := strings.ToUpper(unit) langChoice := strings.ToUpper(lang) if forecastType != "16" && forecastType != "5" { return nil, errForecastUnavailable } if !ValidDataUnit(unitChoice) { return nil, errUnitUnavailable } if !ValidLangCode(langChoice) { return nil, errLangUnavailable } settings := NewSettings() if err := setOptions(settings, options); err != nil { return nil, err } var err error k, err := setKey(key) if err != nil { return nil, err } forecastData := ForecastWeatherData{ Unit: DataUnits[unitChoice], Lang: langChoice, Key: k, Settings: settings, } if forecastType == "16" { forecastData.baseURL = forecast16Base forecastData.ForecastWeatherJson = &Forecast16WeatherData{} } else { forecastData.baseURL = forecast5Base forecastData.ForecastWeatherJson = &Forecast5WeatherData{} } return &forecastData, nil }
[ "func", "NewForecast", "(", "forecastType", ",", "unit", ",", "lang", ",", "key", "string", ",", "options", "...", "Option", ")", "(", "*", "ForecastWeatherData", ",", "error", ")", "{", "unitChoice", ":=", "strings", ".", "ToUpper", "(", "unit", ")", "\...
// NewForecast returns a new HistoricalWeatherData pointer with // the supplied arguments.
[ "NewForecast", "returns", "a", "new", "HistoricalWeatherData", "pointer", "with", "the", "supplied", "arguments", "." ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/forecast.go#L73-L115
11,706
briandowns/openweathermap
forecast.go
DailyByName
func (f *ForecastWeatherData) DailyByName(location string, days int) error { response, err := f.client.Get(fmt.Sprintf(f.baseURL, f.Key, fmt.Sprintf("%s=%s", "q", url.QueryEscape(location)), f.Unit, f.Lang, days)) if err != nil { return err } defer response.Body.Close() return f.ForecastWeatherJson.Decode(response.Body) }
go
func (f *ForecastWeatherData) DailyByName(location string, days int) error { response, err := f.client.Get(fmt.Sprintf(f.baseURL, f.Key, fmt.Sprintf("%s=%s", "q", url.QueryEscape(location)), f.Unit, f.Lang, days)) if err != nil { return err } defer response.Body.Close() return f.ForecastWeatherJson.Decode(response.Body) }
[ "func", "(", "f", "*", "ForecastWeatherData", ")", "DailyByName", "(", "location", "string", ",", "days", "int", ")", "error", "{", "response", ",", "err", ":=", "f", ".", "client", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "f", ".", "baseURL", ",...
// DailyByName will provide a forecast for the location given for the // number of days given.
[ "DailyByName", "will", "provide", "a", "forecast", "for", "the", "location", "given", "for", "the", "number", "of", "days", "given", "." ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/forecast.go#L119-L127
11,707
briandowns/openweathermap
forecast.go
DailyByCoordinates
func (f *ForecastWeatherData) DailyByCoordinates(location *Coordinates, days int) error { response, err := f.client.Get(fmt.Sprintf(f.baseURL, f.Key, fmt.Sprintf("lat=%f&lon=%f", location.Latitude, location.Longitude), f.Unit, f.Lang, days)) if err != nil { return err } defer response.Body.Close() return f.ForecastWeatherJson.Decode(response.Body) }
go
func (f *ForecastWeatherData) DailyByCoordinates(location *Coordinates, days int) error { response, err := f.client.Get(fmt.Sprintf(f.baseURL, f.Key, fmt.Sprintf("lat=%f&lon=%f", location.Latitude, location.Longitude), f.Unit, f.Lang, days)) if err != nil { return err } defer response.Body.Close() return f.ForecastWeatherJson.Decode(response.Body) }
[ "func", "(", "f", "*", "ForecastWeatherData", ")", "DailyByCoordinates", "(", "location", "*", "Coordinates", ",", "days", "int", ")", "error", "{", "response", ",", "err", ":=", "f", ".", "client", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "f", "."...
// DailyByCoordinates will provide a forecast for the coordinates ID give // for the number of days given.
[ "DailyByCoordinates", "will", "provide", "a", "forecast", "for", "the", "coordinates", "ID", "give", "for", "the", "number", "of", "days", "given", "." ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/forecast.go#L131-L139
11,708
briandowns/openweathermap
forecast.go
DailyByID
func (f *ForecastWeatherData) DailyByID(id, days int) error { response, err := f.client.Get(fmt.Sprintf(f.baseURL, f.Key, fmt.Sprintf("%s=%s", "id", strconv.Itoa(id)), f.Unit, f.Lang, days)) if err != nil { return err } defer response.Body.Close() return f.ForecastWeatherJson.Decode(response.Body) }
go
func (f *ForecastWeatherData) DailyByID(id, days int) error { response, err := f.client.Get(fmt.Sprintf(f.baseURL, f.Key, fmt.Sprintf("%s=%s", "id", strconv.Itoa(id)), f.Unit, f.Lang, days)) if err != nil { return err } defer response.Body.Close() return f.ForecastWeatherJson.Decode(response.Body) }
[ "func", "(", "f", "*", "ForecastWeatherData", ")", "DailyByID", "(", "id", ",", "days", "int", ")", "error", "{", "response", ",", "err", ":=", "f", ".", "client", ".", "Get", "(", "fmt", ".", "Sprintf", "(", "f", ".", "baseURL", ",", "f", ".", "...
// DailyByID will provide a forecast for the location ID give for the // number of days given.
[ "DailyByID", "will", "provide", "a", "forecast", "for", "the", "location", "ID", "give", "for", "the", "number", "of", "days", "given", "." ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/forecast.go#L143-L151
11,709
briandowns/openweathermap
openweathermap.go
setKey
func setKey(key string) (string, error) { if err := ValidAPIKey(key); err != nil { return "", err } return key, nil }
go
func setKey(key string) (string, error) { if err := ValidAPIKey(key); err != nil { return "", err } return key, nil }
[ "func", "setKey", "(", "key", "string", ")", "(", "string", ",", "error", ")", "{", "if", "err", ":=", "ValidAPIKey", "(", "key", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "key", ",", "nil", ...
// return key // }
[ "return", "key", "}" ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/openweathermap.go#L139-L144
11,710
briandowns/openweathermap
openweathermap.go
ValidDataUnit
func ValidDataUnit(u string) bool { for d := range DataUnits { if u == d { return true } } return false }
go
func ValidDataUnit(u string) bool { for d := range DataUnits { if u == d { return true } } return false }
[ "func", "ValidDataUnit", "(", "u", "string", ")", "bool", "{", "for", "d", ":=", "range", "DataUnits", "{", "if", "u", "==", "d", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// ValidDataUnit makes sure the string passed in is an accepted // unit of measure to be used for the return data.
[ "ValidDataUnit", "makes", "sure", "the", "string", "passed", "in", "is", "an", "accepted", "unit", "of", "measure", "to", "be", "used", "for", "the", "return", "data", "." ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/openweathermap.go#L148-L155
11,711
briandowns/openweathermap
openweathermap.go
ValidLangCode
func ValidLangCode(c string) bool { for d := range LangCodes { if c == d { return true } } return false }
go
func ValidLangCode(c string) bool { for d := range LangCodes { if c == d { return true } } return false }
[ "func", "ValidLangCode", "(", "c", "string", ")", "bool", "{", "for", "d", ":=", "range", "LangCodes", "{", "if", "c", "==", "d", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// ValidLangCode makes sure the string passed in is an // acceptable lang code.
[ "ValidLangCode", "makes", "sure", "the", "string", "passed", "in", "is", "an", "acceptable", "lang", "code", "." ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/openweathermap.go#L159-L166
11,712
briandowns/openweathermap
openweathermap.go
ValidDataUnitSymbol
func ValidDataUnitSymbol(u string) bool { for _, d := range DataUnits { if u == d { return true } } return false }
go
func ValidDataUnitSymbol(u string) bool { for _, d := range DataUnits { if u == d { return true } } return false }
[ "func", "ValidDataUnitSymbol", "(", "u", "string", ")", "bool", "{", "for", "_", ",", "d", ":=", "range", "DataUnits", "{", "if", "u", "==", "d", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// ValidDataUnitSymbol makes sure the string passed in is an // acceptable data unit symbol.
[ "ValidDataUnitSymbol", "makes", "sure", "the", "string", "passed", "in", "is", "an", "acceptable", "data", "unit", "symbol", "." ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/openweathermap.go#L170-L177
11,713
briandowns/openweathermap
openweathermap.go
WithHttpClient
func WithHttpClient(c *http.Client) Option { return func(s *Settings) error { if c == nil { return errInvalidHttpClient } s.client = c return nil } }
go
func WithHttpClient(c *http.Client) Option { return func(s *Settings) error { if c == nil { return errInvalidHttpClient } s.client = c return nil } }
[ "func", "WithHttpClient", "(", "c", "*", "http", ".", "Client", ")", "Option", "{", "return", "func", "(", "s", "*", "Settings", ")", "error", "{", "if", "c", "==", "nil", "{", "return", "errInvalidHttpClient", "\n", "}", "\n", "s", ".", "client", "=...
// WithHttpClient sets custom http client when creating a new Client.
[ "WithHttpClient", "sets", "custom", "http", "client", "when", "creating", "a", "new", "Client", "." ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/openweathermap.go#L206-L214
11,714
briandowns/openweathermap
openweathermap.go
setOptions
func setOptions(settings *Settings, options []Option) error { for _, option := range options { if option == nil { return errInvalidOption } err := option(settings) if err != nil { return err } } return nil }
go
func setOptions(settings *Settings, options []Option) error { for _, option := range options { if option == nil { return errInvalidOption } err := option(settings) if err != nil { return err } } return nil }
[ "func", "setOptions", "(", "settings", "*", "Settings", ",", "options", "[", "]", "Option", ")", "error", "{", "for", "_", ",", "option", ":=", "range", "options", "{", "if", "option", "==", "nil", "{", "return", "errInvalidOption", "\n", "}", "\n", "e...
// setOptions sets Optional client settings to the Settings pointer
[ "setOptions", "sets", "Optional", "client", "settings", "to", "the", "Settings", "pointer" ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/openweathermap.go#L217-L228
11,715
briandowns/openweathermap
conditions.go
RetrieveIcon
func RetrieveIcon(destination, iconFile string) (int64, error) { fullFilePath := fmt.Sprintf("%s/%s", destination, iconFile) // Check to see if we've already gotten that icon file. If so, use it // rather than getting it again. if _, err := os.Stat(fullFilePath); err != nil { response, err := http.Get(fmt.Sprintf(iconURL, iconFile)) if err != nil { return 0, err } defer response.Body.Close() // Create the icon file out, err := os.Create(fullFilePath) if err != nil { return 0, err } defer out.Close() // Fill the empty file with the actual content n, err := io.Copy(out, response.Body) if err != nil { return 0, err } return n, nil } return 0, nil }
go
func RetrieveIcon(destination, iconFile string) (int64, error) { fullFilePath := fmt.Sprintf("%s/%s", destination, iconFile) // Check to see if we've already gotten that icon file. If so, use it // rather than getting it again. if _, err := os.Stat(fullFilePath); err != nil { response, err := http.Get(fmt.Sprintf(iconURL, iconFile)) if err != nil { return 0, err } defer response.Body.Close() // Create the icon file out, err := os.Create(fullFilePath) if err != nil { return 0, err } defer out.Close() // Fill the empty file with the actual content n, err := io.Copy(out, response.Body) if err != nil { return 0, err } return n, nil } return 0, nil }
[ "func", "RetrieveIcon", "(", "destination", ",", "iconFile", "string", ")", "(", "int64", ",", "error", ")", "{", "fullFilePath", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "destination", ",", "iconFile", ")", "\n\n", "// Check to see if we've already ...
// RetrieveIcon will get the specified icon from the API.
[ "RetrieveIcon", "will", "get", "the", "specified", "icon", "from", "the", "API", "." ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/conditions.go#L40-L67
11,716
briandowns/openweathermap
_examples/web/weatherweb.go
main
func main() { http.HandleFunc("/here", hereHandler) // Make sure we can serve our icon files once retrieved http.HandleFunc("/static/", func(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, r.URL.Path[1:]) }) http.ListenAndServe(":8888", nil) }
go
func main() { http.HandleFunc("/here", hereHandler) // Make sure we can serve our icon files once retrieved http.HandleFunc("/static/", func(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, r.URL.Path[1:]) }) http.ListenAndServe(":8888", nil) }
[ "func", "main", "(", ")", "{", "http", ".", "HandleFunc", "(", "\"", "\"", ",", "hereHandler", ")", "\n", "// Make sure we can serve our icon files once retrieved", "http", ".", "HandleFunc", "(", "\"", "\"", ",", "func", "(", "w", "http", ".", "ResponseWriter...
// Run the app
[ "Run", "the", "app" ]
5f41b7c9d92de5d74bf32f4486375c7547bc8a3c
https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/_examples/web/weatherweb.go#L98-L105
11,717
fluffle/goirc
client/commands.go
Privmsgf
func (conn *Conn) Privmsgf(t, format string, a ...interface{}) { msg := fmt.Sprintf(format, a...) conn.Privmsg(t, msg) }
go
func (conn *Conn) Privmsgf(t, format string, a ...interface{}) { msg := fmt.Sprintf(format, a...) conn.Privmsg(t, msg) }
[ "func", "(", "conn", "*", "Conn", ")", "Privmsgf", "(", "t", ",", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "msg", ":=", "fmt", ".", "Sprintf", "(", "format", ",", "a", "...", ")", "\n", "conn", ".", "Privmsg", "(", ...
// Privmsgf is the variadic version of Privmsg that formats the message // that is sent to the target nick or channel t using the // fmt.Sprintf function.
[ "Privmsgf", "is", "the", "variadic", "version", "of", "Privmsg", "that", "formats", "the", "message", "that", "is", "sent", "to", "the", "target", "nick", "or", "channel", "t", "using", "the", "fmt", ".", "Sprintf", "function", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/commands.go#L182-L185
11,718
fluffle/goirc
client/commands.go
Invite
func (conn *Conn) Invite(nick, channel string) { conn.Raw(INVITE + " " + nick + " " + channel) }
go
func (conn *Conn) Invite(nick, channel string) { conn.Raw(INVITE + " " + nick + " " + channel) }
[ "func", "(", "conn", "*", "Conn", ")", "Invite", "(", "nick", ",", "channel", "string", ")", "{", "conn", ".", "Raw", "(", "INVITE", "+", "\"", "\"", "+", "nick", "+", "\"", "\"", "+", "channel", ")", "\n", "}" ]
// Invite sends an INVITE command to the server. // INVITE nick channel
[ "Invite", "sends", "an", "INVITE", "command", "to", "the", "server", ".", "INVITE", "nick", "channel" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/commands.go#L275-L277
11,719
fluffle/goirc
client/connection.go
SimpleClient
func SimpleClient(nick string, args ...string) *Conn { conn := Client(NewConfig(nick, args...)) return conn }
go
func SimpleClient(nick string, args ...string) *Conn { conn := Client(NewConfig(nick, args...)) return conn }
[ "func", "SimpleClient", "(", "nick", "string", ",", "args", "...", "string", ")", "*", "Conn", "{", "conn", ":=", "Client", "(", "NewConfig", "(", "nick", ",", "args", "...", ")", ")", "\n", "return", "conn", "\n", "}" ]
// SimpleClient creates a new Conn, passing its arguments to NewConfig. // If you don't need to change any client options and just want to get // started quickly, this is a convenient shortcut.
[ "SimpleClient", "creates", "a", "new", "Conn", "passing", "its", "arguments", "to", "NewConfig", ".", "If", "you", "don", "t", "need", "to", "change", "any", "client", "options", "and", "just", "want", "to", "get", "started", "quickly", "this", "is", "a", ...
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/connection.go#L149-L152
11,720
fluffle/goirc
client/connection.go
Client
func Client(cfg *Config) *Conn { if cfg == nil { cfg = NewConfig("__idiot__") } if cfg.Me == nil || cfg.Me.Nick == "" || cfg.Me.Ident == "" { cfg.Me = &state.Nick{Nick: "__idiot__"} cfg.Me.Ident = "goirc" cfg.Me.Name = "Powered by GoIRC" } dialer := new(net.Dialer) dialer.Timeout = cfg.Timeout dialer.DualStack = cfg.DualStack if cfg.LocalAddr != "" { if !hasPort(cfg.LocalAddr) { cfg.LocalAddr += ":0" } local, err := net.ResolveTCPAddr("tcp", cfg.LocalAddr) if err == nil { dialer.LocalAddr = local } else { logging.Error("irc.Client(): Cannot resolve local address %s: %s", cfg.LocalAddr, err) } } conn := &Conn{ cfg: cfg, dialer: dialer, intHandlers: handlerSet(), fgHandlers: handlerSet(), bgHandlers: handlerSet(), stRemovers: make([]Remover, 0, len(stHandlers)), lastsent: time.Now(), } conn.addIntHandlers() return conn }
go
func Client(cfg *Config) *Conn { if cfg == nil { cfg = NewConfig("__idiot__") } if cfg.Me == nil || cfg.Me.Nick == "" || cfg.Me.Ident == "" { cfg.Me = &state.Nick{Nick: "__idiot__"} cfg.Me.Ident = "goirc" cfg.Me.Name = "Powered by GoIRC" } dialer := new(net.Dialer) dialer.Timeout = cfg.Timeout dialer.DualStack = cfg.DualStack if cfg.LocalAddr != "" { if !hasPort(cfg.LocalAddr) { cfg.LocalAddr += ":0" } local, err := net.ResolveTCPAddr("tcp", cfg.LocalAddr) if err == nil { dialer.LocalAddr = local } else { logging.Error("irc.Client(): Cannot resolve local address %s: %s", cfg.LocalAddr, err) } } conn := &Conn{ cfg: cfg, dialer: dialer, intHandlers: handlerSet(), fgHandlers: handlerSet(), bgHandlers: handlerSet(), stRemovers: make([]Remover, 0, len(stHandlers)), lastsent: time.Now(), } conn.addIntHandlers() return conn }
[ "func", "Client", "(", "cfg", "*", "Config", ")", "*", "Conn", "{", "if", "cfg", "==", "nil", "{", "cfg", "=", "NewConfig", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "cfg", ".", "Me", "==", "nil", "||", "cfg", ".", "Me", ".", "Nick", "==",...
// Client takes a Config struct and returns a new Conn ready to have // handlers added and connect to a server.
[ "Client", "takes", "a", "Config", "struct", "and", "returns", "a", "new", "Conn", "ready", "to", "have", "handlers", "added", "and", "connect", "to", "a", "server", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/connection.go#L156-L193
11,721
fluffle/goirc
client/connection.go
Connected
func (conn *Conn) Connected() bool { conn.mu.RLock() defer conn.mu.RUnlock() return conn.connected }
go
func (conn *Conn) Connected() bool { conn.mu.RLock() defer conn.mu.RUnlock() return conn.connected }
[ "func", "(", "conn", "*", "Conn", ")", "Connected", "(", ")", "bool", "{", "conn", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "conn", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "conn", ".", "connected", "\n", "}" ]
// Connected returns true if the client is successfully connected to // an IRC server. It becomes true when the TCP connection is established, // and false again when the connection is closed.
[ "Connected", "returns", "true", "if", "the", "client", "is", "successfully", "connected", "to", "an", "IRC", "server", ".", "It", "becomes", "true", "when", "the", "TCP", "connection", "is", "established", "and", "false", "again", "when", "the", "connection", ...
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/connection.go#L198-L202
11,722
fluffle/goirc
client/connection.go
Me
func (conn *Conn) Me() *state.Nick { if conn.st != nil { conn.cfg.Me = conn.st.Me() } return conn.cfg.Me }
go
func (conn *Conn) Me() *state.Nick { if conn.st != nil { conn.cfg.Me = conn.st.Me() } return conn.cfg.Me }
[ "func", "(", "conn", "*", "Conn", ")", "Me", "(", ")", "*", "state", ".", "Nick", "{", "if", "conn", ".", "st", "!=", "nil", "{", "conn", ".", "cfg", ".", "Me", "=", "conn", ".", "st", ".", "Me", "(", ")", "\n", "}", "\n", "return", "conn",...
// Me returns a state.Nick that reflects the client's IRC nick at the // time it is called. If state tracking is enabled, this comes from // the tracker, otherwise it is equivalent to conn.cfg.Me.
[ "Me", "returns", "a", "state", ".", "Nick", "that", "reflects", "the", "client", "s", "IRC", "nick", "at", "the", "time", "it", "is", "called", ".", "If", "state", "tracking", "is", "enabled", "this", "comes", "from", "the", "tracker", "otherwise", "it",...
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/connection.go#L220-L225
11,723
fluffle/goirc
client/connection.go
DisableStateTracking
func (conn *Conn) DisableStateTracking() { conn.mu.Lock() defer conn.mu.Unlock() if conn.st != nil { conn.cfg.Me = conn.st.Me() conn.delSTHandlers() conn.st.Wipe() conn.st = nil } }
go
func (conn *Conn) DisableStateTracking() { conn.mu.Lock() defer conn.mu.Unlock() if conn.st != nil { conn.cfg.Me = conn.st.Me() conn.delSTHandlers() conn.st.Wipe() conn.st = nil } }
[ "func", "(", "conn", "*", "Conn", ")", "DisableStateTracking", "(", ")", "{", "conn", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "conn", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "conn", ".", "st", "!=", "nil", "{", "conn", ".", "cf...
// DisableStateTracking causes the client to stop tracking information // about the channels and nicks it knows of. It will also wipe current // state from the state tracker.
[ "DisableStateTracking", "causes", "the", "client", "to", "stop", "tracking", "information", "about", "the", "channels", "and", "nicks", "it", "knows", "of", ".", "It", "will", "also", "wipe", "current", "state", "from", "the", "state", "tracker", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/connection.go#L257-L266
11,724
fluffle/goirc
client/connection.go
initialise
func (conn *Conn) initialise() { conn.io = nil conn.sock = nil conn.in = make(chan *Line, 32) conn.out = make(chan string, 32) conn.die = make(chan struct{}) if conn.st != nil { conn.st.Wipe() } }
go
func (conn *Conn) initialise() { conn.io = nil conn.sock = nil conn.in = make(chan *Line, 32) conn.out = make(chan string, 32) conn.die = make(chan struct{}) if conn.st != nil { conn.st.Wipe() } }
[ "func", "(", "conn", "*", "Conn", ")", "initialise", "(", ")", "{", "conn", ".", "io", "=", "nil", "\n", "conn", ".", "sock", "=", "nil", "\n", "conn", ".", "in", "=", "make", "(", "chan", "*", "Line", ",", "32", ")", "\n", "conn", ".", "out"...
// Per-connection state initialisation.
[ "Per", "-", "connection", "state", "initialisation", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/connection.go#L269-L278
11,725
fluffle/goirc
client/connection.go
internalConnect
func (conn *Conn) internalConnect() error { conn.mu.Lock() defer conn.mu.Unlock() conn.initialise() if conn.cfg.Server == "" { return fmt.Errorf("irc.Connect(): cfg.Server must be non-empty") } if conn.connected { return fmt.Errorf("irc.Connect(): Cannot connect to %s, already connected.", conn.cfg.Server) } if !hasPort(conn.cfg.Server) { if conn.cfg.SSL { conn.cfg.Server = net.JoinHostPort(conn.cfg.Server, "6697") } else { conn.cfg.Server = net.JoinHostPort(conn.cfg.Server, "6667") } } if conn.cfg.Proxy != "" { proxyURL, err := url.Parse(conn.cfg.Proxy) if err != nil { return err } conn.proxyDialer, err = proxy.FromURL(proxyURL, conn.dialer) if err != nil { return err } logging.Info("irc.Connect(): Connecting to %s.", conn.cfg.Server) if s, err := conn.proxyDialer.Dial("tcp", conn.cfg.Server); err == nil { conn.sock = s } else { return err } } else { logging.Info("irc.Connect(): Connecting to %s.", conn.cfg.Server) if s, err := conn.dialer.Dial("tcp", conn.cfg.Server); err == nil { conn.sock = s } else { return err } } if conn.cfg.SSL { logging.Info("irc.Connect(): Performing SSL handshake.") s := tls.Client(conn.sock, conn.cfg.SSLConfig) if err := s.Handshake(); err != nil { return err } conn.sock = s } conn.postConnect(true) conn.connected = true return nil }
go
func (conn *Conn) internalConnect() error { conn.mu.Lock() defer conn.mu.Unlock() conn.initialise() if conn.cfg.Server == "" { return fmt.Errorf("irc.Connect(): cfg.Server must be non-empty") } if conn.connected { return fmt.Errorf("irc.Connect(): Cannot connect to %s, already connected.", conn.cfg.Server) } if !hasPort(conn.cfg.Server) { if conn.cfg.SSL { conn.cfg.Server = net.JoinHostPort(conn.cfg.Server, "6697") } else { conn.cfg.Server = net.JoinHostPort(conn.cfg.Server, "6667") } } if conn.cfg.Proxy != "" { proxyURL, err := url.Parse(conn.cfg.Proxy) if err != nil { return err } conn.proxyDialer, err = proxy.FromURL(proxyURL, conn.dialer) if err != nil { return err } logging.Info("irc.Connect(): Connecting to %s.", conn.cfg.Server) if s, err := conn.proxyDialer.Dial("tcp", conn.cfg.Server); err == nil { conn.sock = s } else { return err } } else { logging.Info("irc.Connect(): Connecting to %s.", conn.cfg.Server) if s, err := conn.dialer.Dial("tcp", conn.cfg.Server); err == nil { conn.sock = s } else { return err } } if conn.cfg.SSL { logging.Info("irc.Connect(): Performing SSL handshake.") s := tls.Client(conn.sock, conn.cfg.SSLConfig) if err := s.Handshake(); err != nil { return err } conn.sock = s } conn.postConnect(true) conn.connected = true return nil }
[ "func", "(", "conn", "*", "Conn", ")", "internalConnect", "(", ")", "error", "{", "conn", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "conn", ".", "mu", ".", "Unlock", "(", ")", "\n", "conn", ".", "initialise", "(", ")", "\n\n", "if", "conn"...
// internalConnect handles the work of actually connecting to the server.
[ "internalConnect", "handles", "the", "work", "of", "actually", "connecting", "to", "the", "server", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/connection.go#L315-L372
11,726
fluffle/goirc
client/connection.go
postConnect
func (conn *Conn) postConnect(start bool) { conn.io = bufio.NewReadWriter( bufio.NewReader(conn.sock), bufio.NewWriter(conn.sock)) if start { conn.wg.Add(3) go conn.send() go conn.recv() go conn.runLoop() if conn.cfg.PingFreq > 0 { conn.wg.Add(1) go conn.ping() } } }
go
func (conn *Conn) postConnect(start bool) { conn.io = bufio.NewReadWriter( bufio.NewReader(conn.sock), bufio.NewWriter(conn.sock)) if start { conn.wg.Add(3) go conn.send() go conn.recv() go conn.runLoop() if conn.cfg.PingFreq > 0 { conn.wg.Add(1) go conn.ping() } } }
[ "func", "(", "conn", "*", "Conn", ")", "postConnect", "(", "start", "bool", ")", "{", "conn", ".", "io", "=", "bufio", ".", "NewReadWriter", "(", "bufio", ".", "NewReader", "(", "conn", ".", "sock", ")", ",", "bufio", ".", "NewWriter", "(", "conn", ...
// postConnect performs post-connection setup, for ease of testing.
[ "postConnect", "performs", "post", "-", "connection", "setup", "for", "ease", "of", "testing", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/connection.go#L375-L389
11,727
fluffle/goirc
client/connection.go
recv
func (conn *Conn) recv() { for { s, err := conn.io.ReadString('\n') if err != nil { if err != io.EOF { logging.Error("irc.recv(): %s", err.Error()) } // We can't defer this, because Close() waits for it. conn.wg.Done() conn.Close() return } s = strings.Trim(s, "\r\n") logging.Debug("<- %s", s) if line := ParseLine(s); line != nil { line.Time = time.Now() conn.in <- line } else { logging.Warn("irc.recv(): problems parsing line:\n %s", s) } } }
go
func (conn *Conn) recv() { for { s, err := conn.io.ReadString('\n') if err != nil { if err != io.EOF { logging.Error("irc.recv(): %s", err.Error()) } // We can't defer this, because Close() waits for it. conn.wg.Done() conn.Close() return } s = strings.Trim(s, "\r\n") logging.Debug("<- %s", s) if line := ParseLine(s); line != nil { line.Time = time.Now() conn.in <- line } else { logging.Warn("irc.recv(): problems parsing line:\n %s", s) } } }
[ "func", "(", "conn", "*", "Conn", ")", "recv", "(", ")", "{", "for", "{", "s", ",", "err", ":=", "conn", ".", "io", ".", "ReadString", "(", "'\\n'", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "!=", "io", ".", "EOF", "{", "logging"...
// recv is started as a goroutine after a connection is established. // It receives "\r\n" terminated lines from the server, parses them into // Lines, and sends them to the input channel.
[ "recv", "is", "started", "as", "a", "goroutine", "after", "a", "connection", "is", "established", ".", "It", "receives", "\\", "r", "\\", "n", "terminated", "lines", "from", "the", "server", "parses", "them", "into", "Lines", "and", "sends", "them", "to", ...
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/connection.go#L422-L444
11,728
fluffle/goirc
client/connection.go
ping
func (conn *Conn) ping() { defer conn.wg.Done() tick := time.NewTicker(conn.cfg.PingFreq) for { select { case <-tick.C: conn.Ping(fmt.Sprintf("%d", time.Now().UnixNano())) case <-conn.die: // control channel closed, bail out tick.Stop() return } } }
go
func (conn *Conn) ping() { defer conn.wg.Done() tick := time.NewTicker(conn.cfg.PingFreq) for { select { case <-tick.C: conn.Ping(fmt.Sprintf("%d", time.Now().UnixNano())) case <-conn.die: // control channel closed, bail out tick.Stop() return } } }
[ "func", "(", "conn", "*", "Conn", ")", "ping", "(", ")", "{", "defer", "conn", ".", "wg", ".", "Done", "(", ")", "\n", "tick", ":=", "time", ".", "NewTicker", "(", "conn", ".", "cfg", ".", "PingFreq", ")", "\n", "for", "{", "select", "{", "case...
// ping is started as a goroutine after a connection is established, as // long as Config.PingFreq >0. It pings the server every PingFreq seconds.
[ "ping", "is", "started", "as", "a", "goroutine", "after", "a", "connection", "is", "established", "as", "long", "as", "Config", ".", "PingFreq", ">", "0", ".", "It", "pings", "the", "server", "every", "PingFreq", "seconds", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/connection.go#L448-L461
11,729
fluffle/goirc
client/connection.go
runLoop
func (conn *Conn) runLoop() { defer conn.wg.Done() for { select { case line := <-conn.in: conn.dispatch(line) case <-conn.die: // control channel closed, bail out return } } }
go
func (conn *Conn) runLoop() { defer conn.wg.Done() for { select { case line := <-conn.in: conn.dispatch(line) case <-conn.die: // control channel closed, bail out return } } }
[ "func", "(", "conn", "*", "Conn", ")", "runLoop", "(", ")", "{", "defer", "conn", ".", "wg", ".", "Done", "(", ")", "\n", "for", "{", "select", "{", "case", "line", ":=", "<-", "conn", ".", "in", ":", "conn", ".", "dispatch", "(", "line", ")", ...
// runLoop is started as a goroutine after a connection is established. // It pulls Lines from the input channel and dispatches them to any // handlers that have been registered for that IRC verb.
[ "runLoop", "is", "started", "as", "a", "goroutine", "after", "a", "connection", "is", "established", ".", "It", "pulls", "Lines", "from", "the", "input", "channel", "and", "dispatches", "them", "to", "any", "handlers", "that", "have", "been", "registered", "...
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/connection.go#L466-L477
11,730
fluffle/goirc
client/connection.go
write
func (conn *Conn) write(line string) error { if !conn.cfg.Flood { if t := conn.rateLimit(len(line)); t != 0 { // sleep for the current line's time value before sending it logging.Info("irc.rateLimit(): Flood! Sleeping for %.2f secs.", t.Seconds()) <-time.After(t) } } if _, err := conn.io.WriteString(line + "\r\n"); err != nil { return err } if err := conn.io.Flush(); err != nil { return err } if strings.HasPrefix(line, "PASS") { line = "PASS **************" } logging.Debug("-> %s", line) return nil }
go
func (conn *Conn) write(line string) error { if !conn.cfg.Flood { if t := conn.rateLimit(len(line)); t != 0 { // sleep for the current line's time value before sending it logging.Info("irc.rateLimit(): Flood! Sleeping for %.2f secs.", t.Seconds()) <-time.After(t) } } if _, err := conn.io.WriteString(line + "\r\n"); err != nil { return err } if err := conn.io.Flush(); err != nil { return err } if strings.HasPrefix(line, "PASS") { line = "PASS **************" } logging.Debug("-> %s", line) return nil }
[ "func", "(", "conn", "*", "Conn", ")", "write", "(", "line", "string", ")", "error", "{", "if", "!", "conn", ".", "cfg", ".", "Flood", "{", "if", "t", ":=", "conn", ".", "rateLimit", "(", "len", "(", "line", ")", ")", ";", "t", "!=", "0", "{"...
// write writes a \r\n terminated line of output to the connected server, // using Hybrid's algorithm to rate limit if conn.cfg.Flood is false.
[ "write", "writes", "a", "\\", "r", "\\", "n", "terminated", "line", "of", "output", "to", "the", "connected", "server", "using", "Hybrid", "s", "algorithm", "to", "rate", "limit", "if", "conn", ".", "cfg", ".", "Flood", "is", "false", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/connection.go#L481-L502
11,731
fluffle/goirc
client/connection.go
rateLimit
func (conn *Conn) rateLimit(chars int) time.Duration { // Hybrid's algorithm allows for 2 seconds per line and an additional // 1/120 of a second per character on that line. linetime := 2*time.Second + time.Duration(chars)*time.Second/120 elapsed := time.Now().Sub(conn.lastsent) if conn.badness += linetime - elapsed; conn.badness < 0 { // negative badness times are badness... conn.badness = 0 } conn.lastsent = time.Now() // If we've sent more than 10 second's worth of lines according to the // calculation above, then we're at risk of "Excess Flood". if conn.badness > 10*time.Second { return linetime } return 0 }
go
func (conn *Conn) rateLimit(chars int) time.Duration { // Hybrid's algorithm allows for 2 seconds per line and an additional // 1/120 of a second per character on that line. linetime := 2*time.Second + time.Duration(chars)*time.Second/120 elapsed := time.Now().Sub(conn.lastsent) if conn.badness += linetime - elapsed; conn.badness < 0 { // negative badness times are badness... conn.badness = 0 } conn.lastsent = time.Now() // If we've sent more than 10 second's worth of lines according to the // calculation above, then we're at risk of "Excess Flood". if conn.badness > 10*time.Second { return linetime } return 0 }
[ "func", "(", "conn", "*", "Conn", ")", "rateLimit", "(", "chars", "int", ")", "time", ".", "Duration", "{", "// Hybrid's algorithm allows for 2 seconds per line and an additional", "// 1/120 of a second per character on that line.", "linetime", ":=", "2", "*", "time", "."...
// rateLimit implements Hybrid's flood control algorithm for outgoing lines.
[ "rateLimit", "implements", "Hybrid", "s", "flood", "control", "algorithm", "for", "outgoing", "lines", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/connection.go#L505-L521
11,732
fluffle/goirc
client/connection.go
Close
func (conn *Conn) Close() error { // Guard against double-call of Close() if we get an error in send() // as calling sock.Close() will cause recv() to receive EOF in readstring() conn.mu.Lock() if !conn.connected { conn.mu.Unlock() return nil } logging.Info("irc.Close(): Disconnected from server.") conn.connected = false err := conn.sock.Close() close(conn.die) // Drain both in and out channels to avoid a deadlock if the buffers // have filled. See TestSendDeadlockOnFullBuffer in connection_test.go. conn.drainIn() conn.drainOut() conn.wg.Wait() conn.mu.Unlock() // Dispatch after closing connection but before reinit // so event handlers can still access state information. conn.dispatch(&Line{Cmd: DISCONNECTED, Time: time.Now()}) return err }
go
func (conn *Conn) Close() error { // Guard against double-call of Close() if we get an error in send() // as calling sock.Close() will cause recv() to receive EOF in readstring() conn.mu.Lock() if !conn.connected { conn.mu.Unlock() return nil } logging.Info("irc.Close(): Disconnected from server.") conn.connected = false err := conn.sock.Close() close(conn.die) // Drain both in and out channels to avoid a deadlock if the buffers // have filled. See TestSendDeadlockOnFullBuffer in connection_test.go. conn.drainIn() conn.drainOut() conn.wg.Wait() conn.mu.Unlock() // Dispatch after closing connection but before reinit // so event handlers can still access state information. conn.dispatch(&Line{Cmd: DISCONNECTED, Time: time.Now()}) return err }
[ "func", "(", "conn", "*", "Conn", ")", "Close", "(", ")", "error", "{", "// Guard against double-call of Close() if we get an error in send()", "// as calling sock.Close() will cause recv() to receive EOF in readstring()", "conn", ".", "mu", ".", "Lock", "(", ")", "\n", "if...
// Close tears down all connection-related state. It is called when either // the sending or receiving goroutines encounter an error. // It may also be used to forcibly shut down the connection to the server.
[ "Close", "tears", "down", "all", "connection", "-", "related", "state", ".", "It", "is", "called", "when", "either", "the", "sending", "or", "receiving", "goroutines", "encounter", "an", "error", ".", "It", "may", "also", "be", "used", "to", "forcibly", "s...
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/connection.go#L526-L548
11,733
fluffle/goirc
client/connection.go
String
func (conn *Conn) String() string { str := "GoIRC Connection\n" str += "----------------\n\n" if conn.Connected() { str += "Connected to " + conn.cfg.Server + "\n\n" } else { str += "Not currently connected!\n\n" } str += conn.Me().String() + "\n" if conn.st != nil { str += conn.st.String() + "\n" } return str }
go
func (conn *Conn) String() string { str := "GoIRC Connection\n" str += "----------------\n\n" if conn.Connected() { str += "Connected to " + conn.cfg.Server + "\n\n" } else { str += "Not currently connected!\n\n" } str += conn.Me().String() + "\n" if conn.st != nil { str += conn.st.String() + "\n" } return str }
[ "func", "(", "conn", "*", "Conn", ")", "String", "(", ")", "string", "{", "str", ":=", "\"", "\\n", "\"", "\n", "str", "+=", "\"", "\\n", "\\n", "\"", "\n", "if", "conn", ".", "Connected", "(", ")", "{", "str", "+=", "\"", "\"", "+", "conn", ...
// Dumps a load of information about the current state of the connection to a // string for debugging state tracking and other such things.
[ "Dumps", "a", "load", "of", "information", "about", "the", "current", "state", "of", "the", "connection", "to", "a", "string", "for", "debugging", "state", "tracking", "and", "other", "such", "things", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/connection.go#L574-L587
11,734
fluffle/goirc
client/state_handlers.go
h_STNICK
func (conn *Conn) h_STNICK(line *Line) { // all nicks should be handled the same way, our own included conn.st.ReNick(line.Nick, line.Args[0]) }
go
func (conn *Conn) h_STNICK(line *Line) { // all nicks should be handled the same way, our own included conn.st.ReNick(line.Nick, line.Args[0]) }
[ "func", "(", "conn", "*", "Conn", ")", "h_STNICK", "(", "line", "*", "Line", ")", "{", "// all nicks should be handled the same way, our own included", "conn", ".", "st", ".", "ReNick", "(", "line", ".", "Nick", ",", "line", ".", "Args", "[", "0", "]", ")"...
// Handle NICK messages that need to update the state tracker
[ "Handle", "NICK", "messages", "that", "need", "to", "update", "the", "state", "tracker" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/state_handlers.go#L42-L45
11,735
fluffle/goirc
client/state_handlers.go
h_JOIN
func (conn *Conn) h_JOIN(line *Line) { ch := conn.st.GetChannel(line.Args[0]) nk := conn.st.GetNick(line.Nick) if ch == nil { // first we've seen of this channel, so should be us joining it // NOTE this will also take care of nk == nil && ch == nil if !conn.Me().Equals(nk) { logging.Warn("irc.JOIN(): JOIN to unknown channel %s received "+ "from (non-me) nick %s", line.Args[0], line.Nick) return } conn.st.NewChannel(line.Args[0]) // since we don't know much about this channel, ask server for info // we get the channel users automatically in 353 and the channel // topic in 332 on join, so we just need to get the modes conn.Mode(line.Args[0]) // sending a WHO for the channel is MUCH more efficient than // triggering a WHOIS on every nick from the 353 handler conn.Who(line.Args[0]) } if nk == nil { // this is the first we've seen of this nick conn.st.NewNick(line.Nick) conn.st.NickInfo(line.Nick, line.Ident, line.Host, "") // since we don't know much about this nick, ask server for info conn.Who(line.Nick) } // this takes care of both nick and channel linking \o/ conn.st.Associate(line.Args[0], line.Nick) }
go
func (conn *Conn) h_JOIN(line *Line) { ch := conn.st.GetChannel(line.Args[0]) nk := conn.st.GetNick(line.Nick) if ch == nil { // first we've seen of this channel, so should be us joining it // NOTE this will also take care of nk == nil && ch == nil if !conn.Me().Equals(nk) { logging.Warn("irc.JOIN(): JOIN to unknown channel %s received "+ "from (non-me) nick %s", line.Args[0], line.Nick) return } conn.st.NewChannel(line.Args[0]) // since we don't know much about this channel, ask server for info // we get the channel users automatically in 353 and the channel // topic in 332 on join, so we just need to get the modes conn.Mode(line.Args[0]) // sending a WHO for the channel is MUCH more efficient than // triggering a WHOIS on every nick from the 353 handler conn.Who(line.Args[0]) } if nk == nil { // this is the first we've seen of this nick conn.st.NewNick(line.Nick) conn.st.NickInfo(line.Nick, line.Ident, line.Host, "") // since we don't know much about this nick, ask server for info conn.Who(line.Nick) } // this takes care of both nick and channel linking \o/ conn.st.Associate(line.Args[0], line.Nick) }
[ "func", "(", "conn", "*", "Conn", ")", "h_JOIN", "(", "line", "*", "Line", ")", "{", "ch", ":=", "conn", ".", "st", ".", "GetChannel", "(", "line", ".", "Args", "[", "0", "]", ")", "\n", "nk", ":=", "conn", ".", "st", ".", "GetNick", "(", "li...
// Handle JOINs to channels to maintain state
[ "Handle", "JOINs", "to", "channels", "to", "maintain", "state" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/state_handlers.go#L48-L77
11,736
fluffle/goirc
client/state_handlers.go
h_PART
func (conn *Conn) h_PART(line *Line) { conn.st.Dissociate(line.Args[0], line.Nick) }
go
func (conn *Conn) h_PART(line *Line) { conn.st.Dissociate(line.Args[0], line.Nick) }
[ "func", "(", "conn", "*", "Conn", ")", "h_PART", "(", "line", "*", "Line", ")", "{", "conn", ".", "st", ".", "Dissociate", "(", "line", ".", "Args", "[", "0", "]", ",", "line", ".", "Nick", ")", "\n", "}" ]
// Handle PARTs from channels to maintain state
[ "Handle", "PARTs", "from", "channels", "to", "maintain", "state" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/state_handlers.go#L80-L82
11,737
fluffle/goirc
client/state_handlers.go
h_KICK
func (conn *Conn) h_KICK(line *Line) { if !line.argslen(1) { return } // XXX: this won't handle autorejoining channels on KICK // it's trivial to do this in a seperate handler... conn.st.Dissociate(line.Args[0], line.Args[1]) }
go
func (conn *Conn) h_KICK(line *Line) { if !line.argslen(1) { return } // XXX: this won't handle autorejoining channels on KICK // it's trivial to do this in a seperate handler... conn.st.Dissociate(line.Args[0], line.Args[1]) }
[ "func", "(", "conn", "*", "Conn", ")", "h_KICK", "(", "line", "*", "Line", ")", "{", "if", "!", "line", ".", "argslen", "(", "1", ")", "{", "return", "\n", "}", "\n", "// XXX: this won't handle autorejoining channels on KICK", "// it's trivial to do this in a se...
// Handle KICKs from channels to maintain state
[ "Handle", "KICKs", "from", "channels", "to", "maintain", "state" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/state_handlers.go#L85-L92
11,738
fluffle/goirc
client/state_handlers.go
h_QUIT
func (conn *Conn) h_QUIT(line *Line) { conn.st.DelNick(line.Nick) }
go
func (conn *Conn) h_QUIT(line *Line) { conn.st.DelNick(line.Nick) }
[ "func", "(", "conn", "*", "Conn", ")", "h_QUIT", "(", "line", "*", "Line", ")", "{", "conn", ".", "st", ".", "DelNick", "(", "line", ".", "Nick", ")", "\n", "}" ]
// Handle other people's QUITs
[ "Handle", "other", "people", "s", "QUITs" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/state_handlers.go#L95-L97
11,739
fluffle/goirc
client/state_handlers.go
h_311
func (conn *Conn) h_311(line *Line) { if !line.argslen(5) { return } if nk := conn.st.GetNick(line.Args[1]); (nk != nil) && !conn.Me().Equals(nk) { conn.st.NickInfo(line.Args[1], line.Args[2], line.Args[3], line.Args[5]) } else { logging.Warn("irc.311(): received WHOIS info for unknown nick %s", line.Args[1]) } }
go
func (conn *Conn) h_311(line *Line) { if !line.argslen(5) { return } if nk := conn.st.GetNick(line.Args[1]); (nk != nil) && !conn.Me().Equals(nk) { conn.st.NickInfo(line.Args[1], line.Args[2], line.Args[3], line.Args[5]) } else { logging.Warn("irc.311(): received WHOIS info for unknown nick %s", line.Args[1]) } }
[ "func", "(", "conn", "*", "Conn", ")", "h_311", "(", "line", "*", "Line", ")", "{", "if", "!", "line", ".", "argslen", "(", "5", ")", "{", "return", "\n", "}", "\n", "if", "nk", ":=", "conn", ".", "st", ".", "GetNick", "(", "line", ".", "Args...
// Handle 311 whois reply
[ "Handle", "311", "whois", "reply" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/state_handlers.go#L135-L145
11,740
fluffle/goirc
client/state_handlers.go
h_324
func (conn *Conn) h_324(line *Line) { if !line.argslen(2) { return } if ch := conn.st.GetChannel(line.Args[1]); ch != nil { conn.st.ChannelModes(line.Args[1], line.Args[2], line.Args[3:]...) } else { logging.Warn("irc.324(): received MODE settings for unknown channel %s", line.Args[1]) } }
go
func (conn *Conn) h_324(line *Line) { if !line.argslen(2) { return } if ch := conn.st.GetChannel(line.Args[1]); ch != nil { conn.st.ChannelModes(line.Args[1], line.Args[2], line.Args[3:]...) } else { logging.Warn("irc.324(): received MODE settings for unknown channel %s", line.Args[1]) } }
[ "func", "(", "conn", "*", "Conn", ")", "h_324", "(", "line", "*", "Line", ")", "{", "if", "!", "line", ".", "argslen", "(", "2", ")", "{", "return", "\n", "}", "\n", "if", "ch", ":=", "conn", ".", "st", ".", "GetChannel", "(", "line", ".", "A...
// Handle 324 mode reply
[ "Handle", "324", "mode", "reply" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/state_handlers.go#L148-L158
11,741
fluffle/goirc
client/state_handlers.go
h_332
func (conn *Conn) h_332(line *Line) { if !line.argslen(2) { return } if ch := conn.st.GetChannel(line.Args[1]); ch != nil { conn.st.Topic(line.Args[1], line.Args[2]) } else { logging.Warn("irc.332(): received TOPIC value for unknown channel %s", line.Args[1]) } }
go
func (conn *Conn) h_332(line *Line) { if !line.argslen(2) { return } if ch := conn.st.GetChannel(line.Args[1]); ch != nil { conn.st.Topic(line.Args[1], line.Args[2]) } else { logging.Warn("irc.332(): received TOPIC value for unknown channel %s", line.Args[1]) } }
[ "func", "(", "conn", "*", "Conn", ")", "h_332", "(", "line", "*", "Line", ")", "{", "if", "!", "line", ".", "argslen", "(", "2", ")", "{", "return", "\n", "}", "\n", "if", "ch", ":=", "conn", ".", "st", ".", "GetChannel", "(", "line", ".", "A...
// Handle 332 topic reply on join to channel
[ "Handle", "332", "topic", "reply", "on", "join", "to", "channel" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/state_handlers.go#L161-L171
11,742
fluffle/goirc
client/state_handlers.go
h_352
func (conn *Conn) h_352(line *Line) { if !line.argslen(5) { return } nk := conn.st.GetNick(line.Args[5]) if nk == nil { logging.Warn("irc.352(): received WHO reply for unknown nick %s", line.Args[5]) return } if conn.Me().Equals(nk) { return } // XXX: do we care about the actual server the nick is on? // or the hop count to this server? // last arg contains "<hop count> <real name>" a := strings.SplitN(line.Args[len(line.Args)-1], " ", 2) conn.st.NickInfo(nk.Nick, line.Args[2], line.Args[3], a[1]) if !line.argslen(6) { return } if idx := strings.Index(line.Args[6], "*"); idx != -1 { conn.st.NickModes(nk.Nick, "+o") } if idx := strings.Index(line.Args[6], "B"); idx != -1 { conn.st.NickModes(nk.Nick, "+B") } if idx := strings.Index(line.Args[6], "H"); idx != -1 { conn.st.NickModes(nk.Nick, "+i") } }
go
func (conn *Conn) h_352(line *Line) { if !line.argslen(5) { return } nk := conn.st.GetNick(line.Args[5]) if nk == nil { logging.Warn("irc.352(): received WHO reply for unknown nick %s", line.Args[5]) return } if conn.Me().Equals(nk) { return } // XXX: do we care about the actual server the nick is on? // or the hop count to this server? // last arg contains "<hop count> <real name>" a := strings.SplitN(line.Args[len(line.Args)-1], " ", 2) conn.st.NickInfo(nk.Nick, line.Args[2], line.Args[3], a[1]) if !line.argslen(6) { return } if idx := strings.Index(line.Args[6], "*"); idx != -1 { conn.st.NickModes(nk.Nick, "+o") } if idx := strings.Index(line.Args[6], "B"); idx != -1 { conn.st.NickModes(nk.Nick, "+B") } if idx := strings.Index(line.Args[6], "H"); idx != -1 { conn.st.NickModes(nk.Nick, "+i") } }
[ "func", "(", "conn", "*", "Conn", ")", "h_352", "(", "line", "*", "Line", ")", "{", "if", "!", "line", ".", "argslen", "(", "5", ")", "{", "return", "\n", "}", "\n", "nk", ":=", "conn", ".", "st", ".", "GetNick", "(", "line", ".", "Args", "["...
// Handle 352 who reply
[ "Handle", "352", "who", "reply" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/state_handlers.go#L174-L204
11,743
fluffle/goirc
client/state_handlers.go
h_353
func (conn *Conn) h_353(line *Line) { if !line.argslen(2) { return } if ch := conn.st.GetChannel(line.Args[2]); ch != nil { nicks := strings.Split(line.Args[len(line.Args)-1], " ") for _, nick := range nicks { // UnrealIRCd's coders are lazy and leave a trailing space if nick == "" { continue } switch c := nick[0]; c { case '~', '&', '@', '%', '+': nick = nick[1:] fallthrough default: if conn.st.GetNick(nick) == nil { // we don't know this nick yet! conn.st.NewNick(nick) } if _, ok := conn.st.IsOn(ch.Name, nick); !ok { // This nick isn't associated with this channel yet! conn.st.Associate(ch.Name, nick) } switch c { case '~': conn.st.ChannelModes(ch.Name, "+q", nick) case '&': conn.st.ChannelModes(ch.Name, "+a", nick) case '@': conn.st.ChannelModes(ch.Name, "+o", nick) case '%': conn.st.ChannelModes(ch.Name, "+h", nick) case '+': conn.st.ChannelModes(ch.Name, "+v", nick) } } } } else { logging.Warn("irc.353(): received NAMES list for unknown channel %s", line.Args[2]) } }
go
func (conn *Conn) h_353(line *Line) { if !line.argslen(2) { return } if ch := conn.st.GetChannel(line.Args[2]); ch != nil { nicks := strings.Split(line.Args[len(line.Args)-1], " ") for _, nick := range nicks { // UnrealIRCd's coders are lazy and leave a trailing space if nick == "" { continue } switch c := nick[0]; c { case '~', '&', '@', '%', '+': nick = nick[1:] fallthrough default: if conn.st.GetNick(nick) == nil { // we don't know this nick yet! conn.st.NewNick(nick) } if _, ok := conn.st.IsOn(ch.Name, nick); !ok { // This nick isn't associated with this channel yet! conn.st.Associate(ch.Name, nick) } switch c { case '~': conn.st.ChannelModes(ch.Name, "+q", nick) case '&': conn.st.ChannelModes(ch.Name, "+a", nick) case '@': conn.st.ChannelModes(ch.Name, "+o", nick) case '%': conn.st.ChannelModes(ch.Name, "+h", nick) case '+': conn.st.ChannelModes(ch.Name, "+v", nick) } } } } else { logging.Warn("irc.353(): received NAMES list for unknown channel %s", line.Args[2]) } }
[ "func", "(", "conn", "*", "Conn", ")", "h_353", "(", "line", "*", "Line", ")", "{", "if", "!", "line", ".", "argslen", "(", "2", ")", "{", "return", "\n", "}", "\n", "if", "ch", ":=", "conn", ".", "st", ".", "GetChannel", "(", "line", ".", "A...
// Handle 353 names reply
[ "Handle", "353", "names", "reply" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/state_handlers.go#L207-L249
11,744
fluffle/goirc
state/channel.go
Channel
func (ch *channel) Channel() *Channel { c := &Channel{ Name: ch.name, Topic: ch.topic, Modes: ch.modes.Copy(), Nicks: make(map[string]*ChanPrivs), } for n, cp := range ch.nicks { c.Nicks[n.nick] = cp.Copy() } return c }
go
func (ch *channel) Channel() *Channel { c := &Channel{ Name: ch.name, Topic: ch.topic, Modes: ch.modes.Copy(), Nicks: make(map[string]*ChanPrivs), } for n, cp := range ch.nicks { c.Nicks[n.nick] = cp.Copy() } return c }
[ "func", "(", "ch", "*", "channel", ")", "Channel", "(", ")", "*", "Channel", "{", "c", ":=", "&", "Channel", "{", "Name", ":", "ch", ".", "name", ",", "Topic", ":", "ch", ".", "topic", ",", "Modes", ":", "ch", ".", "modes", ".", "Copy", "(", ...
// Returns a copy of the internal tracker channel state at this time. // Relies on tracker-level locking for concurrent access.
[ "Returns", "a", "copy", "of", "the", "internal", "tracker", "channel", "state", "at", "this", "time", ".", "Relies", "on", "tracker", "-", "level", "locking", "for", "concurrent", "access", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/channel.go#L118-L129
11,745
fluffle/goirc
state/channel.go
addNick
func (ch *channel) addNick(nk *nick, cp *ChanPrivs) { if _, ok := ch.nicks[nk]; !ok { ch.nicks[nk] = cp ch.lookup[nk.nick] = nk } else { logging.Warn("Channel.addNick(): %s already on %s.", nk.nick, ch.name) } }
go
func (ch *channel) addNick(nk *nick, cp *ChanPrivs) { if _, ok := ch.nicks[nk]; !ok { ch.nicks[nk] = cp ch.lookup[nk.nick] = nk } else { logging.Warn("Channel.addNick(): %s already on %s.", nk.nick, ch.name) } }
[ "func", "(", "ch", "*", "channel", ")", "addNick", "(", "nk", "*", "nick", ",", "cp", "*", "ChanPrivs", ")", "{", "if", "_", ",", "ok", ":=", "ch", ".", "nicks", "[", "nk", "]", ";", "!", "ok", "{", "ch", ".", "nicks", "[", "nk", "]", "=", ...
// Associates a Nick with a Channel
[ "Associates", "a", "Nick", "with", "a", "Channel" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/channel.go#L137-L144
11,746
fluffle/goirc
state/channel.go
delNick
func (ch *channel) delNick(nk *nick) { if _, ok := ch.nicks[nk]; ok { delete(ch.nicks, nk) delete(ch.lookup, nk.nick) } else { logging.Warn("Channel.delNick(): %s not on %s.", nk.nick, ch.name) } }
go
func (ch *channel) delNick(nk *nick) { if _, ok := ch.nicks[nk]; ok { delete(ch.nicks, nk) delete(ch.lookup, nk.nick) } else { logging.Warn("Channel.delNick(): %s not on %s.", nk.nick, ch.name) } }
[ "func", "(", "ch", "*", "channel", ")", "delNick", "(", "nk", "*", "nick", ")", "{", "if", "_", ",", "ok", ":=", "ch", ".", "nicks", "[", "nk", "]", ";", "ok", "{", "delete", "(", "ch", ".", "nicks", ",", "nk", ")", "\n", "delete", "(", "ch...
// Disassociates a Nick from a Channel.
[ "Disassociates", "a", "Nick", "from", "a", "Channel", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/channel.go#L147-L154
11,747
fluffle/goirc
state/channel.go
parseModes
func (ch *channel) parseModes(modes string, modeargs ...string) { var modeop bool // true => add mode, false => remove mode var modestr string for i := 0; i < len(modes); i++ { switch m := modes[i]; m { case '+': modeop = true modestr = string(m) case '-': modeop = false modestr = string(m) case 'i': ch.modes.InviteOnly = modeop case 'm': ch.modes.Moderated = modeop case 'n': ch.modes.NoExternalMsg = modeop case 'p': ch.modes.Private = modeop case 'r': ch.modes.Registered = modeop case 's': ch.modes.Secret = modeop case 't': ch.modes.ProtectedTopic = modeop case 'z': ch.modes.SSLOnly = modeop case 'Z': ch.modes.AllSSL = modeop case 'O': ch.modes.OperOnly = modeop case 'k': if modeop && len(modeargs) != 0 { ch.modes.Key, modeargs = modeargs[0], modeargs[1:] } else if !modeop { ch.modes.Key = "" } else { logging.Warn("Channel.ParseModes(): not enough arguments to "+ "process MODE %s %s%c", ch.name, modestr, m) } case 'l': if modeop && len(modeargs) != 0 { ch.modes.Limit, _ = strconv.Atoi(modeargs[0]) modeargs = modeargs[1:] } else if !modeop { ch.modes.Limit = 0 } else { logging.Warn("Channel.ParseModes(): not enough arguments to "+ "process MODE %s %s%c", ch.name, modestr, m) } case 'q', 'a', 'o', 'h', 'v': if len(modeargs) != 0 { if nk, ok := ch.lookup[modeargs[0]]; ok { cp := ch.nicks[nk] switch m { case 'q': cp.Owner = modeop case 'a': cp.Admin = modeop case 'o': cp.Op = modeop case 'h': cp.HalfOp = modeop case 'v': cp.Voice = modeop } modeargs = modeargs[1:] } else { logging.Warn("Channel.ParseModes(): untracked nick %s "+ "received MODE on channel %s", modeargs[0], ch.name) } } else { logging.Warn("Channel.ParseModes(): not enough arguments to "+ "process MODE %s %s%c", ch.name, modestr, m) } default: logging.Info("Channel.ParseModes(): unknown mode char %c", m) } } }
go
func (ch *channel) parseModes(modes string, modeargs ...string) { var modeop bool // true => add mode, false => remove mode var modestr string for i := 0; i < len(modes); i++ { switch m := modes[i]; m { case '+': modeop = true modestr = string(m) case '-': modeop = false modestr = string(m) case 'i': ch.modes.InviteOnly = modeop case 'm': ch.modes.Moderated = modeop case 'n': ch.modes.NoExternalMsg = modeop case 'p': ch.modes.Private = modeop case 'r': ch.modes.Registered = modeop case 's': ch.modes.Secret = modeop case 't': ch.modes.ProtectedTopic = modeop case 'z': ch.modes.SSLOnly = modeop case 'Z': ch.modes.AllSSL = modeop case 'O': ch.modes.OperOnly = modeop case 'k': if modeop && len(modeargs) != 0 { ch.modes.Key, modeargs = modeargs[0], modeargs[1:] } else if !modeop { ch.modes.Key = "" } else { logging.Warn("Channel.ParseModes(): not enough arguments to "+ "process MODE %s %s%c", ch.name, modestr, m) } case 'l': if modeop && len(modeargs) != 0 { ch.modes.Limit, _ = strconv.Atoi(modeargs[0]) modeargs = modeargs[1:] } else if !modeop { ch.modes.Limit = 0 } else { logging.Warn("Channel.ParseModes(): not enough arguments to "+ "process MODE %s %s%c", ch.name, modestr, m) } case 'q', 'a', 'o', 'h', 'v': if len(modeargs) != 0 { if nk, ok := ch.lookup[modeargs[0]]; ok { cp := ch.nicks[nk] switch m { case 'q': cp.Owner = modeop case 'a': cp.Admin = modeop case 'o': cp.Op = modeop case 'h': cp.HalfOp = modeop case 'v': cp.Voice = modeop } modeargs = modeargs[1:] } else { logging.Warn("Channel.ParseModes(): untracked nick %s "+ "received MODE on channel %s", modeargs[0], ch.name) } } else { logging.Warn("Channel.ParseModes(): not enough arguments to "+ "process MODE %s %s%c", ch.name, modestr, m) } default: logging.Info("Channel.ParseModes(): unknown mode char %c", m) } } }
[ "func", "(", "ch", "*", "channel", ")", "parseModes", "(", "modes", "string", ",", "modeargs", "...", "string", ")", "{", "var", "modeop", "bool", "// true => add mode, false => remove mode", "\n", "var", "modestr", "string", "\n", "for", "i", ":=", "0", ";"...
// Parses mode strings for a channel.
[ "Parses", "mode", "strings", "for", "a", "channel", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/channel.go#L157-L236
11,748
fluffle/goirc
state/channel.go
IsOn
func (ch *Channel) IsOn(nk string) (*ChanPrivs, bool) { cp, ok := ch.Nicks[nk] return cp, ok }
go
func (ch *Channel) IsOn(nk string) (*ChanPrivs, bool) { cp, ok := ch.Nicks[nk] return cp, ok }
[ "func", "(", "ch", "*", "Channel", ")", "IsOn", "(", "nk", "string", ")", "(", "*", "ChanPrivs", ",", "bool", ")", "{", "cp", ",", "ok", ":=", "ch", ".", "Nicks", "[", "nk", "]", "\n", "return", "cp", ",", "ok", "\n", "}" ]
// Returns true if the Nick is associated with the Channel
[ "Returns", "true", "if", "the", "Nick", "is", "associated", "with", "the", "Channel" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/channel.go#L239-L242
11,749
fluffle/goirc
state/channel.go
Equals
func (ch *Channel) Equals(other *Channel) bool { return reflect.DeepEqual(ch, other) }
go
func (ch *Channel) Equals(other *Channel) bool { return reflect.DeepEqual(ch, other) }
[ "func", "(", "ch", "*", "Channel", ")", "Equals", "(", "other", "*", "Channel", ")", "bool", "{", "return", "reflect", ".", "DeepEqual", "(", "ch", ",", "other", ")", "\n", "}" ]
// Test Channel equality.
[ "Test", "Channel", "equality", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/channel.go#L245-L247
11,750
fluffle/goirc
state/channel.go
Copy
func (cm *ChanMode) Copy() *ChanMode { if cm == nil { return nil } c := *cm return &c }
go
func (cm *ChanMode) Copy() *ChanMode { if cm == nil { return nil } c := *cm return &c }
[ "func", "(", "cm", "*", "ChanMode", ")", "Copy", "(", ")", "*", "ChanMode", "{", "if", "cm", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "c", ":=", "*", "cm", "\n", "return", "&", "c", "\n", "}" ]
// Duplicates a ChanMode struct.
[ "Duplicates", "a", "ChanMode", "struct", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/channel.go#L250-L256
11,751
fluffle/goirc
state/channel.go
Equals
func (cm *ChanMode) Equals(other *ChanMode) bool { return reflect.DeepEqual(cm, other) }
go
func (cm *ChanMode) Equals(other *ChanMode) bool { return reflect.DeepEqual(cm, other) }
[ "func", "(", "cm", "*", "ChanMode", ")", "Equals", "(", "other", "*", "ChanMode", ")", "bool", "{", "return", "reflect", ".", "DeepEqual", "(", "cm", ",", "other", ")", "\n", "}" ]
// Test ChanMode equality.
[ "Test", "ChanMode", "equality", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/channel.go#L259-L261
11,752
fluffle/goirc
state/channel.go
Copy
func (cp *ChanPrivs) Copy() *ChanPrivs { if cp == nil { return nil } c := *cp return &c }
go
func (cp *ChanPrivs) Copy() *ChanPrivs { if cp == nil { return nil } c := *cp return &c }
[ "func", "(", "cp", "*", "ChanPrivs", ")", "Copy", "(", ")", "*", "ChanPrivs", "{", "if", "cp", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "c", ":=", "*", "cp", "\n", "return", "&", "c", "\n", "}" ]
// Duplicates a ChanPrivs struct.
[ "Duplicates", "a", "ChanPrivs", "struct", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/channel.go#L264-L270
11,753
fluffle/goirc
state/channel.go
Equals
func (cp *ChanPrivs) Equals(other *ChanPrivs) bool { return reflect.DeepEqual(cp, other) }
go
func (cp *ChanPrivs) Equals(other *ChanPrivs) bool { return reflect.DeepEqual(cp, other) }
[ "func", "(", "cp", "*", "ChanPrivs", ")", "Equals", "(", "other", "*", "ChanPrivs", ")", "bool", "{", "return", "reflect", ".", "DeepEqual", "(", "cp", ",", "other", ")", "\n", "}" ]
// Test ChanPrivs equality.
[ "Test", "ChanPrivs", "equality", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/channel.go#L273-L275
11,754
fluffle/goirc
state/nick.go
Nick
func (nk *nick) Nick() *Nick { n := &Nick{ Nick: nk.nick, Ident: nk.ident, Host: nk.host, Name: nk.name, Modes: nk.modes.Copy(), Channels: make(map[string]*ChanPrivs), } for c, cp := range nk.chans { n.Channels[c.name] = cp.Copy() } return n }
go
func (nk *nick) Nick() *Nick { n := &Nick{ Nick: nk.nick, Ident: nk.ident, Host: nk.host, Name: nk.name, Modes: nk.modes.Copy(), Channels: make(map[string]*ChanPrivs), } for c, cp := range nk.chans { n.Channels[c.name] = cp.Copy() } return n }
[ "func", "(", "nk", "*", "nick", ")", "Nick", "(", ")", "*", "Nick", "{", "n", ":=", "&", "Nick", "{", "Nick", ":", "nk", ".", "nick", ",", "Ident", ":", "nk", ".", "ident", ",", "Host", ":", "nk", ".", "host", ",", "Name", ":", "nk", ".", ...
// Returns a copy of the internal tracker nick state at this time. // Relies on tracker-level locking for concurrent access.
[ "Returns", "a", "copy", "of", "the", "internal", "tracker", "nick", "state", "at", "this", "time", ".", "Relies", "on", "tracker", "-", "level", "locking", "for", "concurrent", "access", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/nick.go#L67-L80
11,755
fluffle/goirc
state/nick.go
addChannel
func (nk *nick) addChannel(ch *channel, cp *ChanPrivs) { if _, ok := nk.chans[ch]; !ok { nk.chans[ch] = cp nk.lookup[ch.name] = ch } else { logging.Warn("Nick.addChannel(): %s already on %s.", nk.nick, ch.name) } }
go
func (nk *nick) addChannel(ch *channel, cp *ChanPrivs) { if _, ok := nk.chans[ch]; !ok { nk.chans[ch] = cp nk.lookup[ch.name] = ch } else { logging.Warn("Nick.addChannel(): %s already on %s.", nk.nick, ch.name) } }
[ "func", "(", "nk", "*", "nick", ")", "addChannel", "(", "ch", "*", "channel", ",", "cp", "*", "ChanPrivs", ")", "{", "if", "_", ",", "ok", ":=", "nk", ".", "chans", "[", "ch", "]", ";", "!", "ok", "{", "nk", ".", "chans", "[", "ch", "]", "=...
// Associates a Channel with a Nick.
[ "Associates", "a", "Channel", "with", "a", "Nick", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/nick.go#L88-L95
11,756
fluffle/goirc
state/nick.go
delChannel
func (nk *nick) delChannel(ch *channel) { if _, ok := nk.chans[ch]; ok { delete(nk.chans, ch) delete(nk.lookup, ch.name) } else { logging.Warn("Nick.delChannel(): %s not on %s.", nk.nick, ch.name) } }
go
func (nk *nick) delChannel(ch *channel) { if _, ok := nk.chans[ch]; ok { delete(nk.chans, ch) delete(nk.lookup, ch.name) } else { logging.Warn("Nick.delChannel(): %s not on %s.", nk.nick, ch.name) } }
[ "func", "(", "nk", "*", "nick", ")", "delChannel", "(", "ch", "*", "channel", ")", "{", "if", "_", ",", "ok", ":=", "nk", ".", "chans", "[", "ch", "]", ";", "ok", "{", "delete", "(", "nk", ".", "chans", ",", "ch", ")", "\n", "delete", "(", ...
// Disassociates a Channel from a Nick.
[ "Disassociates", "a", "Channel", "from", "a", "Nick", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/nick.go#L98-L105
11,757
fluffle/goirc
state/nick.go
parseModes
func (nk *nick) parseModes(modes string) { var modeop bool // true => add mode, false => remove mode for i := 0; i < len(modes); i++ { switch m := modes[i]; m { case '+': modeop = true case '-': modeop = false case 'B': nk.modes.Bot = modeop case 'i': nk.modes.Invisible = modeop case 'o': nk.modes.Oper = modeop case 'w': nk.modes.WallOps = modeop case 'x': nk.modes.HiddenHost = modeop case 'z': nk.modes.SSL = modeop default: logging.Info("Nick.ParseModes(): unknown mode char %c", m) } } }
go
func (nk *nick) parseModes(modes string) { var modeop bool // true => add mode, false => remove mode for i := 0; i < len(modes); i++ { switch m := modes[i]; m { case '+': modeop = true case '-': modeop = false case 'B': nk.modes.Bot = modeop case 'i': nk.modes.Invisible = modeop case 'o': nk.modes.Oper = modeop case 'w': nk.modes.WallOps = modeop case 'x': nk.modes.HiddenHost = modeop case 'z': nk.modes.SSL = modeop default: logging.Info("Nick.ParseModes(): unknown mode char %c", m) } } }
[ "func", "(", "nk", "*", "nick", ")", "parseModes", "(", "modes", "string", ")", "{", "var", "modeop", "bool", "// true => add mode, false => remove mode", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "modes", ")", ";", "i", "++", "{", "switc...
// Parse mode strings for a Nick.
[ "Parse", "mode", "strings", "for", "a", "Nick", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/nick.go#L108-L132
11,758
fluffle/goirc
state/nick.go
IsOn
func (nk *Nick) IsOn(ch string) (*ChanPrivs, bool) { cp, ok := nk.Channels[ch] return cp, ok }
go
func (nk *Nick) IsOn(ch string) (*ChanPrivs, bool) { cp, ok := nk.Channels[ch] return cp, ok }
[ "func", "(", "nk", "*", "Nick", ")", "IsOn", "(", "ch", "string", ")", "(", "*", "ChanPrivs", ",", "bool", ")", "{", "cp", ",", "ok", ":=", "nk", ".", "Channels", "[", "ch", "]", "\n", "return", "cp", ",", "ok", "\n", "}" ]
// Returns true if the Nick is associated with the Channel.
[ "Returns", "true", "if", "the", "Nick", "is", "associated", "with", "the", "Channel", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/nick.go#L135-L138
11,759
fluffle/goirc
state/nick.go
Equals
func (nk *Nick) Equals(other *Nick) bool { return reflect.DeepEqual(nk, other) }
go
func (nk *Nick) Equals(other *Nick) bool { return reflect.DeepEqual(nk, other) }
[ "func", "(", "nk", "*", "Nick", ")", "Equals", "(", "other", "*", "Nick", ")", "bool", "{", "return", "reflect", ".", "DeepEqual", "(", "nk", ",", "other", ")", "\n", "}" ]
// Tests Nick equality.
[ "Tests", "Nick", "equality", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/nick.go#L141-L143
11,760
fluffle/goirc
state/nick.go
Copy
func (nm *NickMode) Copy() *NickMode { if nm == nil { return nil } n := *nm return &n }
go
func (nm *NickMode) Copy() *NickMode { if nm == nil { return nil } n := *nm return &n }
[ "func", "(", "nm", "*", "NickMode", ")", "Copy", "(", ")", "*", "NickMode", "{", "if", "nm", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "n", ":=", "*", "nm", "\n", "return", "&", "n", "\n", "}" ]
// Duplicates a NickMode struct.
[ "Duplicates", "a", "NickMode", "struct", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/nick.go#L146-L152
11,761
fluffle/goirc
state/nick.go
Equals
func (nm *NickMode) Equals(other *NickMode) bool { return reflect.DeepEqual(nm, other) }
go
func (nm *NickMode) Equals(other *NickMode) bool { return reflect.DeepEqual(nm, other) }
[ "func", "(", "nm", "*", "NickMode", ")", "Equals", "(", "other", "*", "NickMode", ")", "bool", "{", "return", "reflect", ".", "DeepEqual", "(", "nm", ",", "other", ")", "\n", "}" ]
// Tests NickMode equality.
[ "Tests", "NickMode", "equality", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/nick.go#L155-L157
11,762
fluffle/goirc
client/line.go
Copy
func (l *Line) Copy() *Line { nl := *l nl.Args = make([]string, len(l.Args)) copy(nl.Args, l.Args) if l.Tags != nil { nl.Tags = make(map[string]string) for k, v := range l.Tags { nl.Tags[k] = v } } return &nl }
go
func (l *Line) Copy() *Line { nl := *l nl.Args = make([]string, len(l.Args)) copy(nl.Args, l.Args) if l.Tags != nil { nl.Tags = make(map[string]string) for k, v := range l.Tags { nl.Tags[k] = v } } return &nl }
[ "func", "(", "l", "*", "Line", ")", "Copy", "(", ")", "*", "Line", "{", "nl", ":=", "*", "l", "\n", "nl", ".", "Args", "=", "make", "(", "[", "]", "string", ",", "len", "(", "l", ".", "Args", ")", ")", "\n", "copy", "(", "nl", ".", "Args"...
// Copy returns a deep copy of the Line.
[ "Copy", "returns", "a", "deep", "copy", "of", "the", "Line", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/line.go#L28-L39
11,763
fluffle/goirc
client/line.go
Target
func (line *Line) Target() string { // TODO(fluffle): Add 005 CHANTYPES parsing for this? switch line.Cmd { case PRIVMSG, NOTICE, ACTION: if !line.Public() { return line.Nick } case CTCP, CTCPREPLY: if !line.Public() { return line.Nick } return line.Args[1] } if len(line.Args) > 0 { return line.Args[0] } return "" }
go
func (line *Line) Target() string { // TODO(fluffle): Add 005 CHANTYPES parsing for this? switch line.Cmd { case PRIVMSG, NOTICE, ACTION: if !line.Public() { return line.Nick } case CTCP, CTCPREPLY: if !line.Public() { return line.Nick } return line.Args[1] } if len(line.Args) > 0 { return line.Args[0] } return "" }
[ "func", "(", "line", "*", "Line", ")", "Target", "(", ")", "string", "{", "// TODO(fluffle): Add 005 CHANTYPES parsing for this?", "switch", "line", ".", "Cmd", "{", "case", "PRIVMSG", ",", "NOTICE", ",", "ACTION", ":", "if", "!", "line", ".", "Public", "(",...
// Target returns the contextual target of the line, usually the first Arg // for the IRC verb. If the line was broadcast from a channel, the target // will be that channel. If the line was sent directly by a user, the target // will be that user.
[ "Target", "returns", "the", "contextual", "target", "of", "the", "line", "usually", "the", "first", "Arg", "for", "the", "IRC", "verb", ".", "If", "the", "line", "was", "broadcast", "from", "a", "channel", "the", "target", "will", "be", "that", "channel", ...
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/line.go#L54-L71
11,764
fluffle/goirc
state/tracker.go
NewTracker
func NewTracker(mynick string) *stateTracker { st := &stateTracker{ chans: make(map[string]*channel), nicks: make(map[string]*nick), } st.me = newNick(mynick) st.nicks[mynick] = st.me return st }
go
func NewTracker(mynick string) *stateTracker { st := &stateTracker{ chans: make(map[string]*channel), nicks: make(map[string]*nick), } st.me = newNick(mynick) st.nicks[mynick] = st.me return st }
[ "func", "NewTracker", "(", "mynick", "string", ")", "*", "stateTracker", "{", "st", ":=", "&", "stateTracker", "{", "chans", ":", "make", "(", "map", "[", "string", "]", "*", "channel", ")", ",", "nicks", ":", "make", "(", "map", "[", "string", "]", ...
// ... and a constructor to make it ...
[ "...", "and", "a", "constructor", "to", "make", "it", "..." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/tracker.go#L52-L60
11,765
fluffle/goirc
state/tracker.go
Wipe
func (st *stateTracker) Wipe() { st.mu.Lock() defer st.mu.Unlock() // Deleting all the channels implicitly deletes every nick but me. for _, ch := range st.chans { st.delChannel(ch) } }
go
func (st *stateTracker) Wipe() { st.mu.Lock() defer st.mu.Unlock() // Deleting all the channels implicitly deletes every nick but me. for _, ch := range st.chans { st.delChannel(ch) } }
[ "func", "(", "st", "*", "stateTracker", ")", "Wipe", "(", ")", "{", "st", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "st", ".", "mu", ".", "Unlock", "(", ")", "\n", "// Deleting all the channels implicitly deletes every nick but me.", "for", "_", ","...
// ... and a method to wipe the state clean.
[ "...", "and", "a", "method", "to", "wipe", "the", "state", "clean", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/tracker.go#L63-L70
11,766
fluffle/goirc
state/tracker.go
GetNick
func (st *stateTracker) GetNick(n string) *Nick { st.mu.Lock() defer st.mu.Unlock() if nk, ok := st.nicks[n]; ok { return nk.Nick() } return nil }
go
func (st *stateTracker) GetNick(n string) *Nick { st.mu.Lock() defer st.mu.Unlock() if nk, ok := st.nicks[n]; ok { return nk.Nick() } return nil }
[ "func", "(", "st", "*", "stateTracker", ")", "GetNick", "(", "n", "string", ")", "*", "Nick", "{", "st", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "st", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "nk", ",", "ok", ":=", "st", ".", ...
// Returns a nick for the nick n, if we're tracking it.
[ "Returns", "a", "nick", "for", "the", "nick", "n", "if", "we", "re", "tracking", "it", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/tracker.go#L94-L101
11,767
fluffle/goirc
state/tracker.go
ReNick
func (st *stateTracker) ReNick(old, neu string) *Nick { st.mu.Lock() defer st.mu.Unlock() nk, ok := st.nicks[old] if !ok { logging.Warn("Tracker.ReNick(): %s not tracked.", old) return nil } if _, ok := st.nicks[neu]; ok { logging.Warn("Tracker.ReNick(): %s already exists.", neu) return nil } nk.nick = neu delete(st.nicks, old) st.nicks[neu] = nk for ch, _ := range nk.chans { // We also need to update the lookup maps of all the channels // the nick is on, to keep things in sync. delete(ch.lookup, old) ch.lookup[neu] = nk } return nk.Nick() }
go
func (st *stateTracker) ReNick(old, neu string) *Nick { st.mu.Lock() defer st.mu.Unlock() nk, ok := st.nicks[old] if !ok { logging.Warn("Tracker.ReNick(): %s not tracked.", old) return nil } if _, ok := st.nicks[neu]; ok { logging.Warn("Tracker.ReNick(): %s already exists.", neu) return nil } nk.nick = neu delete(st.nicks, old) st.nicks[neu] = nk for ch, _ := range nk.chans { // We also need to update the lookup maps of all the channels // the nick is on, to keep things in sync. delete(ch.lookup, old) ch.lookup[neu] = nk } return nk.Nick() }
[ "func", "(", "st", "*", "stateTracker", ")", "ReNick", "(", "old", ",", "neu", "string", ")", "*", "Nick", "{", "st", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "st", ".", "mu", ".", "Unlock", "(", ")", "\n", "nk", ",", "ok", ":=", "st"...
// Signals to the tracker that a nick should be tracked // under a "neu" nick rather than the old one.
[ "Signals", "to", "the", "tracker", "that", "a", "nick", "should", "be", "tracked", "under", "a", "neu", "nick", "rather", "than", "the", "old", "one", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/tracker.go#L105-L128
11,768
fluffle/goirc
state/tracker.go
DelNick
func (st *stateTracker) DelNick(n string) *Nick { st.mu.Lock() defer st.mu.Unlock() if nk, ok := st.nicks[n]; ok { if nk == st.me { logging.Warn("Tracker.DelNick(): won't delete myself.") return nil } st.delNick(nk) return nk.Nick() } logging.Warn("Tracker.DelNick(): %s not tracked.", n) return nil }
go
func (st *stateTracker) DelNick(n string) *Nick { st.mu.Lock() defer st.mu.Unlock() if nk, ok := st.nicks[n]; ok { if nk == st.me { logging.Warn("Tracker.DelNick(): won't delete myself.") return nil } st.delNick(nk) return nk.Nick() } logging.Warn("Tracker.DelNick(): %s not tracked.", n) return nil }
[ "func", "(", "st", "*", "stateTracker", ")", "DelNick", "(", "n", "string", ")", "*", "Nick", "{", "st", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "st", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "nk", ",", "ok", ":=", "st", ".", ...
// Removes a nick from being tracked.
[ "Removes", "a", "nick", "from", "being", "tracked", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/tracker.go#L131-L144
11,769
fluffle/goirc
state/tracker.go
NickInfo
func (st *stateTracker) NickInfo(n, ident, host, name string) *Nick { st.mu.Lock() defer st.mu.Unlock() nk, ok := st.nicks[n] if !ok { return nil } nk.ident = ident nk.host = host nk.name = name return nk.Nick() }
go
func (st *stateTracker) NickInfo(n, ident, host, name string) *Nick { st.mu.Lock() defer st.mu.Unlock() nk, ok := st.nicks[n] if !ok { return nil } nk.ident = ident nk.host = host nk.name = name return nk.Nick() }
[ "func", "(", "st", "*", "stateTracker", ")", "NickInfo", "(", "n", ",", "ident", ",", "host", ",", "name", "string", ")", "*", "Nick", "{", "st", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "st", ".", "mu", ".", "Unlock", "(", ")", "\n", ...
// Sets ident, host and "real" name for the nick.
[ "Sets", "ident", "host", "and", "real", "name", "for", "the", "nick", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/tracker.go#L167-L178
11,770
fluffle/goirc
state/tracker.go
NickModes
func (st *stateTracker) NickModes(n, modes string) *Nick { st.mu.Lock() defer st.mu.Unlock() nk, ok := st.nicks[n] if !ok { return nil } nk.parseModes(modes) return nk.Nick() }
go
func (st *stateTracker) NickModes(n, modes string) *Nick { st.mu.Lock() defer st.mu.Unlock() nk, ok := st.nicks[n] if !ok { return nil } nk.parseModes(modes) return nk.Nick() }
[ "func", "(", "st", "*", "stateTracker", ")", "NickModes", "(", "n", ",", "modes", "string", ")", "*", "Nick", "{", "st", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "st", ".", "mu", ".", "Unlock", "(", ")", "\n", "nk", ",", "ok", ":=", "...
// Sets user modes for the nick.
[ "Sets", "user", "modes", "for", "the", "nick", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/tracker.go#L181-L190
11,771
fluffle/goirc
state/tracker.go
NewChannel
func (st *stateTracker) NewChannel(c string) *Channel { if c == "" { logging.Warn("Tracker.NewChannel(): Not tracking empty channel.") return nil } st.mu.Lock() defer st.mu.Unlock() if _, ok := st.chans[c]; ok { logging.Warn("Tracker.NewChannel(): %s already tracked.", c) return nil } st.chans[c] = newChannel(c) return st.chans[c].Channel() }
go
func (st *stateTracker) NewChannel(c string) *Channel { if c == "" { logging.Warn("Tracker.NewChannel(): Not tracking empty channel.") return nil } st.mu.Lock() defer st.mu.Unlock() if _, ok := st.chans[c]; ok { logging.Warn("Tracker.NewChannel(): %s already tracked.", c) return nil } st.chans[c] = newChannel(c) return st.chans[c].Channel() }
[ "func", "(", "st", "*", "stateTracker", ")", "NewChannel", "(", "c", "string", ")", "*", "Channel", "{", "if", "c", "==", "\"", "\"", "{", "logging", ".", "Warn", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}", "\n", "st", ".", "mu", "....
// Creates a new Channel, initialises it, and stores it so it // can be properly tracked for state management purposes.
[ "Creates", "a", "new", "Channel", "initialises", "it", "and", "stores", "it", "so", "it", "can", "be", "properly", "tracked", "for", "state", "management", "purposes", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/tracker.go#L194-L207
11,772
fluffle/goirc
state/tracker.go
DelChannel
func (st *stateTracker) DelChannel(c string) *Channel { st.mu.Lock() defer st.mu.Unlock() if ch, ok := st.chans[c]; ok { st.delChannel(ch) return ch.Channel() } logging.Warn("Tracker.DelChannel(): %s not tracked.", c) return nil }
go
func (st *stateTracker) DelChannel(c string) *Channel { st.mu.Lock() defer st.mu.Unlock() if ch, ok := st.chans[c]; ok { st.delChannel(ch) return ch.Channel() } logging.Warn("Tracker.DelChannel(): %s not tracked.", c) return nil }
[ "func", "(", "st", "*", "stateTracker", ")", "DelChannel", "(", "c", "string", ")", "*", "Channel", "{", "st", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "st", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "ch", ",", "ok", ":=", "st", ...
// Removes a Channel from being tracked.
[ "Removes", "a", "Channel", "from", "being", "tracked", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/tracker.go#L220-L229
11,773
fluffle/goirc
state/tracker.go
Topic
func (st *stateTracker) Topic(c, topic string) *Channel { st.mu.Lock() defer st.mu.Unlock() ch, ok := st.chans[c] if !ok { return nil } ch.topic = topic return ch.Channel() }
go
func (st *stateTracker) Topic(c, topic string) *Channel { st.mu.Lock() defer st.mu.Unlock() ch, ok := st.chans[c] if !ok { return nil } ch.topic = topic return ch.Channel() }
[ "func", "(", "st", "*", "stateTracker", ")", "Topic", "(", "c", ",", "topic", "string", ")", "*", "Channel", "{", "st", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "st", ".", "mu", ".", "Unlock", "(", ")", "\n", "ch", ",", "ok", ":=", "s...
// Sets the topic of a channel.
[ "Sets", "the", "topic", "of", "a", "channel", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/tracker.go#L245-L254
11,774
fluffle/goirc
state/tracker.go
ChannelModes
func (st *stateTracker) ChannelModes(c, modes string, args ...string) *Channel { st.mu.Lock() defer st.mu.Unlock() ch, ok := st.chans[c] if !ok { return nil } ch.parseModes(modes, args...) return ch.Channel() }
go
func (st *stateTracker) ChannelModes(c, modes string, args ...string) *Channel { st.mu.Lock() defer st.mu.Unlock() ch, ok := st.chans[c] if !ok { return nil } ch.parseModes(modes, args...) return ch.Channel() }
[ "func", "(", "st", "*", "stateTracker", ")", "ChannelModes", "(", "c", ",", "modes", "string", ",", "args", "...", "string", ")", "*", "Channel", "{", "st", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "st", ".", "mu", ".", "Unlock", "(", ")"...
// Sets modes for a channel, including privileges like +o.
[ "Sets", "modes", "for", "a", "channel", "including", "privileges", "like", "+", "o", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/tracker.go#L257-L266
11,775
fluffle/goirc
state/tracker.go
IsOn
func (st *stateTracker) IsOn(c, n string) (*ChanPrivs, bool) { st.mu.Lock() defer st.mu.Unlock() nk, nok := st.nicks[n] ch, cok := st.chans[c] if nok && cok { return nk.isOn(ch) } return nil, false }
go
func (st *stateTracker) IsOn(c, n string) (*ChanPrivs, bool) { st.mu.Lock() defer st.mu.Unlock() nk, nok := st.nicks[n] ch, cok := st.chans[c] if nok && cok { return nk.isOn(ch) } return nil, false }
[ "func", "(", "st", "*", "stateTracker", ")", "IsOn", "(", "c", ",", "n", "string", ")", "(", "*", "ChanPrivs", ",", "bool", ")", "{", "st", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "st", ".", "mu", ".", "Unlock", "(", ")", "\n", "nk",...
// Returns true if both the channel c and the nick n are tracked // and the nick is associated with the channel.
[ "Returns", "true", "if", "both", "the", "channel", "c", "and", "the", "nick", "n", "are", "tracked", "and", "the", "nick", "is", "associated", "with", "the", "channel", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/tracker.go#L278-L287
11,776
fluffle/goirc
state/tracker.go
Associate
func (st *stateTracker) Associate(c, n string) *ChanPrivs { st.mu.Lock() defer st.mu.Unlock() nk, nok := st.nicks[n] ch, cok := st.chans[c] if !cok { // As we can implicitly delete both nicks and channels from being // tracked by dissociating one from the other, we should verify that // we're not being passed an old Nick or Channel. logging.Error("Tracker.Associate(): channel %s not found in "+ "internal state.", c) return nil } else if !nok { logging.Error("Tracker.Associate(): nick %s not found in "+ "internal state.", n) return nil } else if _, ok := nk.isOn(ch); ok { logging.Warn("Tracker.Associate(): %s already on %s.", nk, ch) return nil } cp := new(ChanPrivs) ch.addNick(nk, cp) nk.addChannel(ch, cp) return cp.Copy() }
go
func (st *stateTracker) Associate(c, n string) *ChanPrivs { st.mu.Lock() defer st.mu.Unlock() nk, nok := st.nicks[n] ch, cok := st.chans[c] if !cok { // As we can implicitly delete both nicks and channels from being // tracked by dissociating one from the other, we should verify that // we're not being passed an old Nick or Channel. logging.Error("Tracker.Associate(): channel %s not found in "+ "internal state.", c) return nil } else if !nok { logging.Error("Tracker.Associate(): nick %s not found in "+ "internal state.", n) return nil } else if _, ok := nk.isOn(ch); ok { logging.Warn("Tracker.Associate(): %s already on %s.", nk, ch) return nil } cp := new(ChanPrivs) ch.addNick(nk, cp) nk.addChannel(ch, cp) return cp.Copy() }
[ "func", "(", "st", "*", "stateTracker", ")", "Associate", "(", "c", ",", "n", "string", ")", "*", "ChanPrivs", "{", "st", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "st", ".", "mu", ".", "Unlock", "(", ")", "\n", "nk", ",", "nok", ":=", ...
// Associates an already known nick with an already known channel.
[ "Associates", "an", "already", "known", "nick", "with", "an", "already", "known", "channel", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/tracker.go#L290-L316
11,777
fluffle/goirc
state/tracker.go
Dissociate
func (st *stateTracker) Dissociate(c, n string) { st.mu.Lock() defer st.mu.Unlock() nk, nok := st.nicks[n] ch, cok := st.chans[c] if !cok { // As we can implicitly delete both nicks and channels from being // tracked by dissociating one from the other, we should verify that // we're not being passed an old Nick or Channel. logging.Error("Tracker.Dissociate(): channel %s not found in "+ "internal state.", c) } else if !nok { logging.Error("Tracker.Dissociate(): nick %s not found in "+ "internal state.", n) } else if _, ok := nk.isOn(ch); !ok { logging.Warn("Tracker.Dissociate(): %s not on %s.", nk.nick, ch.name) } else if nk == st.me { // I'm leaving the channel for some reason, so it won't be tracked. st.delChannel(ch) } else { // Remove the nick from the channel and the channel from the nick. ch.delNick(nk) nk.delChannel(ch) if len(nk.chans) == 0 { // We're no longer in any channels with this nick. st.delNick(nk) } } }
go
func (st *stateTracker) Dissociate(c, n string) { st.mu.Lock() defer st.mu.Unlock() nk, nok := st.nicks[n] ch, cok := st.chans[c] if !cok { // As we can implicitly delete both nicks and channels from being // tracked by dissociating one from the other, we should verify that // we're not being passed an old Nick or Channel. logging.Error("Tracker.Dissociate(): channel %s not found in "+ "internal state.", c) } else if !nok { logging.Error("Tracker.Dissociate(): nick %s not found in "+ "internal state.", n) } else if _, ok := nk.isOn(ch); !ok { logging.Warn("Tracker.Dissociate(): %s not on %s.", nk.nick, ch.name) } else if nk == st.me { // I'm leaving the channel for some reason, so it won't be tracked. st.delChannel(ch) } else { // Remove the nick from the channel and the channel from the nick. ch.delNick(nk) nk.delChannel(ch) if len(nk.chans) == 0 { // We're no longer in any channels with this nick. st.delNick(nk) } } }
[ "func", "(", "st", "*", "stateTracker", ")", "Dissociate", "(", "c", ",", "n", "string", ")", "{", "st", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "st", ".", "mu", ".", "Unlock", "(", ")", "\n", "nk", ",", "nok", ":=", "st", ".", "nick...
// Dissociates an already known nick from an already known channel. // Does some tidying up to stop tracking nicks we're no longer on // any common channels with, and channels we're no longer on.
[ "Dissociates", "an", "already", "known", "nick", "from", "an", "already", "known", "channel", ".", "Does", "some", "tidying", "up", "to", "stop", "tracking", "nicks", "we", "re", "no", "longer", "on", "any", "common", "channels", "with", "and", "channels", ...
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/state/tracker.go#L321-L351
11,778
fluffle/goirc
client/dispatch.go
add
func (hs *hSet) add(ev string, h Handler) Remover { hs.Lock() defer hs.Unlock() ev = strings.ToLower(ev) l, ok := hs.set[ev] if !ok { l = &hList{} } hn := &hNode{ set: hs, event: ev, handler: h, } if !ok { l.start = hn } else { hn.prev = l.end l.end.next = hn } l.end = hn hs.set[ev] = l return hn }
go
func (hs *hSet) add(ev string, h Handler) Remover { hs.Lock() defer hs.Unlock() ev = strings.ToLower(ev) l, ok := hs.set[ev] if !ok { l = &hList{} } hn := &hNode{ set: hs, event: ev, handler: h, } if !ok { l.start = hn } else { hn.prev = l.end l.end.next = hn } l.end = hn hs.set[ev] = l return hn }
[ "func", "(", "hs", "*", "hSet", ")", "add", "(", "ev", "string", ",", "h", "Handler", ")", "Remover", "{", "hs", ".", "Lock", "(", ")", "\n", "defer", "hs", ".", "Unlock", "(", ")", "\n", "ev", "=", "strings", ".", "ToLower", "(", "ev", ")", ...
// When a new Handler is added for an event, it is wrapped in a hNode and // returned as a Remover so the caller can remove it at a later time.
[ "When", "a", "new", "Handler", "is", "added", "for", "an", "event", "it", "is", "wrapped", "in", "a", "hNode", "and", "returned", "as", "a", "Remover", "so", "the", "caller", "can", "remove", "it", "at", "a", "later", "time", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/dispatch.go#L82-L104
11,779
fluffle/goirc
client/dispatch.go
Handle
func (conn *Conn) Handle(name string, h Handler) Remover { return conn.fgHandlers.add(name, h) }
go
func (conn *Conn) Handle(name string, h Handler) Remover { return conn.fgHandlers.add(name, h) }
[ "func", "(", "conn", "*", "Conn", ")", "Handle", "(", "name", "string", ",", "h", "Handler", ")", "Remover", "{", "return", "conn", ".", "fgHandlers", ".", "add", "(", "name", ",", "h", ")", "\n", "}" ]
// Handle adds the provided handler to the foreground set for the named event. // It will return a Remover that allows that handler to be removed again.
[ "Handle", "adds", "the", "provided", "handler", "to", "the", "foreground", "set", "for", "the", "named", "event", ".", "It", "will", "return", "a", "Remover", "that", "allows", "that", "handler", "to", "be", "removed", "again", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/dispatch.go#L162-L164
11,780
fluffle/goirc
client/dispatch.go
HandleBG
func (conn *Conn) HandleBG(name string, h Handler) Remover { return conn.bgHandlers.add(name, h) }
go
func (conn *Conn) HandleBG(name string, h Handler) Remover { return conn.bgHandlers.add(name, h) }
[ "func", "(", "conn", "*", "Conn", ")", "HandleBG", "(", "name", "string", ",", "h", "Handler", ")", "Remover", "{", "return", "conn", ".", "bgHandlers", ".", "add", "(", "name", ",", "h", ")", "\n", "}" ]
// HandleBG adds the provided handler to the background set for the named // event. It may go away in the future. // It will return a Remover that allows that handler to be removed again.
[ "HandleBG", "adds", "the", "provided", "handler", "to", "the", "background", "set", "for", "the", "named", "event", ".", "It", "may", "go", "away", "in", "the", "future", ".", "It", "will", "return", "a", "Remover", "that", "allows", "that", "handler", "...
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/dispatch.go#L169-L171
11,781
fluffle/goirc
client/dispatch.go
HandleFunc
func (conn *Conn) HandleFunc(name string, hf HandlerFunc) Remover { return conn.Handle(name, hf) }
go
func (conn *Conn) HandleFunc(name string, hf HandlerFunc) Remover { return conn.Handle(name, hf) }
[ "func", "(", "conn", "*", "Conn", ")", "HandleFunc", "(", "name", "string", ",", "hf", "HandlerFunc", ")", "Remover", "{", "return", "conn", ".", "Handle", "(", "name", ",", "hf", ")", "\n", "}" ]
// HandleFunc adds the provided function as a handler in the foreground set // for the named event. // It will return a Remover that allows that handler to be removed again.
[ "HandleFunc", "adds", "the", "provided", "function", "as", "a", "handler", "in", "the", "foreground", "set", "for", "the", "named", "event", ".", "It", "will", "return", "a", "Remover", "that", "allows", "that", "handler", "to", "be", "removed", "again", "...
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/dispatch.go#L180-L182
11,782
fluffle/goirc
client/handlers.go
h_REGISTER
func (conn *Conn) h_REGISTER(line *Line) { if conn.cfg.Pass != "" { conn.Pass(conn.cfg.Pass) } conn.Nick(conn.cfg.Me.Nick) conn.User(conn.cfg.Me.Ident, conn.cfg.Me.Name) }
go
func (conn *Conn) h_REGISTER(line *Line) { if conn.cfg.Pass != "" { conn.Pass(conn.cfg.Pass) } conn.Nick(conn.cfg.Me.Nick) conn.User(conn.cfg.Me.Ident, conn.cfg.Me.Name) }
[ "func", "(", "conn", "*", "Conn", ")", "h_REGISTER", "(", "line", "*", "Line", ")", "{", "if", "conn", ".", "cfg", ".", "Pass", "!=", "\"", "\"", "{", "conn", ".", "Pass", "(", "conn", ".", "cfg", ".", "Pass", ")", "\n", "}", "\n", "conn", "....
// Handler for initial registration with server once tcp connection is made.
[ "Handler", "for", "initial", "registration", "with", "server", "once", "tcp", "connection", "is", "made", "." ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/handlers.go#L35-L41
11,783
fluffle/goirc
client/handlers.go
h_001
func (conn *Conn) h_001(line *Line) { // we're connected! conn.dispatch(&Line{Cmd: CONNECTED, Time: time.Now()}) // and we're being given our hostname (from the server's perspective) t := line.Args[len(line.Args)-1] if idx := strings.LastIndex(t, " "); idx != -1 { t = t[idx+1:] if idx = strings.Index(t, "@"); idx != -1 { if conn.st != nil { me := conn.Me() conn.st.NickInfo(me.Nick, me.Ident, t[idx+1:], me.Name) } else { conn.cfg.Me.Host = t[idx+1:] } } } }
go
func (conn *Conn) h_001(line *Line) { // we're connected! conn.dispatch(&Line{Cmd: CONNECTED, Time: time.Now()}) // and we're being given our hostname (from the server's perspective) t := line.Args[len(line.Args)-1] if idx := strings.LastIndex(t, " "); idx != -1 { t = t[idx+1:] if idx = strings.Index(t, "@"); idx != -1 { if conn.st != nil { me := conn.Me() conn.st.NickInfo(me.Nick, me.Ident, t[idx+1:], me.Name) } else { conn.cfg.Me.Host = t[idx+1:] } } } }
[ "func", "(", "conn", "*", "Conn", ")", "h_001", "(", "line", "*", "Line", ")", "{", "// we're connected!", "conn", ".", "dispatch", "(", "&", "Line", "{", "Cmd", ":", "CONNECTED", ",", "Time", ":", "time", ".", "Now", "(", ")", "}", ")", "\n", "/...
// Handler to trigger a CONNECTED event on receipt of numeric 001
[ "Handler", "to", "trigger", "a", "CONNECTED", "event", "on", "receipt", "of", "numeric", "001" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/handlers.go#L44-L60
11,784
fluffle/goirc
client/handlers.go
h_CTCP
func (conn *Conn) h_CTCP(line *Line) { if line.Args[0] == VERSION { conn.CtcpReply(line.Nick, VERSION, conn.cfg.Version) } else if line.Args[0] == PING && line.argslen(2) { conn.CtcpReply(line.Nick, PING, line.Args[2]) } }
go
func (conn *Conn) h_CTCP(line *Line) { if line.Args[0] == VERSION { conn.CtcpReply(line.Nick, VERSION, conn.cfg.Version) } else if line.Args[0] == PING && line.argslen(2) { conn.CtcpReply(line.Nick, PING, line.Args[2]) } }
[ "func", "(", "conn", "*", "Conn", ")", "h_CTCP", "(", "line", "*", "Line", ")", "{", "if", "line", ".", "Args", "[", "0", "]", "==", "VERSION", "{", "conn", ".", "CtcpReply", "(", "line", ".", "Nick", ",", "VERSION", ",", "conn", ".", "cfg", "....
// Handle VERSION requests and CTCP PING
[ "Handle", "VERSION", "requests", "and", "CTCP", "PING" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/handlers.go#L92-L98
11,785
fluffle/goirc
client/handlers.go
h_NICK
func (conn *Conn) h_NICK(line *Line) { if conn.st == nil && line.Nick == conn.cfg.Me.Nick { conn.cfg.Me.Nick = line.Args[0] } }
go
func (conn *Conn) h_NICK(line *Line) { if conn.st == nil && line.Nick == conn.cfg.Me.Nick { conn.cfg.Me.Nick = line.Args[0] } }
[ "func", "(", "conn", "*", "Conn", ")", "h_NICK", "(", "line", "*", "Line", ")", "{", "if", "conn", ".", "st", "==", "nil", "&&", "line", ".", "Nick", "==", "conn", ".", "cfg", ".", "Me", ".", "Nick", "{", "conn", ".", "cfg", ".", "Me", ".", ...
// Handle updating our own NICK if we're not using the state tracker
[ "Handle", "updating", "our", "own", "NICK", "if", "we", "re", "not", "using", "the", "state", "tracker" ]
08c1bcf17445781669bcecc47159c627962e18f1
https://github.com/fluffle/goirc/blob/08c1bcf17445781669bcecc47159c627962e18f1/client/handlers.go#L101-L105
11,786
howeyc/crc16
hash.go
tableSum
func tableSum(t *Table) uint16 { var a [1024]byte b := a[:0] if t != nil { for _, x := range t.entries { b = appendUint16(b, x) } } return ChecksumIBM(b) }
go
func tableSum(t *Table) uint16 { var a [1024]byte b := a[:0] if t != nil { for _, x := range t.entries { b = appendUint16(b, x) } } return ChecksumIBM(b) }
[ "func", "tableSum", "(", "t", "*", "Table", ")", "uint16", "{", "var", "a", "[", "1024", "]", "byte", "\n", "b", ":=", "a", "[", ":", "0", "]", "\n", "if", "t", "!=", "nil", "{", "for", "_", ",", "x", ":=", "range", "t", ".", "entries", "{"...
// tableSum returns the IBM checksum of table t.
[ "tableSum", "returns", "the", "IBM", "checksum", "of", "table", "t", "." ]
2b2a61e366a66d3efb279e46176e7291001e0354
https://github.com/howeyc/crc16/blob/2b2a61e366a66d3efb279e46176e7291001e0354/hash.go#L107-L116
11,787
howeyc/crc16
crc16.go
MakeTableNoXOR
func MakeTableNoXOR(poly uint16) *Table { tab := makeTable(poly) tab.noXOR = true return tab }
go
func MakeTableNoXOR(poly uint16) *Table { tab := makeTable(poly) tab.noXOR = true return tab }
[ "func", "MakeTableNoXOR", "(", "poly", "uint16", ")", "*", "Table", "{", "tab", ":=", "makeTable", "(", "poly", ")", "\n", "tab", ".", "noXOR", "=", "true", "\n", "return", "tab", "\n", "}" ]
// MakeTableNoXOR returns the Table constructed from the specified polynomial. // Updates happen without XOR in and XOR out.
[ "MakeTableNoXOR", "returns", "the", "Table", "constructed", "from", "the", "specified", "polynomial", ".", "Updates", "happen", "without", "XOR", "in", "and", "XOR", "out", "." ]
2b2a61e366a66d3efb279e46176e7291001e0354
https://github.com/howeyc/crc16/blob/2b2a61e366a66d3efb279e46176e7291001e0354/crc16.go#L58-L62
11,788
howeyc/crc16
crc16.go
makeBitsReversedTable
func makeBitsReversedTable(poly uint16) *Table { t := &Table{ reversed: true, } width := uint16(16) for i := uint16(0); i < 256; i++ { crc := i << (width - 8) for j := 0; j < 8; j++ { if crc&(1<<(width-1)) != 0 { crc = (crc << 1) ^ poly } else { crc <<= 1 } } t.entries[i] = crc } return t }
go
func makeBitsReversedTable(poly uint16) *Table { t := &Table{ reversed: true, } width := uint16(16) for i := uint16(0); i < 256; i++ { crc := i << (width - 8) for j := 0; j < 8; j++ { if crc&(1<<(width-1)) != 0 { crc = (crc << 1) ^ poly } else { crc <<= 1 } } t.entries[i] = crc } return t }
[ "func", "makeBitsReversedTable", "(", "poly", "uint16", ")", "*", "Table", "{", "t", ":=", "&", "Table", "{", "reversed", ":", "true", ",", "}", "\n", "width", ":=", "uint16", "(", "16", ")", "\n", "for", "i", ":=", "uint16", "(", "0", ")", ";", ...
// makeTable returns the Table constructed from the specified polynomial.
[ "makeTable", "returns", "the", "Table", "constructed", "from", "the", "specified", "polynomial", "." ]
2b2a61e366a66d3efb279e46176e7291001e0354
https://github.com/howeyc/crc16/blob/2b2a61e366a66d3efb279e46176e7291001e0354/crc16.go#L65-L82
11,789
gopherjs/websocket
websocketjs/websocketjs.go
New
func New(url string) (ws *WebSocket, err error) { defer func() { e := recover() if e == nil { return } if jsErr, ok := e.(*js.Error); ok && jsErr != nil { ws = nil err = jsErr } else { panic(e) } }() object := js.Global.Get("WebSocket").New(url) ws = &WebSocket{ Object: object, } return }
go
func New(url string) (ws *WebSocket, err error) { defer func() { e := recover() if e == nil { return } if jsErr, ok := e.(*js.Error); ok && jsErr != nil { ws = nil err = jsErr } else { panic(e) } }() object := js.Global.Get("WebSocket").New(url) ws = &WebSocket{ Object: object, } return }
[ "func", "New", "(", "url", "string", ")", "(", "ws", "*", "WebSocket", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "e", ":=", "recover", "(", ")", "\n", "if", "e", "==", "nil", "{", "return", "\n", "}", "\n", "if", "jsErr", ...
// New creates a new low-level WebSocket. It immediately returns the new // WebSocket.
[ "New", "creates", "a", "new", "low", "-", "level", "WebSocket", ".", "It", "immediately", "returns", "the", "new", "WebSocket", "." ]
87ee47603f137e7f8419765b3621b3c36e715a08
https://github.com/gopherjs/websocket/blob/87ee47603f137e7f8419765b3621b3c36e715a08/websocketjs/websocketjs.go#L70-L91
11,790
gopherjs/websocket
conn.go
initialize
func (c *conn) initialize() { // We need this so that received binary data is in ArrayBufferView format so // that it can easily be read. c.BinaryType = "arraybuffer" c.AddEventListener("message", false, c.onMessage) c.AddEventListener("close", false, c.onClose) }
go
func (c *conn) initialize() { // We need this so that received binary data is in ArrayBufferView format so // that it can easily be read. c.BinaryType = "arraybuffer" c.AddEventListener("message", false, c.onMessage) c.AddEventListener("close", false, c.onClose) }
[ "func", "(", "c", "*", "conn", ")", "initialize", "(", ")", "{", "// We need this so that received binary data is in ArrayBufferView format so", "// that it can easily be read.", "c", ".", "BinaryType", "=", "\"", "\"", "\n\n", "c", ".", "AddEventListener", "(", "\"", ...
// initialize adds all of the event handlers necessary for a conn to function. // It should never be called more than once and is already called if Dial was // used to create the conn.
[ "initialize", "adds", "all", "of", "the", "event", "handlers", "necessary", "for", "a", "conn", "to", "function", ".", "It", "should", "never", "be", "called", "more", "than", "once", "and", "is", "already", "called", "if", "Dial", "was", "used", "to", "...
87ee47603f137e7f8419765b3621b3c36e715a08
https://github.com/gopherjs/websocket/blob/87ee47603f137e7f8419765b3621b3c36e715a08/conn.go#L141-L148
11,791
gopherjs/websocket
conn.go
handleFrame
func (c *conn) handleFrame(message *messageEvent, ok bool) (*messageEvent, error) { if !ok { // The channel has been closed return nil, io.EOF } else if message == nil { // See onClose for the explanation about sending a nil item. close(c.ch) return nil, io.EOF } return message, nil }
go
func (c *conn) handleFrame(message *messageEvent, ok bool) (*messageEvent, error) { if !ok { // The channel has been closed return nil, io.EOF } else if message == nil { // See onClose for the explanation about sending a nil item. close(c.ch) return nil, io.EOF } return message, nil }
[ "func", "(", "c", "*", "conn", ")", "handleFrame", "(", "message", "*", "messageEvent", ",", "ok", "bool", ")", "(", "*", "messageEvent", ",", "error", ")", "{", "if", "!", "ok", "{", "// The channel has been closed", "return", "nil", ",", "io", ".", "...
// handleFrame handles a single frame received from the channel. This is a // convenience funciton to dedupe code for the multiple deadline cases.
[ "handleFrame", "handles", "a", "single", "frame", "received", "from", "the", "channel", ".", "This", "is", "a", "convenience", "funciton", "to", "dedupe", "code", "for", "the", "multiple", "deadline", "cases", "." ]
87ee47603f137e7f8419765b3621b3c36e715a08
https://github.com/gopherjs/websocket/blob/87ee47603f137e7f8419765b3621b3c36e715a08/conn.go#L152-L162
11,792
gopherjs/websocket
conn.go
receiveFrame
func (c *conn) receiveFrame(observeDeadline bool) (*messageEvent, error) { var deadlineChan <-chan time.Time // Receiving on a nil channel always blocks indefinitely if observeDeadline && !c.readDeadline.IsZero() { now := time.Now() if now.After(c.readDeadline) { select { case item, ok := <-c.ch: return c.handleFrame(item, ok) default: return nil, errDeadlineReached } } timer := time.NewTimer(c.readDeadline.Sub(now)) defer timer.Stop() deadlineChan = timer.C } select { case item, ok := <-c.ch: return c.handleFrame(item, ok) case <-deadlineChan: return nil, errDeadlineReached } }
go
func (c *conn) receiveFrame(observeDeadline bool) (*messageEvent, error) { var deadlineChan <-chan time.Time // Receiving on a nil channel always blocks indefinitely if observeDeadline && !c.readDeadline.IsZero() { now := time.Now() if now.After(c.readDeadline) { select { case item, ok := <-c.ch: return c.handleFrame(item, ok) default: return nil, errDeadlineReached } } timer := time.NewTimer(c.readDeadline.Sub(now)) defer timer.Stop() deadlineChan = timer.C } select { case item, ok := <-c.ch: return c.handleFrame(item, ok) case <-deadlineChan: return nil, errDeadlineReached } }
[ "func", "(", "c", "*", "conn", ")", "receiveFrame", "(", "observeDeadline", "bool", ")", "(", "*", "messageEvent", ",", "error", ")", "{", "var", "deadlineChan", "<-", "chan", "time", ".", "Time", "// Receiving on a nil channel always blocks indefinitely", "\n\n",...
// receiveFrame receives one full frame from the WebSocket. It blocks until the // frame is received.
[ "receiveFrame", "receives", "one", "full", "frame", "from", "the", "WebSocket", ".", "It", "blocks", "until", "the", "frame", "is", "received", "." ]
87ee47603f137e7f8419765b3621b3c36e715a08
https://github.com/gopherjs/websocket/blob/87ee47603f137e7f8419765b3621b3c36e715a08/conn.go#L166-L192
11,793
gopherjs/websocket
conn.go
Write
func (c *conn) Write(b []byte) (n int, err error) { // []byte is converted to an Uint8Array by GopherJS, which fullfils the // ArrayBufferView definition. err = c.Send(b) if err != nil { return 0, err } return len(b), nil }
go
func (c *conn) Write(b []byte) (n int, err error) { // []byte is converted to an Uint8Array by GopherJS, which fullfils the // ArrayBufferView definition. err = c.Send(b) if err != nil { return 0, err } return len(b), nil }
[ "func", "(", "c", "*", "conn", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "// []byte is converted to an Uint8Array by GopherJS, which fullfils the", "// ArrayBufferView definition.", "err", "=", "c", ".", "Send...
// Write writes the contents of b to the WebSocket using a binary opcode.
[ "Write", "writes", "the", "contents", "of", "b", "to", "the", "WebSocket", "using", "a", "binary", "opcode", "." ]
87ee47603f137e7f8419765b3621b3c36e715a08
https://github.com/gopherjs/websocket/blob/87ee47603f137e7f8419765b3621b3c36e715a08/conn.go#L237-L245
11,794
gopherjs/websocket
conn.go
RemoteAddr
func (c *conn) RemoteAddr() net.Addr { wsURL, err := url.Parse(c.URL) if err != nil { // TODO(nightexcessive): Should we be panicking for this? panic(err) } return &addr{wsURL} }
go
func (c *conn) RemoteAddr() net.Addr { wsURL, err := url.Parse(c.URL) if err != nil { // TODO(nightexcessive): Should we be panicking for this? panic(err) } return &addr{wsURL} }
[ "func", "(", "c", "*", "conn", ")", "RemoteAddr", "(", ")", "net", ".", "Addr", "{", "wsURL", ",", "err", ":=", "url", ".", "Parse", "(", "c", ".", "URL", ")", "\n", "if", "err", "!=", "nil", "{", "// TODO(nightexcessive): Should we be panicking for this...
// RemoteAddr returns the remote network address, based on // websocket.WebSocket.URL.
[ "RemoteAddr", "returns", "the", "remote", "network", "address", "based", "on", "websocket", ".", "WebSocket", ".", "URL", "." ]
87ee47603f137e7f8419765b3621b3c36e715a08
https://github.com/gopherjs/websocket/blob/87ee47603f137e7f8419765b3621b3c36e715a08/conn.go#L260-L267
11,795
xxtea/xxtea-go
xxtea/xxtea.go
Encrypt
func Encrypt(data []byte, key []byte) []byte { if data == nil || len(data) == 0 { return data } return toBytes(encrypt(toUint32s(data, true), toUint32s(key, false)), false) }
go
func Encrypt(data []byte, key []byte) []byte { if data == nil || len(data) == 0 { return data } return toBytes(encrypt(toUint32s(data, true), toUint32s(key, false)), false) }
[ "func", "Encrypt", "(", "data", "[", "]", "byte", ",", "key", "[", "]", "byte", ")", "[", "]", "byte", "{", "if", "data", "==", "nil", "||", "len", "(", "data", ")", "==", "0", "{", "return", "data", "\n", "}", "\n", "return", "toBytes", "(", ...
// Encrypt the data with key. // data is the bytes to be encrypted. // key is the encrypt key. It is the same as the decrypt key.
[ "Encrypt", "the", "data", "with", "key", ".", "data", "is", "the", "bytes", "to", "be", "encrypted", ".", "key", "is", "the", "encrypt", "key", ".", "It", "is", "the", "same", "as", "the", "decrypt", "key", "." ]
35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242
https://github.com/xxtea/xxtea-go/blob/35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242/xxtea/xxtea.go#L120-L125
11,796
xxtea/xxtea-go
xxtea/xxtea.go
Decrypt
func Decrypt(data []byte, key []byte) []byte { if data == nil || len(data) == 0 { return data } return toBytes(decrypt(toUint32s(data, false), toUint32s(key, false)), true) }
go
func Decrypt(data []byte, key []byte) []byte { if data == nil || len(data) == 0 { return data } return toBytes(decrypt(toUint32s(data, false), toUint32s(key, false)), true) }
[ "func", "Decrypt", "(", "data", "[", "]", "byte", ",", "key", "[", "]", "byte", ")", "[", "]", "byte", "{", "if", "data", "==", "nil", "||", "len", "(", "data", ")", "==", "0", "{", "return", "data", "\n", "}", "\n", "return", "toBytes", "(", ...
// Decrypt the data with key. // data is the bytes to be decrypted. // key is the decrypted key. It is the same as the encrypt key.
[ "Decrypt", "the", "data", "with", "key", ".", "data", "is", "the", "bytes", "to", "be", "decrypted", ".", "key", "is", "the", "decrypted", "key", ".", "It", "is", "the", "same", "as", "the", "encrypt", "key", "." ]
35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242
https://github.com/xxtea/xxtea-go/blob/35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242/xxtea/xxtea.go#L130-L135
11,797
xxtea/xxtea-go
xxtea/xxtea.go
EncryptString
func EncryptString(str, key string) string { s := []byte(str) k := []byte(key) b64 := base64.StdEncoding return b64.EncodeToString(Encrypt(s, k)) }
go
func EncryptString(str, key string) string { s := []byte(str) k := []byte(key) b64 := base64.StdEncoding return b64.EncodeToString(Encrypt(s, k)) }
[ "func", "EncryptString", "(", "str", ",", "key", "string", ")", "string", "{", "s", ":=", "[", "]", "byte", "(", "str", ")", "\n", "k", ":=", "[", "]", "byte", "(", "key", ")", "\n", "b64", ":=", "base64", ".", "StdEncoding", "\n", "return", "b64...
// Encrypt the data with key. // data is the string to be encrypted. // key is the string of encrypt key.
[ "Encrypt", "the", "data", "with", "key", ".", "data", "is", "the", "string", "to", "be", "encrypted", ".", "key", "is", "the", "string", "of", "encrypt", "key", "." ]
35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242
https://github.com/xxtea/xxtea-go/blob/35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242/xxtea/xxtea.go#L140-L145
11,798
xxtea/xxtea-go
xxtea/xxtea.go
DecryptString
func DecryptString(str, key string) (string, error) { k := []byte(key) b64 := base64.StdEncoding decodeStr, err := b64.DecodeString(str) if err != nil { return "", err } result := Decrypt([]byte(decodeStr), k) return string(result), nil }
go
func DecryptString(str, key string) (string, error) { k := []byte(key) b64 := base64.StdEncoding decodeStr, err := b64.DecodeString(str) if err != nil { return "", err } result := Decrypt([]byte(decodeStr), k) return string(result), nil }
[ "func", "DecryptString", "(", "str", ",", "key", "string", ")", "(", "string", ",", "error", ")", "{", "k", ":=", "[", "]", "byte", "(", "key", ")", "\n", "b64", ":=", "base64", ".", "StdEncoding", "\n", "decodeStr", ",", "err", ":=", "b64", ".", ...
// Decrypt the data with key. // data is the string to be decrypted. // key is the decrypted key. It is the same as the encrypt key.
[ "Decrypt", "the", "data", "with", "key", ".", "data", "is", "the", "string", "to", "be", "decrypted", ".", "key", "is", "the", "decrypted", "key", ".", "It", "is", "the", "same", "as", "the", "encrypt", "key", "." ]
35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242
https://github.com/xxtea/xxtea-go/blob/35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242/xxtea/xxtea.go#L150-L159
11,799
xxtea/xxtea-go
xxtea/xxtea.go
DecryptURLToStdString
func DecryptURLToStdString(str, key string) (string, error) { return DecryptString(decryptBase64ToStdFormat(str), key) }
go
func DecryptURLToStdString(str, key string) (string, error) { return DecryptString(decryptBase64ToStdFormat(str), key) }
[ "func", "DecryptURLToStdString", "(", "str", ",", "key", "string", ")", "(", "string", ",", "error", ")", "{", "return", "DecryptString", "(", "decryptBase64ToStdFormat", "(", "str", ")", ",", "key", ")", "\n", "}" ]
// Decrypt the URL string with key and convert the URL string to the origin string
[ "Decrypt", "the", "URL", "string", "with", "key", "and", "convert", "the", "URL", "string", "to", "the", "origin", "string" ]
35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242
https://github.com/xxtea/xxtea-go/blob/35c4b17eecf6c3c2350f8cecaf1b3f9f7fafc242/xxtea/xxtea.go#L167-L169