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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
133,700 | mailjet/mailjet-apiv3-go | mailjet_client.go | SendMail | func (c *Client) SendMail(data *InfoSendMail) (res *SentResult, err error) {
url := c.apiBase + "/send/message"
req, err := createRequest("POST", url, data, nil)
if err != nil {
return res, err
}
headers := map[string]string{"Content-Type": "application/json"}
c.Lock()
defer c.Unlock()
_, _, err = c.httpCli... | go | func (c *Client) SendMail(data *InfoSendMail) (res *SentResult, err error) {
url := c.apiBase + "/send/message"
req, err := createRequest("POST", url, data, nil)
if err != nil {
return res, err
}
headers := map[string]string{"Content-Type": "application/json"}
c.Lock()
defer c.Unlock()
_, _, err = c.httpCli... | [
"func",
"(",
"c",
"*",
"Client",
")",
"SendMail",
"(",
"data",
"*",
"InfoSendMail",
")",
"(",
"res",
"*",
"SentResult",
",",
"err",
"error",
")",
"{",
"url",
":=",
"c",
".",
"apiBase",
"+",
"\"",
"\"",
"\n",
"req",
",",
"err",
":=",
"createRequest"... | // SendMail send mail via API. | [
"SendMail",
"send",
"mail",
"via",
"API",
"."
] | e508c28bf11623de2171a2331fc673391b066867 | https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/mailjet_client.go#L205-L218 |
133,701 | mailjet/mailjet-apiv3-go | mailjet_client.go | SendMailSMTP | func (c *Client) SendMailSMTP(info *InfoSMTP) error {
return c.smtpClient.SendMail(
info.From,
info.Recipients,
buildMessage(info.Header, info.Content))
} | go | func (c *Client) SendMailSMTP(info *InfoSMTP) error {
return c.smtpClient.SendMail(
info.From,
info.Recipients,
buildMessage(info.Header, info.Content))
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SendMailSMTP",
"(",
"info",
"*",
"InfoSMTP",
")",
"error",
"{",
"return",
"c",
".",
"smtpClient",
".",
"SendMail",
"(",
"info",
".",
"From",
",",
"info",
".",
"Recipients",
",",
"buildMessage",
"(",
"info",
".",
... | // SendMailSMTP send mail via SMTP. | [
"SendMailSMTP",
"send",
"mail",
"via",
"SMTP",
"."
] | e508c28bf11623de2171a2331fc673391b066867 | https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/mailjet_client.go#L221-L226 |
133,702 | mailjet/mailjet-apiv3-go | mailjet_client.go | SendMailV31 | func (c *Client) SendMailV31(data *MessagesV31) (*ResultsV31, error) {
url := c.apiBase + ".1/send"
req, err := createRequest("POST", url, data, nil)
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
req.SetBasicAuth(c.APIKeyPublic(), c.APIKeyPrivate())
r, err := c.httpClie... | go | func (c *Client) SendMailV31(data *MessagesV31) (*ResultsV31, error) {
url := c.apiBase + ".1/send"
req, err := createRequest("POST", url, data, nil)
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
req.SetBasicAuth(c.APIKeyPublic(), c.APIKeyPrivate())
r, err := c.httpClie... | [
"func",
"(",
"c",
"*",
"Client",
")",
"SendMailV31",
"(",
"data",
"*",
"MessagesV31",
")",
"(",
"*",
"ResultsV31",
",",
"error",
")",
"{",
"url",
":=",
"c",
".",
"apiBase",
"+",
"\"",
"\"",
"\n",
"req",
",",
"err",
":=",
"createRequest",
"(",
"\"",... | // SendMailV31 sends a mail to the send API v3.1 | [
"SendMailV31",
"sends",
"a",
"mail",
"to",
"the",
"send",
"API",
"v3",
".",
"1"
] | e508c28bf11623de2171a2331fc673391b066867 | https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/mailjet_client.go#L240-L282 |
133,703 | briandowns/openweathermap | uv.go | NewUV | func NewUV(key string, options ...Option) (*UV, error) {
k, err := setKey(key)
if err != nil {
return nil, err
}
u := &UV{
Key: k,
Settings: NewSettings(),
}
if err := setOptions(u.Settings, options); err != nil {
return nil, err
}
return u, nil
} | go | func NewUV(key string, options ...Option) (*UV, error) {
k, err := setKey(key)
if err != nil {
return nil, err
}
u := &UV{
Key: k,
Settings: NewSettings(),
}
if err := setOptions(u.Settings, options); err != nil {
return nil, err
}
return u, nil
} | [
"func",
"NewUV",
"(",
"key",
"string",
",",
"options",
"...",
"Option",
")",
"(",
"*",
"UV",
",",
"error",
")",
"{",
"k",
",",
"err",
":=",
"setKey",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
... | // NewUV creates a new reference to UV | [
"NewUV",
"creates",
"a",
"new",
"reference",
"to",
"UV"
] | 5f41b7c9d92de5d74bf32f4486375c7547bc8a3c | https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/uv.go#L33-L47 |
133,704 | briandowns/openweathermap | uv.go | Current | func (u *UV) Current(coord *Coordinates) error {
response, err := u.client.Get(fmt.Sprintf("%suvi?lat=%f&lon=%f&appid=%s", uvURL, coord.Latitude, coord.Longitude, u.Key))
if err != nil {
return err
}
defer response.Body.Close()
if err = json.NewDecoder(response.Body).Decode(&u); err != nil {
return err
}
r... | go | func (u *UV) Current(coord *Coordinates) error {
response, err := u.client.Get(fmt.Sprintf("%suvi?lat=%f&lon=%f&appid=%s", uvURL, coord.Latitude, coord.Longitude, u.Key))
if err != nil {
return err
}
defer response.Body.Close()
if err = json.NewDecoder(response.Body).Decode(&u); err != nil {
return err
}
r... | [
"func",
"(",
"u",
"*",
"UV",
")",
"Current",
"(",
"coord",
"*",
"Coordinates",
")",
"error",
"{",
"response",
",",
"err",
":=",
"u",
".",
"client",
".",
"Get",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"uvURL",
",",
"coord",
".",
"Latitud... | // Current gets the current UV data for the given coordinates | [
"Current",
"gets",
"the",
"current",
"UV",
"data",
"for",
"the",
"given",
"coordinates"
] | 5f41b7c9d92de5d74bf32f4486375c7547bc8a3c | https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/uv.go#L50-L62 |
133,705 | briandowns/openweathermap | uv.go | Historical | func (u *UV) Historical(coord *Coordinates, start, end time.Time) error {
response, err := u.client.Get(fmt.Sprintf("%shistory?lat=%f&lon=%f&start=%d&end=%d&appid=%s", uvURL, coord.Latitude, coord.Longitude, start.Unix(), end.Unix(), u.Key))
if err != nil {
return err
}
defer response.Body.Close()
if err = json... | go | func (u *UV) Historical(coord *Coordinates, start, end time.Time) error {
response, err := u.client.Get(fmt.Sprintf("%shistory?lat=%f&lon=%f&start=%d&end=%d&appid=%s", uvURL, coord.Latitude, coord.Longitude, start.Unix(), end.Unix(), u.Key))
if err != nil {
return err
}
defer response.Body.Close()
if err = json... | [
"func",
"(",
"u",
"*",
"UV",
")",
"Historical",
"(",
"coord",
"*",
"Coordinates",
",",
"start",
",",
"end",
"time",
".",
"Time",
")",
"error",
"{",
"response",
",",
"err",
":=",
"u",
".",
"client",
".",
"Get",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"... | // Historical gets the historical UV data for the coordinates and times | [
"Historical",
"gets",
"the",
"historical",
"UV",
"data",
"for",
"the",
"coordinates",
"and",
"times"
] | 5f41b7c9d92de5d74bf32f4486375c7547bc8a3c | https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/uv.go#L65-L77 |
133,706 | briandowns/openweathermap | uv.go | UVInformation | func (u *UV) UVInformation() ([]UVIndexInfo, error) {
switch {
case u.Value != 0:
switch {
case u.Value < 2.9:
return []UVIndexInfo{UVData[0]}, nil
case u.Value > 3 && u.Value < 5.9:
return []UVIndexInfo{UVData[1]}, nil
case u.Value > 6 && u.Value < 7.9:
return []UVIndexInfo{UVData[2]}, nil
case u.... | go | func (u *UV) UVInformation() ([]UVIndexInfo, error) {
switch {
case u.Value != 0:
switch {
case u.Value < 2.9:
return []UVIndexInfo{UVData[0]}, nil
case u.Value > 3 && u.Value < 5.9:
return []UVIndexInfo{UVData[1]}, nil
case u.Value > 6 && u.Value < 7.9:
return []UVIndexInfo{UVData[2]}, nil
case u.... | [
"func",
"(",
"u",
"*",
"UV",
")",
"UVInformation",
"(",
")",
"(",
"[",
"]",
"UVIndexInfo",
",",
"error",
")",
"{",
"switch",
"{",
"case",
"u",
".",
"Value",
"!=",
"0",
":",
"switch",
"{",
"case",
"u",
".",
"Value",
"<",
"2.9",
":",
"return",
"[... | // UVInformation provides information on the given UV data which includes the severity
// and "Recommended protection" | [
"UVInformation",
"provides",
"information",
"on",
"the",
"given",
"UV",
"data",
"which",
"includes",
"the",
"severity",
"and",
"Recommended",
"protection"
] | 5f41b7c9d92de5d74bf32f4486375c7547bc8a3c | https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/uv.go#L131-L170 |
133,707 | briandowns/openweathermap | station.go | ValidateStationDataParameter | func ValidateStationDataParameter(param string) bool {
for _, p := range StationDataParameters {
if param == p {
return true
}
}
return false
} | go | func ValidateStationDataParameter(param string) bool {
for _, p := range StationDataParameters {
if param == p {
return true
}
}
return false
} | [
"func",
"ValidateStationDataParameter",
"(",
"param",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"p",
":=",
"range",
"StationDataParameters",
"{",
"if",
"param",
"==",
"p",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"... | // ValidateStationDataParameter will make sure that whatever parameter
// supplied is one that can actually be used in the POST request. | [
"ValidateStationDataParameter",
"will",
"make",
"sure",
"that",
"whatever",
"parameter",
"supplied",
"is",
"one",
"that",
"can",
"actually",
"be",
"used",
"in",
"the",
"POST",
"request",
"."
] | 5f41b7c9d92de5d74bf32f4486375c7547bc8a3c | https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/station.go#L48-L56 |
133,708 | briandowns/openweathermap | station.go | SendStationData | func SendStationData(data url.Values) {
resp, err := http.PostForm(dataPostURL, data)
if err != nil {
fmt.Println(err)
}
fmt.Println(resp.Body)
} | go | func SendStationData(data url.Values) {
resp, err := http.PostForm(dataPostURL, data)
if err != nil {
fmt.Println(err)
}
fmt.Println(resp.Body)
} | [
"func",
"SendStationData",
"(",
"data",
"url",
".",
"Values",
")",
"{",
"resp",
",",
"err",
":=",
"http",
".",
"PostForm",
"(",
"dataPostURL",
",",
"data",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Println",
"(",
"err",
")",
"\n",
"}",... | // SendStationData will send an instance the provided url.Values to the
// provided URL. | [
"SendStationData",
"will",
"send",
"an",
"instance",
"the",
"provided",
"url",
".",
"Values",
"to",
"the",
"provided",
"URL",
"."
] | 5f41b7c9d92de5d74bf32f4486375c7547bc8a3c | https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/station.go#L73-L80 |
133,709 | briandowns/openweathermap | history.go | NewHistorical | func NewHistorical(unit, key string, options ...Option) (*HistoricalWeatherData, error) {
h := &HistoricalWeatherData{
Settings: NewSettings(),
}
unitChoice := strings.ToUpper(unit)
if !ValidDataUnit(unitChoice) {
return nil, errUnitUnavailable
}
h.Unit = DataUnits[unitChoice]
var err error
h.Key, err = s... | go | func NewHistorical(unit, key string, options ...Option) (*HistoricalWeatherData, error) {
h := &HistoricalWeatherData{
Settings: NewSettings(),
}
unitChoice := strings.ToUpper(unit)
if !ValidDataUnit(unitChoice) {
return nil, errUnitUnavailable
}
h.Unit = DataUnits[unitChoice]
var err error
h.Key, err = s... | [
"func",
"NewHistorical",
"(",
"unit",
",",
"key",
"string",
",",
"options",
"...",
"Option",
")",
"(",
"*",
"HistoricalWeatherData",
",",
"error",
")",
"{",
"h",
":=",
"&",
"HistoricalWeatherData",
"{",
"Settings",
":",
"NewSettings",
"(",
")",
",",
"}",
... | // NewHistorical returns a new HistoricalWeatherData pointer with
//the supplied arguments. | [
"NewHistorical",
"returns",
"a",
"new",
"HistoricalWeatherData",
"pointer",
"with",
"the",
"supplied",
"arguments",
"."
] | 5f41b7c9d92de5d74bf32f4486375c7547bc8a3c | https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/history.go#L69-L90 |
133,710 | briandowns/openweathermap | history.go | HistoryByName | func (h *HistoricalWeatherData) HistoryByName(location string) error {
response, err := h.client.Get(fmt.Sprintf(fmt.Sprintf(historyURL, "city?appid=%s&q=%s"), h.Key, url.QueryEscape(location)))
if err != nil {
return err
}
defer response.Body.Close()
if err = json.NewDecoder(response.Body).Decode(&h); err != n... | go | func (h *HistoricalWeatherData) HistoryByName(location string) error {
response, err := h.client.Get(fmt.Sprintf(fmt.Sprintf(historyURL, "city?appid=%s&q=%s"), h.Key, url.QueryEscape(location)))
if err != nil {
return err
}
defer response.Body.Close()
if err = json.NewDecoder(response.Body).Decode(&h); err != n... | [
"func",
"(",
"h",
"*",
"HistoricalWeatherData",
")",
"HistoryByName",
"(",
"location",
"string",
")",
"error",
"{",
"response",
",",
"err",
":=",
"h",
".",
"client",
".",
"Get",
"(",
"fmt",
".",
"Sprintf",
"(",
"fmt",
".",
"Sprintf",
"(",
"historyURL",
... | // HistoryByName will return the history for the provided location | [
"HistoryByName",
"will",
"return",
"the",
"history",
"for",
"the",
"provided",
"location"
] | 5f41b7c9d92de5d74bf32f4486375c7547bc8a3c | https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/history.go#L93-L105 |
133,711 | briandowns/openweathermap | history.go | HistoryByID | func (h *HistoricalWeatherData) HistoryByID(id int, hp ...*HistoricalParameters) error {
if len(hp) > 0 {
response, err := h.client.Get(fmt.Sprintf(fmt.Sprintf(historyURL, "city?appid=%s&id=%d&type=hour&start%d&end=%d&cnt=%d"), h.Key, id, hp[0].Start, hp[0].End, hp[0].Cnt))
if err != nil {
return err
}
defe... | go | func (h *HistoricalWeatherData) HistoryByID(id int, hp ...*HistoricalParameters) error {
if len(hp) > 0 {
response, err := h.client.Get(fmt.Sprintf(fmt.Sprintf(historyURL, "city?appid=%s&id=%d&type=hour&start%d&end=%d&cnt=%d"), h.Key, id, hp[0].Start, hp[0].End, hp[0].Cnt))
if err != nil {
return err
}
defe... | [
"func",
"(",
"h",
"*",
"HistoricalWeatherData",
")",
"HistoryByID",
"(",
"id",
"int",
",",
"hp",
"...",
"*",
"HistoricalParameters",
")",
"error",
"{",
"if",
"len",
"(",
"hp",
")",
">",
"0",
"{",
"response",
",",
"err",
":=",
"h",
".",
"client",
".",... | // HistoryByID will return the history for the provided location ID | [
"HistoryByID",
"will",
"return",
"the",
"history",
"for",
"the",
"provided",
"location",
"ID"
] | 5f41b7c9d92de5d74bf32f4486375c7547bc8a3c | https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/history.go#L108-L132 |
133,712 | briandowns/openweathermap | history.go | HistoryByCoord | func (h *HistoricalWeatherData) HistoryByCoord(location *Coordinates, hp *HistoricalParameters) error {
response, err := h.client.Get(fmt.Sprintf(fmt.Sprintf(historyURL, "appid=%s&lat=%f&lon=%f&start=%d&end=%d"), h.Key, location.Latitude, location.Longitude, hp.Start, hp.End))
if err != nil {
return err
}
defer r... | go | func (h *HistoricalWeatherData) HistoryByCoord(location *Coordinates, hp *HistoricalParameters) error {
response, err := h.client.Get(fmt.Sprintf(fmt.Sprintf(historyURL, "appid=%s&lat=%f&lon=%f&start=%d&end=%d"), h.Key, location.Latitude, location.Longitude, hp.Start, hp.End))
if err != nil {
return err
}
defer r... | [
"func",
"(",
"h",
"*",
"HistoricalWeatherData",
")",
"HistoryByCoord",
"(",
"location",
"*",
"Coordinates",
",",
"hp",
"*",
"HistoricalParameters",
")",
"error",
"{",
"response",
",",
"err",
":=",
"h",
".",
"client",
".",
"Get",
"(",
"fmt",
".",
"Sprintf",... | // HistoryByCoord will return the history for the provided coordinates | [
"HistoryByCoord",
"will",
"return",
"the",
"history",
"for",
"the",
"provided",
"coordinates"
] | 5f41b7c9d92de5d74bf32f4486375c7547bc8a3c | https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/history.go#L135-L147 |
133,713 | briandowns/openweathermap | pollution.go | ValidAlias | func ValidAlias(alias string) bool {
for _, i := range DateTimeAliases {
if i == alias {
return true
}
}
return false
} | go | func ValidAlias(alias string) bool {
for _, i := range DateTimeAliases {
if i == alias {
return true
}
}
return false
} | [
"func",
"ValidAlias",
"(",
"alias",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"i",
":=",
"range",
"DateTimeAliases",
"{",
"if",
"i",
"==",
"alias",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // ValidAlias checks to make sure the given alias is a valid one | [
"ValidAlias",
"checks",
"to",
"make",
"sure",
"the",
"given",
"alias",
"is",
"a",
"valid",
"one"
] | 5f41b7c9d92de5d74bf32f4486375c7547bc8a3c | https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/pollution.go#L14-L21 |
133,714 | briandowns/openweathermap | pollution.go | NewPollution | func NewPollution(key string, options ...Option) (*Pollution, error) {
k, err := setKey(key)
if err != nil {
return nil, err
}
p := &Pollution{
Key: k,
Settings: NewSettings(),
}
if err := setOptions(p.Settings, options); err != nil {
return nil, err
}
return p, nil
} | go | func NewPollution(key string, options ...Option) (*Pollution, error) {
k, err := setKey(key)
if err != nil {
return nil, err
}
p := &Pollution{
Key: k,
Settings: NewSettings(),
}
if err := setOptions(p.Settings, options); err != nil {
return nil, err
}
return p, nil
} | [
"func",
"NewPollution",
"(",
"key",
"string",
",",
"options",
"...",
"Option",
")",
"(",
"*",
"Pollution",
",",
"error",
")",
"{",
"k",
",",
"err",
":=",
"setKey",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
... | // NewPollution creates a new reference to Pollution | [
"NewPollution",
"creates",
"a",
"new",
"reference",
"to",
"Pollution"
] | 5f41b7c9d92de5d74bf32f4486375c7547bc8a3c | https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/pollution.go#L47-L61 |
133,715 | briandowns/openweathermap | pollution.go | PollutionByParams | func (p *Pollution) PollutionByParams(params *PollutionParameters) error {
url := fmt.Sprintf("%s%s,%s/%s.json?appid=%s",
pollutionURL,
strconv.FormatFloat(params.Location.Latitude, 'f', -1, 64),
strconv.FormatFloat(params.Location.Longitude, 'f', -1, 64),
params.Datetime,
p.Key)
response, err := p.client.G... | go | func (p *Pollution) PollutionByParams(params *PollutionParameters) error {
url := fmt.Sprintf("%s%s,%s/%s.json?appid=%s",
pollutionURL,
strconv.FormatFloat(params.Location.Latitude, 'f', -1, 64),
strconv.FormatFloat(params.Location.Longitude, 'f', -1, 64),
params.Datetime,
p.Key)
response, err := p.client.G... | [
"func",
"(",
"p",
"*",
"Pollution",
")",
"PollutionByParams",
"(",
"params",
"*",
"PollutionParameters",
")",
"error",
"{",
"url",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"pollutionURL",
",",
"strconv",
".",
"FormatFloat",
"(",
"params",
".",
... | // PollutionByParams gets the pollution data based on the given parameters | [
"PollutionByParams",
"gets",
"the",
"pollution",
"data",
"based",
"on",
"the",
"given",
"parameters"
] | 5f41b7c9d92de5d74bf32f4486375c7547bc8a3c | https://github.com/briandowns/openweathermap/blob/5f41b7c9d92de5d74bf32f4486375c7547bc8a3c/pollution.go#L64-L82 |
133,716 | 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, errUnitU... | 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, errUnitU... | [
"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 |
133,717 | 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.Bod... | 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.Bod... | [
"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 |
133,718 | 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 e... | 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 e... | [
"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 |
133,719 | 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 {
retu... | 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 {
retu... | [
"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 |
133,720 | 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(respons... | 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(respons... | [
"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 |
133,721 | 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, e... | 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, e... | [
"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 |
133,722 | 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(respo... | 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(respo... | [
"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 |
133,723 | 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.Fore... | 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.Fore... | [
"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 |
133,724 | 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 |
133,725 | 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 |
133,726 | 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 |
133,727 | 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 |
133,728 | 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 |
133,729 | 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 |
133,730 | 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 |
133,731 | 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.Sprin... | 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.Sprin... | [
"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 |
133,732 | 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 |
133,733 | 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 |
133,734 | 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 |
133,735 | 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 |
133,736 | 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.Du... | 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.Du... | [
"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 |
133,737 | 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 |
133,738 | 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 |
133,739 | 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 |
133,740 | 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 |
133,741 | 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)
... | 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)
... | [
"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 |
133,742 | 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 |
133,743 | 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("<- ... | 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("<- ... | [
"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 |
133,744 | 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 |
133,745 | 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 |
133,746 | 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.WriteStrin... | 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.WriteStrin... | [
"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 |
133,747 | 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 - elaps... | 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 - elaps... | [
"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 |
133,748 | 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.conn... | 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.conn... | [
"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 |
133,749 | 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"
}
retu... | 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"
}
retu... | [
"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 |
133,750 | 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 |
133,751 | 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 t... | 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 t... | [
"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 |
133,752 | 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 |
133,753 | 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 |
133,754 | 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 |
133,755 | 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[... | 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[... | [
"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 |
133,756 | 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 |
133,757 | 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 |
133,758 | 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... | 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... | [
"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 |
133,759 | 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
}
... | 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
}
... | [
"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 |
133,760 | 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 |
133,761 | 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 |
133,762 | 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 |
133,763 | 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 ... | 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 ... | [
"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 |
133,764 | 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 |
133,765 | 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 |
133,766 | 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 |
133,767 | 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 |
133,768 | 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 |
133,769 | 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 |
133,770 | 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 |
133,771 | 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 |
133,772 | 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 |
133,773 | 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':
n... | 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':
n... | [
"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 |
133,774 | 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 |
133,775 | 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 |
133,776 | 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 |
133,777 | 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 |
133,778 | 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 |
133,779 | 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.... | 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.... | [
"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 |
133,780 | 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 |
133,781 | 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 |
133,782 | 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 |
133,783 | 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 =... | 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 =... | [
"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 |
133,784 | 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 |
133,785 | 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 |
133,786 | 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 |
133,787 | 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] = newCh... | 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] = newCh... | [
"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 |
133,788 | 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 |
133,789 | 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 |
133,790 | 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 |
133,791 | 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 |
133,792 | 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 pass... | 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 pass... | [
"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 |
133,793 | 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 ... | 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 ... | [
"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 |
133,794 | 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... | 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... | [
"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 |
133,795 | 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 |
133,796 | 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 |
133,797 | 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 |
133,798 | 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 |
133,799 | 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, "@"); ... | 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, "@"); ... | [
"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 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.