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
sequence
docstring
stringlengths
6
2.61k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
85
252
13,700
opsgenie/opsgenie-go-sdk
client/client.go
ScheduleRotationV2
func (cli *OpsGenieClient) ScheduleRotationV2() (*OpsGenieScheduleRotationV2Client, error) { cli.makeHTTPTransportSettings() scheduleRotationClient := new(OpsGenieScheduleRotationV2Client) scheduleRotationClient.SetOpsGenieClient(*cli) if cli.opsGenieAPIURL == "" { scheduleRotationClient.SetOpsGenieAPIUrl(endpointURL) } return scheduleRotationClient, nil }
go
func (cli *OpsGenieClient) ScheduleRotationV2() (*OpsGenieScheduleRotationV2Client, error) { cli.makeHTTPTransportSettings() scheduleRotationClient := new(OpsGenieScheduleRotationV2Client) scheduleRotationClient.SetOpsGenieClient(*cli) if cli.opsGenieAPIURL == "" { scheduleRotationClient.SetOpsGenieAPIUrl(endpointURL) } return scheduleRotationClient, nil }
[ "func", "(", "cli", "*", "OpsGenieClient", ")", "ScheduleRotationV2", "(", ")", "(", "*", "OpsGenieScheduleRotationV2Client", ",", "error", ")", "{", "cli", ".", "makeHTTPTransportSettings", "(", ")", "\n\n", "scheduleRotationClient", ":=", "new", "(", "OpsGenieScheduleRotationV2Client", ")", "\n", "scheduleRotationClient", ".", "SetOpsGenieClient", "(", "*", "cli", ")", "\n\n", "if", "cli", ".", "opsGenieAPIURL", "==", "\"", "\"", "{", "scheduleRotationClient", ".", "SetOpsGenieAPIUrl", "(", "endpointURL", ")", "\n", "}", "\n\n", "return", "scheduleRotationClient", ",", "nil", "\n", "}" ]
// ScheduleRotationV2 instantiates a new OpsGenieScheduleRotationV2Client
[ "ScheduleRotationV2", "instantiates", "a", "new", "OpsGenieScheduleRotationV2Client" ]
d57b8391ca905cccc085a075a2f7c1308d01cca3
https://github.com/opsgenie/opsgenie-go-sdk/blob/d57b8391ca905cccc085a075a2f7c1308d01cca3/client/client.go#L361-L372
13,701
opsgenie/opsgenie-go-sdk
client/client.go
buildCommonRequestProps
func (cli *OpsGenieClient) buildCommonRequestProps() goreq.Request { if cli.httpTransportSettings == nil { cli.makeHTTPTransportSettings() } goreq.SetConnectTimeout(cli.httpTransportSettings.ConnectionTimeout) req := goreq.Request{} if cli.proxy != nil { req.Proxy = cli.proxy.toString() } req.UserAgent = userAgentParam.ToString() req.Timeout = cli.httpTransportSettings.RequestTimeout req.Insecure = true return req }
go
func (cli *OpsGenieClient) buildCommonRequestProps() goreq.Request { if cli.httpTransportSettings == nil { cli.makeHTTPTransportSettings() } goreq.SetConnectTimeout(cli.httpTransportSettings.ConnectionTimeout) req := goreq.Request{} if cli.proxy != nil { req.Proxy = cli.proxy.toString() } req.UserAgent = userAgentParam.ToString() req.Timeout = cli.httpTransportSettings.RequestTimeout req.Insecure = true return req }
[ "func", "(", "cli", "*", "OpsGenieClient", ")", "buildCommonRequestProps", "(", ")", "goreq", ".", "Request", "{", "if", "cli", ".", "httpTransportSettings", "==", "nil", "{", "cli", ".", "makeHTTPTransportSettings", "(", ")", "\n", "}", "\n", "goreq", ".", "SetConnectTimeout", "(", "cli", ".", "httpTransportSettings", ".", "ConnectionTimeout", ")", "\n", "req", ":=", "goreq", ".", "Request", "{", "}", "\n", "if", "cli", ".", "proxy", "!=", "nil", "{", "req", ".", "Proxy", "=", "cli", ".", "proxy", ".", "toString", "(", ")", "\n", "}", "\n", "req", ".", "UserAgent", "=", "userAgentParam", ".", "ToString", "(", ")", "\n", "req", ".", "Timeout", "=", "cli", ".", "httpTransportSettings", ".", "RequestTimeout", "\n", "req", ".", "Insecure", "=", "true", "\n\n", "return", "req", "\n", "}" ]
// buildCommonRequestProps is an internal method to set common properties of requests that will send to OpsGenie.
[ "buildCommonRequestProps", "is", "an", "internal", "method", "to", "set", "common", "properties", "of", "requests", "that", "will", "send", "to", "OpsGenie", "." ]
d57b8391ca905cccc085a075a2f7c1308d01cca3
https://github.com/opsgenie/opsgenie-go-sdk/blob/d57b8391ca905cccc085a075a2f7c1308d01cca3/client/client.go#L388-L402
13,702
opsgenie/opsgenie-go-sdk
client/client.go
buildGetRequest
func (cli *OpsGenieClient) buildGetRequest(uri string, request interface{}) goreq.Request { req := cli.buildCommonRequestProps() req.Method = "GET" req.ContentType = "application/x-www-form-urlencoded; charset=UTF-8" uri = cli.OpsGenieAPIUrl() + uri if request != nil { v, _ := goquery.Values(request) req.Uri = uri + "?" + v.Encode() } else { req.Uri = uri } logging.Logger().Info("Executing OpsGenie request to [" + uri + "] with parameters: ") return req }
go
func (cli *OpsGenieClient) buildGetRequest(uri string, request interface{}) goreq.Request { req := cli.buildCommonRequestProps() req.Method = "GET" req.ContentType = "application/x-www-form-urlencoded; charset=UTF-8" uri = cli.OpsGenieAPIUrl() + uri if request != nil { v, _ := goquery.Values(request) req.Uri = uri + "?" + v.Encode() } else { req.Uri = uri } logging.Logger().Info("Executing OpsGenie request to [" + uri + "] with parameters: ") return req }
[ "func", "(", "cli", "*", "OpsGenieClient", ")", "buildGetRequest", "(", "uri", "string", ",", "request", "interface", "{", "}", ")", "goreq", ".", "Request", "{", "req", ":=", "cli", ".", "buildCommonRequestProps", "(", ")", "\n", "req", ".", "Method", "=", "\"", "\"", "\n", "req", ".", "ContentType", "=", "\"", "\"", "\n", "uri", "=", "cli", ".", "OpsGenieAPIUrl", "(", ")", "+", "uri", "\n", "if", "request", "!=", "nil", "{", "v", ",", "_", ":=", "goquery", ".", "Values", "(", "request", ")", "\n", "req", ".", "Uri", "=", "uri", "+", "\"", "\"", "+", "v", ".", "Encode", "(", ")", "\n", "}", "else", "{", "req", ".", "Uri", "=", "uri", "\n", "}", "\n\n", "logging", ".", "Logger", "(", ")", ".", "Info", "(", "\"", "\"", "+", "uri", "+", "\"", "\"", ")", "\n", "return", "req", "\n", "}" ]
// buildGetRequest is an internal method to prepare a "GET" request that will send to OpsGenie.
[ "buildGetRequest", "is", "an", "internal", "method", "to", "prepare", "a", "GET", "request", "that", "will", "send", "to", "OpsGenie", "." ]
d57b8391ca905cccc085a075a2f7c1308d01cca3
https://github.com/opsgenie/opsgenie-go-sdk/blob/d57b8391ca905cccc085a075a2f7c1308d01cca3/client/client.go#L405-L419
13,703
opsgenie/opsgenie-go-sdk
client/client.go
buildPostRequest
func (cli *OpsGenieClient) buildPostRequest(uri string, request interface{}) goreq.Request { req := cli.buildCommonRequestProps() req.Method = "POST" req.ContentType = "application/json; charset=utf-8" req.Uri = cli.OpsGenieAPIUrl() + uri req.Body = request j, _ := json.Marshal(request) logging.Logger().Info("Executing OpsGenie request to ["+req.Uri+"] with content parameters: ", string(j)) return req }
go
func (cli *OpsGenieClient) buildPostRequest(uri string, request interface{}) goreq.Request { req := cli.buildCommonRequestProps() req.Method = "POST" req.ContentType = "application/json; charset=utf-8" req.Uri = cli.OpsGenieAPIUrl() + uri req.Body = request j, _ := json.Marshal(request) logging.Logger().Info("Executing OpsGenie request to ["+req.Uri+"] with content parameters: ", string(j)) return req }
[ "func", "(", "cli", "*", "OpsGenieClient", ")", "buildPostRequest", "(", "uri", "string", ",", "request", "interface", "{", "}", ")", "goreq", ".", "Request", "{", "req", ":=", "cli", ".", "buildCommonRequestProps", "(", ")", "\n", "req", ".", "Method", "=", "\"", "\"", "\n", "req", ".", "ContentType", "=", "\"", "\"", "\n", "req", ".", "Uri", "=", "cli", ".", "OpsGenieAPIUrl", "(", ")", "+", "uri", "\n", "req", ".", "Body", "=", "request", "\n", "j", ",", "_", ":=", "json", ".", "Marshal", "(", "request", ")", "\n", "logging", ".", "Logger", "(", ")", ".", "Info", "(", "\"", "\"", "+", "req", ".", "Uri", "+", "\"", "\"", ",", "string", "(", "j", ")", ")", "\n\n", "return", "req", "\n", "}" ]
// buildPostRequest is an internal method to prepare a "POST" request that will send to OpsGenie.
[ "buildPostRequest", "is", "an", "internal", "method", "to", "prepare", "a", "POST", "request", "that", "will", "send", "to", "OpsGenie", "." ]
d57b8391ca905cccc085a075a2f7c1308d01cca3
https://github.com/opsgenie/opsgenie-go-sdk/blob/d57b8391ca905cccc085a075a2f7c1308d01cca3/client/client.go#L422-L432
13,704
opsgenie/opsgenie-go-sdk
client/client.go
buildDeleteRequest
func (cli *OpsGenieClient) buildDeleteRequest(uri string, request interface{}) goreq.Request { req := cli.buildGetRequest(uri, request) req.Method = "DELETE" return req }
go
func (cli *OpsGenieClient) buildDeleteRequest(uri string, request interface{}) goreq.Request { req := cli.buildGetRequest(uri, request) req.Method = "DELETE" return req }
[ "func", "(", "cli", "*", "OpsGenieClient", ")", "buildDeleteRequest", "(", "uri", "string", ",", "request", "interface", "{", "}", ")", "goreq", ".", "Request", "{", "req", ":=", "cli", ".", "buildGetRequest", "(", "uri", ",", "request", ")", "\n", "req", ".", "Method", "=", "\"", "\"", "\n", "return", "req", "\n", "}" ]
// buildDeleteRequest is an internal method to prepare a "DELETE" request that will send to OpsGenie.
[ "buildDeleteRequest", "is", "an", "internal", "method", "to", "prepare", "a", "DELETE", "request", "that", "will", "send", "to", "OpsGenie", "." ]
d57b8391ca905cccc085a075a2f7c1308d01cca3
https://github.com/opsgenie/opsgenie-go-sdk/blob/d57b8391ca905cccc085a075a2f7c1308d01cca3/client/client.go#L534-L538
13,705
opsgenie/opsgenie-go-sdk
client/client.go
buildPutRequest
func (cli *OpsGenieClient) buildPutRequest(uri string, request interface{}) goreq.Request { req := cli.buildPostRequest(uri, request) req.Method = "PUT" return req }
go
func (cli *OpsGenieClient) buildPutRequest(uri string, request interface{}) goreq.Request { req := cli.buildPostRequest(uri, request) req.Method = "PUT" return req }
[ "func", "(", "cli", "*", "OpsGenieClient", ")", "buildPutRequest", "(", "uri", "string", ",", "request", "interface", "{", "}", ")", "goreq", ".", "Request", "{", "req", ":=", "cli", ".", "buildPostRequest", "(", "uri", ",", "request", ")", "\n", "req", ".", "Method", "=", "\"", "\"", "\n", "return", "req", "\n", "}" ]
// buildPutRequest is an internal method to prepare a "DELETE" request that will send to OpsGenie.
[ "buildPutRequest", "is", "an", "internal", "method", "to", "prepare", "a", "DELETE", "request", "that", "will", "send", "to", "OpsGenie", "." ]
d57b8391ca905cccc085a075a2f7c1308d01cca3
https://github.com/opsgenie/opsgenie-go-sdk/blob/d57b8391ca905cccc085a075a2f7c1308d01cca3/client/client.go#L541-L545
13,706
opsgenie/opsgenie-go-sdk
client/client.go
sendRequest
func (cli *OpsGenieClient) sendRequest(req goreq.Request) (*goreq.Response, error) { // send the request var resp *goreq.Response var err error for i := 0; i < cli.httpTransportSettings.MaxRetryAttempts; i++ { resp, err = req.Do() if err == nil && resp.StatusCode < 500 { break } if resp != nil { defer resp.Body.Close() logging.Logger().Info(fmt.Sprintf("Retrying request [%s] ResponseCode:[%d]. RetryCount: %d", req.Uri, resp.StatusCode, (i + 1))) } else { logging.Logger().Info(fmt.Sprintf("Retrying request [%s] Reason:[%s]. RetryCount: %d", req.Uri, err.Error(), (i + 1))) } time.Sleep(timeSleepBetweenRequests * time.Duration(i+1)) } if err != nil { message := "Unable to send the request " + err.Error() logging.Logger().Warn(message) return nil, errors.New(message) } // check for the returning http status statusCode := resp.StatusCode if statusCode >= 400 { body, err := resp.Body.ToString() if err != nil { message := "Server response with error can not be parsed " + err.Error() logging.Logger().Warn(message) return nil, errors.New(message) } return nil, errorMessage(statusCode, body) } return resp, nil }
go
func (cli *OpsGenieClient) sendRequest(req goreq.Request) (*goreq.Response, error) { // send the request var resp *goreq.Response var err error for i := 0; i < cli.httpTransportSettings.MaxRetryAttempts; i++ { resp, err = req.Do() if err == nil && resp.StatusCode < 500 { break } if resp != nil { defer resp.Body.Close() logging.Logger().Info(fmt.Sprintf("Retrying request [%s] ResponseCode:[%d]. RetryCount: %d", req.Uri, resp.StatusCode, (i + 1))) } else { logging.Logger().Info(fmt.Sprintf("Retrying request [%s] Reason:[%s]. RetryCount: %d", req.Uri, err.Error(), (i + 1))) } time.Sleep(timeSleepBetweenRequests * time.Duration(i+1)) } if err != nil { message := "Unable to send the request " + err.Error() logging.Logger().Warn(message) return nil, errors.New(message) } // check for the returning http status statusCode := resp.StatusCode if statusCode >= 400 { body, err := resp.Body.ToString() if err != nil { message := "Server response with error can not be parsed " + err.Error() logging.Logger().Warn(message) return nil, errors.New(message) } return nil, errorMessage(statusCode, body) } return resp, nil }
[ "func", "(", "cli", "*", "OpsGenieClient", ")", "sendRequest", "(", "req", "goreq", ".", "Request", ")", "(", "*", "goreq", ".", "Response", ",", "error", ")", "{", "// send the request", "var", "resp", "*", "goreq", ".", "Response", "\n", "var", "err", "error", "\n", "for", "i", ":=", "0", ";", "i", "<", "cli", ".", "httpTransportSettings", ".", "MaxRetryAttempts", ";", "i", "++", "{", "resp", ",", "err", "=", "req", ".", "Do", "(", ")", "\n", "if", "err", "==", "nil", "&&", "resp", ".", "StatusCode", "<", "500", "{", "break", "\n", "}", "\n", "if", "resp", "!=", "nil", "{", "defer", "resp", ".", "Body", ".", "Close", "(", ")", "\n", "logging", ".", "Logger", "(", ")", ".", "Info", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "req", ".", "Uri", ",", "resp", ".", "StatusCode", ",", "(", "i", "+", "1", ")", ")", ")", "\n", "}", "else", "{", "logging", ".", "Logger", "(", ")", ".", "Info", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "req", ".", "Uri", ",", "err", ".", "Error", "(", ")", ",", "(", "i", "+", "1", ")", ")", ")", "\n", "}", "\n", "time", ".", "Sleep", "(", "timeSleepBetweenRequests", "*", "time", ".", "Duration", "(", "i", "+", "1", ")", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "message", ":=", "\"", "\"", "+", "err", ".", "Error", "(", ")", "\n", "logging", ".", "Logger", "(", ")", ".", "Warn", "(", "message", ")", "\n", "return", "nil", ",", "errors", ".", "New", "(", "message", ")", "\n", "}", "\n", "// check for the returning http status", "statusCode", ":=", "resp", ".", "StatusCode", "\n", "if", "statusCode", ">=", "400", "{", "body", ",", "err", ":=", "resp", ".", "Body", ".", "ToString", "(", ")", "\n", "if", "err", "!=", "nil", "{", "message", ":=", "\"", "\"", "+", "err", ".", "Error", "(", ")", "\n", "logging", ".", "Logger", "(", ")", ".", "Warn", "(", "message", ")", "\n", "return", "nil", ",", "errors", ".", "New", "(", "message", ")", "\n", "}", "\n", "return", "nil", ",", "errorMessage", "(", "statusCode", ",", "body", ")", "\n", "}", "\n", "return", "resp", ",", "nil", "\n", "}" ]
// sendRequest is an internal method to send the prepared requests to OpsGenie.
[ "sendRequest", "is", "an", "internal", "method", "to", "send", "the", "prepared", "requests", "to", "OpsGenie", "." ]
d57b8391ca905cccc085a075a2f7c1308d01cca3
https://github.com/opsgenie/opsgenie-go-sdk/blob/d57b8391ca905cccc085a075a2f7c1308d01cca3/client/client.go#L548-L582
13,707
opsgenie/opsgenie-go-sdk
client/client.go
errorMessage
func errorMessage(httpStatusCode int, responseBody string) error { if httpStatusCode >= 400 && httpStatusCode < 500 { message := fmt.Sprintf("Client error occurred; Response Code: %d, Response Body: %s", httpStatusCode, responseBody) logging.Logger().Warn(message) return errors.New(message) } if httpStatusCode >= 500 { message := fmt.Sprintf("Server error occurred; Response Code: %d, Response Body: %s", httpStatusCode, responseBody) logging.Logger().Info(message) return errors.New(message) } return nil }
go
func errorMessage(httpStatusCode int, responseBody string) error { if httpStatusCode >= 400 && httpStatusCode < 500 { message := fmt.Sprintf("Client error occurred; Response Code: %d, Response Body: %s", httpStatusCode, responseBody) logging.Logger().Warn(message) return errors.New(message) } if httpStatusCode >= 500 { message := fmt.Sprintf("Server error occurred; Response Code: %d, Response Body: %s", httpStatusCode, responseBody) logging.Logger().Info(message) return errors.New(message) } return nil }
[ "func", "errorMessage", "(", "httpStatusCode", "int", ",", "responseBody", "string", ")", "error", "{", "if", "httpStatusCode", ">=", "400", "&&", "httpStatusCode", "<", "500", "{", "message", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "httpStatusCode", ",", "responseBody", ")", "\n", "logging", ".", "Logger", "(", ")", ".", "Warn", "(", "message", ")", "\n", "return", "errors", ".", "New", "(", "message", ")", "\n", "}", "\n", "if", "httpStatusCode", ">=", "500", "{", "message", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "httpStatusCode", ",", "responseBody", ")", "\n", "logging", ".", "Logger", "(", ")", ".", "Info", "(", "message", ")", "\n", "return", "errors", ".", "New", "(", "message", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// errorMessage is an internal method to return formatted error message according to HTTP status code of the response.
[ "errorMessage", "is", "an", "internal", "method", "to", "return", "formatted", "error", "message", "according", "to", "HTTP", "status", "code", "of", "the", "response", "." ]
d57b8391ca905cccc085a075a2f7c1308d01cca3
https://github.com/opsgenie/opsgenie-go-sdk/blob/d57b8391ca905cccc085a075a2f7c1308d01cca3/client/client.go#L585-L597
13,708
opsgenie/opsgenie-go-sdk
userv2/list_user_schedules_request.go
GenerateUrl
func (r *ListUserSchedulesRequest) GenerateUrl() (string, url.Values, error) { baseUrl, params, err := r.Identifier.GenerateUrl() if err != nil { return "", nil, err } return baseUrl + "/schedules", params, err; }
go
func (r *ListUserSchedulesRequest) GenerateUrl() (string, url.Values, error) { baseUrl, params, err := r.Identifier.GenerateUrl() if err != nil { return "", nil, err } return baseUrl + "/schedules", params, err; }
[ "func", "(", "r", "*", "ListUserSchedulesRequest", ")", "GenerateUrl", "(", ")", "(", "string", ",", "url", ".", "Values", ",", "error", ")", "{", "baseUrl", ",", "params", ",", "err", ":=", "r", ".", "Identifier", ".", "GenerateUrl", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "nil", ",", "err", "\n", "}", "\n", "return", "baseUrl", "+", "\"", "\"", ",", "params", ",", "err", ";", "}" ]
// GenerateUrl generates API url using specified attributes of identifier.
[ "GenerateUrl", "generates", "API", "url", "using", "specified", "attributes", "of", "identifier", "." ]
d57b8391ca905cccc085a075a2f7c1308d01cca3
https://github.com/opsgenie/opsgenie-go-sdk/blob/d57b8391ca905cccc085a075a2f7c1308d01cca3/userv2/list_user_schedules_request.go#L17-L24
13,709
safchain/ethtool
ethtool.go
DriverName
func (e *Ethtool) DriverName(intf string) (string, error) { info, err := e.getDriverInfo(intf) if err != nil { return "", err } return string(bytes.Trim(info.driver[:], "\x00")), nil }
go
func (e *Ethtool) DriverName(intf string) (string, error) { info, err := e.getDriverInfo(intf) if err != nil { return "", err } return string(bytes.Trim(info.driver[:], "\x00")), nil }
[ "func", "(", "e", "*", "Ethtool", ")", "DriverName", "(", "intf", "string", ")", "(", "string", ",", "error", ")", "{", "info", ",", "err", ":=", "e", ".", "getDriverInfo", "(", "intf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "string", "(", "bytes", ".", "Trim", "(", "info", ".", "driver", "[", ":", "]", ",", "\"", "\\x00", "\"", ")", ")", ",", "nil", "\n", "}" ]
// DriverName returns the driver name of the given interface name.
[ "DriverName", "returns", "the", "driver", "name", "of", "the", "given", "interface", "name", "." ]
42ed695e3de80b9d695f280295fd7994639f209d
https://github.com/safchain/ethtool/blob/42ed695e3de80b9d695f280295fd7994639f209d/ethtool.go#L177-L183
13,710
safchain/ethtool
ethtool.go
BusInfo
func (e *Ethtool) BusInfo(intf string) (string, error) { info, err := e.getDriverInfo(intf) if err != nil { return "", err } return string(bytes.Trim(info.bus_info[:], "\x00")), nil }
go
func (e *Ethtool) BusInfo(intf string) (string, error) { info, err := e.getDriverInfo(intf) if err != nil { return "", err } return string(bytes.Trim(info.bus_info[:], "\x00")), nil }
[ "func", "(", "e", "*", "Ethtool", ")", "BusInfo", "(", "intf", "string", ")", "(", "string", ",", "error", ")", "{", "info", ",", "err", ":=", "e", ".", "getDriverInfo", "(", "intf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "string", "(", "bytes", ".", "Trim", "(", "info", ".", "bus_info", "[", ":", "]", ",", "\"", "\\x00", "\"", ")", ")", ",", "nil", "\n", "}" ]
// BusInfo returns the bus information of the given interface name.
[ "BusInfo", "returns", "the", "bus", "information", "of", "the", "given", "interface", "name", "." ]
42ed695e3de80b9d695f280295fd7994639f209d
https://github.com/safchain/ethtool/blob/42ed695e3de80b9d695f280295fd7994639f209d/ethtool.go#L186-L192
13,711
safchain/ethtool
ethtool.go
DriverInfo
func (e *Ethtool) DriverInfo(intf string) (ethtoolDrvInfo, error) { drvInfo, err := e.getDriverInfo(intf) if err != nil { return ethtoolDrvInfo{}, err } return drvInfo, nil }
go
func (e *Ethtool) DriverInfo(intf string) (ethtoolDrvInfo, error) { drvInfo, err := e.getDriverInfo(intf) if err != nil { return ethtoolDrvInfo{}, err } return drvInfo, nil }
[ "func", "(", "e", "*", "Ethtool", ")", "DriverInfo", "(", "intf", "string", ")", "(", "ethtoolDrvInfo", ",", "error", ")", "{", "drvInfo", ",", "err", ":=", "e", ".", "getDriverInfo", "(", "intf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ethtoolDrvInfo", "{", "}", ",", "err", "\n", "}", "\n\n", "return", "drvInfo", ",", "nil", "\n", "}" ]
// DriverInfo returns driver information of the given interface name.
[ "DriverInfo", "returns", "driver", "information", "of", "the", "given", "interface", "name", "." ]
42ed695e3de80b9d695f280295fd7994639f209d
https://github.com/safchain/ethtool/blob/42ed695e3de80b9d695f280295fd7994639f209d/ethtool.go#L215-L222
13,712
safchain/ethtool
ethtool.go
PermAddr
func (e *Ethtool) PermAddr(intf string) (string, error) { permAddr, err := e.getPermAddr(intf) if err != nil { return "", err } if permAddr.data[0] == 0 && permAddr.data[1] == 0 && permAddr.data[2] == 0 && permAddr.data[3] == 0 && permAddr.data[4] == 0 && permAddr.data[5] == 0 { return "", nil } return fmt.Sprintf("%x:%x:%x:%x:%x:%x", permAddr.data[0:1], permAddr.data[1:2], permAddr.data[2:3], permAddr.data[3:4], permAddr.data[4:5], permAddr.data[5:6], ), nil }
go
func (e *Ethtool) PermAddr(intf string) (string, error) { permAddr, err := e.getPermAddr(intf) if err != nil { return "", err } if permAddr.data[0] == 0 && permAddr.data[1] == 0 && permAddr.data[2] == 0 && permAddr.data[3] == 0 && permAddr.data[4] == 0 && permAddr.data[5] == 0 { return "", nil } return fmt.Sprintf("%x:%x:%x:%x:%x:%x", permAddr.data[0:1], permAddr.data[1:2], permAddr.data[2:3], permAddr.data[3:4], permAddr.data[4:5], permAddr.data[5:6], ), nil }
[ "func", "(", "e", "*", "Ethtool", ")", "PermAddr", "(", "intf", "string", ")", "(", "string", ",", "error", ")", "{", "permAddr", ",", "err", ":=", "e", ".", "getPermAddr", "(", "intf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "if", "permAddr", ".", "data", "[", "0", "]", "==", "0", "&&", "permAddr", ".", "data", "[", "1", "]", "==", "0", "&&", "permAddr", ".", "data", "[", "2", "]", "==", "0", "&&", "permAddr", ".", "data", "[", "3", "]", "==", "0", "&&", "permAddr", ".", "data", "[", "4", "]", "==", "0", "&&", "permAddr", ".", "data", "[", "5", "]", "==", "0", "{", "return", "\"", "\"", ",", "nil", "\n", "}", "\n\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "permAddr", ".", "data", "[", "0", ":", "1", "]", ",", "permAddr", ".", "data", "[", "1", ":", "2", "]", ",", "permAddr", ".", "data", "[", "2", ":", "3", "]", ",", "permAddr", ".", "data", "[", "3", ":", "4", "]", ",", "permAddr", ".", "data", "[", "4", ":", "5", "]", ",", "permAddr", ".", "data", "[", "5", ":", "6", "]", ",", ")", ",", "nil", "\n", "}" ]
// PermAddr returns permanent address of the given interface name.
[ "PermAddr", "returns", "permanent", "address", "of", "the", "given", "interface", "name", "." ]
42ed695e3de80b9d695f280295fd7994639f209d
https://github.com/safchain/ethtool/blob/42ed695e3de80b9d695f280295fd7994639f209d/ethtool.go#L225-L245
13,713
safchain/ethtool
ethtool.go
FeatureNames
func (e *Ethtool) FeatureNames(intf string) (map[string]uint, error) { ssetInfo := ethtoolSsetInfo{ cmd: ETHTOOL_GSSET_INFO, sset_mask: 1 << ETH_SS_FEATURES, } if err := e.ioctl(intf, uintptr(unsafe.Pointer(&ssetInfo))); err != nil { return nil, err } length := uint32(ssetInfo.data) if length == 0 { return map[string]uint{}, nil } else if length > MAX_GSTRINGS { return nil, fmt.Errorf("ethtool currently doesn't support more than %d entries, received %d", MAX_GSTRINGS, length) } gstrings := ethtoolGStrings{ cmd: ETHTOOL_GSTRINGS, string_set: ETH_SS_FEATURES, len: length, data: [MAX_GSTRINGS * ETH_GSTRING_LEN]byte{}, } if err := e.ioctl(intf, uintptr(unsafe.Pointer(&gstrings))); err != nil { return nil, err } var result = make(map[string]uint) for i := 0; i != int(length); i++ { b := gstrings.data[i*ETH_GSTRING_LEN : i*ETH_GSTRING_LEN+ETH_GSTRING_LEN] key := string(bytes.Trim(b, "\x00")) if key != "" { result[key] = uint(i) } } return result, nil }
go
func (e *Ethtool) FeatureNames(intf string) (map[string]uint, error) { ssetInfo := ethtoolSsetInfo{ cmd: ETHTOOL_GSSET_INFO, sset_mask: 1 << ETH_SS_FEATURES, } if err := e.ioctl(intf, uintptr(unsafe.Pointer(&ssetInfo))); err != nil { return nil, err } length := uint32(ssetInfo.data) if length == 0 { return map[string]uint{}, nil } else if length > MAX_GSTRINGS { return nil, fmt.Errorf("ethtool currently doesn't support more than %d entries, received %d", MAX_GSTRINGS, length) } gstrings := ethtoolGStrings{ cmd: ETHTOOL_GSTRINGS, string_set: ETH_SS_FEATURES, len: length, data: [MAX_GSTRINGS * ETH_GSTRING_LEN]byte{}, } if err := e.ioctl(intf, uintptr(unsafe.Pointer(&gstrings))); err != nil { return nil, err } var result = make(map[string]uint) for i := 0; i != int(length); i++ { b := gstrings.data[i*ETH_GSTRING_LEN : i*ETH_GSTRING_LEN+ETH_GSTRING_LEN] key := string(bytes.Trim(b, "\x00")) if key != "" { result[key] = uint(i) } } return result, nil }
[ "func", "(", "e", "*", "Ethtool", ")", "FeatureNames", "(", "intf", "string", ")", "(", "map", "[", "string", "]", "uint", ",", "error", ")", "{", "ssetInfo", ":=", "ethtoolSsetInfo", "{", "cmd", ":", "ETHTOOL_GSSET_INFO", ",", "sset_mask", ":", "1", "<<", "ETH_SS_FEATURES", ",", "}", "\n\n", "if", "err", ":=", "e", ".", "ioctl", "(", "intf", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "ssetInfo", ")", ")", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "length", ":=", "uint32", "(", "ssetInfo", ".", "data", ")", "\n", "if", "length", "==", "0", "{", "return", "map", "[", "string", "]", "uint", "{", "}", ",", "nil", "\n", "}", "else", "if", "length", ">", "MAX_GSTRINGS", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "MAX_GSTRINGS", ",", "length", ")", "\n", "}", "\n\n", "gstrings", ":=", "ethtoolGStrings", "{", "cmd", ":", "ETHTOOL_GSTRINGS", ",", "string_set", ":", "ETH_SS_FEATURES", ",", "len", ":", "length", ",", "data", ":", "[", "MAX_GSTRINGS", "*", "ETH_GSTRING_LEN", "]", "byte", "{", "}", ",", "}", "\n\n", "if", "err", ":=", "e", ".", "ioctl", "(", "intf", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "gstrings", ")", ")", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "result", "=", "make", "(", "map", "[", "string", "]", "uint", ")", "\n", "for", "i", ":=", "0", ";", "i", "!=", "int", "(", "length", ")", ";", "i", "++", "{", "b", ":=", "gstrings", ".", "data", "[", "i", "*", "ETH_GSTRING_LEN", ":", "i", "*", "ETH_GSTRING_LEN", "+", "ETH_GSTRING_LEN", "]", "\n", "key", ":=", "string", "(", "bytes", ".", "Trim", "(", "b", ",", "\"", "\\x00", "\"", ")", ")", "\n", "if", "key", "!=", "\"", "\"", "{", "result", "[", "key", "]", "=", "uint", "(", "i", ")", "\n", "}", "\n", "}", "\n\n", "return", "result", ",", "nil", "\n", "}" ]
// FeatureNames shows supported features by their name.
[ "FeatureNames", "shows", "supported", "features", "by", "their", "name", "." ]
42ed695e3de80b9d695f280295fd7994639f209d
https://github.com/safchain/ethtool/blob/42ed695e3de80b9d695f280295fd7994639f209d/ethtool.go#L332-L370
13,714
safchain/ethtool
ethtool.go
Features
func (e *Ethtool) Features(intf string) (map[string]bool, error) { names, err := e.FeatureNames(intf) if err != nil { return nil, err } length := uint32(len(names)) if length == 0 { return map[string]bool{}, nil } features := ethtoolGfeatures{ cmd: ETHTOOL_GFEATURES, size: (length + 32 - 1) / 32, } if err := e.ioctl(intf, uintptr(unsafe.Pointer(&features))); err != nil { return nil, err } var result = make(map[string]bool, length) for key, index := range names { result[key] = isFeatureBitSet(features.blocks, index) } return result, nil }
go
func (e *Ethtool) Features(intf string) (map[string]bool, error) { names, err := e.FeatureNames(intf) if err != nil { return nil, err } length := uint32(len(names)) if length == 0 { return map[string]bool{}, nil } features := ethtoolGfeatures{ cmd: ETHTOOL_GFEATURES, size: (length + 32 - 1) / 32, } if err := e.ioctl(intf, uintptr(unsafe.Pointer(&features))); err != nil { return nil, err } var result = make(map[string]bool, length) for key, index := range names { result[key] = isFeatureBitSet(features.blocks, index) } return result, nil }
[ "func", "(", "e", "*", "Ethtool", ")", "Features", "(", "intf", "string", ")", "(", "map", "[", "string", "]", "bool", ",", "error", ")", "{", "names", ",", "err", ":=", "e", ".", "FeatureNames", "(", "intf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "length", ":=", "uint32", "(", "len", "(", "names", ")", ")", "\n", "if", "length", "==", "0", "{", "return", "map", "[", "string", "]", "bool", "{", "}", ",", "nil", "\n", "}", "\n\n", "features", ":=", "ethtoolGfeatures", "{", "cmd", ":", "ETHTOOL_GFEATURES", ",", "size", ":", "(", "length", "+", "32", "-", "1", ")", "/", "32", ",", "}", "\n\n", "if", "err", ":=", "e", ".", "ioctl", "(", "intf", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "features", ")", ")", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "result", "=", "make", "(", "map", "[", "string", "]", "bool", ",", "length", ")", "\n", "for", "key", ",", "index", ":=", "range", "names", "{", "result", "[", "key", "]", "=", "isFeatureBitSet", "(", "features", ".", "blocks", ",", "index", ")", "\n", "}", "\n\n", "return", "result", ",", "nil", "\n", "}" ]
// Features retrieves features of the given interface name.
[ "Features", "retrieves", "features", "of", "the", "given", "interface", "name", "." ]
42ed695e3de80b9d695f280295fd7994639f209d
https://github.com/safchain/ethtool/blob/42ed695e3de80b9d695f280295fd7994639f209d/ethtool.go#L373-L399
13,715
safchain/ethtool
ethtool.go
Change
func (e *Ethtool) Change(intf string, config map[string]bool) error { names, err := e.FeatureNames(intf) if err != nil { return err } length := uint32(len(names)) features := ethtoolSfeatures{ cmd: ETHTOOL_SFEATURES, size: (length + 32 - 1) / 32, } for key, value := range config { if index, ok := names[key]; ok { setFeatureBit(&features.blocks, index, value) } else { return fmt.Errorf("unsupported feature %q", key) } } return e.ioctl(intf, uintptr(unsafe.Pointer(&features))) }
go
func (e *Ethtool) Change(intf string, config map[string]bool) error { names, err := e.FeatureNames(intf) if err != nil { return err } length := uint32(len(names)) features := ethtoolSfeatures{ cmd: ETHTOOL_SFEATURES, size: (length + 32 - 1) / 32, } for key, value := range config { if index, ok := names[key]; ok { setFeatureBit(&features.blocks, index, value) } else { return fmt.Errorf("unsupported feature %q", key) } } return e.ioctl(intf, uintptr(unsafe.Pointer(&features))) }
[ "func", "(", "e", "*", "Ethtool", ")", "Change", "(", "intf", "string", ",", "config", "map", "[", "string", "]", "bool", ")", "error", "{", "names", ",", "err", ":=", "e", ".", "FeatureNames", "(", "intf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "length", ":=", "uint32", "(", "len", "(", "names", ")", ")", "\n\n", "features", ":=", "ethtoolSfeatures", "{", "cmd", ":", "ETHTOOL_SFEATURES", ",", "size", ":", "(", "length", "+", "32", "-", "1", ")", "/", "32", ",", "}", "\n\n", "for", "key", ",", "value", ":=", "range", "config", "{", "if", "index", ",", "ok", ":=", "names", "[", "key", "]", ";", "ok", "{", "setFeatureBit", "(", "&", "features", ".", "blocks", ",", "index", ",", "value", ")", "\n", "}", "else", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "key", ")", "\n", "}", "\n", "}", "\n\n", "return", "e", ".", "ioctl", "(", "intf", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "features", ")", ")", ")", "\n", "}" ]
// Change requests a change in the given device's features.
[ "Change", "requests", "a", "change", "in", "the", "given", "device", "s", "features", "." ]
42ed695e3de80b9d695f280295fd7994639f209d
https://github.com/safchain/ethtool/blob/42ed695e3de80b9d695f280295fd7994639f209d/ethtool.go#L402-L424
13,716
safchain/ethtool
ethtool.go
LinkState
func (e *Ethtool) LinkState(intf string) (uint32, error) { x := ethtoolLink{ cmd: ETHTOOL_GLINK, } if err := e.ioctl(intf, uintptr(unsafe.Pointer(&x))); err != nil { return 0, err } return x.data, nil }
go
func (e *Ethtool) LinkState(intf string) (uint32, error) { x := ethtoolLink{ cmd: ETHTOOL_GLINK, } if err := e.ioctl(intf, uintptr(unsafe.Pointer(&x))); err != nil { return 0, err } return x.data, nil }
[ "func", "(", "e", "*", "Ethtool", ")", "LinkState", "(", "intf", "string", ")", "(", "uint32", ",", "error", ")", "{", "x", ":=", "ethtoolLink", "{", "cmd", ":", "ETHTOOL_GLINK", ",", "}", "\n\n", "if", "err", ":=", "e", ".", "ioctl", "(", "intf", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "x", ")", ")", ")", ";", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n\n", "return", "x", ".", "data", ",", "nil", "\n", "}" ]
// Get state of a link.
[ "Get", "state", "of", "a", "link", "." ]
42ed695e3de80b9d695f280295fd7994639f209d
https://github.com/safchain/ethtool/blob/42ed695e3de80b9d695f280295fd7994639f209d/ethtool.go#L427-L437
13,717
safchain/ethtool
ethtool.go
Stats
func (e *Ethtool) Stats(intf string) (map[string]uint64, error) { drvinfo := ethtoolDrvInfo{ cmd: ETHTOOL_GDRVINFO, } if err := e.ioctl(intf, uintptr(unsafe.Pointer(&drvinfo))); err != nil { return nil, err } if drvinfo.n_stats*ETH_GSTRING_LEN > MAX_GSTRINGS*ETH_GSTRING_LEN { return nil, fmt.Errorf("ethtool currently doesn't support more than %d entries, received %d", MAX_GSTRINGS, drvinfo.n_stats) } gstrings := ethtoolGStrings{ cmd: ETHTOOL_GSTRINGS, string_set: ETH_SS_STATS, len: drvinfo.n_stats, data: [MAX_GSTRINGS * ETH_GSTRING_LEN]byte{}, } if err := e.ioctl(intf, uintptr(unsafe.Pointer(&gstrings))); err != nil { return nil, err } stats := ethtoolStats{ cmd: ETHTOOL_GSTATS, n_stats: drvinfo.n_stats, data: [MAX_GSTRINGS]uint64{}, } if err := e.ioctl(intf, uintptr(unsafe.Pointer(&stats))); err != nil { return nil, err } var result = make(map[string]uint64) for i := 0; i != int(drvinfo.n_stats); i++ { b := gstrings.data[i*ETH_GSTRING_LEN : i*ETH_GSTRING_LEN+ETH_GSTRING_LEN] key := string(b[:strings.Index(string(b), "\x00")]) if len(key) != 0 { result[key] = stats.data[i] } } return result, nil }
go
func (e *Ethtool) Stats(intf string) (map[string]uint64, error) { drvinfo := ethtoolDrvInfo{ cmd: ETHTOOL_GDRVINFO, } if err := e.ioctl(intf, uintptr(unsafe.Pointer(&drvinfo))); err != nil { return nil, err } if drvinfo.n_stats*ETH_GSTRING_LEN > MAX_GSTRINGS*ETH_GSTRING_LEN { return nil, fmt.Errorf("ethtool currently doesn't support more than %d entries, received %d", MAX_GSTRINGS, drvinfo.n_stats) } gstrings := ethtoolGStrings{ cmd: ETHTOOL_GSTRINGS, string_set: ETH_SS_STATS, len: drvinfo.n_stats, data: [MAX_GSTRINGS * ETH_GSTRING_LEN]byte{}, } if err := e.ioctl(intf, uintptr(unsafe.Pointer(&gstrings))); err != nil { return nil, err } stats := ethtoolStats{ cmd: ETHTOOL_GSTATS, n_stats: drvinfo.n_stats, data: [MAX_GSTRINGS]uint64{}, } if err := e.ioctl(intf, uintptr(unsafe.Pointer(&stats))); err != nil { return nil, err } var result = make(map[string]uint64) for i := 0; i != int(drvinfo.n_stats); i++ { b := gstrings.data[i*ETH_GSTRING_LEN : i*ETH_GSTRING_LEN+ETH_GSTRING_LEN] key := string(b[:strings.Index(string(b), "\x00")]) if len(key) != 0 { result[key] = stats.data[i] } } return result, nil }
[ "func", "(", "e", "*", "Ethtool", ")", "Stats", "(", "intf", "string", ")", "(", "map", "[", "string", "]", "uint64", ",", "error", ")", "{", "drvinfo", ":=", "ethtoolDrvInfo", "{", "cmd", ":", "ETHTOOL_GDRVINFO", ",", "}", "\n\n", "if", "err", ":=", "e", ".", "ioctl", "(", "intf", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "drvinfo", ")", ")", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "drvinfo", ".", "n_stats", "*", "ETH_GSTRING_LEN", ">", "MAX_GSTRINGS", "*", "ETH_GSTRING_LEN", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "MAX_GSTRINGS", ",", "drvinfo", ".", "n_stats", ")", "\n", "}", "\n\n", "gstrings", ":=", "ethtoolGStrings", "{", "cmd", ":", "ETHTOOL_GSTRINGS", ",", "string_set", ":", "ETH_SS_STATS", ",", "len", ":", "drvinfo", ".", "n_stats", ",", "data", ":", "[", "MAX_GSTRINGS", "*", "ETH_GSTRING_LEN", "]", "byte", "{", "}", ",", "}", "\n\n", "if", "err", ":=", "e", ".", "ioctl", "(", "intf", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "gstrings", ")", ")", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "stats", ":=", "ethtoolStats", "{", "cmd", ":", "ETHTOOL_GSTATS", ",", "n_stats", ":", "drvinfo", ".", "n_stats", ",", "data", ":", "[", "MAX_GSTRINGS", "]", "uint64", "{", "}", ",", "}", "\n\n", "if", "err", ":=", "e", ".", "ioctl", "(", "intf", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "stats", ")", ")", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "result", "=", "make", "(", "map", "[", "string", "]", "uint64", ")", "\n", "for", "i", ":=", "0", ";", "i", "!=", "int", "(", "drvinfo", ".", "n_stats", ")", ";", "i", "++", "{", "b", ":=", "gstrings", ".", "data", "[", "i", "*", "ETH_GSTRING_LEN", ":", "i", "*", "ETH_GSTRING_LEN", "+", "ETH_GSTRING_LEN", "]", "\n", "key", ":=", "string", "(", "b", "[", ":", "strings", ".", "Index", "(", "string", "(", "b", ")", ",", "\"", "\\x00", "\"", ")", "]", ")", "\n", "if", "len", "(", "key", ")", "!=", "0", "{", "result", "[", "key", "]", "=", "stats", ".", "data", "[", "i", "]", "\n", "}", "\n", "}", "\n\n", "return", "result", ",", "nil", "\n", "}" ]
// Stats retrieves stats of the given interface name.
[ "Stats", "retrieves", "stats", "of", "the", "given", "interface", "name", "." ]
42ed695e3de80b9d695f280295fd7994639f209d
https://github.com/safchain/ethtool/blob/42ed695e3de80b9d695f280295fd7994639f209d/ethtool.go#L440-L484
13,718
safchain/ethtool
ethtool.go
NewEthtool
func NewEthtool() (*Ethtool, error) { fd, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_DGRAM, syscall.IPPROTO_IP) if err != nil { return nil, err } return &Ethtool{ fd: int(fd), }, nil }
go
func NewEthtool() (*Ethtool, error) { fd, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_DGRAM, syscall.IPPROTO_IP) if err != nil { return nil, err } return &Ethtool{ fd: int(fd), }, nil }
[ "func", "NewEthtool", "(", ")", "(", "*", "Ethtool", ",", "error", ")", "{", "fd", ",", "err", ":=", "syscall", ".", "Socket", "(", "syscall", ".", "AF_INET", ",", "syscall", ".", "SOCK_DGRAM", ",", "syscall", ".", "IPPROTO_IP", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "Ethtool", "{", "fd", ":", "int", "(", "fd", ")", ",", "}", ",", "nil", "\n", "}" ]
// NewEthtool returns a new ethtool handler
[ "NewEthtool", "returns", "a", "new", "ethtool", "handler" ]
42ed695e3de80b9d695f280295fd7994639f209d
https://github.com/safchain/ethtool/blob/42ed695e3de80b9d695f280295fd7994639f209d/ethtool.go#L492-L501
13,719
safchain/ethtool
ethtool.go
BusInfo
func BusInfo(intf string) (string, error) { e, err := NewEthtool() if err != nil { return "", err } defer e.Close() return e.BusInfo(intf) }
go
func BusInfo(intf string) (string, error) { e, err := NewEthtool() if err != nil { return "", err } defer e.Close() return e.BusInfo(intf) }
[ "func", "BusInfo", "(", "intf", "string", ")", "(", "string", ",", "error", ")", "{", "e", ",", "err", ":=", "NewEthtool", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "defer", "e", ".", "Close", "(", ")", "\n", "return", "e", ".", "BusInfo", "(", "intf", ")", "\n", "}" ]
// BusInfo returns bus information of the given interface name.
[ "BusInfo", "returns", "bus", "information", "of", "the", "given", "interface", "name", "." ]
42ed695e3de80b9d695f280295fd7994639f209d
https://github.com/safchain/ethtool/blob/42ed695e3de80b9d695f280295fd7994639f209d/ethtool.go#L504-L511
13,720
safchain/ethtool
ethtool_cmd.go
CmdSet
func (ecmd *EthtoolCmd) CmdSet(intf string) (uint32, error) { e, err := NewEthtool() if err != nil { return 0, err } defer e.Close() return e.CmdSet(ecmd, intf) }
go
func (ecmd *EthtoolCmd) CmdSet(intf string) (uint32, error) { e, err := NewEthtool() if err != nil { return 0, err } defer e.Close() return e.CmdSet(ecmd, intf) }
[ "func", "(", "ecmd", "*", "EthtoolCmd", ")", "CmdSet", "(", "intf", "string", ")", "(", "uint32", ",", "error", ")", "{", "e", ",", "err", ":=", "NewEthtool", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "defer", "e", ".", "Close", "(", ")", "\n", "return", "e", ".", "CmdSet", "(", "ecmd", ",", "intf", ")", "\n", "}" ]
// CmdSet sets and returns the settings in the receiver struct // and returns speed
[ "CmdSet", "sets", "and", "returns", "the", "settings", "in", "the", "receiver", "struct", "and", "returns", "speed" ]
42ed695e3de80b9d695f280295fd7994639f209d
https://github.com/safchain/ethtool/blob/42ed695e3de80b9d695f280295fd7994639f209d/ethtool_cmd.go#L68-L75
13,721
safchain/ethtool
ethtool_cmd.go
CmdGet
func (e *Ethtool) CmdGet(ecmd *EthtoolCmd, intf string) (uint32, error) { ecmd.Cmd = ETHTOOL_GSET var name [IFNAMSIZ]byte copy(name[:], []byte(intf)) ifr := ifreq{ ifr_name: name, ifr_data: uintptr(unsafe.Pointer(ecmd)), } _, _, ep := syscall.Syscall(syscall.SYS_IOCTL, uintptr(e.fd), SIOCETHTOOL, uintptr(unsafe.Pointer(&ifr))) if ep != 0 { return 0, syscall.Errno(ep) } var speedval uint32 = (uint32(ecmd.Speed_hi) << 16) | (uint32(ecmd.Speed) & 0xffff) if speedval == math.MaxUint16 { speedval = math.MaxUint32 } return speedval, nil }
go
func (e *Ethtool) CmdGet(ecmd *EthtoolCmd, intf string) (uint32, error) { ecmd.Cmd = ETHTOOL_GSET var name [IFNAMSIZ]byte copy(name[:], []byte(intf)) ifr := ifreq{ ifr_name: name, ifr_data: uintptr(unsafe.Pointer(ecmd)), } _, _, ep := syscall.Syscall(syscall.SYS_IOCTL, uintptr(e.fd), SIOCETHTOOL, uintptr(unsafe.Pointer(&ifr))) if ep != 0 { return 0, syscall.Errno(ep) } var speedval uint32 = (uint32(ecmd.Speed_hi) << 16) | (uint32(ecmd.Speed) & 0xffff) if speedval == math.MaxUint16 { speedval = math.MaxUint32 } return speedval, nil }
[ "func", "(", "e", "*", "Ethtool", ")", "CmdGet", "(", "ecmd", "*", "EthtoolCmd", ",", "intf", "string", ")", "(", "uint32", ",", "error", ")", "{", "ecmd", ".", "Cmd", "=", "ETHTOOL_GSET", "\n\n", "var", "name", "[", "IFNAMSIZ", "]", "byte", "\n", "copy", "(", "name", "[", ":", "]", ",", "[", "]", "byte", "(", "intf", ")", ")", "\n\n", "ifr", ":=", "ifreq", "{", "ifr_name", ":", "name", ",", "ifr_data", ":", "uintptr", "(", "unsafe", ".", "Pointer", "(", "ecmd", ")", ")", ",", "}", "\n\n", "_", ",", "_", ",", "ep", ":=", "syscall", ".", "Syscall", "(", "syscall", ".", "SYS_IOCTL", ",", "uintptr", "(", "e", ".", "fd", ")", ",", "SIOCETHTOOL", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "ifr", ")", ")", ")", "\n", "if", "ep", "!=", "0", "{", "return", "0", ",", "syscall", ".", "Errno", "(", "ep", ")", "\n", "}", "\n\n", "var", "speedval", "uint32", "=", "(", "uint32", "(", "ecmd", ".", "Speed_hi", ")", "<<", "16", ")", "|", "(", "uint32", "(", "ecmd", ".", "Speed", ")", "&", "0xffff", ")", "\n", "if", "speedval", "==", "math", ".", "MaxUint16", "{", "speedval", "=", "math", ".", "MaxUint32", "\n", "}", "\n\n", "return", "speedval", ",", "nil", "\n", "}" ]
// CmdGet returns the interface settings in the receiver struct // and returns speed
[ "CmdGet", "returns", "the", "interface", "settings", "in", "the", "receiver", "struct", "and", "returns", "speed" ]
42ed695e3de80b9d695f280295fd7994639f209d
https://github.com/safchain/ethtool/blob/42ed695e3de80b9d695f280295fd7994639f209d/ethtool_cmd.go#L113-L137
13,722
safchain/ethtool
ethtool_cmd.go
CmdGetMapped
func (e *Ethtool) CmdGetMapped(intf string) (map[string]uint64, error) { ecmd := EthtoolCmd{ Cmd: ETHTOOL_GSET, } var name [IFNAMSIZ]byte copy(name[:], []byte(intf)) ifr := ifreq{ ifr_name: name, ifr_data: uintptr(unsafe.Pointer(&ecmd)), } _, _, ep := syscall.Syscall(syscall.SYS_IOCTL, uintptr(e.fd), SIOCETHTOOL, uintptr(unsafe.Pointer(&ifr))) if ep != 0 { return nil, syscall.Errno(ep) } var result = make(map[string]uint64) // ref https://gist.github.com/drewolson/4771479 // Golang Reflection Example ecmd.reflect(&result) var speedval uint32 = (uint32(ecmd.Speed_hi) << 16) | (uint32(ecmd.Speed) & 0xffff) result["speed"] = uint64(speedval) return result, nil }
go
func (e *Ethtool) CmdGetMapped(intf string) (map[string]uint64, error) { ecmd := EthtoolCmd{ Cmd: ETHTOOL_GSET, } var name [IFNAMSIZ]byte copy(name[:], []byte(intf)) ifr := ifreq{ ifr_name: name, ifr_data: uintptr(unsafe.Pointer(&ecmd)), } _, _, ep := syscall.Syscall(syscall.SYS_IOCTL, uintptr(e.fd), SIOCETHTOOL, uintptr(unsafe.Pointer(&ifr))) if ep != 0 { return nil, syscall.Errno(ep) } var result = make(map[string]uint64) // ref https://gist.github.com/drewolson/4771479 // Golang Reflection Example ecmd.reflect(&result) var speedval uint32 = (uint32(ecmd.Speed_hi) << 16) | (uint32(ecmd.Speed) & 0xffff) result["speed"] = uint64(speedval) return result, nil }
[ "func", "(", "e", "*", "Ethtool", ")", "CmdGetMapped", "(", "intf", "string", ")", "(", "map", "[", "string", "]", "uint64", ",", "error", ")", "{", "ecmd", ":=", "EthtoolCmd", "{", "Cmd", ":", "ETHTOOL_GSET", ",", "}", "\n\n", "var", "name", "[", "IFNAMSIZ", "]", "byte", "\n", "copy", "(", "name", "[", ":", "]", ",", "[", "]", "byte", "(", "intf", ")", ")", "\n\n", "ifr", ":=", "ifreq", "{", "ifr_name", ":", "name", ",", "ifr_data", ":", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "ecmd", ")", ")", ",", "}", "\n\n", "_", ",", "_", ",", "ep", ":=", "syscall", ".", "Syscall", "(", "syscall", ".", "SYS_IOCTL", ",", "uintptr", "(", "e", ".", "fd", ")", ",", "SIOCETHTOOL", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "ifr", ")", ")", ")", "\n", "if", "ep", "!=", "0", "{", "return", "nil", ",", "syscall", ".", "Errno", "(", "ep", ")", "\n", "}", "\n\n", "var", "result", "=", "make", "(", "map", "[", "string", "]", "uint64", ")", "\n\n", "// ref https://gist.github.com/drewolson/4771479", "// Golang Reflection Example", "ecmd", ".", "reflect", "(", "&", "result", ")", "\n\n", "var", "speedval", "uint32", "=", "(", "uint32", "(", "ecmd", ".", "Speed_hi", ")", "<<", "16", ")", "|", "(", "uint32", "(", "ecmd", ".", "Speed", ")", "&", "0xffff", ")", "\n", "result", "[", "\"", "\"", "]", "=", "uint64", "(", "speedval", ")", "\n\n", "return", "result", ",", "nil", "\n", "}" ]
// CmdGetMapped returns the interface settings in a map
[ "CmdGetMapped", "returns", "the", "interface", "settings", "in", "a", "map" ]
42ed695e3de80b9d695f280295fd7994639f209d
https://github.com/safchain/ethtool/blob/42ed695e3de80b9d695f280295fd7994639f209d/ethtool_cmd.go#L168-L198
13,723
mikeflynn/go-alexa
skillserver/skillserver.go
Run
func Run(apps map[string]interface{}, port string) { router := mux.NewRouter() initialize(apps, router) n := negroni.Classic() n.UseHandler(router) n.Run(":" + port) }
go
func Run(apps map[string]interface{}, port string) { router := mux.NewRouter() initialize(apps, router) n := negroni.Classic() n.UseHandler(router) n.Run(":" + port) }
[ "func", "Run", "(", "apps", "map", "[", "string", "]", "interface", "{", "}", ",", "port", "string", ")", "{", "router", ":=", "mux", ".", "NewRouter", "(", ")", "\n", "initialize", "(", "apps", ",", "router", ")", "\n\n", "n", ":=", "negroni", ".", "Classic", "(", ")", "\n", "n", ".", "UseHandler", "(", "router", ")", "\n", "n", ".", "Run", "(", "\"", "\"", "+", "port", ")", "\n", "}" ]
// Run will initialize the apps provided and start an HTTP server listening on the specified port.
[ "Run", "will", "initialize", "the", "apps", "provided", "and", "start", "an", "HTTP", "server", "listening", "on", "the", "specified", "port", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/skillserver.go#L72-L79
13,724
mikeflynn/go-alexa
skillserver/skillserver.go
GetEchoRequest
func GetEchoRequest(r *http.Request) *EchoRequest { return r.Context().Value(requestContextKey("echoRequest")).(*EchoRequest) }
go
func GetEchoRequest(r *http.Request) *EchoRequest { return r.Context().Value(requestContextKey("echoRequest")).(*EchoRequest) }
[ "func", "GetEchoRequest", "(", "r", "*", "http", ".", "Request", ")", "*", "EchoRequest", "{", "return", "r", ".", "Context", "(", ")", ".", "Value", "(", "requestContextKey", "(", "\"", "\"", ")", ")", ".", "(", "*", "EchoRequest", ")", "\n", "}" ]
// GetEchoRequest is a convenience method for retrieving and casting an `EchoRequest` out of a // standard `http.Request`.
[ "GetEchoRequest", "is", "a", "convenience", "method", "for", "retrieving", "and", "casting", "an", "EchoRequest", "out", "of", "a", "standard", "http", ".", "Request", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/skillserver.go#L188-L190
13,725
mikeflynn/go-alexa
skillserver/skillserver.go
HTTPError
func HTTPError(w http.ResponseWriter, logMsg string, err string, errCode int) { if logMsg != "" { log.Println(logMsg) } http.Error(w, err, errCode) }
go
func HTTPError(w http.ResponseWriter, logMsg string, err string, errCode int) { if logMsg != "" { log.Println(logMsg) } http.Error(w, err, errCode) }
[ "func", "HTTPError", "(", "w", "http", ".", "ResponseWriter", ",", "logMsg", "string", ",", "err", "string", ",", "errCode", "int", ")", "{", "if", "logMsg", "!=", "\"", "\"", "{", "log", ".", "Println", "(", "logMsg", ")", "\n", "}", "\n\n", "http", ".", "Error", "(", "w", ",", "err", ",", "errCode", ")", "\n", "}" ]
// HTTPError is a convenience method for logging a message and writing the provided error message // and error code to the HTTP response.
[ "HTTPError", "is", "a", "convenience", "method", "for", "logging", "a", "message", "and", "writing", "the", "provided", "error", "message", "and", "error", "code", "to", "the", "HTTP", "response", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/skillserver.go#L194-L200
13,726
mikeflynn/go-alexa
skillserver/skillserver.go
verifyJSON
func verifyJSON(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) { var echoReq *EchoRequest err := json.NewDecoder(r.Body).Decode(&echoReq) if err != nil { HTTPError(w, err.Error(), "Bad Request", 400) return } // Check the timestamp if !echoReq.VerifyTimestamp() && r.URL.Query().Get("_dev") == "" { HTTPError(w, "Request too old to continue (>150s).", "Bad Request", 400) return } // Check the app id if !echoReq.VerifyAppID(applications[r.URL.Path].(EchoApplication).AppID) { HTTPError(w, "Echo AppID mismatch!", "Bad Request", 400) return } r = r.WithContext(context.WithValue(r.Context(), requestContextKey("echoRequest"), echoReq)) next(w, r) }
go
func verifyJSON(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) { var echoReq *EchoRequest err := json.NewDecoder(r.Body).Decode(&echoReq) if err != nil { HTTPError(w, err.Error(), "Bad Request", 400) return } // Check the timestamp if !echoReq.VerifyTimestamp() && r.URL.Query().Get("_dev") == "" { HTTPError(w, "Request too old to continue (>150s).", "Bad Request", 400) return } // Check the app id if !echoReq.VerifyAppID(applications[r.URL.Path].(EchoApplication).AppID) { HTTPError(w, "Echo AppID mismatch!", "Bad Request", 400) return } r = r.WithContext(context.WithValue(r.Context(), requestContextKey("echoRequest"), echoReq)) next(w, r) }
[ "func", "verifyJSON", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "next", "http", ".", "HandlerFunc", ")", "{", "var", "echoReq", "*", "EchoRequest", "\n", "err", ":=", "json", ".", "NewDecoder", "(", "r", ".", "Body", ")", ".", "Decode", "(", "&", "echoReq", ")", "\n", "if", "err", "!=", "nil", "{", "HTTPError", "(", "w", ",", "err", ".", "Error", "(", ")", ",", "\"", "\"", ",", "400", ")", "\n", "return", "\n", "}", "\n\n", "// Check the timestamp", "if", "!", "echoReq", ".", "VerifyTimestamp", "(", ")", "&&", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "==", "\"", "\"", "{", "HTTPError", "(", "w", ",", "\"", "\"", ",", "\"", "\"", ",", "400", ")", "\n", "return", "\n", "}", "\n\n", "// Check the app id", "if", "!", "echoReq", ".", "VerifyAppID", "(", "applications", "[", "r", ".", "URL", ".", "Path", "]", ".", "(", "EchoApplication", ")", ".", "AppID", ")", "{", "HTTPError", "(", "w", ",", "\"", "\"", ",", "\"", "\"", ",", "400", ")", "\n", "return", "\n", "}", "\n\n", "r", "=", "r", ".", "WithContext", "(", "context", ".", "WithValue", "(", "r", ".", "Context", "(", ")", ",", "requestContextKey", "(", "\"", "\"", ")", ",", "echoReq", ")", ")", "\n\n", "next", "(", "w", ",", "r", ")", "\n", "}" ]
// Decode the JSON request and verify it.
[ "Decode", "the", "JSON", "request", "and", "verify", "it", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/skillserver.go#L203-L226
13,727
mikeflynn/go-alexa
skillserver/skillserver.go
validateRequest
func validateRequest(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) { devFlag := r.URL.Query().Get("_dev") isDev := devFlag != "" if !isDev && !IsValidAlexaRequest(w, r) { log.Println("Request invalid") return } next(w, r) }
go
func validateRequest(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) { devFlag := r.URL.Query().Get("_dev") isDev := devFlag != "" if !isDev && !IsValidAlexaRequest(w, r) { log.Println("Request invalid") return } next(w, r) }
[ "func", "validateRequest", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "next", "http", ".", "HandlerFunc", ")", "{", "devFlag", ":=", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "isDev", ":=", "devFlag", "!=", "\"", "\"", "\n", "if", "!", "isDev", "&&", "!", "IsValidAlexaRequest", "(", "w", ",", "r", ")", "{", "log", ".", "Println", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "next", "(", "w", ",", "r", ")", "\n", "}" ]
// Run all mandatory Amazon security checks on the request.
[ "Run", "all", "mandatory", "Amazon", "security", "checks", "on", "the", "request", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/skillserver.go#L229-L237
13,728
mikeflynn/go-alexa
skillserver/ssml-builder.go
AppendPlainSpeech
func (builder *SSMLTextBuilder) AppendPlainSpeech(text string) *SSMLTextBuilder { builder.buffer.WriteString(text) return builder }
go
func (builder *SSMLTextBuilder) AppendPlainSpeech(text string) *SSMLTextBuilder { builder.buffer.WriteString(text) return builder }
[ "func", "(", "builder", "*", "SSMLTextBuilder", ")", "AppendPlainSpeech", "(", "text", "string", ")", "*", "SSMLTextBuilder", "{", "builder", ".", "buffer", ".", "WriteString", "(", "text", ")", "\n\n", "return", "builder", "\n", "}" ]
// AppendPlainSpeech will append the supplied text as regular speech to be spoken by the Alexa device.
[ "AppendPlainSpeech", "will", "append", "the", "supplied", "text", "as", "regular", "speech", "to", "be", "spoken", "by", "the", "Alexa", "device", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/ssml-builder.go#L59-L64
13,729
mikeflynn/go-alexa
skillserver/ssml-builder.go
AppendAmazonEffect
func (builder *SSMLTextBuilder) AppendAmazonEffect(text, name string) *SSMLTextBuilder { builder.buffer.WriteString(fmt.Sprintf("<amazon:effect name=\"%s\">%s</amazon:effect>", name, text)) return builder }
go
func (builder *SSMLTextBuilder) AppendAmazonEffect(text, name string) *SSMLTextBuilder { builder.buffer.WriteString(fmt.Sprintf("<amazon:effect name=\"%s\">%s</amazon:effect>", name, text)) return builder }
[ "func", "(", "builder", "*", "SSMLTextBuilder", ")", "AppendAmazonEffect", "(", "text", ",", "name", "string", ")", "*", "SSMLTextBuilder", "{", "builder", ".", "buffer", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\\\"", "\\\"", "\"", ",", "name", ",", "text", ")", ")", "\n\n", "return", "builder", "\n", "}" ]
// AppendAmazonEffect will add a new speech string with the provided effect name. // Check the SSML reference page for a list of available effects.
[ "AppendAmazonEffect", "will", "add", "a", "new", "speech", "string", "with", "the", "provided", "effect", "name", ".", "Check", "the", "SSML", "reference", "page", "for", "a", "list", "of", "available", "effects", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/ssml-builder.go#L68-L73
13,730
mikeflynn/go-alexa
skillserver/ssml-builder.go
AppendAudio
func (builder *SSMLTextBuilder) AppendAudio(src string) *SSMLTextBuilder { builder.buffer.WriteString(fmt.Sprintf("<audio src=\"%s\"/>", src)) return builder }
go
func (builder *SSMLTextBuilder) AppendAudio(src string) *SSMLTextBuilder { builder.buffer.WriteString(fmt.Sprintf("<audio src=\"%s\"/>", src)) return builder }
[ "func", "(", "builder", "*", "SSMLTextBuilder", ")", "AppendAudio", "(", "src", "string", ")", "*", "SSMLTextBuilder", "{", "builder", ".", "buffer", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\\\"", "\\\"", "\"", ",", "src", ")", ")", "\n\n", "return", "builder", "\n", "}" ]
// AppendAudio will append the playback of an MP3 file to the response. The audio playback // will take place at the specific point in the text to speech response.
[ "AppendAudio", "will", "append", "the", "playback", "of", "an", "MP3", "file", "to", "the", "response", ".", "The", "audio", "playback", "will", "take", "place", "at", "the", "specific", "point", "in", "the", "text", "to", "speech", "response", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/ssml-builder.go#L77-L82
13,731
mikeflynn/go-alexa
skillserver/ssml-builder.go
AppendBreak
func (builder *SSMLTextBuilder) AppendBreak(strength, time string) *SSMLTextBuilder { if strength == "" { // The default strength is medium strength = "medium" } builder.buffer.WriteString(fmt.Sprintf("<break strength=\"%s\" time=\"%s\"/>", strength, time)) return builder }
go
func (builder *SSMLTextBuilder) AppendBreak(strength, time string) *SSMLTextBuilder { if strength == "" { // The default strength is medium strength = "medium" } builder.buffer.WriteString(fmt.Sprintf("<break strength=\"%s\" time=\"%s\"/>", strength, time)) return builder }
[ "func", "(", "builder", "*", "SSMLTextBuilder", ")", "AppendBreak", "(", "strength", ",", "time", "string", ")", "*", "SSMLTextBuilder", "{", "if", "strength", "==", "\"", "\"", "{", "// The default strength is medium", "strength", "=", "\"", "\"", "\n", "}", "\n\n", "builder", ".", "buffer", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\\\"", "\\\"", "\\\"", "\\\"", "\"", ",", "strength", ",", "time", ")", ")", "\n\n", "return", "builder", "\n", "}" ]
// AppendBreak will add a pause to the text to speech output. The default is a medium pause. // Refer to the SSML reference for the available strength values.
[ "AppendBreak", "will", "add", "a", "pause", "to", "the", "text", "to", "speech", "output", ".", "The", "default", "is", "a", "medium", "pause", ".", "Refer", "to", "the", "SSML", "reference", "for", "the", "available", "strength", "values", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/ssml-builder.go#L86-L96
13,732
mikeflynn/go-alexa
skillserver/ssml-builder.go
AppendEmphasis
func (builder *SSMLTextBuilder) AppendEmphasis(text, level string) *SSMLTextBuilder { builder.buffer.WriteString(fmt.Sprintf("<emphasis level=\"%s\">%s</emphasis>", level, text)) return builder }
go
func (builder *SSMLTextBuilder) AppendEmphasis(text, level string) *SSMLTextBuilder { builder.buffer.WriteString(fmt.Sprintf("<emphasis level=\"%s\">%s</emphasis>", level, text)) return builder }
[ "func", "(", "builder", "*", "SSMLTextBuilder", ")", "AppendEmphasis", "(", "text", ",", "level", "string", ")", "*", "SSMLTextBuilder", "{", "builder", ".", "buffer", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\\\"", "\\\"", "\"", ",", "level", ",", "text", ")", ")", "\n\n", "return", "builder", "\n", "}" ]
// AppendEmphasis will include a set of text to be spoken with the specific level of emphasis. // Refer to the SSML reference for available emphasis level values.
[ "AppendEmphasis", "will", "include", "a", "set", "of", "text", "to", "be", "spoken", "with", "the", "specific", "level", "of", "emphasis", ".", "Refer", "to", "the", "SSML", "reference", "for", "available", "emphasis", "level", "values", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/ssml-builder.go#L100-L105
13,733
mikeflynn/go-alexa
skillserver/ssml-builder.go
AppendParagraph
func (builder *SSMLTextBuilder) AppendParagraph(text string) *SSMLTextBuilder { builder.buffer.WriteString(fmt.Sprintf("<p>%s</p>", text)) return builder }
go
func (builder *SSMLTextBuilder) AppendParagraph(text string) *SSMLTextBuilder { builder.buffer.WriteString(fmt.Sprintf("<p>%s</p>", text)) return builder }
[ "func", "(", "builder", "*", "SSMLTextBuilder", ")", "AppendParagraph", "(", "text", "string", ")", "*", "SSMLTextBuilder", "{", "builder", ".", "buffer", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "text", ")", ")", "\n\n", "return", "builder", "\n", "}" ]
// AppendParagraph will append the specific text as a new paragraph. Extra strong breaks will // be used before and after this text.
[ "AppendParagraph", "will", "append", "the", "specific", "text", "as", "a", "new", "paragraph", ".", "Extra", "strong", "breaks", "will", "be", "used", "before", "and", "after", "this", "text", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/ssml-builder.go#L109-L114
13,734
mikeflynn/go-alexa
skillserver/ssml-builder.go
AppendProsody
func (builder *SSMLTextBuilder) AppendProsody(text, rate, pitch, volume string) *SSMLTextBuilder { builder.buffer.WriteString(fmt.Sprintf("<prosody rate=\"%s\" pitch=\"%s\" volume=\"%s\">%s</prosody>", rate, pitch, volume, text)) return builder }
go
func (builder *SSMLTextBuilder) AppendProsody(text, rate, pitch, volume string) *SSMLTextBuilder { builder.buffer.WriteString(fmt.Sprintf("<prosody rate=\"%s\" pitch=\"%s\" volume=\"%s\">%s</prosody>", rate, pitch, volume, text)) return builder }
[ "func", "(", "builder", "*", "SSMLTextBuilder", ")", "AppendProsody", "(", "text", ",", "rate", ",", "pitch", ",", "volume", "string", ")", "*", "SSMLTextBuilder", "{", "builder", ".", "buffer", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\\\"", "\\\"", "\\\"", "\\\"", "\\\"", "\\\"", "\"", ",", "rate", ",", "pitch", ",", "volume", ",", "text", ")", ")", "\n\n", "return", "builder", "\n", "}" ]
// AppendProsody provides a way to modify the rate, pitch, and volume of a piece of spoken text.
[ "AppendProsody", "provides", "a", "way", "to", "modify", "the", "rate", "pitch", "and", "volume", "of", "a", "piece", "of", "spoken", "text", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/ssml-builder.go#L117-L122
13,735
mikeflynn/go-alexa
skillserver/ssml-builder.go
AppendPartOfSpeech
func (builder *SSMLTextBuilder) AppendPartOfSpeech(role WordRole, text string) *SSMLTextBuilder { if role != "" { builder.buffer.WriteString(fmt.Sprintf("<w role=\"%s\">%s</w>", role, text)) } return builder }
go
func (builder *SSMLTextBuilder) AppendPartOfSpeech(role WordRole, text string) *SSMLTextBuilder { if role != "" { builder.buffer.WriteString(fmt.Sprintf("<w role=\"%s\">%s</w>", role, text)) } return builder }
[ "func", "(", "builder", "*", "SSMLTextBuilder", ")", "AppendPartOfSpeech", "(", "role", "WordRole", ",", "text", "string", ")", "*", "SSMLTextBuilder", "{", "if", "role", "!=", "\"", "\"", "{", "builder", ".", "buffer", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\\\"", "\\\"", "\"", ",", "role", ",", "text", ")", ")", "\n", "}", "\n\n", "return", "builder", "\n", "}" ]
// AppendPartOfSpeech is used to explictily define the part of speech for a word that is being // appended to the text to speech output sent in a skill server response.
[ "AppendPartOfSpeech", "is", "used", "to", "explictily", "define", "the", "part", "of", "speech", "for", "a", "word", "that", "is", "being", "appended", "to", "the", "text", "to", "speech", "output", "sent", "in", "a", "skill", "server", "response", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/ssml-builder.go#L135-L142
13,736
mikeflynn/go-alexa
skillserver/ssml-builder.go
AppendSubstitution
func (builder *SSMLTextBuilder) AppendSubstitution(text, alias string) *SSMLTextBuilder { builder.buffer.WriteString(fmt.Sprintf("<sub alias=\"%s\">%s</sub>", alias, text)) return builder }
go
func (builder *SSMLTextBuilder) AppendSubstitution(text, alias string) *SSMLTextBuilder { builder.buffer.WriteString(fmt.Sprintf("<sub alias=\"%s\">%s</sub>", alias, text)) return builder }
[ "func", "(", "builder", "*", "SSMLTextBuilder", ")", "AppendSubstitution", "(", "text", ",", "alias", "string", ")", "*", "SSMLTextBuilder", "{", "builder", ".", "buffer", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\\\"", "\\\"", "\"", ",", "alias", ",", "text", ")", ")", "\n\n", "return", "builder", "\n", "}" ]
// AppendSubstitution provides a way to indicate an alternate pronunciation for a piece of text.
[ "AppendSubstitution", "provides", "a", "way", "to", "indicate", "an", "alternate", "pronunciation", "for", "a", "piece", "of", "text", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/ssml-builder.go#L145-L150
13,737
mikeflynn/go-alexa
skillserver/ssml-builder.go
AppendSayAs
func (builder *SSMLTextBuilder) AppendSayAs(interpretAs, format, text string) *SSMLTextBuilder { if interpretAs == "date" { builder.buffer.WriteString(fmt.Sprintf("<say-as interpret-as=\"%s\" format=\"%s\">%s</say-as>", interpretAs, format, text)) } else if interpretAs != "" { builder.buffer.WriteString(fmt.Sprintf("<say-as interpret-as=\"%s\">%s</say-as>", interpretAs, text)) } return builder }
go
func (builder *SSMLTextBuilder) AppendSayAs(interpretAs, format, text string) *SSMLTextBuilder { if interpretAs == "date" { builder.buffer.WriteString(fmt.Sprintf("<say-as interpret-as=\"%s\" format=\"%s\">%s</say-as>", interpretAs, format, text)) } else if interpretAs != "" { builder.buffer.WriteString(fmt.Sprintf("<say-as interpret-as=\"%s\">%s</say-as>", interpretAs, text)) } return builder }
[ "func", "(", "builder", "*", "SSMLTextBuilder", ")", "AppendSayAs", "(", "interpretAs", ",", "format", ",", "text", "string", ")", "*", "SSMLTextBuilder", "{", "if", "interpretAs", "==", "\"", "\"", "{", "builder", ".", "buffer", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\\\"", "\\\"", "\\\"", "\\\"", "\"", ",", "interpretAs", ",", "format", ",", "text", ")", ")", "\n", "}", "else", "if", "interpretAs", "!=", "\"", "\"", "{", "builder", ".", "buffer", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\\\"", "\\\"", "\"", ",", "interpretAs", ",", "text", ")", ")", "\n", "}", "\n\n", "return", "builder", "\n", "}" ]
// AppendSayAs is used to provide additional information about how the text string being appended // should be interpreted. For example this can be used to interpret the string as a list // of individual characters or to read out digits one at a time. The format string is // ignored unless the interpret-as argument is `date`. Refer to the SSML referene for valid // values for the interpretAs parameter.
[ "AppendSayAs", "is", "used", "to", "provide", "additional", "information", "about", "how", "the", "text", "string", "being", "appended", "should", "be", "interpreted", ".", "For", "example", "this", "can", "be", "used", "to", "interpret", "the", "string", "as", "a", "list", "of", "individual", "characters", "or", "to", "read", "out", "digits", "one", "at", "a", "time", ".", "The", "format", "string", "is", "ignored", "unless", "the", "interpret", "-", "as", "argument", "is", "date", ".", "Refer", "to", "the", "SSML", "referene", "for", "valid", "values", "for", "the", "interpretAs", "parameter", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/ssml-builder.go#L157-L167
13,738
mikeflynn/go-alexa
skillserver/ssml-builder.go
AppendPhoneme
func (builder *SSMLTextBuilder) AppendPhoneme(alphabet PhoneticAlphabet, phoneme, text string) *SSMLTextBuilder { if phoneme != "" && text != "" && alphabet != PhoneticAlphabet("") { builder.buffer.WriteString(fmt.Sprintf("<phoneme alphabet=\"%s\" ph=\"%s\">%s</phoneme>", alphabet, phoneme, text)) } return builder }
go
func (builder *SSMLTextBuilder) AppendPhoneme(alphabet PhoneticAlphabet, phoneme, text string) *SSMLTextBuilder { if phoneme != "" && text != "" && alphabet != PhoneticAlphabet("") { builder.buffer.WriteString(fmt.Sprintf("<phoneme alphabet=\"%s\" ph=\"%s\">%s</phoneme>", alphabet, phoneme, text)) } return builder }
[ "func", "(", "builder", "*", "SSMLTextBuilder", ")", "AppendPhoneme", "(", "alphabet", "PhoneticAlphabet", ",", "phoneme", ",", "text", "string", ")", "*", "SSMLTextBuilder", "{", "if", "phoneme", "!=", "\"", "\"", "&&", "text", "!=", "\"", "\"", "&&", "alphabet", "!=", "PhoneticAlphabet", "(", "\"", "\"", ")", "{", "builder", ".", "buffer", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\\\"", "\\\"", "\\\"", "\\\"", "\"", ",", "alphabet", ",", "phoneme", ",", "text", ")", ")", "\n", "}", "\n\n", "return", "builder", "\n", "}" ]
// AppendPhoneme is used to specify a phonetic pronunciation for a piece of text to be appended // to the response.
[ "AppendPhoneme", "is", "used", "to", "specify", "a", "phonetic", "pronunciation", "for", "a", "piece", "of", "text", "to", "be", "appended", "to", "the", "response", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/ssml-builder.go#L171-L178
13,739
mikeflynn/go-alexa
skillserver/echo.go
VerifyTimestamp
func (r *EchoRequest) VerifyTimestamp() bool { reqTimestamp, _ := time.Parse("2006-01-02T15:04:05Z", r.Request.Timestamp) if time.Since(reqTimestamp) < time.Duration(150)*time.Second { return true } return false }
go
func (r *EchoRequest) VerifyTimestamp() bool { reqTimestamp, _ := time.Parse("2006-01-02T15:04:05Z", r.Request.Timestamp) if time.Since(reqTimestamp) < time.Duration(150)*time.Second { return true } return false }
[ "func", "(", "r", "*", "EchoRequest", ")", "VerifyTimestamp", "(", ")", "bool", "{", "reqTimestamp", ",", "_", ":=", "time", ".", "Parse", "(", "\"", "\"", ",", "r", ".", "Request", ".", "Timestamp", ")", "\n", "if", "time", ".", "Since", "(", "reqTimestamp", ")", "<", "time", ".", "Duration", "(", "150", ")", "*", "time", ".", "Second", "{", "return", "true", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
// Request Functions // VerifyTimestamp will parse the timestamp in the EchoRequest and verify that it is in the correct // format and is not too old. True will be returned if the timestamp is valid; false otherwise.
[ "Request", "Functions", "VerifyTimestamp", "will", "parse", "the", "timestamp", "in", "the", "EchoRequest", "and", "verify", "that", "it", "is", "in", "the", "correct", "format", "and", "is", "not", "too", "old", ".", "True", "will", "be", "returned", "if", "the", "timestamp", "is", "valid", ";", "false", "otherwise", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/echo.go#L29-L36
13,740
mikeflynn/go-alexa
skillserver/echo.go
VerifyAppID
func (r *EchoRequest) VerifyAppID(myAppID string) bool { if r.Session.Application.ApplicationID == myAppID || r.Context.System.Application.ApplicationID == myAppID { return true } return false }
go
func (r *EchoRequest) VerifyAppID(myAppID string) bool { if r.Session.Application.ApplicationID == myAppID || r.Context.System.Application.ApplicationID == myAppID { return true } return false }
[ "func", "(", "r", "*", "EchoRequest", ")", "VerifyAppID", "(", "myAppID", "string", ")", "bool", "{", "if", "r", ".", "Session", ".", "Application", ".", "ApplicationID", "==", "myAppID", "||", "r", ".", "Context", ".", "System", ".", "Application", ".", "ApplicationID", "==", "myAppID", "{", "return", "true", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
// VerifyAppID check that the incoming application ID matches the application ID provided // when running the server. This is a step required for skill certification.
[ "VerifyAppID", "check", "that", "the", "incoming", "application", "ID", "matches", "the", "application", "ID", "provided", "when", "running", "the", "server", ".", "This", "is", "a", "step", "required", "for", "skill", "certification", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/echo.go#L40-L47
13,741
mikeflynn/go-alexa
skillserver/echo.go
GetIntentName
func (r *EchoRequest) GetIntentName() string { if r.GetRequestType() == "IntentRequest" { return r.Request.Intent.Name } return r.GetRequestType() }
go
func (r *EchoRequest) GetIntentName() string { if r.GetRequestType() == "IntentRequest" { return r.Request.Intent.Name } return r.GetRequestType() }
[ "func", "(", "r", "*", "EchoRequest", ")", "GetIntentName", "(", ")", "string", "{", "if", "r", ".", "GetRequestType", "(", ")", "==", "\"", "\"", "{", "return", "r", ".", "Request", ".", "Intent", ".", "Name", "\n", "}", "\n\n", "return", "r", ".", "GetRequestType", "(", ")", "\n", "}" ]
// GetIntentName is a convenience method for getting the intent name out of an EchoRequest.
[ "GetIntentName", "is", "a", "convenience", "method", "for", "getting", "the", "intent", "name", "out", "of", "an", "EchoRequest", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/echo.go#L65-L71
13,742
mikeflynn/go-alexa
skillserver/echo.go
GetSlotValue
func (r *EchoRequest) GetSlotValue(slotName string) (string, error) { slot, err := r.GetSlot(slotName) if err != nil { return "", err } return slot.Value, nil }
go
func (r *EchoRequest) GetSlotValue(slotName string) (string, error) { slot, err := r.GetSlot(slotName) if err != nil { return "", err } return slot.Value, nil }
[ "func", "(", "r", "*", "EchoRequest", ")", "GetSlotValue", "(", "slotName", "string", ")", "(", "string", ",", "error", ")", "{", "slot", ",", "err", ":=", "r", ".", "GetSlot", "(", "slotName", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "return", "slot", ".", "Value", ",", "nil", "\n", "}" ]
// GetSlotValue is a convenience method for getting the value of the specified slot out of an EchoRequest // as a string. An error is returned if a slot with that value is not found in the request.
[ "GetSlotValue", "is", "a", "convenience", "method", "for", "getting", "the", "value", "of", "the", "specified", "slot", "out", "of", "an", "EchoRequest", "as", "a", "string", ".", "An", "error", "is", "returned", "if", "a", "slot", "with", "that", "value", "is", "not", "found", "in", "the", "request", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/echo.go#L75-L83
13,743
mikeflynn/go-alexa
skillserver/echo.go
GetSlot
func (r *EchoRequest) GetSlot(slotName string) (EchoSlot, error) { if _, ok := r.Request.Intent.Slots[slotName]; ok { return r.Request.Intent.Slots[slotName], nil } return EchoSlot{}, errors.New("slot name not found") }
go
func (r *EchoRequest) GetSlot(slotName string) (EchoSlot, error) { if _, ok := r.Request.Intent.Slots[slotName]; ok { return r.Request.Intent.Slots[slotName], nil } return EchoSlot{}, errors.New("slot name not found") }
[ "func", "(", "r", "*", "EchoRequest", ")", "GetSlot", "(", "slotName", "string", ")", "(", "EchoSlot", ",", "error", ")", "{", "if", "_", ",", "ok", ":=", "r", ".", "Request", ".", "Intent", ".", "Slots", "[", "slotName", "]", ";", "ok", "{", "return", "r", ".", "Request", ".", "Intent", ".", "Slots", "[", "slotName", "]", ",", "nil", "\n", "}", "\n\n", "return", "EchoSlot", "{", "}", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
// GetSlot will return an EchoSlot from the EchoRequest with the given name.
[ "GetSlot", "will", "return", "an", "EchoSlot", "from", "the", "EchoRequest", "with", "the", "given", "name", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/echo.go#L86-L92
13,744
mikeflynn/go-alexa
skillserver/echo.go
Card
func (r *EchoResponse) Card(title string, content string) *EchoResponse { return r.SimpleCard(title, content) }
go
func (r *EchoResponse) Card(title string, content string) *EchoResponse { return r.SimpleCard(title, content) }
[ "func", "(", "r", "*", "EchoResponse", ")", "Card", "(", "title", "string", ",", "content", "string", ")", "*", "EchoResponse", "{", "return", "r", ".", "SimpleCard", "(", "title", ",", "content", ")", "\n", "}" ]
// Card will add a card to the Alexa app's response with the provided title and content strings.
[ "Card", "will", "add", "a", "card", "to", "the", "Alexa", "app", "s", "response", "with", "the", "provided", "title", "and", "content", "strings", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/echo.go#L133-L135
13,745
mikeflynn/go-alexa
skillserver/echo.go
OutputSpeechSSML
func (r *EchoResponse) OutputSpeechSSML(text string) *EchoResponse { r.Response.OutputSpeech = &EchoRespPayload{ Type: "SSML", SSML: text, } return r }
go
func (r *EchoResponse) OutputSpeechSSML(text string) *EchoResponse { r.Response.OutputSpeech = &EchoRespPayload{ Type: "SSML", SSML: text, } return r }
[ "func", "(", "r", "*", "EchoResponse", ")", "OutputSpeechSSML", "(", "text", "string", ")", "*", "EchoResponse", "{", "r", ".", "Response", ".", "OutputSpeech", "=", "&", "EchoRespPayload", "{", "Type", ":", "\"", "\"", ",", "SSML", ":", "text", ",", "}", "\n\n", "return", "r", "\n", "}" ]
// OutputSpeechSSML will add the text string provided and indicate the speech type is SSML in the response. // This should only be used if the text to speech string includes special SSML tags.
[ "OutputSpeechSSML", "will", "add", "the", "text", "string", "provided", "and", "indicate", "the", "speech", "type", "is", "SSML", "in", "the", "response", ".", "This", "should", "only", "be", "used", "if", "the", "text", "to", "speech", "string", "includes", "special", "SSML", "tags", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/echo.go#L139-L146
13,746
mikeflynn/go-alexa
skillserver/echo.go
SimpleCard
func (r *EchoResponse) SimpleCard(title string, content string) *EchoResponse { r.Response.Card = &EchoRespPayload{ Type: "Simple", Title: title, Content: content, } return r }
go
func (r *EchoResponse) SimpleCard(title string, content string) *EchoResponse { r.Response.Card = &EchoRespPayload{ Type: "Simple", Title: title, Content: content, } return r }
[ "func", "(", "r", "*", "EchoResponse", ")", "SimpleCard", "(", "title", "string", ",", "content", "string", ")", "*", "EchoResponse", "{", "r", ".", "Response", ".", "Card", "=", "&", "EchoRespPayload", "{", "Type", ":", "\"", "\"", ",", "Title", ":", "title", ",", "Content", ":", "content", ",", "}", "\n\n", "return", "r", "\n", "}" ]
// SimpleCard will indicate that a card should be included in the Alexa companion app as part of the response. // The card will be shown with the provided title and content.
[ "SimpleCard", "will", "indicate", "that", "a", "card", "should", "be", "included", "in", "the", "Alexa", "companion", "app", "as", "part", "of", "the", "response", ".", "The", "card", "will", "be", "shown", "with", "the", "provided", "title", "and", "content", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/echo.go#L150-L158
13,747
mikeflynn/go-alexa
skillserver/echo.go
StandardCard
func (r *EchoResponse) StandardCard(title string, content string, smallImg string, largeImg string) *EchoResponse { r.Response.Card = &EchoRespPayload{ Type: "Standard", Title: title, Content: content, } if smallImg != "" { r.Response.Card.Image.SmallImageURL = smallImg } if largeImg != "" { r.Response.Card.Image.LargeImageURL = largeImg } return r }
go
func (r *EchoResponse) StandardCard(title string, content string, smallImg string, largeImg string) *EchoResponse { r.Response.Card = &EchoRespPayload{ Type: "Standard", Title: title, Content: content, } if smallImg != "" { r.Response.Card.Image.SmallImageURL = smallImg } if largeImg != "" { r.Response.Card.Image.LargeImageURL = largeImg } return r }
[ "func", "(", "r", "*", "EchoResponse", ")", "StandardCard", "(", "title", "string", ",", "content", "string", ",", "smallImg", "string", ",", "largeImg", "string", ")", "*", "EchoResponse", "{", "r", ".", "Response", ".", "Card", "=", "&", "EchoRespPayload", "{", "Type", ":", "\"", "\"", ",", "Title", ":", "title", ",", "Content", ":", "content", ",", "}", "\n\n", "if", "smallImg", "!=", "\"", "\"", "{", "r", ".", "Response", ".", "Card", ".", "Image", ".", "SmallImageURL", "=", "smallImg", "\n", "}", "\n\n", "if", "largeImg", "!=", "\"", "\"", "{", "r", ".", "Response", ".", "Card", ".", "Image", ".", "LargeImageURL", "=", "largeImg", "\n", "}", "\n\n", "return", "r", "\n", "}" ]
// StandardCard will indicate that a card should be shown in the Alexa companion app as part of the response. // The card shown will include the provided title and content as well as images loaded from the locations provided // as remote locations.
[ "StandardCard", "will", "indicate", "that", "a", "card", "should", "be", "shown", "in", "the", "Alexa", "companion", "app", "as", "part", "of", "the", "response", ".", "The", "card", "shown", "will", "include", "the", "provided", "title", "and", "content", "as", "well", "as", "images", "loaded", "from", "the", "locations", "provided", "as", "remote", "locations", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/echo.go#L163-L179
13,748
mikeflynn/go-alexa
skillserver/echo.go
LinkAccountCard
func (r *EchoResponse) LinkAccountCard() *EchoResponse { r.Response.Card = &EchoRespPayload{ Type: "LinkAccount", } return r }
go
func (r *EchoResponse) LinkAccountCard() *EchoResponse { r.Response.Card = &EchoRespPayload{ Type: "LinkAccount", } return r }
[ "func", "(", "r", "*", "EchoResponse", ")", "LinkAccountCard", "(", ")", "*", "EchoResponse", "{", "r", ".", "Response", ".", "Card", "=", "&", "EchoRespPayload", "{", "Type", ":", "\"", "\"", ",", "}", "\n\n", "return", "r", "\n", "}" ]
// LinkAccountCard is used to indicate that account linking still needs to be completed to continue // using the Alexa skill. This will force an account linking card to be shown in the user's companion app.
[ "LinkAccountCard", "is", "used", "to", "indicate", "that", "account", "linking", "still", "needs", "to", "be", "completed", "to", "continue", "using", "the", "Alexa", "skill", ".", "This", "will", "force", "an", "account", "linking", "card", "to", "be", "shown", "in", "the", "user", "s", "companion", "app", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/echo.go#L183-L189
13,749
mikeflynn/go-alexa
skillserver/echo.go
Reprompt
func (r *EchoResponse) Reprompt(text string) *EchoResponse { r.Response.Reprompt = &EchoReprompt{ OutputSpeech: EchoRespPayload{ Type: "PlainText", Text: text, }, } return r }
go
func (r *EchoResponse) Reprompt(text string) *EchoResponse { r.Response.Reprompt = &EchoReprompt{ OutputSpeech: EchoRespPayload{ Type: "PlainText", Text: text, }, } return r }
[ "func", "(", "r", "*", "EchoResponse", ")", "Reprompt", "(", "text", "string", ")", "*", "EchoResponse", "{", "r", ".", "Response", ".", "Reprompt", "=", "&", "EchoReprompt", "{", "OutputSpeech", ":", "EchoRespPayload", "{", "Type", ":", "\"", "\"", ",", "Text", ":", "text", ",", "}", ",", "}", "\n\n", "return", "r", "\n", "}" ]
// Reprompt will send a prompt back to the user, this could be used to request additional information from the user.
[ "Reprompt", "will", "send", "a", "prompt", "back", "to", "the", "user", "this", "could", "be", "used", "to", "request", "additional", "information", "from", "the", "user", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/echo.go#L192-L201
13,750
mikeflynn/go-alexa
skillserver/echo.go
EndSession
func (r *EchoResponse) EndSession(flag bool) *EchoResponse { r.Response.ShouldEndSession = flag return r }
go
func (r *EchoResponse) EndSession(flag bool) *EchoResponse { r.Response.ShouldEndSession = flag return r }
[ "func", "(", "r", "*", "EchoResponse", ")", "EndSession", "(", "flag", "bool", ")", "*", "EchoResponse", "{", "r", ".", "Response", ".", "ShouldEndSession", "=", "flag", "\n\n", "return", "r", "\n", "}" ]
// EndSession is a convenience method for setting the flag in the response that will // indicate if the session between the end user's device and the skillserver should be closed.
[ "EndSession", "is", "a", "convenience", "method", "for", "setting", "the", "flag", "in", "the", "response", "that", "will", "indicate", "if", "the", "session", "between", "the", "end", "user", "s", "device", "and", "the", "skillserver", "should", "be", "closed", "." ]
a6af545a423613c641bf760600e729115d0eabd2
https://github.com/mikeflynn/go-alexa/blob/a6af545a423613c641bf760600e729115d0eabd2/skillserver/echo.go#L218-L222
13,751
twpayne/go-kml
icon/icon.go
PaletteHref
func PaletteHref(pal, icon int) string { return "https://maps.google.com/mapfiles/kml/pal" + strconv.Itoa(pal) + "/icon" + strconv.Itoa(icon) + ".png" }
go
func PaletteHref(pal, icon int) string { return "https://maps.google.com/mapfiles/kml/pal" + strconv.Itoa(pal) + "/icon" + strconv.Itoa(icon) + ".png" }
[ "func", "PaletteHref", "(", "pal", ",", "icon", "int", ")", "string", "{", "return", "\"", "\"", "+", "strconv", ".", "Itoa", "(", "pal", ")", "+", "\"", "\"", "+", "strconv", ".", "Itoa", "(", "icon", ")", "+", "\"", "\"", "\n", "}" ]
// PaletteHref returns the href of icon in pal.
[ "PaletteHref", "returns", "the", "href", "of", "icon", "in", "pal", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/icon/icon.go#L63-L65
13,752
twpayne/go-kml
sphere/sphere.go
Offset
func (t T) Offset(origin kml.Coordinate, distance, bearing float64) kml.Coordinate { lat := math.Asin(math.Sin(origin.Lat*radians)*math.Cos(distance/t.R) + math.Cos(origin.Lat*radians)*math.Sin(distance/t.R)*math.Cos(bearing*radians)) lon := origin.Lon*radians + math.Atan2(math.Sin(bearing*radians)*math.Sin(distance/t.R)*math.Cos(origin.Lat*radians), math.Cos(distance/t.R)-math.Sin(origin.Lat*radians)*math.Sin(lat)) return kml.Coordinate{ Lon: lon * degrees, Lat: lat * degrees, Alt: origin.Alt, } }
go
func (t T) Offset(origin kml.Coordinate, distance, bearing float64) kml.Coordinate { lat := math.Asin(math.Sin(origin.Lat*radians)*math.Cos(distance/t.R) + math.Cos(origin.Lat*radians)*math.Sin(distance/t.R)*math.Cos(bearing*radians)) lon := origin.Lon*radians + math.Atan2(math.Sin(bearing*radians)*math.Sin(distance/t.R)*math.Cos(origin.Lat*radians), math.Cos(distance/t.R)-math.Sin(origin.Lat*radians)*math.Sin(lat)) return kml.Coordinate{ Lon: lon * degrees, Lat: lat * degrees, Alt: origin.Alt, } }
[ "func", "(", "t", "T", ")", "Offset", "(", "origin", "kml", ".", "Coordinate", ",", "distance", ",", "bearing", "float64", ")", "kml", ".", "Coordinate", "{", "lat", ":=", "math", ".", "Asin", "(", "math", ".", "Sin", "(", "origin", ".", "Lat", "*", "radians", ")", "*", "math", ".", "Cos", "(", "distance", "/", "t", ".", "R", ")", "+", "math", ".", "Cos", "(", "origin", ".", "Lat", "*", "radians", ")", "*", "math", ".", "Sin", "(", "distance", "/", "t", ".", "R", ")", "*", "math", ".", "Cos", "(", "bearing", "*", "radians", ")", ")", "\n", "lon", ":=", "origin", ".", "Lon", "*", "radians", "+", "math", ".", "Atan2", "(", "math", ".", "Sin", "(", "bearing", "*", "radians", ")", "*", "math", ".", "Sin", "(", "distance", "/", "t", ".", "R", ")", "*", "math", ".", "Cos", "(", "origin", ".", "Lat", "*", "radians", ")", ",", "math", ".", "Cos", "(", "distance", "/", "t", ".", "R", ")", "-", "math", ".", "Sin", "(", "origin", ".", "Lat", "*", "radians", ")", "*", "math", ".", "Sin", "(", "lat", ")", ")", "\n", "return", "kml", ".", "Coordinate", "{", "Lon", ":", "lon", "*", "degrees", ",", "Lat", ":", "lat", "*", "degrees", ",", "Alt", ":", "origin", ".", "Alt", ",", "}", "\n", "}" ]
// Offset returns the coordinate at distance from origin in direction bearing.
[ "Offset", "returns", "the", "coordinate", "at", "distance", "from", "origin", "in", "direction", "bearing", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/sphere/sphere.go#L34-L42
13,753
twpayne/go-kml
sphere/sphere.go
Circle
func (t T) Circle(center kml.Coordinate, radius, maxErr float64) []kml.Coordinate { numVertices := int(math.Ceil(math.Pi / math.Acos((radius-maxErr)/(radius+maxErr)))) cs := make([]kml.Coordinate, numVertices+1) for i := 0; i < numVertices; i++ { cs[i] = t.Offset(center, radius, 360*float64(i)/float64(numVertices)) } cs[numVertices] = cs[0] return cs }
go
func (t T) Circle(center kml.Coordinate, radius, maxErr float64) []kml.Coordinate { numVertices := int(math.Ceil(math.Pi / math.Acos((radius-maxErr)/(radius+maxErr)))) cs := make([]kml.Coordinate, numVertices+1) for i := 0; i < numVertices; i++ { cs[i] = t.Offset(center, radius, 360*float64(i)/float64(numVertices)) } cs[numVertices] = cs[0] return cs }
[ "func", "(", "t", "T", ")", "Circle", "(", "center", "kml", ".", "Coordinate", ",", "radius", ",", "maxErr", "float64", ")", "[", "]", "kml", ".", "Coordinate", "{", "numVertices", ":=", "int", "(", "math", ".", "Ceil", "(", "math", ".", "Pi", "/", "math", ".", "Acos", "(", "(", "radius", "-", "maxErr", ")", "/", "(", "radius", "+", "maxErr", ")", ")", ")", ")", "\n", "cs", ":=", "make", "(", "[", "]", "kml", ".", "Coordinate", ",", "numVertices", "+", "1", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "numVertices", ";", "i", "++", "{", "cs", "[", "i", "]", "=", "t", ".", "Offset", "(", "center", ",", "radius", ",", "360", "*", "float64", "(", "i", ")", "/", "float64", "(", "numVertices", ")", ")", "\n", "}", "\n", "cs", "[", "numVertices", "]", "=", "cs", "[", "0", "]", "\n", "return", "cs", "\n", "}" ]
// Circle returns an array of kml.Coordinates that approximate a circle of // radius radius centered on center with a maximum error of maxErr.
[ "Circle", "returns", "an", "array", "of", "kml", ".", "Coordinates", "that", "approximate", "a", "circle", "of", "radius", "radius", "centered", "on", "center", "with", "a", "maximum", "error", "of", "maxErr", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/sphere/sphere.go#L46-L54
13,754
twpayne/go-kml
sphere/sphere.go
HaversineDistance
func (t T) HaversineDistance(c1, c2 kml.Coordinate) float64 { lat1 := c1.Lat * radians lat2 := c2.Lat * radians deltaLat := lat2 - lat1 deltaLon := (c1.Lon - c2.Lon) * radians a := math.Sin(deltaLat/2)*math.Sin(deltaLat/2) + math.Cos(lat1)*math.Cos(lat2)*math.Sin(deltaLon/2)*math.Sin(deltaLon/2) c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a)) return t.R * c }
go
func (t T) HaversineDistance(c1, c2 kml.Coordinate) float64 { lat1 := c1.Lat * radians lat2 := c2.Lat * radians deltaLat := lat2 - lat1 deltaLon := (c1.Lon - c2.Lon) * radians a := math.Sin(deltaLat/2)*math.Sin(deltaLat/2) + math.Cos(lat1)*math.Cos(lat2)*math.Sin(deltaLon/2)*math.Sin(deltaLon/2) c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a)) return t.R * c }
[ "func", "(", "t", "T", ")", "HaversineDistance", "(", "c1", ",", "c2", "kml", ".", "Coordinate", ")", "float64", "{", "lat1", ":=", "c1", ".", "Lat", "*", "radians", "\n", "lat2", ":=", "c2", ".", "Lat", "*", "radians", "\n", "deltaLat", ":=", "lat2", "-", "lat1", "\n", "deltaLon", ":=", "(", "c1", ".", "Lon", "-", "c2", ".", "Lon", ")", "*", "radians", "\n", "a", ":=", "math", ".", "Sin", "(", "deltaLat", "/", "2", ")", "*", "math", ".", "Sin", "(", "deltaLat", "/", "2", ")", "+", "math", ".", "Cos", "(", "lat1", ")", "*", "math", ".", "Cos", "(", "lat2", ")", "*", "math", ".", "Sin", "(", "deltaLon", "/", "2", ")", "*", "math", ".", "Sin", "(", "deltaLon", "/", "2", ")", "\n", "c", ":=", "2", "*", "math", ".", "Atan2", "(", "math", ".", "Sqrt", "(", "a", ")", ",", "math", ".", "Sqrt", "(", "1", "-", "a", ")", ")", "\n", "return", "t", ".", "R", "*", "c", "\n", "}" ]
// HaversineDistance returns the great circle distance beween c1 and c2 using // the Haversine formula. Altitude is ignored.
[ "HaversineDistance", "returns", "the", "great", "circle", "distance", "beween", "c1", "and", "c2", "using", "the", "Haversine", "formula", ".", "Altitude", "is", "ignored", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/sphere/sphere.go#L58-L66
13,755
twpayne/go-kml
kml.go
MarshalXML
func (se *SimpleElement) MarshalXML(e *xml.Encoder, start xml.StartElement) error { return e.EncodeElement(xml.CharData(se.value), se.StartElement) }
go
func (se *SimpleElement) MarshalXML(e *xml.Encoder, start xml.StartElement) error { return e.EncodeElement(xml.CharData(se.value), se.StartElement) }
[ "func", "(", "se", "*", "SimpleElement", ")", "MarshalXML", "(", "e", "*", "xml", ".", "Encoder", ",", "start", "xml", ".", "StartElement", ")", "error", "{", "return", "e", ".", "EncodeElement", "(", "xml", ".", "CharData", "(", "se", ".", "value", ")", ",", "se", ".", "StartElement", ")", "\n", "}" ]
// MarshalXML marshals se to e. start is ignored.
[ "MarshalXML", "marshals", "se", "to", "e", ".", "start", "is", "ignored", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L101-L103
13,756
twpayne/go-kml
kml.go
Write
func (se *SimpleElement) Write(w io.Writer) error { return write(w, "", "", se) }
go
func (se *SimpleElement) Write(w io.Writer) error { return write(w, "", "", se) }
[ "func", "(", "se", "*", "SimpleElement", ")", "Write", "(", "w", "io", ".", "Writer", ")", "error", "{", "return", "write", "(", "w", ",", "\"", "\"", ",", "\"", "\"", ",", "se", ")", "\n", "}" ]
// Write writes an XML header and se to w.
[ "Write", "writes", "an", "XML", "header", "and", "se", "to", "w", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L106-L108
13,757
twpayne/go-kml
kml.go
WriteIndent
func (se *SimpleElement) WriteIndent(w io.Writer, prefix, indent string) error { return write(w, prefix, indent, se) }
go
func (se *SimpleElement) WriteIndent(w io.Writer, prefix, indent string) error { return write(w, prefix, indent, se) }
[ "func", "(", "se", "*", "SimpleElement", ")", "WriteIndent", "(", "w", "io", ".", "Writer", ",", "prefix", ",", "indent", "string", ")", "error", "{", "return", "write", "(", "w", ",", "prefix", ",", "indent", ",", "se", ")", "\n", "}" ]
// WriteIndent writes an XML header and se to w.
[ "WriteIndent", "writes", "an", "XML", "header", "and", "se", "to", "w", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L111-L113
13,758
twpayne/go-kml
kml.go
Add
func (ce *CompoundElement) Add(children ...Element) *CompoundElement { ce.children = append(ce.children, children...) return ce }
go
func (ce *CompoundElement) Add(children ...Element) *CompoundElement { ce.children = append(ce.children, children...) return ce }
[ "func", "(", "ce", "*", "CompoundElement", ")", "Add", "(", "children", "...", "Element", ")", "*", "CompoundElement", "{", "ce", ".", "children", "=", "append", "(", "ce", ".", "children", ",", "children", "...", ")", "\n", "return", "ce", "\n", "}" ]
// Add adds children to ce.
[ "Add", "adds", "children", "to", "ce", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L116-L119
13,759
twpayne/go-kml
kml.go
WriteIndent
func (ce *CoordinatesElement) WriteIndent(w io.Writer, prefix, indent string) error { return write(w, prefix, indent, ce) }
go
func (ce *CoordinatesElement) WriteIndent(w io.Writer, prefix, indent string) error { return write(w, prefix, indent, ce) }
[ "func", "(", "ce", "*", "CoordinatesElement", ")", "WriteIndent", "(", "w", "io", ".", "Writer", ",", "prefix", ",", "indent", "string", ")", "error", "{", "return", "write", "(", "w", ",", "prefix", ",", "indent", ",", "ce", ")", "\n", "}" ]
// WriteIndent writes an XML header and ce to w.
[ "WriteIndent", "writes", "an", "XML", "header", "and", "ce", "to", "w", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L181-L183
13,760
twpayne/go-kml
kml.go
MarshalXML
func (cae *CoordinatesArrayElement) MarshalXML(e *xml.Encoder, start xml.StartElement) error { if err := e.EncodeToken(coordinatesStartElement); err != nil { return err } for i, c := range cae.coordinates { s := "" if i != 0 { s = " " } s += strconv.FormatFloat(c[0], 'f', -1, 64) + "," + strconv.FormatFloat(c[1], 'f', -1, 64) if len(c) > 2 && c[2] != 0 { s += "," + strconv.FormatFloat(c[2], 'f', -1, 64) } if err := e.EncodeToken(xml.CharData([]byte(s))); err != nil { return err } } return e.EncodeToken(coordinatesEndElement) }
go
func (cae *CoordinatesArrayElement) MarshalXML(e *xml.Encoder, start xml.StartElement) error { if err := e.EncodeToken(coordinatesStartElement); err != nil { return err } for i, c := range cae.coordinates { s := "" if i != 0 { s = " " } s += strconv.FormatFloat(c[0], 'f', -1, 64) + "," + strconv.FormatFloat(c[1], 'f', -1, 64) if len(c) > 2 && c[2] != 0 { s += "," + strconv.FormatFloat(c[2], 'f', -1, 64) } if err := e.EncodeToken(xml.CharData([]byte(s))); err != nil { return err } } return e.EncodeToken(coordinatesEndElement) }
[ "func", "(", "cae", "*", "CoordinatesArrayElement", ")", "MarshalXML", "(", "e", "*", "xml", ".", "Encoder", ",", "start", "xml", ".", "StartElement", ")", "error", "{", "if", "err", ":=", "e", ".", "EncodeToken", "(", "coordinatesStartElement", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "i", ",", "c", ":=", "range", "cae", ".", "coordinates", "{", "s", ":=", "\"", "\"", "\n", "if", "i", "!=", "0", "{", "s", "=", "\"", "\"", "\n", "}", "\n", "s", "+=", "strconv", ".", "FormatFloat", "(", "c", "[", "0", "]", ",", "'f'", ",", "-", "1", ",", "64", ")", "+", "\"", "\"", "+", "strconv", ".", "FormatFloat", "(", "c", "[", "1", "]", ",", "'f'", ",", "-", "1", ",", "64", ")", "\n", "if", "len", "(", "c", ")", ">", "2", "&&", "c", "[", "2", "]", "!=", "0", "{", "s", "+=", "\"", "\"", "+", "strconv", ".", "FormatFloat", "(", "c", "[", "2", "]", ",", "'f'", ",", "-", "1", ",", "64", ")", "\n", "}", "\n", "if", "err", ":=", "e", ".", "EncodeToken", "(", "xml", ".", "CharData", "(", "[", "]", "byte", "(", "s", ")", ")", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "e", ".", "EncodeToken", "(", "coordinatesEndElement", ")", "\n", "}" ]
// MarshalXML marshals cae to e. start is ignored.
[ "MarshalXML", "marshals", "cae", "to", "e", ".", "start", "is", "ignored", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L186-L204
13,761
twpayne/go-kml
kml.go
Write
func (cae *CoordinatesArrayElement) Write(w io.Writer) error { return write(w, "", " ", cae) }
go
func (cae *CoordinatesArrayElement) Write(w io.Writer) error { return write(w, "", " ", cae) }
[ "func", "(", "cae", "*", "CoordinatesArrayElement", ")", "Write", "(", "w", "io", ".", "Writer", ")", "error", "{", "return", "write", "(", "w", ",", "\"", "\"", ",", "\"", "\"", ",", "cae", ")", "\n", "}" ]
// Write writes an XML header and cae to w.
[ "Write", "writes", "an", "XML", "header", "and", "cae", "to", "w", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L207-L209
13,762
twpayne/go-kml
kml.go
WriteIndent
func (cae *CoordinatesArrayElement) WriteIndent(w io.Writer, prefix, indent string) error { return write(w, prefix, indent, cae) }
go
func (cae *CoordinatesArrayElement) WriteIndent(w io.Writer, prefix, indent string) error { return write(w, prefix, indent, cae) }
[ "func", "(", "cae", "*", "CoordinatesArrayElement", ")", "WriteIndent", "(", "w", "io", ".", "Writer", ",", "prefix", ",", "indent", "string", ")", "error", "{", "return", "write", "(", "w", ",", "prefix", ",", "indent", ",", "cae", ")", "\n", "}" ]
// WriteIndent writes an XML header and cae to w.
[ "WriteIndent", "writes", "an", "XML", "header", "and", "cae", "to", "w", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L212-L214
13,763
twpayne/go-kml
kml.go
MarshalXML
func (cfe *CoordinatesFlatElement) MarshalXML(e *xml.Encoder, start xml.StartElement) error { if err := e.EncodeToken(coordinatesStartElement); err != nil { return err } for i := cfe.offset; i < cfe.end; i += cfe.stride { s := "" if i != cfe.offset { s = " " } s += strconv.FormatFloat(cfe.flatCoords[i], 'f', -1, 64) + "," + strconv.FormatFloat(cfe.flatCoords[i+1], 'f', -1, 64) if cfe.dim > 2 && cfe.flatCoords[i+2] != 0 { s += "," + strconv.FormatFloat(cfe.flatCoords[i+2], 'f', -1, 64) } if err := e.EncodeToken(xml.CharData([]byte(s))); err != nil { return err } } return e.EncodeToken(coordinatesEndElement) }
go
func (cfe *CoordinatesFlatElement) MarshalXML(e *xml.Encoder, start xml.StartElement) error { if err := e.EncodeToken(coordinatesStartElement); err != nil { return err } for i := cfe.offset; i < cfe.end; i += cfe.stride { s := "" if i != cfe.offset { s = " " } s += strconv.FormatFloat(cfe.flatCoords[i], 'f', -1, 64) + "," + strconv.FormatFloat(cfe.flatCoords[i+1], 'f', -1, 64) if cfe.dim > 2 && cfe.flatCoords[i+2] != 0 { s += "," + strconv.FormatFloat(cfe.flatCoords[i+2], 'f', -1, 64) } if err := e.EncodeToken(xml.CharData([]byte(s))); err != nil { return err } } return e.EncodeToken(coordinatesEndElement) }
[ "func", "(", "cfe", "*", "CoordinatesFlatElement", ")", "MarshalXML", "(", "e", "*", "xml", ".", "Encoder", ",", "start", "xml", ".", "StartElement", ")", "error", "{", "if", "err", ":=", "e", ".", "EncodeToken", "(", "coordinatesStartElement", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "i", ":=", "cfe", ".", "offset", ";", "i", "<", "cfe", ".", "end", ";", "i", "+=", "cfe", ".", "stride", "{", "s", ":=", "\"", "\"", "\n", "if", "i", "!=", "cfe", ".", "offset", "{", "s", "=", "\"", "\"", "\n", "}", "\n", "s", "+=", "strconv", ".", "FormatFloat", "(", "cfe", ".", "flatCoords", "[", "i", "]", ",", "'f'", ",", "-", "1", ",", "64", ")", "+", "\"", "\"", "+", "strconv", ".", "FormatFloat", "(", "cfe", ".", "flatCoords", "[", "i", "+", "1", "]", ",", "'f'", ",", "-", "1", ",", "64", ")", "\n", "if", "cfe", ".", "dim", ">", "2", "&&", "cfe", ".", "flatCoords", "[", "i", "+", "2", "]", "!=", "0", "{", "s", "+=", "\"", "\"", "+", "strconv", ".", "FormatFloat", "(", "cfe", ".", "flatCoords", "[", "i", "+", "2", "]", ",", "'f'", ",", "-", "1", ",", "64", ")", "\n", "}", "\n", "if", "err", ":=", "e", ".", "EncodeToken", "(", "xml", ".", "CharData", "(", "[", "]", "byte", "(", "s", ")", ")", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "e", ".", "EncodeToken", "(", "coordinatesEndElement", ")", "\n", "}" ]
// MarshalXML marshals cfe to e. start is ignored.
[ "MarshalXML", "marshals", "cfe", "to", "e", ".", "start", "is", "ignored", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L217-L235
13,764
twpayne/go-kml
kml.go
Write
func (cfe *CoordinatesFlatElement) Write(w io.Writer) error { return write(w, "", " ", cfe) }
go
func (cfe *CoordinatesFlatElement) Write(w io.Writer) error { return write(w, "", " ", cfe) }
[ "func", "(", "cfe", "*", "CoordinatesFlatElement", ")", "Write", "(", "w", "io", ".", "Writer", ")", "error", "{", "return", "write", "(", "w", ",", "\"", "\"", ",", "\"", "\"", ",", "cfe", ")", "\n", "}" ]
// Write writes an XML header and cfe to w.
[ "Write", "writes", "an", "XML", "header", "and", "cfe", "to", "w", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L238-L240
13,765
twpayne/go-kml
kml.go
WriteIndent
func (cfe *CoordinatesFlatElement) WriteIndent(w io.Writer, prefix, indent string) error { return write(w, prefix, indent, cfe) }
go
func (cfe *CoordinatesFlatElement) WriteIndent(w io.Writer, prefix, indent string) error { return write(w, prefix, indent, cfe) }
[ "func", "(", "cfe", "*", "CoordinatesFlatElement", ")", "WriteIndent", "(", "w", "io", ".", "Writer", ",", "prefix", ",", "indent", "string", ")", "error", "{", "return", "write", "(", "w", ",", "prefix", ",", "indent", ",", "cfe", ")", "\n", "}" ]
// WriteIndent writes an XML header and cfe to w.
[ "WriteIndent", "writes", "an", "XML", "header", "and", "cfe", "to", "w", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L243-L245
13,766
twpayne/go-kml
kml.go
CoordinatesFlat
func CoordinatesFlat(flatCoords []float64, offset, end, stride, dim int) *CoordinatesFlatElement { return &CoordinatesFlatElement{ flatCoords: flatCoords, offset: offset, end: end, stride: stride, dim: dim, } }
go
func CoordinatesFlat(flatCoords []float64, offset, end, stride, dim int) *CoordinatesFlatElement { return &CoordinatesFlatElement{ flatCoords: flatCoords, offset: offset, end: end, stride: stride, dim: dim, } }
[ "func", "CoordinatesFlat", "(", "flatCoords", "[", "]", "float64", ",", "offset", ",", "end", ",", "stride", ",", "dim", "int", ")", "*", "CoordinatesFlatElement", "{", "return", "&", "CoordinatesFlatElement", "{", "flatCoords", ":", "flatCoords", ",", "offset", ":", "offset", ",", "end", ":", "end", ",", "stride", ":", "stride", ",", "dim", ":", "dim", ",", "}", "\n", "}" ]
// CoordinatesFlat returns a new Coordinates element from flat coordinates.
[ "CoordinatesFlat", "returns", "a", "new", "Coordinates", "element", "from", "flat", "coordinates", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L624-L632
13,767
twpayne/go-kml
kml.go
LinkSnippet
func LinkSnippet(maxLines int, value string) *SimpleElement { return &SimpleElement{ StartElement: xml.StartElement{ Name: xml.Name{Local: "linkSnippet"}, Attr: []xml.Attr{ {Name: xml.Name{Local: "maxLines"}, Value: strconv.Itoa(maxLines)}, }, }, value: value, } }
go
func LinkSnippet(maxLines int, value string) *SimpleElement { return &SimpleElement{ StartElement: xml.StartElement{ Name: xml.Name{Local: "linkSnippet"}, Attr: []xml.Attr{ {Name: xml.Name{Local: "maxLines"}, Value: strconv.Itoa(maxLines)}, }, }, value: value, } }
[ "func", "LinkSnippet", "(", "maxLines", "int", ",", "value", "string", ")", "*", "SimpleElement", "{", "return", "&", "SimpleElement", "{", "StartElement", ":", "xml", ".", "StartElement", "{", "Name", ":", "xml", ".", "Name", "{", "Local", ":", "\"", "\"", "}", ",", "Attr", ":", "[", "]", "xml", ".", "Attr", "{", "{", "Name", ":", "xml", ".", "Name", "{", "Local", ":", "\"", "\"", "}", ",", "Value", ":", "strconv", ".", "Itoa", "(", "maxLines", ")", "}", ",", "}", ",", "}", ",", "value", ":", "value", ",", "}", "\n", "}" ]
// LinkSnippet returns a new LinkSnippet element.
[ "LinkSnippet", "returns", "a", "new", "LinkSnippet", "element", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L677-L687
13,768
twpayne/go-kml
kml.go
Schema
func Schema(id, name string, children ...Element) *SharedElement { return &SharedElement{ CompoundElement: CompoundElement{ StartElement: xml.StartElement{ Name: xml.Name{Local: "Schema"}, Attr: []xml.Attr{ {Name: xml.Name{Local: "id"}, Value: id}, {Name: xml.Name{Local: "name"}, Value: name}, }, }, children: children, }, id: id, } }
go
func Schema(id, name string, children ...Element) *SharedElement { return &SharedElement{ CompoundElement: CompoundElement{ StartElement: xml.StartElement{ Name: xml.Name{Local: "Schema"}, Attr: []xml.Attr{ {Name: xml.Name{Local: "id"}, Value: id}, {Name: xml.Name{Local: "name"}, Value: name}, }, }, children: children, }, id: id, } }
[ "func", "Schema", "(", "id", ",", "name", "string", ",", "children", "...", "Element", ")", "*", "SharedElement", "{", "return", "&", "SharedElement", "{", "CompoundElement", ":", "CompoundElement", "{", "StartElement", ":", "xml", ".", "StartElement", "{", "Name", ":", "xml", ".", "Name", "{", "Local", ":", "\"", "\"", "}", ",", "Attr", ":", "[", "]", "xml", ".", "Attr", "{", "{", "Name", ":", "xml", ".", "Name", "{", "Local", ":", "\"", "\"", "}", ",", "Value", ":", "id", "}", ",", "{", "Name", ":", "xml", ".", "Name", "{", "Local", ":", "\"", "\"", "}", ",", "Value", ":", "name", "}", ",", "}", ",", "}", ",", "children", ":", "children", ",", "}", ",", "id", ":", "id", ",", "}", "\n", "}" ]
// Schema returns a new Schema element.
[ "Schema", "returns", "a", "new", "Schema", "element", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L695-L709
13,769
twpayne/go-kml
kml.go
SchemaData
func SchemaData(schemaURL string, children ...Element) *CompoundElement { return &CompoundElement{ StartElement: xml.StartElement{ Name: xml.Name{Local: "SchemaData"}, Attr: []xml.Attr{ {Name: xml.Name{Local: "schemaUrl"}, Value: schemaURL}, }, }, children: children, } }
go
func SchemaData(schemaURL string, children ...Element) *CompoundElement { return &CompoundElement{ StartElement: xml.StartElement{ Name: xml.Name{Local: "SchemaData"}, Attr: []xml.Attr{ {Name: xml.Name{Local: "schemaUrl"}, Value: schemaURL}, }, }, children: children, } }
[ "func", "SchemaData", "(", "schemaURL", "string", ",", "children", "...", "Element", ")", "*", "CompoundElement", "{", "return", "&", "CompoundElement", "{", "StartElement", ":", "xml", ".", "StartElement", "{", "Name", ":", "xml", ".", "Name", "{", "Local", ":", "\"", "\"", "}", ",", "Attr", ":", "[", "]", "xml", ".", "Attr", "{", "{", "Name", ":", "xml", ".", "Name", "{", "Local", ":", "\"", "\"", "}", ",", "Value", ":", "schemaURL", "}", ",", "}", ",", "}", ",", "children", ":", "children", ",", "}", "\n", "}" ]
// SchemaData returns a new SchemaData element.
[ "SchemaData", "returns", "a", "new", "SchemaData", "element", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L712-L722
13,770
twpayne/go-kml
kml.go
SimpleData
func SimpleData(name, value string) *SimpleElement { return &SimpleElement{ StartElement: xml.StartElement{ Name: xml.Name{Local: "SimpleData"}, Attr: []xml.Attr{ {Name: xml.Name{Local: "name"}, Value: name}, }, }, value: value, } }
go
func SimpleData(name, value string) *SimpleElement { return &SimpleElement{ StartElement: xml.StartElement{ Name: xml.Name{Local: "SimpleData"}, Attr: []xml.Attr{ {Name: xml.Name{Local: "name"}, Value: name}, }, }, value: value, } }
[ "func", "SimpleData", "(", "name", ",", "value", "string", ")", "*", "SimpleElement", "{", "return", "&", "SimpleElement", "{", "StartElement", ":", "xml", ".", "StartElement", "{", "Name", ":", "xml", ".", "Name", "{", "Local", ":", "\"", "\"", "}", ",", "Attr", ":", "[", "]", "xml", ".", "Attr", "{", "{", "Name", ":", "xml", ".", "Name", "{", "Local", ":", "\"", "\"", "}", ",", "Value", ":", "name", "}", ",", "}", ",", "}", ",", "value", ":", "value", ",", "}", "\n", "}" ]
// SimpleData returns a new SimpleData element.
[ "SimpleData", "returns", "a", "new", "SimpleData", "element", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L735-L745
13,771
twpayne/go-kml
kml.go
SimpleField
func SimpleField(name, _type string, children ...Element) *CompoundElement { return &CompoundElement{ StartElement: xml.StartElement{ Name: xml.Name{Local: "SimpleField"}, Attr: []xml.Attr{ {Name: xml.Name{Local: "name"}, Value: name}, {Name: xml.Name{Local: "type"}, Value: _type}, }, }, children: children, } }
go
func SimpleField(name, _type string, children ...Element) *CompoundElement { return &CompoundElement{ StartElement: xml.StartElement{ Name: xml.Name{Local: "SimpleField"}, Attr: []xml.Attr{ {Name: xml.Name{Local: "name"}, Value: name}, {Name: xml.Name{Local: "type"}, Value: _type}, }, }, children: children, } }
[ "func", "SimpleField", "(", "name", ",", "_type", "string", ",", "children", "...", "Element", ")", "*", "CompoundElement", "{", "return", "&", "CompoundElement", "{", "StartElement", ":", "xml", ".", "StartElement", "{", "Name", ":", "xml", ".", "Name", "{", "Local", ":", "\"", "\"", "}", ",", "Attr", ":", "[", "]", "xml", ".", "Attr", "{", "{", "Name", ":", "xml", ".", "Name", "{", "Local", ":", "\"", "\"", "}", ",", "Value", ":", "name", "}", ",", "{", "Name", ":", "xml", ".", "Name", "{", "Local", ":", "\"", "\"", "}", ",", "Value", ":", "_type", "}", ",", "}", ",", "}", ",", "children", ":", "children", ",", "}", "\n", "}" ]
// SimpleField returns a new SimpleField element.
[ "SimpleField", "returns", "a", "new", "SimpleField", "element", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L748-L759
13,772
twpayne/go-kml
kml.go
KML
func KML(children ...Element) *CompoundElement { return &CompoundElement{ StartElement: xml.StartElement{ Name: xml.Name{Space: Namespace, Local: "kml"}, }, children: children, } }
go
func KML(children ...Element) *CompoundElement { return &CompoundElement{ StartElement: xml.StartElement{ Name: xml.Name{Space: Namespace, Local: "kml"}, }, children: children, } }
[ "func", "KML", "(", "children", "...", "Element", ")", "*", "CompoundElement", "{", "return", "&", "CompoundElement", "{", "StartElement", ":", "xml", ".", "StartElement", "{", "Name", ":", "xml", ".", "Name", "{", "Space", ":", "Namespace", ",", "Local", ":", "\"", "\"", "}", ",", "}", ",", "children", ":", "children", ",", "}", "\n", "}" ]
// KML returns a new kml element.
[ "KML", "returns", "a", "new", "kml", "element", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L762-L769
13,773
twpayne/go-kml
kml.go
GxKML
func GxKML(children ...Element) *CompoundElement { kml := KML(children...) // FIXME find a more correct way to do this kml.Attr = append(kml.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:gx"}, Value: GxNamespace}) return kml }
go
func GxKML(children ...Element) *CompoundElement { kml := KML(children...) // FIXME find a more correct way to do this kml.Attr = append(kml.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:gx"}, Value: GxNamespace}) return kml }
[ "func", "GxKML", "(", "children", "...", "Element", ")", "*", "CompoundElement", "{", "kml", ":=", "KML", "(", "children", "...", ")", "\n", "// FIXME find a more correct way to do this", "kml", ".", "Attr", "=", "append", "(", "kml", ".", "Attr", ",", "xml", ".", "Attr", "{", "Name", ":", "xml", ".", "Name", "{", "Local", ":", "\"", "\"", "}", ",", "Value", ":", "GxNamespace", "}", ")", "\n", "return", "kml", "\n", "}" ]
// GxKML returns a new kml element with Google Earth extensions.
[ "GxKML", "returns", "a", "new", "kml", "element", "with", "Google", "Earth", "extensions", "." ]
6c6eeaa06f794edd7647cc6bc00c208fa92c1a48
https://github.com/twpayne/go-kml/blob/6c6eeaa06f794edd7647cc6bc00c208fa92c1a48/kml.go#L772-L777
13,774
coyim/otr3
message_events.go
String
func (s MessageEvent) String() string { switch s { case MessageEventEncryptionRequired: return "MessageEventEncryptionRequired" case MessageEventEncryptionError: return "MessageEventEncryptionError" case MessageEventConnectionEnded: return "MessageEventConnectionEnded" case MessageEventSetupError: return "MessageEventSetupError" case MessageEventMessageReflected: return "MessageEventMessageReflected" case MessageEventMessageSent: return "MessageEventMessageSent" case MessageEventMessageResent: return "MessageEventMessageResent" case MessageEventReceivedMessageNotInPrivate: return "MessageEventReceivedMessageNotInPrivate" case MessageEventReceivedMessageUnreadable: return "MessageEventReceivedMessageUnreadable" case MessageEventReceivedMessageMalformed: return "MessageEventReceivedMessageMalformed" case MessageEventLogHeartbeatReceived: return "MessageEventLogHeartbeatReceived" case MessageEventLogHeartbeatSent: return "MessageEventLogHeartbeatSent" case MessageEventReceivedMessageGeneralError: return "MessageEventReceivedMessageGeneralError" case MessageEventReceivedMessageUnencrypted: return "MessageEventReceivedMessageUnencrypted" case MessageEventReceivedMessageUnrecognized: return "MessageEventReceivedMessageUnrecognized" case MessageEventReceivedMessageForOtherInstance: return "MessageEventReceivedMessageForOtherInstance" default: return "MESSAGE EVENT: (THIS SHOULD NEVER HAPPEN)" } }
go
func (s MessageEvent) String() string { switch s { case MessageEventEncryptionRequired: return "MessageEventEncryptionRequired" case MessageEventEncryptionError: return "MessageEventEncryptionError" case MessageEventConnectionEnded: return "MessageEventConnectionEnded" case MessageEventSetupError: return "MessageEventSetupError" case MessageEventMessageReflected: return "MessageEventMessageReflected" case MessageEventMessageSent: return "MessageEventMessageSent" case MessageEventMessageResent: return "MessageEventMessageResent" case MessageEventReceivedMessageNotInPrivate: return "MessageEventReceivedMessageNotInPrivate" case MessageEventReceivedMessageUnreadable: return "MessageEventReceivedMessageUnreadable" case MessageEventReceivedMessageMalformed: return "MessageEventReceivedMessageMalformed" case MessageEventLogHeartbeatReceived: return "MessageEventLogHeartbeatReceived" case MessageEventLogHeartbeatSent: return "MessageEventLogHeartbeatSent" case MessageEventReceivedMessageGeneralError: return "MessageEventReceivedMessageGeneralError" case MessageEventReceivedMessageUnencrypted: return "MessageEventReceivedMessageUnencrypted" case MessageEventReceivedMessageUnrecognized: return "MessageEventReceivedMessageUnrecognized" case MessageEventReceivedMessageForOtherInstance: return "MessageEventReceivedMessageForOtherInstance" default: return "MESSAGE EVENT: (THIS SHOULD NEVER HAPPEN)" } }
[ "func", "(", "s", "MessageEvent", ")", "String", "(", ")", "string", "{", "switch", "s", "{", "case", "MessageEventEncryptionRequired", ":", "return", "\"", "\"", "\n", "case", "MessageEventEncryptionError", ":", "return", "\"", "\"", "\n", "case", "MessageEventConnectionEnded", ":", "return", "\"", "\"", "\n", "case", "MessageEventSetupError", ":", "return", "\"", "\"", "\n", "case", "MessageEventMessageReflected", ":", "return", "\"", "\"", "\n", "case", "MessageEventMessageSent", ":", "return", "\"", "\"", "\n", "case", "MessageEventMessageResent", ":", "return", "\"", "\"", "\n", "case", "MessageEventReceivedMessageNotInPrivate", ":", "return", "\"", "\"", "\n", "case", "MessageEventReceivedMessageUnreadable", ":", "return", "\"", "\"", "\n", "case", "MessageEventReceivedMessageMalformed", ":", "return", "\"", "\"", "\n", "case", "MessageEventLogHeartbeatReceived", ":", "return", "\"", "\"", "\n", "case", "MessageEventLogHeartbeatSent", ":", "return", "\"", "\"", "\n", "case", "MessageEventReceivedMessageGeneralError", ":", "return", "\"", "\"", "\n", "case", "MessageEventReceivedMessageUnencrypted", ":", "return", "\"", "\"", "\n", "case", "MessageEventReceivedMessageUnrecognized", ":", "return", "\"", "\"", "\n", "case", "MessageEventReceivedMessageForOtherInstance", ":", "return", "\"", "\"", "\n", "default", ":", "return", "\"", "\"", "\n", "}", "\n", "}" ]
// String returns the string representation of the MessageEvent
[ "String", "returns", "the", "string", "representation", "of", "the", "MessageEvent" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/message_events.go#L94-L131
13,775
coyim/otr3
message_events.go
HandleMessageEvent
func (DebugMessageEventHandler) HandleMessageEvent(event MessageEvent, message []byte, err error, trace ...interface{}) { fmt.Fprintf(standardErrorOutput, "%sHandleMessageEvent(%s, message: %#v, error: %v, trace: %v)\n", debugPrefix, event, string(message), err, trace) }
go
func (DebugMessageEventHandler) HandleMessageEvent(event MessageEvent, message []byte, err error, trace ...interface{}) { fmt.Fprintf(standardErrorOutput, "%sHandleMessageEvent(%s, message: %#v, error: %v, trace: %v)\n", debugPrefix, event, string(message), err, trace) }
[ "func", "(", "DebugMessageEventHandler", ")", "HandleMessageEvent", "(", "event", "MessageEvent", ",", "message", "[", "]", "byte", ",", "err", "error", ",", "trace", "...", "interface", "{", "}", ")", "{", "fmt", ".", "Fprintf", "(", "standardErrorOutput", ",", "\"", "\\n", "\"", ",", "debugPrefix", ",", "event", ",", "string", "(", "message", ")", ",", "err", ",", "trace", ")", "\n", "}" ]
// HandleMessageEvent dumps all message events
[ "HandleMessageEvent", "dumps", "all", "message", "events" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/message_events.go#L155-L157
13,776
coyim/otr3
debug.go
dumpAKE
func (c *Conversation) dumpAKE(w *bufio.Writer) { w.WriteString(" Auth info:\n") if c.ake != nil { w.WriteString(fmt.Sprintf(" State: %d (%s)\n", c.ake.state.identity(), c.ake.state.identityString())) } w.WriteString(fmt.Sprintf(" Our keyid: %d\n", c.keys.ourKeyID)) w.WriteString(fmt.Sprintf(" Their keyid: %d\n", c.keys.theirKeyID)) w.WriteString(fmt.Sprintf(" Their fingerprint: %X\n", c.theirKey.Fingerprint())) w.WriteString(fmt.Sprintf(" Proto version = %d\n", c.version.protocolVersion())) w.Flush() }
go
func (c *Conversation) dumpAKE(w *bufio.Writer) { w.WriteString(" Auth info:\n") if c.ake != nil { w.WriteString(fmt.Sprintf(" State: %d (%s)\n", c.ake.state.identity(), c.ake.state.identityString())) } w.WriteString(fmt.Sprintf(" Our keyid: %d\n", c.keys.ourKeyID)) w.WriteString(fmt.Sprintf(" Their keyid: %d\n", c.keys.theirKeyID)) w.WriteString(fmt.Sprintf(" Their fingerprint: %X\n", c.theirKey.Fingerprint())) w.WriteString(fmt.Sprintf(" Proto version = %d\n", c.version.protocolVersion())) w.Flush() }
[ "func", "(", "c", "*", "Conversation", ")", "dumpAKE", "(", "w", "*", "bufio", ".", "Writer", ")", "{", "w", ".", "WriteString", "(", "\"", "\\n", "\"", ")", "\n\n", "if", "c", ".", "ake", "!=", "nil", "{", "w", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "c", ".", "ake", ".", "state", ".", "identity", "(", ")", ",", "c", ".", "ake", ".", "state", ".", "identityString", "(", ")", ")", ")", "\n", "}", "\n\n", "w", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "c", ".", "keys", ".", "ourKeyID", ")", ")", "\n", "w", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "c", ".", "keys", ".", "theirKeyID", ")", ")", "\n", "w", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "c", ".", "theirKey", ".", "Fingerprint", "(", ")", ")", ")", "\n", "w", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "c", ".", "version", ".", "protocolVersion", "(", ")", ")", ")", "\n", "w", ".", "Flush", "(", ")", "\n", "}" ]
// Will only be called if AKE is valid
[ "Will", "only", "be", "called", "if", "AKE", "is", "valid" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/debug.go#L58-L70
13,777
coyim/otr3
bn_utils.go
divMod
func divMod(l, r, m *big.Int) *big.Int { return mulMod(l, modInverse(r, m), m) }
go
func divMod(l, r, m *big.Int) *big.Int { return mulMod(l, modInverse(r, m), m) }
[ "func", "divMod", "(", "l", ",", "r", ",", "m", "*", "big", ".", "Int", ")", "*", "big", ".", "Int", "{", "return", "mulMod", "(", "l", ",", "modInverse", "(", "r", ",", "m", ")", ",", "m", ")", "\n", "}" ]
// Fast division over a modular field, without using division
[ "Fast", "division", "over", "a", "modular", "field", "without", "using", "division" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/bn_utils.go#L28-L30
13,778
coyim/otr3
whitespace.go
extractWhitespaceTag
func extractWhitespaceTag(message ValidMessage) (plain MessagePlaintext, versions int) { wsPos := bytes.Index(message, whitespaceTagHeader) currentData := message[wsPos+len(whitespaceTagHeader):] for { aw, r, has := nextAllWhite(currentData) if !has { break } currentData = r if bytes.Equal(aw, otrV3{}.whitespaceTag()) { versions |= (1 << 3) } else if bytes.Equal(aw, otrV2{}.whitespaceTag()) { versions |= (1 << 2) } } plain = makeCopy(append(message[:wsPos], currentData...)) return }
go
func extractWhitespaceTag(message ValidMessage) (plain MessagePlaintext, versions int) { wsPos := bytes.Index(message, whitespaceTagHeader) currentData := message[wsPos+len(whitespaceTagHeader):] for { aw, r, has := nextAllWhite(currentData) if !has { break } currentData = r if bytes.Equal(aw, otrV3{}.whitespaceTag()) { versions |= (1 << 3) } else if bytes.Equal(aw, otrV2{}.whitespaceTag()) { versions |= (1 << 2) } } plain = makeCopy(append(message[:wsPos], currentData...)) return }
[ "func", "extractWhitespaceTag", "(", "message", "ValidMessage", ")", "(", "plain", "MessagePlaintext", ",", "versions", "int", ")", "{", "wsPos", ":=", "bytes", ".", "Index", "(", "message", ",", "whitespaceTagHeader", ")", "\n", "currentData", ":=", "message", "[", "wsPos", "+", "len", "(", "whitespaceTagHeader", ")", ":", "]", "\n\n", "for", "{", "aw", ",", "r", ",", "has", ":=", "nextAllWhite", "(", "currentData", ")", "\n", "if", "!", "has", "{", "break", "\n", "}", "\n", "currentData", "=", "r", "\n", "if", "bytes", ".", "Equal", "(", "aw", ",", "otrV3", "{", "}", ".", "whitespaceTag", "(", ")", ")", "{", "versions", "|=", "(", "1", "<<", "3", ")", "\n", "}", "else", "if", "bytes", ".", "Equal", "(", "aw", ",", "otrV2", "{", "}", ".", "whitespaceTag", "(", ")", ")", "{", "versions", "|=", "(", "1", "<<", "2", ")", "\n", "}", "\n", "}", "\n\n", "plain", "=", "makeCopy", "(", "append", "(", "message", "[", ":", "wsPos", "]", ",", "currentData", "...", ")", ")", "\n", "return", "\n", "}" ]
// By the spec "this tag may occur anywhere in the message"
[ "By", "the", "spec", "this", "tag", "may", "occur", "anywhere", "in", "the", "message" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/whitespace.go#L57-L76
13,779
coyim/otr3
inject_message.go
injectMessage
func (c *Conversation) injectMessage(vm ValidMessage) { c.injections.messages = append(c.injections.messages, vm) }
go
func (c *Conversation) injectMessage(vm ValidMessage) { c.injections.messages = append(c.injections.messages, vm) }
[ "func", "(", "c", "*", "Conversation", ")", "injectMessage", "(", "vm", "ValidMessage", ")", "{", "c", ".", "injections", ".", "messages", "=", "append", "(", "c", ".", "injections", ".", "messages", ",", "vm", ")", "\n", "}" ]
// injectMessage will promise to send the messages now or later // The Injected Messages are promised to be well formed valid messages // including fragmentation and encoding
[ "injectMessage", "will", "promise", "to", "send", "the", "messages", "now", "or", "later", "The", "Injected", "Messages", "are", "promised", "to", "be", "well", "formed", "valid", "messages", "including", "fragmentation", "and", "encoding" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/inject_message.go#L10-L12
13,780
coyim/otr3
sexp/symbol.go
ReadSymbol
func ReadSymbol(r *bufio.Reader) Value { ReadWhitespace(r) result := ReadDataUntil(r, isNotSymbolCharacter) return Symbol(result) }
go
func ReadSymbol(r *bufio.Reader) Value { ReadWhitespace(r) result := ReadDataUntil(r, isNotSymbolCharacter) return Symbol(result) }
[ "func", "ReadSymbol", "(", "r", "*", "bufio", ".", "Reader", ")", "Value", "{", "ReadWhitespace", "(", "r", ")", "\n", "result", ":=", "ReadDataUntil", "(", "r", ",", "isNotSymbolCharacter", ")", "\n", "return", "Symbol", "(", "result", ")", "\n", "}" ]
// ReadSymbol will read a symbol from the reader
[ "ReadSymbol", "will", "read", "a", "symbol", "from", "the", "reader" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/sexp/symbol.go#L29-L33
13,781
coyim/otr3
query.go
QueryMessage
func (c Conversation) QueryMessage() ValidMessage { queryMessage := []byte("?OTRv") if c.Policies.has(allowV2) { queryMessage = append(queryMessage, '2') } if c.Policies.has(allowV3) { queryMessage = append(queryMessage, '3') } suffix := "?" if c.friendlyQueryMessage != "" { suffix = "? " + c.friendlyQueryMessage } return append(queryMessage, suffix...) }
go
func (c Conversation) QueryMessage() ValidMessage { queryMessage := []byte("?OTRv") if c.Policies.has(allowV2) { queryMessage = append(queryMessage, '2') } if c.Policies.has(allowV3) { queryMessage = append(queryMessage, '3') } suffix := "?" if c.friendlyQueryMessage != "" { suffix = "? " + c.friendlyQueryMessage } return append(queryMessage, suffix...) }
[ "func", "(", "c", "Conversation", ")", "QueryMessage", "(", ")", "ValidMessage", "{", "queryMessage", ":=", "[", "]", "byte", "(", "\"", "\"", ")", "\n\n", "if", "c", ".", "Policies", ".", "has", "(", "allowV2", ")", "{", "queryMessage", "=", "append", "(", "queryMessage", ",", "'2'", ")", "\n", "}", "\n\n", "if", "c", ".", "Policies", ".", "has", "(", "allowV3", ")", "{", "queryMessage", "=", "append", "(", "queryMessage", ",", "'3'", ")", "\n", "}", "\n\n", "suffix", ":=", "\"", "\"", "\n", "if", "c", ".", "friendlyQueryMessage", "!=", "\"", "\"", "{", "suffix", "=", "\"", "\"", "+", "c", ".", "friendlyQueryMessage", "\n", "}", "\n\n", "return", "append", "(", "queryMessage", ",", "suffix", "...", ")", "\n", "}" ]
//QueryMessage will return a QueryMessage determined by Conversation Policies
[ "QueryMessage", "will", "return", "a", "QueryMessage", "determined", "by", "Conversation", "Policies" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/query.go#L74-L91
13,782
coyim/otr3
keys.go
GenerateMissingKeys
func GenerateMissingKeys(existing [][]byte) ([]PrivateKey, error) { var result []PrivateKey hasDSA := false for _, x := range existing { _, typeTag, ok := gotrax.ExtractShort(x) if ok && typeTag == dsaKeyTypeValue { hasDSA = true } } if !hasDSA { var priv DSAPrivateKey if err := priv.Generate(rand.Reader); err != nil { return nil, err } result = append(result, &priv) } return result, nil }
go
func GenerateMissingKeys(existing [][]byte) ([]PrivateKey, error) { var result []PrivateKey hasDSA := false for _, x := range existing { _, typeTag, ok := gotrax.ExtractShort(x) if ok && typeTag == dsaKeyTypeValue { hasDSA = true } } if !hasDSA { var priv DSAPrivateKey if err := priv.Generate(rand.Reader); err != nil { return nil, err } result = append(result, &priv) } return result, nil }
[ "func", "GenerateMissingKeys", "(", "existing", "[", "]", "[", "]", "byte", ")", "(", "[", "]", "PrivateKey", ",", "error", ")", "{", "var", "result", "[", "]", "PrivateKey", "\n", "hasDSA", ":=", "false", "\n\n", "for", "_", ",", "x", ":=", "range", "existing", "{", "_", ",", "typeTag", ",", "ok", ":=", "gotrax", ".", "ExtractShort", "(", "x", ")", "\n", "if", "ok", "&&", "typeTag", "==", "dsaKeyTypeValue", "{", "hasDSA", "=", "true", "\n", "}", "\n", "}", "\n\n", "if", "!", "hasDSA", "{", "var", "priv", "DSAPrivateKey", "\n", "if", "err", ":=", "priv", ".", "Generate", "(", "rand", ".", "Reader", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "result", "=", "append", "(", "result", ",", "&", "priv", ")", "\n", "}", "\n\n", "return", "result", ",", "nil", "\n", "}" ]
// GenerateMissingKeys will look through the existing serialized keys and generate new keys to ensure that the functioning of this version of OTR will work correctly. It will only return the newly generated keys, not the old ones
[ "GenerateMissingKeys", "will", "look", "through", "the", "existing", "serialized", "keys", "and", "generate", "new", "keys", "to", "ensure", "that", "the", "functioning", "of", "this", "version", "of", "OTR", "will", "work", "correctly", ".", "It", "will", "only", "return", "the", "newly", "generated", "keys", "not", "the", "old", "ones" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/keys.go#L42-L62
13,783
coyim/otr3
keys.go
ImportKeysFromFile
func ImportKeysFromFile(fname string) ([]*Account, error) { f, err := os.Open(fname) if err != nil { return nil, err } defer f.Close() return ImportKeys(f) }
go
func ImportKeysFromFile(fname string) ([]*Account, error) { f, err := os.Open(fname) if err != nil { return nil, err } defer f.Close() return ImportKeys(f) }
[ "func", "ImportKeysFromFile", "(", "fname", "string", ")", "(", "[", "]", "*", "Account", ",", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "fname", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "f", ".", "Close", "(", ")", "\n", "return", "ImportKeys", "(", "f", ")", "\n", "}" ]
// ImportKeysFromFile will read the libotr formatted file given and return all accounts defined in it
[ "ImportKeysFromFile", "will", "read", "the", "libotr", "formatted", "file", "given", "and", "return", "all", "accounts", "defined", "in", "it" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/keys.go#L132-L139
13,784
coyim/otr3
keys.go
ImportKeys
func ImportKeys(r io.Reader) ([]*Account, error) { res, ok := readAccounts(bufio.NewReader(r)) if !ok { return nil, newOtrError("couldn't import data into private key") } return res, nil }
go
func ImportKeys(r io.Reader) ([]*Account, error) { res, ok := readAccounts(bufio.NewReader(r)) if !ok { return nil, newOtrError("couldn't import data into private key") } return res, nil }
[ "func", "ImportKeys", "(", "r", "io", ".", "Reader", ")", "(", "[", "]", "*", "Account", ",", "error", ")", "{", "res", ",", "ok", ":=", "readAccounts", "(", "bufio", ".", "NewReader", "(", "r", ")", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "newOtrError", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "res", ",", "nil", "\n", "}" ]
// ImportKeys will read the libotr formatted data given and return all accounts defined in it
[ "ImportKeys", "will", "read", "the", "libotr", "formatted", "data", "given", "and", "return", "all", "accounts", "defined", "in", "it" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/keys.go#L153-L159
13,785
coyim/otr3
keys.go
IsSame
func (pub *DSAPublicKey) IsSame(other PublicKey) bool { oth, ok := other.(*DSAPublicKey) return ok && pub == oth }
go
func (pub *DSAPublicKey) IsSame(other PublicKey) bool { oth, ok := other.(*DSAPublicKey) return ok && pub == oth }
[ "func", "(", "pub", "*", "DSAPublicKey", ")", "IsSame", "(", "other", "PublicKey", ")", "bool", "{", "oth", ",", "ok", ":=", "other", ".", "(", "*", "DSAPublicKey", ")", "\n", "return", "ok", "&&", "pub", "==", "oth", "\n", "}" ]
// IsSame returns true if the given public key is a DSA public key that is equal to this key
[ "IsSame", "returns", "true", "if", "the", "given", "public", "key", "is", "a", "DSA", "public", "key", "that", "is", "equal", "to", "this", "key" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/keys.go#L279-L282
13,786
coyim/otr3
keys.go
ParsePrivateKey
func ParsePrivateKey(in []byte) (index []byte, ok bool, key PrivateKey) { var typeTag uint16 index, typeTag, ok = gotrax.ExtractShort(in) if !ok { return in, false, nil } switch typeTag { case dsaKeyTypeValue: key = &DSAPrivateKey{} index, ok = key.Parse(in) return } return in, false, nil }
go
func ParsePrivateKey(in []byte) (index []byte, ok bool, key PrivateKey) { var typeTag uint16 index, typeTag, ok = gotrax.ExtractShort(in) if !ok { return in, false, nil } switch typeTag { case dsaKeyTypeValue: key = &DSAPrivateKey{} index, ok = key.Parse(in) return } return in, false, nil }
[ "func", "ParsePrivateKey", "(", "in", "[", "]", "byte", ")", "(", "index", "[", "]", "byte", ",", "ok", "bool", ",", "key", "PrivateKey", ")", "{", "var", "typeTag", "uint16", "\n", "index", ",", "typeTag", ",", "ok", "=", "gotrax", ".", "ExtractShort", "(", "in", ")", "\n", "if", "!", "ok", "{", "return", "in", ",", "false", ",", "nil", "\n", "}", "\n\n", "switch", "typeTag", "{", "case", "dsaKeyTypeValue", ":", "key", "=", "&", "DSAPrivateKey", "{", "}", "\n", "index", ",", "ok", "=", "key", ".", "Parse", "(", "in", ")", "\n", "return", "\n", "}", "\n\n", "return", "in", ",", "false", ",", "nil", "\n", "}" ]
// ParsePrivateKey is an algorithm indepedent way of parsing private keys
[ "ParsePrivateKey", "is", "an", "algorithm", "indepedent", "way", "of", "parsing", "private", "keys" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/keys.go#L285-L300
13,787
coyim/otr3
keys.go
ParsePublicKey
func ParsePublicKey(in []byte) (index []byte, ok bool, key PublicKey) { var typeTag uint16 index, typeTag, ok = gotrax.ExtractShort(in) if !ok { return in, false, nil } switch typeTag { case dsaKeyTypeValue: key = &DSAPublicKey{} index, ok = key.Parse(in) return } return in, false, nil }
go
func ParsePublicKey(in []byte) (index []byte, ok bool, key PublicKey) { var typeTag uint16 index, typeTag, ok = gotrax.ExtractShort(in) if !ok { return in, false, nil } switch typeTag { case dsaKeyTypeValue: key = &DSAPublicKey{} index, ok = key.Parse(in) return } return in, false, nil }
[ "func", "ParsePublicKey", "(", "in", "[", "]", "byte", ")", "(", "index", "[", "]", "byte", ",", "ok", "bool", ",", "key", "PublicKey", ")", "{", "var", "typeTag", "uint16", "\n", "index", ",", "typeTag", ",", "ok", "=", "gotrax", ".", "ExtractShort", "(", "in", ")", "\n", "if", "!", "ok", "{", "return", "in", ",", "false", ",", "nil", "\n", "}", "\n\n", "switch", "typeTag", "{", "case", "dsaKeyTypeValue", ":", "key", "=", "&", "DSAPublicKey", "{", "}", "\n", "index", ",", "ok", "=", "key", ".", "Parse", "(", "in", ")", "\n", "return", "\n", "}", "\n\n", "return", "in", ",", "false", ",", "nil", "\n", "}" ]
// ParsePublicKey is an algorithm independent way of parsing public keys
[ "ParsePublicKey", "is", "an", "algorithm", "independent", "way", "of", "parsing", "public", "keys" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/keys.go#L303-L318
13,788
coyim/otr3
keys.go
Parse
func (pub *DSAPublicKey) Parse(in []byte) (index []byte, ok bool) { var typeTag uint16 if index, typeTag, ok = gotrax.ExtractShort(in); !ok || typeTag != dsaKeyTypeValue { return in, false } if index, pub.P, ok = gotrax.ExtractMPI(index); !ok { return in, false } if index, pub.Q, ok = gotrax.ExtractMPI(index); !ok { return in, false } if index, pub.G, ok = gotrax.ExtractMPI(index); !ok { return in, false } if index, pub.Y, ok = gotrax.ExtractMPI(index); !ok { return in, false } return }
go
func (pub *DSAPublicKey) Parse(in []byte) (index []byte, ok bool) { var typeTag uint16 if index, typeTag, ok = gotrax.ExtractShort(in); !ok || typeTag != dsaKeyTypeValue { return in, false } if index, pub.P, ok = gotrax.ExtractMPI(index); !ok { return in, false } if index, pub.Q, ok = gotrax.ExtractMPI(index); !ok { return in, false } if index, pub.G, ok = gotrax.ExtractMPI(index); !ok { return in, false } if index, pub.Y, ok = gotrax.ExtractMPI(index); !ok { return in, false } return }
[ "func", "(", "pub", "*", "DSAPublicKey", ")", "Parse", "(", "in", "[", "]", "byte", ")", "(", "index", "[", "]", "byte", ",", "ok", "bool", ")", "{", "var", "typeTag", "uint16", "\n", "if", "index", ",", "typeTag", ",", "ok", "=", "gotrax", ".", "ExtractShort", "(", "in", ")", ";", "!", "ok", "||", "typeTag", "!=", "dsaKeyTypeValue", "{", "return", "in", ",", "false", "\n", "}", "\n", "if", "index", ",", "pub", ".", "P", ",", "ok", "=", "gotrax", ".", "ExtractMPI", "(", "index", ")", ";", "!", "ok", "{", "return", "in", ",", "false", "\n", "}", "\n", "if", "index", ",", "pub", ".", "Q", ",", "ok", "=", "gotrax", ".", "ExtractMPI", "(", "index", ")", ";", "!", "ok", "{", "return", "in", ",", "false", "\n", "}", "\n", "if", "index", ",", "pub", ".", "G", ",", "ok", "=", "gotrax", ".", "ExtractMPI", "(", "index", ")", ";", "!", "ok", "{", "return", "in", ",", "false", "\n", "}", "\n", "if", "index", ",", "pub", ".", "Y", ",", "ok", "=", "gotrax", ".", "ExtractMPI", "(", "index", ")", ";", "!", "ok", "{", "return", "in", ",", "false", "\n", "}", "\n", "return", "\n", "}" ]
// Parse takes the given data and tries to parse it into the PublicKey receiver. It will return not ok if the data is malformed or not for a DSA key
[ "Parse", "takes", "the", "given", "data", "and", "tries", "to", "parse", "it", "into", "the", "PublicKey", "receiver", ".", "It", "will", "return", "not", "ok", "if", "the", "data", "is", "malformed", "or", "not", "for", "a", "DSA", "key" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/keys.go#L321-L339
13,789
coyim/otr3
keys.go
Parse
func (priv *DSAPrivateKey) Parse(in []byte) (index []byte, ok bool) { if in, ok = priv.DSAPublicKey.Parse(in); !ok { return nil, false } priv.PrivateKey.PublicKey = priv.DSAPublicKey.PublicKey index, priv.X, ok = gotrax.ExtractMPI(in) return index, ok }
go
func (priv *DSAPrivateKey) Parse(in []byte) (index []byte, ok bool) { if in, ok = priv.DSAPublicKey.Parse(in); !ok { return nil, false } priv.PrivateKey.PublicKey = priv.DSAPublicKey.PublicKey index, priv.X, ok = gotrax.ExtractMPI(in) return index, ok }
[ "func", "(", "priv", "*", "DSAPrivateKey", ")", "Parse", "(", "in", "[", "]", "byte", ")", "(", "index", "[", "]", "byte", ",", "ok", "bool", ")", "{", "if", "in", ",", "ok", "=", "priv", ".", "DSAPublicKey", ".", "Parse", "(", "in", ")", ";", "!", "ok", "{", "return", "nil", ",", "false", "\n", "}", "\n\n", "priv", ".", "PrivateKey", ".", "PublicKey", "=", "priv", ".", "DSAPublicKey", ".", "PublicKey", "\n", "index", ",", "priv", ".", "X", ",", "ok", "=", "gotrax", ".", "ExtractMPI", "(", "in", ")", "\n\n", "return", "index", ",", "ok", "\n", "}" ]
// Parse will parse a Private Key from the given data, by first parsing the public key components and then the private key component. It returns not ok for the same reasons as PublicKey.Parse.
[ "Parse", "will", "parse", "a", "Private", "Key", "from", "the", "given", "data", "by", "first", "parsing", "the", "public", "key", "components", "and", "then", "the", "private", "key", "component", ".", "It", "returns", "not", "ok", "for", "the", "same", "reasons", "as", "PublicKey", ".", "Parse", "." ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/keys.go#L342-L351
13,790
coyim/otr3
keys.go
Fingerprint
func (pub *DSAPublicKey) Fingerprint() []byte { b := pub.serialize() if b == nil { return nil } h := fingerprintHashInstanceForVersion(3) h.Write(b[2:]) // if public key is DSA, ignore the leading 0x00 0x00 for the key type (according to spec) return h.Sum(nil) }
go
func (pub *DSAPublicKey) Fingerprint() []byte { b := pub.serialize() if b == nil { return nil } h := fingerprintHashInstanceForVersion(3) h.Write(b[2:]) // if public key is DSA, ignore the leading 0x00 0x00 for the key type (according to spec) return h.Sum(nil) }
[ "func", "(", "pub", "*", "DSAPublicKey", ")", "Fingerprint", "(", ")", "[", "]", "byte", "{", "b", ":=", "pub", ".", "serialize", "(", ")", "\n", "if", "b", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "h", ":=", "fingerprintHashInstanceForVersion", "(", "3", ")", "\n\n", "h", ".", "Write", "(", "b", "[", "2", ":", "]", ")", "// if public key is DSA, ignore the leading 0x00 0x00 for the key type (according to spec)", "\n", "return", "h", ".", "Sum", "(", "nil", ")", "\n", "}" ]
// Fingerprint will generate a fingerprint of the serialized version of the key using the provided hash.
[ "Fingerprint", "will", "generate", "a", "fingerprint", "of", "the", "serialized", "version", "of", "the", "key", "using", "the", "provided", "hash", "." ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/keys.go#L380-L390
13,791
coyim/otr3
keys.go
Sign
func (priv *DSAPrivateKey) Sign(rand io.Reader, hashed []byte) ([]byte, error) { r, s, err := dsa.Sign(rand, &priv.PrivateKey, hashed) if err == nil { rBytes := r.Bytes() sBytes := s.Bytes() out := make([]byte, 40) copy(out[20-len(rBytes):], rBytes) copy(out[len(out)-len(sBytes):], sBytes) return out, nil } return nil, err }
go
func (priv *DSAPrivateKey) Sign(rand io.Reader, hashed []byte) ([]byte, error) { r, s, err := dsa.Sign(rand, &priv.PrivateKey, hashed) if err == nil { rBytes := r.Bytes() sBytes := s.Bytes() out := make([]byte, 40) copy(out[20-len(rBytes):], rBytes) copy(out[len(out)-len(sBytes):], sBytes) return out, nil } return nil, err }
[ "func", "(", "priv", "*", "DSAPrivateKey", ")", "Sign", "(", "rand", "io", ".", "Reader", ",", "hashed", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "r", ",", "s", ",", "err", ":=", "dsa", ".", "Sign", "(", "rand", ",", "&", "priv", ".", "PrivateKey", ",", "hashed", ")", "\n", "if", "err", "==", "nil", "{", "rBytes", ":=", "r", ".", "Bytes", "(", ")", "\n", "sBytes", ":=", "s", ".", "Bytes", "(", ")", "\n\n", "out", ":=", "make", "(", "[", "]", "byte", ",", "40", ")", "\n", "copy", "(", "out", "[", "20", "-", "len", "(", "rBytes", ")", ":", "]", ",", "rBytes", ")", "\n", "copy", "(", "out", "[", "len", "(", "out", ")", "-", "len", "(", "sBytes", ")", ":", "]", ",", "sBytes", ")", "\n", "return", "out", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}" ]
// Sign will generate a signature of a hashed data using dsa Sign.
[ "Sign", "will", "generate", "a", "signature", "of", "a", "hashed", "data", "using", "dsa", "Sign", "." ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/keys.go#L393-L405
13,792
coyim/otr3
keys.go
Verify
func (pub *DSAPublicKey) Verify(hashed, sig []byte) (nextPoint []byte, sigOk bool) { if len(sig) < 2*20 { return nil, false } r := new(big.Int).SetBytes(sig[:20]) s := new(big.Int).SetBytes(sig[20:40]) ok := dsa.Verify(&pub.PublicKey, hashed, r, s) return sig[20*2:], ok }
go
func (pub *DSAPublicKey) Verify(hashed, sig []byte) (nextPoint []byte, sigOk bool) { if len(sig) < 2*20 { return nil, false } r := new(big.Int).SetBytes(sig[:20]) s := new(big.Int).SetBytes(sig[20:40]) ok := dsa.Verify(&pub.PublicKey, hashed, r, s) return sig[20*2:], ok }
[ "func", "(", "pub", "*", "DSAPublicKey", ")", "Verify", "(", "hashed", ",", "sig", "[", "]", "byte", ")", "(", "nextPoint", "[", "]", "byte", ",", "sigOk", "bool", ")", "{", "if", "len", "(", "sig", ")", "<", "2", "*", "20", "{", "return", "nil", ",", "false", "\n", "}", "\n", "r", ":=", "new", "(", "big", ".", "Int", ")", ".", "SetBytes", "(", "sig", "[", ":", "20", "]", ")", "\n", "s", ":=", "new", "(", "big", ".", "Int", ")", ".", "SetBytes", "(", "sig", "[", "20", ":", "40", "]", ")", "\n", "ok", ":=", "dsa", ".", "Verify", "(", "&", "pub", ".", "PublicKey", ",", "hashed", ",", "r", ",", "s", ")", "\n", "return", "sig", "[", "20", "*", "2", ":", "]", ",", "ok", "\n", "}" ]
// Verify will verify a signature of a hashed data using dsa Verify.
[ "Verify", "will", "verify", "a", "signature", "of", "a", "hashed", "data", "using", "dsa", "Verify", "." ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/keys.go#L408-L416
13,793
coyim/otr3
keys.go
Import
func (priv *DSAPrivateKey) Import(in []byte) bool { mpiStart := []byte(" #") mpis := make([]*big.Int, 5) for i := 0; i < len(mpis); i++ { start := bytes.Index(in, mpiStart) if start == -1 { return false } in = in[start+len(mpiStart):] end := bytes.IndexFunc(in, notHex) if end == -1 { return false } hexBytes := in[:end] in = in[end:] if len(hexBytes)&1 != 0 { return false } mpiBytes := make([]byte, len(hexBytes)/2) if _, err := hex.Decode(mpiBytes, hexBytes); err != nil { return false } mpis[i] = new(big.Int).SetBytes(mpiBytes) } priv.PrivateKey.P = mpis[0] priv.PrivateKey.Q = mpis[1] priv.PrivateKey.G = mpis[2] priv.PrivateKey.Y = mpis[3] priv.PrivateKey.X = mpis[4] priv.DSAPublicKey.PublicKey = priv.PrivateKey.PublicKey a := new(big.Int).Exp(priv.PrivateKey.G, priv.PrivateKey.X, priv.PrivateKey.P) return a.Cmp(priv.PrivateKey.Y) == 0 }
go
func (priv *DSAPrivateKey) Import(in []byte) bool { mpiStart := []byte(" #") mpis := make([]*big.Int, 5) for i := 0; i < len(mpis); i++ { start := bytes.Index(in, mpiStart) if start == -1 { return false } in = in[start+len(mpiStart):] end := bytes.IndexFunc(in, notHex) if end == -1 { return false } hexBytes := in[:end] in = in[end:] if len(hexBytes)&1 != 0 { return false } mpiBytes := make([]byte, len(hexBytes)/2) if _, err := hex.Decode(mpiBytes, hexBytes); err != nil { return false } mpis[i] = new(big.Int).SetBytes(mpiBytes) } priv.PrivateKey.P = mpis[0] priv.PrivateKey.Q = mpis[1] priv.PrivateKey.G = mpis[2] priv.PrivateKey.Y = mpis[3] priv.PrivateKey.X = mpis[4] priv.DSAPublicKey.PublicKey = priv.PrivateKey.PublicKey a := new(big.Int).Exp(priv.PrivateKey.G, priv.PrivateKey.X, priv.PrivateKey.P) return a.Cmp(priv.PrivateKey.Y) == 0 }
[ "func", "(", "priv", "*", "DSAPrivateKey", ")", "Import", "(", "in", "[", "]", "byte", ")", "bool", "{", "mpiStart", ":=", "[", "]", "byte", "(", "\"", "\"", ")", "\n\n", "mpis", ":=", "make", "(", "[", "]", "*", "big", ".", "Int", ",", "5", ")", "\n\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "mpis", ")", ";", "i", "++", "{", "start", ":=", "bytes", ".", "Index", "(", "in", ",", "mpiStart", ")", "\n", "if", "start", "==", "-", "1", "{", "return", "false", "\n", "}", "\n", "in", "=", "in", "[", "start", "+", "len", "(", "mpiStart", ")", ":", "]", "\n", "end", ":=", "bytes", ".", "IndexFunc", "(", "in", ",", "notHex", ")", "\n", "if", "end", "==", "-", "1", "{", "return", "false", "\n", "}", "\n", "hexBytes", ":=", "in", "[", ":", "end", "]", "\n", "in", "=", "in", "[", "end", ":", "]", "\n\n", "if", "len", "(", "hexBytes", ")", "&", "1", "!=", "0", "{", "return", "false", "\n", "}", "\n\n", "mpiBytes", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "hexBytes", ")", "/", "2", ")", "\n", "if", "_", ",", "err", ":=", "hex", ".", "Decode", "(", "mpiBytes", ",", "hexBytes", ")", ";", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n\n", "mpis", "[", "i", "]", "=", "new", "(", "big", ".", "Int", ")", ".", "SetBytes", "(", "mpiBytes", ")", "\n", "}", "\n\n", "priv", ".", "PrivateKey", ".", "P", "=", "mpis", "[", "0", "]", "\n", "priv", ".", "PrivateKey", ".", "Q", "=", "mpis", "[", "1", "]", "\n", "priv", ".", "PrivateKey", ".", "G", "=", "mpis", "[", "2", "]", "\n", "priv", ".", "PrivateKey", ".", "Y", "=", "mpis", "[", "3", "]", "\n", "priv", ".", "PrivateKey", ".", "X", "=", "mpis", "[", "4", "]", "\n", "priv", ".", "DSAPublicKey", ".", "PublicKey", "=", "priv", ".", "PrivateKey", ".", "PublicKey", "\n\n", "a", ":=", "new", "(", "big", ".", "Int", ")", ".", "Exp", "(", "priv", ".", "PrivateKey", ".", "G", ",", "priv", ".", "PrivateKey", ".", "X", ",", "priv", ".", "PrivateKey", ".", "P", ")", "\n", "return", "a", ".", "Cmp", "(", "priv", ".", "PrivateKey", ".", "Y", ")", "==", "0", "\n", "}" ]
// Import parses the contents of a libotr private key file.
[ "Import", "parses", "the", "contents", "of", "a", "libotr", "private", "key", "file", "." ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/keys.go#L442-L481
13,794
coyim/otr3
keys.go
Generate
func (priv *DSAPrivateKey) Generate(rand io.Reader) error { if err := dsa.GenerateParameters(&priv.PrivateKey.PublicKey.Parameters, rand, dsa.L1024N160); err != nil { return err } if err := dsa.GenerateKey(&priv.PrivateKey, rand); err != nil { return err } priv.DSAPublicKey.PublicKey = priv.PrivateKey.PublicKey return nil }
go
func (priv *DSAPrivateKey) Generate(rand io.Reader) error { if err := dsa.GenerateParameters(&priv.PrivateKey.PublicKey.Parameters, rand, dsa.L1024N160); err != nil { return err } if err := dsa.GenerateKey(&priv.PrivateKey, rand); err != nil { return err } priv.DSAPublicKey.PublicKey = priv.PrivateKey.PublicKey return nil }
[ "func", "(", "priv", "*", "DSAPrivateKey", ")", "Generate", "(", "rand", "io", ".", "Reader", ")", "error", "{", "if", "err", ":=", "dsa", ".", "GenerateParameters", "(", "&", "priv", ".", "PrivateKey", ".", "PublicKey", ".", "Parameters", ",", "rand", ",", "dsa", ".", "L1024N160", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "dsa", ".", "GenerateKey", "(", "&", "priv", ".", "PrivateKey", ",", "rand", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "priv", ".", "DSAPublicKey", ".", "PublicKey", "=", "priv", ".", "PrivateKey", ".", "PublicKey", "\n", "return", "nil", "\n", "}" ]
// Generate will generate a new DSA Private Key with the randomness provided. The parameter size used is 1024 and 160.
[ "Generate", "will", "generate", "a", "new", "DSA", "Private", "Key", "with", "the", "randomness", "provided", ".", "The", "parameter", "size", "used", "is", "1024", "and", "160", "." ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/keys.go#L484-L493
13,795
coyim/otr3
smp_events.go
HandleSMPEvent
func (DebugSMPEventHandler) HandleSMPEvent(event SMPEvent, progressPercent int, question string) { fmt.Fprintf(standardErrorOutput, "%sHandleSMPEvent(%s, %d, %#v)\n", debugPrefix, event, progressPercent, question) }
go
func (DebugSMPEventHandler) HandleSMPEvent(event SMPEvent, progressPercent int, question string) { fmt.Fprintf(standardErrorOutput, "%sHandleSMPEvent(%s, %d, %#v)\n", debugPrefix, event, progressPercent, question) }
[ "func", "(", "DebugSMPEventHandler", ")", "HandleSMPEvent", "(", "event", "SMPEvent", ",", "progressPercent", "int", ",", "question", "string", ")", "{", "fmt", ".", "Fprintf", "(", "standardErrorOutput", ",", "\"", "\\n", "\"", ",", "debugPrefix", ",", "event", ",", "progressPercent", ",", "question", ")", "\n", "}" ]
// HandleSMPEvent dumps all SMP events
[ "HandleSMPEvent", "dumps", "all", "SMP", "events" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/smp_events.go#L98-L100
13,796
coyim/otr3
extra_key.go
UseExtraSymmetricKey
func (c *Conversation) UseExtraSymmetricKey(usage uint32, usageData []byte) ([]byte, []ValidMessage, error) { if c.msgState != encrypted || c.keys.theirKeyID == 0 { return nil, nil, newOtrError("cannot send message in current state") } t := tlv{ tlvType: tlvTypeExtraSymmetricKey, tlvLength: 4 + uint16(len(usageData)), tlvValue: append(gotrax.AppendWord(nil, usage), usageData...), } toSend, x, err := c.createSerializedDataMessage(nil, messageFlagIgnoreUnreadable, []tlv{t}) return x.key, toSend, err }
go
func (c *Conversation) UseExtraSymmetricKey(usage uint32, usageData []byte) ([]byte, []ValidMessage, error) { if c.msgState != encrypted || c.keys.theirKeyID == 0 { return nil, nil, newOtrError("cannot send message in current state") } t := tlv{ tlvType: tlvTypeExtraSymmetricKey, tlvLength: 4 + uint16(len(usageData)), tlvValue: append(gotrax.AppendWord(nil, usage), usageData...), } toSend, x, err := c.createSerializedDataMessage(nil, messageFlagIgnoreUnreadable, []tlv{t}) return x.key, toSend, err }
[ "func", "(", "c", "*", "Conversation", ")", "UseExtraSymmetricKey", "(", "usage", "uint32", ",", "usageData", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "[", "]", "ValidMessage", ",", "error", ")", "{", "if", "c", ".", "msgState", "!=", "encrypted", "||", "c", ".", "keys", ".", "theirKeyID", "==", "0", "{", "return", "nil", ",", "nil", ",", "newOtrError", "(", "\"", "\"", ")", "\n", "}", "\n\n", "t", ":=", "tlv", "{", "tlvType", ":", "tlvTypeExtraSymmetricKey", ",", "tlvLength", ":", "4", "+", "uint16", "(", "len", "(", "usageData", ")", ")", ",", "tlvValue", ":", "append", "(", "gotrax", ".", "AppendWord", "(", "nil", ",", "usage", ")", ",", "usageData", "...", ")", ",", "}", "\n\n", "toSend", ",", "x", ",", "err", ":=", "c", ".", "createSerializedDataMessage", "(", "nil", ",", "messageFlagIgnoreUnreadable", ",", "[", "]", "tlv", "{", "t", "}", ")", "\n", "return", "x", ".", "key", ",", "toSend", ",", "err", "\n", "}" ]
// UseExtraSymmetricKey takes a usage parameter and optional usageData and returns the current symmetric key // and a set of messages to send in order to ask the peer to use the same symmetric key for the usage defined
[ "UseExtraSymmetricKey", "takes", "a", "usage", "parameter", "and", "optional", "usageData", "and", "returns", "the", "current", "symmetric", "key", "and", "a", "set", "of", "messages", "to", "send", "in", "order", "to", "ask", "the", "peer", "to", "use", "the", "same", "symmetric", "key", "for", "the", "usage", "defined" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/extra_key.go#L15-L29
13,797
coyim/otr3
version.go
commitToVersionFrom
func (c *Conversation) commitToVersionFrom(versions int) error { if c.version != nil { return nil } var version otrVersion switch { case c.Policies.has(allowV3) && versions&(1<<3) > 0: version = otrV3{} case c.Policies.has(allowV2) && versions&(1<<2) > 0: version = otrV2{} default: return errUnsupportedOTRVersion } c.version = version return c.setKeyMatchingVersion() }
go
func (c *Conversation) commitToVersionFrom(versions int) error { if c.version != nil { return nil } var version otrVersion switch { case c.Policies.has(allowV3) && versions&(1<<3) > 0: version = otrV3{} case c.Policies.has(allowV2) && versions&(1<<2) > 0: version = otrV2{} default: return errUnsupportedOTRVersion } c.version = version return c.setKeyMatchingVersion() }
[ "func", "(", "c", "*", "Conversation", ")", "commitToVersionFrom", "(", "versions", "int", ")", "error", "{", "if", "c", ".", "version", "!=", "nil", "{", "return", "nil", "\n", "}", "\n\n", "var", "version", "otrVersion", "\n\n", "switch", "{", "case", "c", ".", "Policies", ".", "has", "(", "allowV3", ")", "&&", "versions", "&", "(", "1", "<<", "3", ")", ">", "0", ":", "version", "=", "otrV3", "{", "}", "\n", "case", "c", ".", "Policies", ".", "has", "(", "allowV2", ")", "&&", "versions", "&", "(", "1", "<<", "2", ")", ">", "0", ":", "version", "=", "otrV2", "{", "}", "\n", "default", ":", "return", "errUnsupportedOTRVersion", "\n", "}", "\n\n", "c", ".", "version", "=", "version", "\n\n", "return", "c", ".", "setKeyMatchingVersion", "(", ")", "\n", "}" ]
// Based on the policy, commit to a version given a set of versions offered by the other peer unless the conversation has already committed to a version.
[ "Based", "on", "the", "policy", "commit", "to", "a", "version", "given", "a", "set", "of", "versions", "offered", "by", "the", "other", "peer", "unless", "the", "conversation", "has", "already", "committed", "to", "a", "version", "." ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/version.go#L82-L101
13,798
coyim/otr3
bytes.go
Bytes
func Bytes(m []ValidMessage) [][]byte { ret := make([][]byte, len(m)) //copy because we don't want to hold references to m's fragments for i, f := range m { ret[i] = make([]byte, len(f)) copy(ret[i], []byte(f)) } return ret }
go
func Bytes(m []ValidMessage) [][]byte { ret := make([][]byte, len(m)) //copy because we don't want to hold references to m's fragments for i, f := range m { ret[i] = make([]byte, len(f)) copy(ret[i], []byte(f)) } return ret }
[ "func", "Bytes", "(", "m", "[", "]", "ValidMessage", ")", "[", "]", "[", "]", "byte", "{", "ret", ":=", "make", "(", "[", "]", "[", "]", "byte", ",", "len", "(", "m", ")", ")", "\n", "//copy because we don't want to hold references to m's fragments", "for", "i", ",", "f", ":=", "range", "m", "{", "ret", "[", "i", "]", "=", "make", "(", "[", "]", "byte", ",", "len", "(", "f", ")", ")", "\n", "copy", "(", "ret", "[", "i", "]", ",", "[", "]", "byte", "(", "f", ")", ")", "\n", "}", "\n", "return", "ret", "\n", "}" ]
// Bytes will turn a slice of valid messages into a slice of byte slices
[ "Bytes", "will", "turn", "a", "slice", "of", "valid", "messages", "into", "a", "slice", "of", "byte", "slices" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/bytes.go#L17-L25
13,799
coyim/otr3
sexp/cons.go
String
func (l Cons) String() string { return "(" + l.First().String() + " . " + l.Second().String() + ")" }
go
func (l Cons) String() string { return "(" + l.First().String() + " . " + l.Second().String() + ")" }
[ "func", "(", "l", "Cons", ")", "String", "(", ")", "string", "{", "return", "\"", "\"", "+", "l", ".", "First", "(", ")", ".", "String", "(", ")", "+", "\"", "\"", "+", "l", ".", "Second", "(", ")", ".", "String", "(", ")", "+", "\"", "\"", "\n", "}" ]
// String returns the Cons formatted for printing in an S-Expression
[ "String", "returns", "the", "Cons", "formatted", "for", "printing", "in", "an", "S", "-", "Expression" ]
3bc9d9c574442c5f88a941e78f96cb57cb3fa357
https://github.com/coyim/otr3/blob/3bc9d9c574442c5f88a941e78f96cb57cb3fa357/sexp/cons.go#L27-L29