id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
144,500 | NaySoftware/go-fcm | fcm.go | SetDryRun | func (this *FcmClient) SetDryRun(drun bool) *FcmClient {
this.Message.DryRun = drun
return this
} | go | func (this *FcmClient) SetDryRun(drun bool) *FcmClient {
this.Message.DryRun = drun
return this
} | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"SetDryRun",
"(",
"drun",
"bool",
")",
"*",
"FcmClient",
"{",
"this",
".",
"Message",
".",
"DryRun",
"=",
"drun",
"\n\n",
"return",
"this",
"\n",
"}"
] | // SetDryRun This parameter, when set to true, allows developers to test
// a request without actually sending a message.
// The default value is false | [
"SetDryRun",
"This",
"parameter",
"when",
"set",
"to",
"true",
"allows",
"developers",
"to",
"test",
"a",
"request",
"without",
"actually",
"sending",
"a",
"message",
".",
"The",
"default",
"value",
"is",
"false"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L310-L315 |
144,501 | NaySoftware/go-fcm | fcm.go | SetMutableContent | func (this *FcmClient) SetMutableContent(mc bool) *FcmClient {
this.Message.MutableContent = mc
return this
} | go | func (this *FcmClient) SetMutableContent(mc bool) *FcmClient {
this.Message.MutableContent = mc
return this
} | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"SetMutableContent",
"(",
"mc",
"bool",
")",
"*",
"FcmClient",
"{",
"this",
".",
"Message",
".",
"MutableContent",
"=",
"mc",
"\n\n",
"return",
"this",
"\n",
"}"
] | // SetMutableContent Currently for iOS 10+ devices only. On iOS,
// use this field to represent mutable-content in the APNs payload.
// When a notification is sent and this is set to true, the content
// of the notification can be modified before it is displayed,
// using a Notification Service app extension.
// This p... | [
"SetMutableContent",
"Currently",
"for",
"iOS",
"10",
"+",
"devices",
"only",
".",
"On",
"iOS",
"use",
"this",
"field",
"to",
"represent",
"mutable",
"-",
"content",
"in",
"the",
"APNs",
"payload",
".",
"When",
"a",
"notification",
"is",
"sent",
"and",
"th... | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L323-L328 |
144,502 | NaySoftware/go-fcm | fcm.go | PrintResults | func (this *FcmResponseStatus) PrintResults() {
fmt.Println("Status Code :", this.StatusCode)
fmt.Println("Success :", this.Success)
fmt.Println("Fail :", this.Fail)
fmt.Println("Canonical_ids :", this.Canonical_ids)
fmt.Println("Topic MsgId :", this.MsgId)
fmt.Println("Topic Err :", this.E... | go | func (this *FcmResponseStatus) PrintResults() {
fmt.Println("Status Code :", this.StatusCode)
fmt.Println("Success :", this.Success)
fmt.Println("Fail :", this.Fail)
fmt.Println("Canonical_ids :", this.Canonical_ids)
fmt.Println("Topic MsgId :", this.MsgId)
fmt.Println("Topic Err :", this.E... | [
"func",
"(",
"this",
"*",
"FcmResponseStatus",
")",
"PrintResults",
"(",
")",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"StatusCode",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"Success",
")",
"\n",
"f... | // PrintResults prints the FcmResponseStatus results for fast using and debugging | [
"PrintResults",
"prints",
"the",
"FcmResponseStatus",
"results",
"for",
"fast",
"using",
"and",
"debugging"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L331-L344 |
144,503 | NaySoftware/go-fcm | fcm.go | IsTimeout | func (this *FcmResponseStatus) IsTimeout() bool {
if this.StatusCode >= 500 {
return true
} else if this.StatusCode == 200 {
for _, val := range this.Results {
for k, v := range val {
if k == error_key && retreyableErrors[v] == true {
return true
}
}
}
}
return false
} | go | func (this *FcmResponseStatus) IsTimeout() bool {
if this.StatusCode >= 500 {
return true
} else if this.StatusCode == 200 {
for _, val := range this.Results {
for k, v := range val {
if k == error_key && retreyableErrors[v] == true {
return true
}
}
}
}
return false
} | [
"func",
"(",
"this",
"*",
"FcmResponseStatus",
")",
"IsTimeout",
"(",
")",
"bool",
"{",
"if",
"this",
".",
"StatusCode",
">=",
"500",
"{",
"return",
"true",
"\n",
"}",
"else",
"if",
"this",
".",
"StatusCode",
"==",
"200",
"{",
"for",
"_",
",",
"val",... | // IsTimeout check whether the response timeout based on http response status
// code and if any error is retryable | [
"IsTimeout",
"check",
"whether",
"the",
"response",
"timeout",
"based",
"on",
"http",
"response",
"status",
"code",
"and",
"if",
"any",
"error",
"is",
"retryable"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L348-L362 |
144,504 | NaySoftware/go-fcm | fcm.go | GetRetryAfterTime | func (this *FcmResponseStatus) GetRetryAfterTime() (t time.Duration, e error) {
t, e = time.ParseDuration(this.RetryAfter)
return
} | go | func (this *FcmResponseStatus) GetRetryAfterTime() (t time.Duration, e error) {
t, e = time.ParseDuration(this.RetryAfter)
return
} | [
"func",
"(",
"this",
"*",
"FcmResponseStatus",
")",
"GetRetryAfterTime",
"(",
")",
"(",
"t",
"time",
".",
"Duration",
",",
"e",
"error",
")",
"{",
"t",
",",
"e",
"=",
"time",
".",
"ParseDuration",
"(",
"this",
".",
"RetryAfter",
")",
"\n",
"return",
... | // GetRetryAfterTime converts the retrey after response header
// to a time.Duration | [
"GetRetryAfterTime",
"converts",
"the",
"retrey",
"after",
"response",
"header",
"to",
"a",
"time",
".",
"Duration"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L366-L369 |
144,505 | NaySoftware/go-fcm | fcm.go | SetCondition | func (this *FcmClient) SetCondition(condition string) *FcmClient {
this.Message.Condition = condition
return this
} | go | func (this *FcmClient) SetCondition(condition string) *FcmClient {
this.Message.Condition = condition
return this
} | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"SetCondition",
"(",
"condition",
"string",
")",
"*",
"FcmClient",
"{",
"this",
".",
"Message",
".",
"Condition",
"=",
"condition",
"\n",
"return",
"this",
"\n",
"}"
] | // SetCondition to set a logical expression of conditions that determine the message target | [
"SetCondition",
"to",
"set",
"a",
"logical",
"expression",
"of",
"conditions",
"that",
"determine",
"the",
"message",
"target"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L372-L375 |
144,506 | NaySoftware/go-fcm | instanceid.go | GetInfo | func (this *FcmClient) GetInfo(withDetails bool, instanceIdToken string) (*InstanceIdInfoResponse, error) {
var request_url string = generateGetInfoUrl(instance_id_info_no_details_srv_url, instanceIdToken)
if withDetails == true {
request_url = generateGetInfoUrl(instance_id_info_with_details_srv_url, instanceIdT... | go | func (this *FcmClient) GetInfo(withDetails bool, instanceIdToken string) (*InstanceIdInfoResponse, error) {
var request_url string = generateGetInfoUrl(instance_id_info_no_details_srv_url, instanceIdToken)
if withDetails == true {
request_url = generateGetInfoUrl(instance_id_info_with_details_srv_url, instanceIdT... | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"GetInfo",
"(",
"withDetails",
"bool",
",",
"instanceIdToken",
"string",
")",
"(",
"*",
"InstanceIdInfoResponse",
",",
"error",
")",
"{",
"var",
"request_url",
"string",
"=",
"generateGetInfoUrl",
"(",
"instance_id_inf... | // GetInfo gets the instance id info | [
"GetInfo",
"gets",
"the",
"instance",
"id",
"info"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L104-L139 |
144,507 | NaySoftware/go-fcm | instanceid.go | parseGetInfo | func parseGetInfo(body []byte) (*InstanceIdInfoResponse, error) {
info := new(InstanceIdInfoResponse)
if err := json.Unmarshal([]byte(body), &info); err != nil {
return nil, err
}
return info, nil
} | go | func parseGetInfo(body []byte) (*InstanceIdInfoResponse, error) {
info := new(InstanceIdInfoResponse)
if err := json.Unmarshal([]byte(body), &info); err != nil {
return nil, err
}
return info, nil
} | [
"func",
"parseGetInfo",
"(",
"body",
"[",
"]",
"byte",
")",
"(",
"*",
"InstanceIdInfoResponse",
",",
"error",
")",
"{",
"info",
":=",
"new",
"(",
"InstanceIdInfoResponse",
")",
"\n\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
... | // parseGetInfo parses response to InstanceIdInfoResponse | [
"parseGetInfo",
"parses",
"response",
"to",
"InstanceIdInfoResponse"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L142-L152 |
144,508 | NaySoftware/go-fcm | instanceid.go | PrintResults | func (this *InstanceIdInfoResponse) PrintResults() {
fmt.Println("Error : ", this.Error)
fmt.Println("App : ", this.Application)
fmt.Println("Auth : ", this.AuthorizedEntity)
fmt.Println("Ver : ", this.ApplicationVersion)
fmt.Println("Sig : ", this.AppSigner)
fmt.Println("Att : ",... | go | func (this *InstanceIdInfoResponse) PrintResults() {
fmt.Println("Error : ", this.Error)
fmt.Println("App : ", this.Application)
fmt.Println("Auth : ", this.AuthorizedEntity)
fmt.Println("Ver : ", this.ApplicationVersion)
fmt.Println("Sig : ", this.AppSigner)
fmt.Println("Att : ",... | [
"func",
"(",
"this",
"*",
"InstanceIdInfoResponse",
")",
"PrintResults",
"(",
")",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"Error",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"Application",
")",
"\n",
... | // PrintResults prints InstanceIdInfoResponse, for faster debugging | [
"PrintResults",
"prints",
"InstanceIdInfoResponse",
"for",
"faster",
"debugging"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L155-L173 |
144,509 | NaySoftware/go-fcm | instanceid.go | generateGetInfoUrl | func generateGetInfoUrl(srv string, instanceIdToken string) string {
return fmt.Sprintf(srv, instanceIdToken)
} | go | func generateGetInfoUrl(srv string, instanceIdToken string) string {
return fmt.Sprintf(srv, instanceIdToken)
} | [
"func",
"generateGetInfoUrl",
"(",
"srv",
"string",
",",
"instanceIdToken",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"srv",
",",
"instanceIdToken",
")",
"\n",
"}"
] | // generateGetInfoUrl generate based on with details and the instance token | [
"generateGetInfoUrl",
"generate",
"based",
"on",
"with",
"details",
"and",
"the",
"instance",
"token"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L176-L178 |
144,510 | NaySoftware/go-fcm | instanceid.go | parseSubscribeResponse | func parseSubscribeResponse(body []byte, resp *http.Response) (*SubscribeResponse, error) {
subResp := new(SubscribeResponse)
subResp.Status = resp.Status
subResp.StatusCode = resp.StatusCode
if err := json.Unmarshal(body, &subResp); err != nil {
return nil, err
}
return subResp, nil
} | go | func parseSubscribeResponse(body []byte, resp *http.Response) (*SubscribeResponse, error) {
subResp := new(SubscribeResponse)
subResp.Status = resp.Status
subResp.StatusCode = resp.StatusCode
if err := json.Unmarshal(body, &subResp); err != nil {
return nil, err
}
return subResp, nil
} | [
"func",
"parseSubscribeResponse",
"(",
"body",
"[",
"]",
"byte",
",",
"resp",
"*",
"http",
".",
"Response",
")",
"(",
"*",
"SubscribeResponse",
",",
"error",
")",
"{",
"subResp",
":=",
"new",
"(",
"SubscribeResponse",
")",
"\n\n",
"subResp",
".",
"Status",... | // parseSubscribeResponse converts a byte response to a SubscribeResponse | [
"parseSubscribeResponse",
"converts",
"a",
"byte",
"response",
"to",
"a",
"SubscribeResponse"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L213-L224 |
144,511 | NaySoftware/go-fcm | instanceid.go | PrintResults | func (this *SubscribeResponse) PrintResults() {
fmt.Println("Response Status: ", this.Status)
fmt.Println("Response Code : ", this.StatusCode)
if this.StatusCode != 200 {
fmt.Println("Error : ", this.Error)
}
} | go | func (this *SubscribeResponse) PrintResults() {
fmt.Println("Response Status: ", this.Status)
fmt.Println("Response Code : ", this.StatusCode)
if this.StatusCode != 200 {
fmt.Println("Error : ", this.Error)
}
} | [
"func",
"(",
"this",
"*",
"SubscribeResponse",
")",
"PrintResults",
"(",
")",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"Status",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"StatusCode",
")",
"\n",
"if... | // PrintResults prints SubscribeResponse, for faster debugging | [
"PrintResults",
"prints",
"SubscribeResponse",
"for",
"faster",
"debugging"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L227-L235 |
144,512 | NaySoftware/go-fcm | instanceid.go | generateSubToTopicUrl | func generateSubToTopicUrl(instaceId string, topic string) string {
Tmptopic := strings.ToLower(topic)
if strings.Contains(Tmptopic, "/topics/") {
tmp := strings.Split(topic, "/")
topic = tmp[len(tmp)-1]
}
return fmt.Sprintf(subscribe_instanceid_to_topic_srv_url, instaceId, topic)
} | go | func generateSubToTopicUrl(instaceId string, topic string) string {
Tmptopic := strings.ToLower(topic)
if strings.Contains(Tmptopic, "/topics/") {
tmp := strings.Split(topic, "/")
topic = tmp[len(tmp)-1]
}
return fmt.Sprintf(subscribe_instanceid_to_topic_srv_url, instaceId, topic)
} | [
"func",
"generateSubToTopicUrl",
"(",
"instaceId",
"string",
",",
"topic",
"string",
")",
"string",
"{",
"Tmptopic",
":=",
"strings",
".",
"ToLower",
"(",
"topic",
")",
"\n",
"if",
"strings",
".",
"Contains",
"(",
"Tmptopic",
",",
"\"",
"\"",
")",
"{",
"... | // generateSubToTopicUrl generates a url based on the instnace id and topic name | [
"generateSubToTopicUrl",
"generates",
"a",
"url",
"based",
"on",
"the",
"instnace",
"id",
"and",
"topic",
"name"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L238-L245 |
144,513 | NaySoftware/go-fcm | instanceid.go | PrintResults | func (this *BatchResponse) PrintResults() {
fmt.Println("Error : ", this.Error)
fmt.Println("Status : ", this.Status)
fmt.Println("Status Code : ", this.StatusCode)
for i, val := range this.Results {
if batchErrors[val["error"]] == true {
fmt.Println("ID: ", i, " | ", val["error"])
}
}
} | go | func (this *BatchResponse) PrintResults() {
fmt.Println("Error : ", this.Error)
fmt.Println("Status : ", this.Status)
fmt.Println("Status Code : ", this.StatusCode)
for i, val := range this.Results {
if batchErrors[val["error"]] == true {
fmt.Println("ID: ", i, " | ", val["error"])
}
}
} | [
"func",
"(",
"this",
"*",
"BatchResponse",
")",
"PrintResults",
"(",
")",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"Error",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"Status",
")",
"\n",
"fmt",
"."... | // PrintResults prints BatchResponse, for faster debugging | [
"PrintResults",
"prints",
"BatchResponse",
"for",
"faster",
"debugging"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L331-L340 |
144,514 | NaySoftware/go-fcm | instanceid.go | generateBatchRequest | func generateBatchRequest(tokens []string, topic string) ([]byte, error) {
envelope := new(BatchRequest)
envelope.To = topics + extractTopicName(topic)
envelope.RegTokens = make([]string, len(tokens))
copy(envelope.RegTokens, tokens)
return json.Marshal(envelope)
} | go | func generateBatchRequest(tokens []string, topic string) ([]byte, error) {
envelope := new(BatchRequest)
envelope.To = topics + extractTopicName(topic)
envelope.RegTokens = make([]string, len(tokens))
copy(envelope.RegTokens, tokens)
return json.Marshal(envelope)
} | [
"func",
"generateBatchRequest",
"(",
"tokens",
"[",
"]",
"string",
",",
"topic",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"envelope",
":=",
"new",
"(",
"BatchRequest",
")",
"\n",
"envelope",
".",
"To",
"=",
"topics",
"+",
"extractT... | // generateBatchRequest based on tokens and topic | [
"generateBatchRequest",
"based",
"on",
"tokens",
"and",
"topic"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L343-L351 |
144,515 | NaySoftware/go-fcm | instanceid.go | extractTopicName | func extractTopicName(inTopic string) (result string) {
Tmptopic := strings.ToLower(inTopic)
if strings.Contains(Tmptopic, "/topics/") {
tmp := strings.Split(inTopic, "/")
result = tmp[len(tmp)-1]
return
}
result = inTopic
return
} | go | func extractTopicName(inTopic string) (result string) {
Tmptopic := strings.ToLower(inTopic)
if strings.Contains(Tmptopic, "/topics/") {
tmp := strings.Split(inTopic, "/")
result = tmp[len(tmp)-1]
return
}
result = inTopic
return
} | [
"func",
"extractTopicName",
"(",
"inTopic",
"string",
")",
"(",
"result",
"string",
")",
"{",
"Tmptopic",
":=",
"strings",
".",
"ToLower",
"(",
"inTopic",
")",
"\n",
"if",
"strings",
".",
"Contains",
"(",
"Tmptopic",
",",
"\"",
"\"",
")",
"{",
"tmp",
"... | // extractTopicName extract topic name for valid topic name input | [
"extractTopicName",
"extract",
"topic",
"name",
"for",
"valid",
"topic",
"name",
"input"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L354-L364 |
144,516 | NaySoftware/go-fcm | instanceid.go | generateBatchResponse | func generateBatchResponse(resp []byte) (*BatchResponse, error) {
result := new(BatchResponse)
if err := json.Unmarshal(resp, &result); err != nil {
return nil, err
}
return result, nil
} | go | func generateBatchResponse(resp []byte) (*BatchResponse, error) {
result := new(BatchResponse)
if err := json.Unmarshal(resp, &result); err != nil {
return nil, err
}
return result, nil
} | [
"func",
"generateBatchResponse",
"(",
"resp",
"[",
"]",
"byte",
")",
"(",
"*",
"BatchResponse",
",",
"error",
")",
"{",
"result",
":=",
"new",
"(",
"BatchResponse",
")",
"\n\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"resp",
",",
"&",
"resul... | // generateBatchResponse converts a byte response to BatchResponse | [
"generateBatchResponse",
"converts",
"a",
"byte",
"response",
"to",
"BatchResponse"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L367-L376 |
144,517 | NaySoftware/go-fcm | instanceid.go | ApnsBatchImportRequest | func (this *FcmClient) ApnsBatchImportRequest(apnsReq *ApnsBatchRequest) (*ApnsBatchResponse, error) {
jsonByte, err := apnsReq.ToByte()
if err != nil {
return nil, err
}
request, err := http.NewRequest("POST", apns_batch_import_srv_url, bytes.NewBuffer(jsonByte))
request.Header.Set("Authorization", this.apiKe... | go | func (this *FcmClient) ApnsBatchImportRequest(apnsReq *ApnsBatchRequest) (*ApnsBatchResponse, error) {
jsonByte, err := apnsReq.ToByte()
if err != nil {
return nil, err
}
request, err := http.NewRequest("POST", apns_batch_import_srv_url, bytes.NewBuffer(jsonByte))
request.Header.Set("Authorization", this.apiKe... | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"ApnsBatchImportRequest",
"(",
"apnsReq",
"*",
"ApnsBatchRequest",
")",
"(",
"*",
"ApnsBatchResponse",
",",
"error",
")",
"{",
"jsonByte",
",",
"err",
":=",
"apnsReq",
".",
"ToByte",
"(",
")",
"\n",
"if",
"err",
... | // ApnsBatchImportRequest apns import requst | [
"ApnsBatchImportRequest",
"apns",
"import",
"requst"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L379-L420 |
144,518 | NaySoftware/go-fcm | instanceid.go | ToByte | func (this *ApnsBatchRequest) ToByte() ([]byte, error) {
data, err := json.Marshal(this)
if err != nil {
return nil, err
}
return data, nil
} | go | func (this *ApnsBatchRequest) ToByte() ([]byte, error) {
data, err := json.Marshal(this)
if err != nil {
return nil, err
}
return data, nil
} | [
"func",
"(",
"this",
"*",
"ApnsBatchRequest",
")",
"ToByte",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"this",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
... | // ToByte converts ApnsBatchRequest to a byte | [
"ToByte",
"converts",
"ApnsBatchRequest",
"to",
"a",
"byte"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L423-L430 |
144,519 | NaySoftware/go-fcm | instanceid.go | parseApnsBatchResponse | func parseApnsBatchResponse(resp []byte) (*ApnsBatchResponse, error) {
result := new(ApnsBatchResponse)
if err := json.Unmarshal(resp, &result); err != nil {
return nil, err
}
return result, nil
} | go | func parseApnsBatchResponse(resp []byte) (*ApnsBatchResponse, error) {
result := new(ApnsBatchResponse)
if err := json.Unmarshal(resp, &result); err != nil {
return nil, err
}
return result, nil
} | [
"func",
"parseApnsBatchResponse",
"(",
"resp",
"[",
"]",
"byte",
")",
"(",
"*",
"ApnsBatchResponse",
",",
"error",
")",
"{",
"result",
":=",
"new",
"(",
"ApnsBatchResponse",
")",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"resp",
",",
"&",
... | // parseApnsBatchResponse converts apns byte response to ApnsBatchResponse | [
"parseApnsBatchResponse",
"converts",
"apns",
"byte",
"response",
"to",
"ApnsBatchResponse"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L433-L442 |
144,520 | NaySoftware/go-fcm | instanceid.go | PrintResults | func (this *ApnsBatchResponse) PrintResults() {
fmt.Println("Status : ", this.Status)
fmt.Println("StatusCode : ", this.StatusCode)
fmt.Println("Error : ", this.Error)
for i, val := range this.Results {
fmt.Println(i, ":")
fmt.Println("\tAPNS Token", val[apns_token_key])
fmt.Println("\tStatus ", v... | go | func (this *ApnsBatchResponse) PrintResults() {
fmt.Println("Status : ", this.Status)
fmt.Println("StatusCode : ", this.StatusCode)
fmt.Println("Error : ", this.Error)
for i, val := range this.Results {
fmt.Println(i, ":")
fmt.Println("\tAPNS Token", val[apns_token_key])
fmt.Println("\tStatus ", v... | [
"func",
"(",
"this",
"*",
"ApnsBatchResponse",
")",
"PrintResults",
"(",
")",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"Status",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"StatusCode",
")",
"\n",
"fm... | // PrintResults prints ApnsBatchResponse, for faster debugging | [
"PrintResults",
"prints",
"ApnsBatchResponse",
"for",
"faster",
"debugging"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L445-L455 |
144,521 | kavu/go_reuseport | reuseport.go | Listen | func Listen(proto, addr string) (l net.Listener, err error) {
return NewReusablePortListener(proto, addr)
} | go | func Listen(proto, addr string) (l net.Listener, err error) {
return NewReusablePortListener(proto, addr)
} | [
"func",
"Listen",
"(",
"proto",
",",
"addr",
"string",
")",
"(",
"l",
"net",
".",
"Listener",
",",
"err",
"error",
")",
"{",
"return",
"NewReusablePortListener",
"(",
"proto",
",",
"addr",
")",
"\n",
"}"
] | // Listen function is an alias for NewReusablePortListener. | [
"Listen",
"function",
"is",
"an",
"alias",
"for",
"NewReusablePortListener",
"."
] | 1f6171f327ed3893406d2a802c563390993c4bb5 | https://github.com/kavu/go_reuseport/blob/1f6171f327ed3893406d2a802c563390993c4bb5/reuseport.go#L43-L45 |
144,522 | kavu/go_reuseport | reuseport.go | ListenPacket | func ListenPacket(proto, addr string) (l net.PacketConn, err error) {
return NewReusablePortPacketConn(proto, addr)
} | go | func ListenPacket(proto, addr string) (l net.PacketConn, err error) {
return NewReusablePortPacketConn(proto, addr)
} | [
"func",
"ListenPacket",
"(",
"proto",
",",
"addr",
"string",
")",
"(",
"l",
"net",
".",
"PacketConn",
",",
"err",
"error",
")",
"{",
"return",
"NewReusablePortPacketConn",
"(",
"proto",
",",
"addr",
")",
"\n",
"}"
] | // ListenPacket is an alias for NewReusablePortPacketConn. | [
"ListenPacket",
"is",
"an",
"alias",
"for",
"NewReusablePortPacketConn",
"."
] | 1f6171f327ed3893406d2a802c563390993c4bb5 | https://github.com/kavu/go_reuseport/blob/1f6171f327ed3893406d2a802c563390993c4bb5/reuseport.go#L48-L50 |
144,523 | kavu/go_reuseport | udp.go | NewReusablePortPacketConn | func NewReusablePortPacketConn(proto, addr string) (l net.PacketConn, err error) {
var (
soType, fd int
file *os.File
sockaddr syscall.Sockaddr
)
if sockaddr, soType, err = getSockaddr(proto, addr); err != nil {
return nil, err
}
syscall.ForkLock.RLock()
fd, err = syscall.Socket(soType, syscall.... | go | func NewReusablePortPacketConn(proto, addr string) (l net.PacketConn, err error) {
var (
soType, fd int
file *os.File
sockaddr syscall.Sockaddr
)
if sockaddr, soType, err = getSockaddr(proto, addr); err != nil {
return nil, err
}
syscall.ForkLock.RLock()
fd, err = syscall.Socket(soType, syscall.... | [
"func",
"NewReusablePortPacketConn",
"(",
"proto",
",",
"addr",
"string",
")",
"(",
"l",
"net",
".",
"PacketConn",
",",
"err",
"error",
")",
"{",
"var",
"(",
"soType",
",",
"fd",
"int",
"\n",
"file",
"*",
"os",
".",
"File",
"\n",
"sockaddr",
"syscall",... | // NewReusablePortPacketConn returns net.FilePacketConn that created from
// a file discriptor for a socket with SO_REUSEPORT option. | [
"NewReusablePortPacketConn",
"returns",
"net",
".",
"FilePacketConn",
"that",
"created",
"from",
"a",
"file",
"discriptor",
"for",
"a",
"socket",
"with",
"SO_REUSEPORT",
"option",
"."
] | 1f6171f327ed3893406d2a802c563390993c4bb5 | https://github.com/kavu/go_reuseport/blob/1f6171f327ed3893406d2a802c563390993c4bb5/udp.go#L93-L147 |
144,524 | kavu/go_reuseport | tcp.go | NewReusablePortListener | func NewReusablePortListener(proto, addr string) (l net.Listener, err error) {
var (
soType, fd int
file *os.File
sockaddr syscall.Sockaddr
)
if sockaddr, soType, err = getSockaddr(proto, addr); err != nil {
return nil, err
}
syscall.ForkLock.RLock()
if fd, err = syscall.Socket(soType, syscall.S... | go | func NewReusablePortListener(proto, addr string) (l net.Listener, err error) {
var (
soType, fd int
file *os.File
sockaddr syscall.Sockaddr
)
if sockaddr, soType, err = getSockaddr(proto, addr); err != nil {
return nil, err
}
syscall.ForkLock.RLock()
if fd, err = syscall.Socket(soType, syscall.S... | [
"func",
"NewReusablePortListener",
"(",
"proto",
",",
"addr",
"string",
")",
"(",
"l",
"net",
".",
"Listener",
",",
"err",
"error",
")",
"{",
"var",
"(",
"soType",
",",
"fd",
"int",
"\n",
"file",
"*",
"os",
".",
"File",
"\n",
"sockaddr",
"syscall",
"... | // NewReusablePortListener returns net.FileListener that created from
// a file discriptor for a socket with SO_REUSEPORT option. | [
"NewReusablePortListener",
"returns",
"net",
".",
"FileListener",
"that",
"created",
"from",
"a",
"file",
"discriptor",
"for",
"a",
"socket",
"with",
"SO_REUSEPORT",
"option",
"."
] | 1f6171f327ed3893406d2a802c563390993c4bb5 | https://github.com/kavu/go_reuseport/blob/1f6171f327ed3893406d2a802c563390993c4bb5/tcp.go#L96-L147 |
144,525 | sohlich/elogrus | hook.go | Fire | func (hook *ElasticHook) Fire(entry *logrus.Entry) error {
return hook.fireFunc(entry, hook, hook.index())
} | go | func (hook *ElasticHook) Fire(entry *logrus.Entry) error {
return hook.fireFunc(entry, hook, hook.index())
} | [
"func",
"(",
"hook",
"*",
"ElasticHook",
")",
"Fire",
"(",
"entry",
"*",
"logrus",
".",
"Entry",
")",
"error",
"{",
"return",
"hook",
".",
"fireFunc",
"(",
"entry",
",",
"hook",
",",
"hook",
".",
"index",
"(",
")",
")",
"\n",
"}"
] | // Fire is required to implement
// Logrus hook | [
"Fire",
"is",
"required",
"to",
"implement",
"Logrus",
"hook"
] | 1fa29e2f2009c129693c7079e5f6361bfbd34080 | https://github.com/sohlich/elogrus/blob/1fa29e2f2009c129693c7079e5f6361bfbd34080/hook.go#L125-L127 |
144,526 | adrianmo/go-nmea | parser.go | AssertType | func (p *parser) AssertType(typ string) {
if p.Type != typ {
p.SetErr("type", p.Type)
}
} | go | func (p *parser) AssertType(typ string) {
if p.Type != typ {
p.SetErr("type", p.Type)
}
} | [
"func",
"(",
"p",
"*",
"parser",
")",
"AssertType",
"(",
"typ",
"string",
")",
"{",
"if",
"p",
".",
"Type",
"!=",
"typ",
"{",
"p",
".",
"SetErr",
"(",
"\"",
"\"",
",",
"p",
".",
"Type",
")",
"\n",
"}",
"\n",
"}"
] | // AssertType makes sure the sentence's type matches the provided one. | [
"AssertType",
"makes",
"sure",
"the",
"sentence",
"s",
"type",
"matches",
"the",
"provided",
"one",
"."
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L21-L25 |
144,527 | adrianmo/go-nmea | parser.go | SetErr | func (p *parser) SetErr(context, value string) {
if p.err == nil {
p.err = fmt.Errorf("nmea: %s invalid %s: %s", p.Prefix(), context, value)
}
} | go | func (p *parser) SetErr(context, value string) {
if p.err == nil {
p.err = fmt.Errorf("nmea: %s invalid %s: %s", p.Prefix(), context, value)
}
} | [
"func",
"(",
"p",
"*",
"parser",
")",
"SetErr",
"(",
"context",
",",
"value",
"string",
")",
"{",
"if",
"p",
".",
"err",
"==",
"nil",
"{",
"p",
".",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"p",
".",
"Prefix",
"(",
")",
",",
... | // SetErr assigns an error. Calling this method has no
// effect if there is already an error. | [
"SetErr",
"assigns",
"an",
"error",
".",
"Calling",
"this",
"method",
"has",
"no",
"effect",
"if",
"there",
"is",
"already",
"an",
"error",
"."
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L34-L38 |
144,528 | adrianmo/go-nmea | parser.go | String | func (p *parser) String(i int, context string) string {
if p.err != nil {
return ""
}
if i < 0 || i >= len(p.Fields) {
p.SetErr(context, "index out of range")
return ""
}
return p.Fields[i]
} | go | func (p *parser) String(i int, context string) string {
if p.err != nil {
return ""
}
if i < 0 || i >= len(p.Fields) {
p.SetErr(context, "index out of range")
return ""
}
return p.Fields[i]
} | [
"func",
"(",
"p",
"*",
"parser",
")",
"String",
"(",
"i",
"int",
",",
"context",
"string",
")",
"string",
"{",
"if",
"p",
".",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"i",
"<",
"0",
"||",
"i",
">=",
"len",
"(",
... | // String returns the field value at the specified index. | [
"String",
"returns",
"the",
"field",
"value",
"at",
"the",
"specified",
"index",
"."
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L41-L50 |
144,529 | adrianmo/go-nmea | parser.go | EnumString | func (p *parser) EnumString(i int, context string, options ...string) string {
s := p.String(i, context)
if p.err != nil || s == "" {
return ""
}
for _, o := range options {
if o == s {
return s
}
}
p.SetErr(context, s)
return ""
} | go | func (p *parser) EnumString(i int, context string, options ...string) string {
s := p.String(i, context)
if p.err != nil || s == "" {
return ""
}
for _, o := range options {
if o == s {
return s
}
}
p.SetErr(context, s)
return ""
} | [
"func",
"(",
"p",
"*",
"parser",
")",
"EnumString",
"(",
"i",
"int",
",",
"context",
"string",
",",
"options",
"...",
"string",
")",
"string",
"{",
"s",
":=",
"p",
".",
"String",
"(",
"i",
",",
"context",
")",
"\n",
"if",
"p",
".",
"err",
"!=",
... | // EnumString returns the field value at the specified index.
// An error occurs if the value is not one of the options and not empty. | [
"EnumString",
"returns",
"the",
"field",
"value",
"at",
"the",
"specified",
"index",
".",
"An",
"error",
"occurs",
"if",
"the",
"value",
"is",
"not",
"one",
"of",
"the",
"options",
"and",
"not",
"empty",
"."
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L54-L66 |
144,530 | adrianmo/go-nmea | parser.go | EnumChars | func (p *parser) EnumChars(i int, context string, options ...string) []string {
s := p.String(i, context)
if p.err != nil || s == "" {
return []string{}
}
strs := []string{}
for _, r := range s {
rs := string(r)
for _, o := range options {
if o == rs {
strs = append(strs, o)
break
}
}
}
if ... | go | func (p *parser) EnumChars(i int, context string, options ...string) []string {
s := p.String(i, context)
if p.err != nil || s == "" {
return []string{}
}
strs := []string{}
for _, r := range s {
rs := string(r)
for _, o := range options {
if o == rs {
strs = append(strs, o)
break
}
}
}
if ... | [
"func",
"(",
"p",
"*",
"parser",
")",
"EnumChars",
"(",
"i",
"int",
",",
"context",
"string",
",",
"options",
"...",
"string",
")",
"[",
"]",
"string",
"{",
"s",
":=",
"p",
".",
"String",
"(",
"i",
",",
"context",
")",
"\n",
"if",
"p",
".",
"er... | // EnumChars returns an array of strings that are matched in the Mode field.
// It will only match the number of characters that are in the Mode field.
// If the value is empty, it will return an empty array | [
"EnumChars",
"returns",
"an",
"array",
"of",
"strings",
"that",
"are",
"matched",
"in",
"the",
"Mode",
"field",
".",
"It",
"will",
"only",
"match",
"the",
"number",
"of",
"characters",
"that",
"are",
"in",
"the",
"Mode",
"field",
".",
"If",
"the",
"value... | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L71-L92 |
144,531 | adrianmo/go-nmea | parser.go | Int64 | func (p *parser) Int64(i int, context string) int64 {
s := p.String(i, context)
if p.err != nil {
return 0
}
if s == "" {
return 0
}
v, err := strconv.ParseInt(s, 10, 64)
if err != nil {
p.SetErr(context, s)
}
return v
} | go | func (p *parser) Int64(i int, context string) int64 {
s := p.String(i, context)
if p.err != nil {
return 0
}
if s == "" {
return 0
}
v, err := strconv.ParseInt(s, 10, 64)
if err != nil {
p.SetErr(context, s)
}
return v
} | [
"func",
"(",
"p",
"*",
"parser",
")",
"Int64",
"(",
"i",
"int",
",",
"context",
"string",
")",
"int64",
"{",
"s",
":=",
"p",
".",
"String",
"(",
"i",
",",
"context",
")",
"\n",
"if",
"p",
".",
"err",
"!=",
"nil",
"{",
"return",
"0",
"\n",
"}"... | // Int64 returns the int64 value at the specified index.
// If the value is an empty string, 0 is returned. | [
"Int64",
"returns",
"the",
"int64",
"value",
"at",
"the",
"specified",
"index",
".",
"If",
"the",
"value",
"is",
"an",
"empty",
"string",
"0",
"is",
"returned",
"."
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L96-L109 |
144,532 | adrianmo/go-nmea | parser.go | Float64 | func (p *parser) Float64(i int, context string) float64 {
s := p.String(i, context)
if p.err != nil {
return 0
}
if s == "" {
return 0
}
v, err := strconv.ParseFloat(s, 64)
if err != nil {
p.SetErr(context, s)
}
return v
} | go | func (p *parser) Float64(i int, context string) float64 {
s := p.String(i, context)
if p.err != nil {
return 0
}
if s == "" {
return 0
}
v, err := strconv.ParseFloat(s, 64)
if err != nil {
p.SetErr(context, s)
}
return v
} | [
"func",
"(",
"p",
"*",
"parser",
")",
"Float64",
"(",
"i",
"int",
",",
"context",
"string",
")",
"float64",
"{",
"s",
":=",
"p",
".",
"String",
"(",
"i",
",",
"context",
")",
"\n",
"if",
"p",
".",
"err",
"!=",
"nil",
"{",
"return",
"0",
"\n",
... | // Float64 returns the float64 value at the specified index.
// If the value is an empty string, 0 is returned. | [
"Float64",
"returns",
"the",
"float64",
"value",
"at",
"the",
"specified",
"index",
".",
"If",
"the",
"value",
"is",
"an",
"empty",
"string",
"0",
"is",
"returned",
"."
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L113-L126 |
144,533 | adrianmo/go-nmea | parser.go | Time | func (p *parser) Time(i int, context string) Time {
s := p.String(i, context)
if p.err != nil {
return Time{}
}
v, err := ParseTime(s)
if err != nil {
p.SetErr(context, s)
}
return v
} | go | func (p *parser) Time(i int, context string) Time {
s := p.String(i, context)
if p.err != nil {
return Time{}
}
v, err := ParseTime(s)
if err != nil {
p.SetErr(context, s)
}
return v
} | [
"func",
"(",
"p",
"*",
"parser",
")",
"Time",
"(",
"i",
"int",
",",
"context",
"string",
")",
"Time",
"{",
"s",
":=",
"p",
".",
"String",
"(",
"i",
",",
"context",
")",
"\n",
"if",
"p",
".",
"err",
"!=",
"nil",
"{",
"return",
"Time",
"{",
"}"... | // Time returns the Time value at the specified index.
// If the value is empty, the Time is marked as invalid. | [
"Time",
"returns",
"the",
"Time",
"value",
"at",
"the",
"specified",
"index",
".",
"If",
"the",
"value",
"is",
"empty",
"the",
"Time",
"is",
"marked",
"as",
"invalid",
"."
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L130-L140 |
144,534 | adrianmo/go-nmea | parser.go | Date | func (p *parser) Date(i int, context string) Date {
s := p.String(i, context)
if p.err != nil {
return Date{}
}
v, err := ParseDate(s)
if err != nil {
p.SetErr(context, s)
}
return v
} | go | func (p *parser) Date(i int, context string) Date {
s := p.String(i, context)
if p.err != nil {
return Date{}
}
v, err := ParseDate(s)
if err != nil {
p.SetErr(context, s)
}
return v
} | [
"func",
"(",
"p",
"*",
"parser",
")",
"Date",
"(",
"i",
"int",
",",
"context",
"string",
")",
"Date",
"{",
"s",
":=",
"p",
".",
"String",
"(",
"i",
",",
"context",
")",
"\n",
"if",
"p",
".",
"err",
"!=",
"nil",
"{",
"return",
"Date",
"{",
"}"... | // Date returns the Date value at the specified index.
// If the value is empty, the Date is marked as invalid. | [
"Date",
"returns",
"the",
"Date",
"value",
"at",
"the",
"specified",
"index",
".",
"If",
"the",
"value",
"is",
"empty",
"the",
"Date",
"is",
"marked",
"as",
"invalid",
"."
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L144-L154 |
144,535 | adrianmo/go-nmea | parser.go | LatLong | func (p *parser) LatLong(i, j int, context string) float64 {
a := p.String(i, context)
b := p.String(j, context)
if p.err != nil {
return 0
}
s := fmt.Sprintf("%s %s", a, b)
v, err := ParseLatLong(s)
if err != nil {
p.SetErr(context, err.Error())
}
return v
} | go | func (p *parser) LatLong(i, j int, context string) float64 {
a := p.String(i, context)
b := p.String(j, context)
if p.err != nil {
return 0
}
s := fmt.Sprintf("%s %s", a, b)
v, err := ParseLatLong(s)
if err != nil {
p.SetErr(context, err.Error())
}
return v
} | [
"func",
"(",
"p",
"*",
"parser",
")",
"LatLong",
"(",
"i",
",",
"j",
"int",
",",
"context",
"string",
")",
"float64",
"{",
"a",
":=",
"p",
".",
"String",
"(",
"i",
",",
"context",
")",
"\n",
"b",
":=",
"p",
".",
"String",
"(",
"j",
",",
"cont... | // LatLong returns the coordinate value of the specified fields. | [
"LatLong",
"returns",
"the",
"coordinate",
"value",
"of",
"the",
"specified",
"fields",
"."
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L157-L169 |
144,536 | adrianmo/go-nmea | parser.go | SixBitASCIIArmour | func (p *parser) SixBitASCIIArmour(i int, fillBits int, context string) []byte {
if p.err != nil {
return nil
}
if fillBits < 0 || fillBits >= 6 {
p.SetErr(context, "fill bits")
return nil
}
payload := []byte(p.String(i, "encoded payload"))
numBits := len(payload)*6 - fillBits
if numBits < 0 {
p.SetErr... | go | func (p *parser) SixBitASCIIArmour(i int, fillBits int, context string) []byte {
if p.err != nil {
return nil
}
if fillBits < 0 || fillBits >= 6 {
p.SetErr(context, "fill bits")
return nil
}
payload := []byte(p.String(i, "encoded payload"))
numBits := len(payload)*6 - fillBits
if numBits < 0 {
p.SetErr... | [
"func",
"(",
"p",
"*",
"parser",
")",
"SixBitASCIIArmour",
"(",
"i",
"int",
",",
"fillBits",
"int",
",",
"context",
"string",
")",
"[",
"]",
"byte",
"{",
"if",
"p",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"fillBits",
... | // SixBitASCIIArmour decodes the 6-bit ascii armor used for VDM and VDO messages | [
"SixBitASCIIArmour",
"decodes",
"the",
"6",
"-",
"bit",
"ascii",
"armor",
"used",
"for",
"VDM",
"and",
"VDO",
"messages"
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L172-L210 |
144,537 | adrianmo/go-nmea | gsa.go | newGSA | func newGSA(s BaseSentence) (GSA, error) {
p := newParser(s)
p.AssertType(TypeGSA)
m := GSA{
BaseSentence: s,
Mode: p.EnumString(0, "selection mode", Auto, Manual),
FixType: p.EnumString(1, "fix type", FixNone, Fix2D, Fix3D),
}
// Satellites in view.
for i := 2; i < 14; i++ {
if v := p.String... | go | func newGSA(s BaseSentence) (GSA, error) {
p := newParser(s)
p.AssertType(TypeGSA)
m := GSA{
BaseSentence: s,
Mode: p.EnumString(0, "selection mode", Auto, Manual),
FixType: p.EnumString(1, "fix type", FixNone, Fix2D, Fix3D),
}
// Satellites in view.
for i := 2; i < 14; i++ {
if v := p.String... | [
"func",
"newGSA",
"(",
"s",
"BaseSentence",
")",
"(",
"GSA",
",",
"error",
")",
"{",
"p",
":=",
"newParser",
"(",
"s",
")",
"\n",
"p",
".",
"AssertType",
"(",
"TypeGSA",
")",
"\n",
"m",
":=",
"GSA",
"{",
"BaseSentence",
":",
"s",
",",
"Mode",
":"... | // newGSA parses the GSA sentence into this struct. | [
"newGSA",
"parses",
"the",
"GSA",
"sentence",
"into",
"this",
"struct",
"."
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/gsa.go#L31-L50 |
144,538 | adrianmo/go-nmea | sentence.go | parseSentence | func parseSentence(raw string) (BaseSentence, error) {
startIndex := strings.IndexAny(raw, SentenceStart+SentenceStartEncapsulated)
if startIndex != 0 {
return BaseSentence{}, fmt.Errorf("nmea: sentence does not start with a '$' or '!'")
}
sumSepIndex := strings.Index(raw, ChecksumSep)
if sumSepIndex == -1 {
r... | go | func parseSentence(raw string) (BaseSentence, error) {
startIndex := strings.IndexAny(raw, SentenceStart+SentenceStartEncapsulated)
if startIndex != 0 {
return BaseSentence{}, fmt.Errorf("nmea: sentence does not start with a '$' or '!'")
}
sumSepIndex := strings.Index(raw, ChecksumSep)
if sumSepIndex == -1 {
r... | [
"func",
"parseSentence",
"(",
"raw",
"string",
")",
"(",
"BaseSentence",
",",
"error",
")",
"{",
"startIndex",
":=",
"strings",
".",
"IndexAny",
"(",
"raw",
",",
"SentenceStart",
"+",
"SentenceStartEncapsulated",
")",
"\n",
"if",
"startIndex",
"!=",
"0",
"{"... | // parseSentence parses a raw message into it's fields | [
"parseSentence",
"parses",
"a",
"raw",
"message",
"into",
"it",
"s",
"fields"
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/sentence.go#L58-L86 |
144,539 | adrianmo/go-nmea | sentence.go | parsePrefix | func parsePrefix(s string) (string, string) {
if strings.HasPrefix(s, "P") {
return "P", s[1:]
}
if len(s) < 2 {
return s, ""
}
return s[:2], s[2:]
} | go | func parsePrefix(s string) (string, string) {
if strings.HasPrefix(s, "P") {
return "P", s[1:]
}
if len(s) < 2 {
return s, ""
}
return s[:2], s[2:]
} | [
"func",
"parsePrefix",
"(",
"s",
"string",
")",
"(",
"string",
",",
"string",
")",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"s",
",",
"\"",
"\"",
")",
"{",
"return",
"\"",
"\"",
",",
"s",
"[",
"1",
":",
"]",
"\n",
"}",
"\n",
"if",
"len",
... | // parsePrefix takes the first field and splits it into a talker id and data type. | [
"parsePrefix",
"takes",
"the",
"first",
"field",
"and",
"splits",
"it",
"into",
"a",
"talker",
"id",
"and",
"data",
"type",
"."
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/sentence.go#L89-L97 |
144,540 | adrianmo/go-nmea | sentence.go | xorChecksum | func xorChecksum(s string) string {
var checksum uint8
for i := 0; i < len(s); i++ {
checksum ^= s[i]
}
return fmt.Sprintf("%02X", checksum)
} | go | func xorChecksum(s string) string {
var checksum uint8
for i := 0; i < len(s); i++ {
checksum ^= s[i]
}
return fmt.Sprintf("%02X", checksum)
} | [
"func",
"xorChecksum",
"(",
"s",
"string",
")",
"string",
"{",
"var",
"checksum",
"uint8",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"s",
")",
";",
"i",
"++",
"{",
"checksum",
"^=",
"s",
"[",
"i",
"]",
"\n",
"}",
"\n",
"return",
... | // xor all the bytes in a string an return it
// as an uppercase hex string | [
"xor",
"all",
"the",
"bytes",
"in",
"a",
"string",
"an",
"return",
"it",
"as",
"an",
"uppercase",
"hex",
"string"
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/sentence.go#L101-L107 |
144,541 | adrianmo/go-nmea | sentence.go | Parse | func Parse(raw string) (Sentence, error) {
s, err := parseSentence(raw)
if err != nil {
return nil, err
}
if strings.HasPrefix(s.Raw, SentenceStart) {
switch s.Type {
case TypeRMC:
return newRMC(s)
case TypeGGA:
return newGGA(s)
case TypeGSA:
return newGSA(s)
case TypeGLL:
return newGLL(s)
... | go | func Parse(raw string) (Sentence, error) {
s, err := parseSentence(raw)
if err != nil {
return nil, err
}
if strings.HasPrefix(s.Raw, SentenceStart) {
switch s.Type {
case TypeRMC:
return newRMC(s)
case TypeGGA:
return newGGA(s)
case TypeGSA:
return newGSA(s)
case TypeGLL:
return newGLL(s)
... | [
"func",
"Parse",
"(",
"raw",
"string",
")",
"(",
"Sentence",
",",
"error",
")",
"{",
"s",
",",
"err",
":=",
"parseSentence",
"(",
"raw",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"strings",
".",... | // Parse parses the given string into the correct sentence type. | [
"Parse",
"parses",
"the",
"given",
"string",
"into",
"the",
"correct",
"sentence",
"type",
"."
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/sentence.go#L110-L148 |
144,542 | adrianmo/go-nmea | types.go | FormatDMS | func FormatDMS(l float64) string {
val := math.Abs(l)
degrees := int(math.Floor(val))
minutes := int(math.Floor(60 * (val - float64(degrees))))
seconds := 3600 * (val - float64(degrees) - (float64(minutes) / 60))
return fmt.Sprintf("%d\u00B0 %d' %f\"", degrees, minutes, seconds)
} | go | func FormatDMS(l float64) string {
val := math.Abs(l)
degrees := int(math.Floor(val))
minutes := int(math.Floor(60 * (val - float64(degrees))))
seconds := 3600 * (val - float64(degrees) - (float64(minutes) / 60))
return fmt.Sprintf("%d\u00B0 %d' %f\"", degrees, minutes, seconds)
} | [
"func",
"FormatDMS",
"(",
"l",
"float64",
")",
"string",
"{",
"val",
":=",
"math",
".",
"Abs",
"(",
"l",
")",
"\n",
"degrees",
":=",
"int",
"(",
"math",
".",
"Floor",
"(",
"val",
")",
")",
"\n",
"minutes",
":=",
"int",
"(",
"math",
".",
"Floor",
... | // FormatDMS returns the degrees, minutes, seconds format for the given LatLong. | [
"FormatDMS",
"returns",
"the",
"degrees",
"minutes",
"seconds",
"format",
"for",
"the",
"given",
"LatLong",
"."
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/types.go#L160-L166 |
144,543 | adrianmo/go-nmea | types.go | String | func (t Time) String() string {
seconds := float64(t.Second) + float64(t.Millisecond)/1000
return fmt.Sprintf("%02d:%02d:%07.4f", t.Hour, t.Minute, seconds)
} | go | func (t Time) String() string {
seconds := float64(t.Second) + float64(t.Millisecond)/1000
return fmt.Sprintf("%02d:%02d:%07.4f", t.Hour, t.Minute, seconds)
} | [
"func",
"(",
"t",
"Time",
")",
"String",
"(",
")",
"string",
"{",
"seconds",
":=",
"float64",
"(",
"t",
".",
"Second",
")",
"+",
"float64",
"(",
"t",
".",
"Millisecond",
")",
"/",
"1000",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",... | // String representation of Time | [
"String",
"representation",
"of",
"Time"
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/types.go#L178-L181 |
144,544 | adrianmo/go-nmea | types.go | String | func (d Date) String() string {
return fmt.Sprintf("%02d/%02d/%02d", d.DD, d.MM, d.YY)
} | go | func (d Date) String() string {
return fmt.Sprintf("%02d/%02d/%02d", d.DD, d.MM, d.YY)
} | [
"func",
"(",
"d",
"Date",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"d",
".",
"DD",
",",
"d",
".",
"MM",
",",
"d",
".",
"YY",
")",
"\n",
"}"
] | // String representation of date | [
"String",
"representation",
"of",
"date"
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/types.go#L223-L225 |
144,545 | adrianmo/go-nmea | types.go | ParseDate | func ParseDate(ddmmyy string) (Date, error) {
if ddmmyy == "" {
return Date{}, nil
}
if len(ddmmyy) != 6 {
return Date{}, fmt.Errorf("parse date: exptected ddmmyy format, got '%s'", ddmmyy)
}
dd, err := strconv.Atoi(ddmmyy[0:2])
if err != nil {
return Date{}, errors.New(ddmmyy)
}
mm, err := strconv.Atoi(d... | go | func ParseDate(ddmmyy string) (Date, error) {
if ddmmyy == "" {
return Date{}, nil
}
if len(ddmmyy) != 6 {
return Date{}, fmt.Errorf("parse date: exptected ddmmyy format, got '%s'", ddmmyy)
}
dd, err := strconv.Atoi(ddmmyy[0:2])
if err != nil {
return Date{}, errors.New(ddmmyy)
}
mm, err := strconv.Atoi(d... | [
"func",
"ParseDate",
"(",
"ddmmyy",
"string",
")",
"(",
"Date",
",",
"error",
")",
"{",
"if",
"ddmmyy",
"==",
"\"",
"\"",
"{",
"return",
"Date",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n",
"if",
"len",
"(",
"ddmmyy",
")",
"!=",
"6",
"{",
"return",
"... | // ParseDate field ddmmyy format | [
"ParseDate",
"field",
"ddmmyy",
"format"
] | 7572fbeb90aaa0bd3d1dcb674938ffbc0a943123 | https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/types.go#L228-L248 |
144,546 | jessevdk/go-flags | group.go | Find | func (g *Group) Find(shortDescription string) *Group {
lshortDescription := strings.ToLower(shortDescription)
var ret *Group
g.eachGroup(func(gg *Group) {
if gg != g && strings.ToLower(gg.ShortDescription) == lshortDescription {
ret = gg
}
})
return ret
} | go | func (g *Group) Find(shortDescription string) *Group {
lshortDescription := strings.ToLower(shortDescription)
var ret *Group
g.eachGroup(func(gg *Group) {
if gg != g && strings.ToLower(gg.ShortDescription) == lshortDescription {
ret = gg
}
})
return ret
} | [
"func",
"(",
"g",
"*",
"Group",
")",
"Find",
"(",
"shortDescription",
"string",
")",
"*",
"Group",
"{",
"lshortDescription",
":=",
"strings",
".",
"ToLower",
"(",
"shortDescription",
")",
"\n\n",
"var",
"ret",
"*",
"Group",
"\n\n",
"g",
".",
"eachGroup",
... | // Find locates the subgroup with the given short description and returns it.
// If no such group can be found Find will return nil. Note that the description
// is matched case insensitively. | [
"Find",
"locates",
"the",
"subgroup",
"with",
"the",
"given",
"short",
"description",
"and",
"returns",
"it",
".",
"If",
"no",
"such",
"group",
"can",
"be",
"found",
"Find",
"will",
"return",
"nil",
".",
"Note",
"that",
"the",
"description",
"is",
"matched... | c0795c8afcf41dd1d786bebce68636c199b3bb45 | https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/group.go#L89-L101 |
144,547 | jessevdk/go-flags | group.go | FindOptionByShortName | func (g *Group) FindOptionByShortName(shortName rune) *Option {
return g.findOption(func(option *Option) bool {
return option.ShortName == shortName
})
} | go | func (g *Group) FindOptionByShortName(shortName rune) *Option {
return g.findOption(func(option *Option) bool {
return option.ShortName == shortName
})
} | [
"func",
"(",
"g",
"*",
"Group",
")",
"FindOptionByShortName",
"(",
"shortName",
"rune",
")",
"*",
"Option",
"{",
"return",
"g",
".",
"findOption",
"(",
"func",
"(",
"option",
"*",
"Option",
")",
"bool",
"{",
"return",
"option",
".",
"ShortName",
"==",
... | // FindOptionByShortName finds an option that is part of the group, or any of
// its subgroups, by matching its short name. | [
"FindOptionByShortName",
"finds",
"an",
"option",
"that",
"is",
"part",
"of",
"the",
"group",
"or",
"any",
"of",
"its",
"subgroups",
"by",
"matching",
"its",
"short",
"name",
"."
] | c0795c8afcf41dd1d786bebce68636c199b3bb45 | https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/group.go#L125-L129 |
144,548 | jessevdk/go-flags | man.go | WriteManPage | func (p *Parser) WriteManPage(wr io.Writer) {
t := time.Now()
source_date_epoch := os.Getenv("SOURCE_DATE_EPOCH")
if source_date_epoch != "" {
sde, err := strconv.ParseInt(source_date_epoch, 10, 64)
if err != nil {
panic(fmt.Sprintf("Invalid SOURCE_DATE_EPOCH: %s", err))
}
t = time.Unix(sde, 0)
}
fmt.F... | go | func (p *Parser) WriteManPage(wr io.Writer) {
t := time.Now()
source_date_epoch := os.Getenv("SOURCE_DATE_EPOCH")
if source_date_epoch != "" {
sde, err := strconv.ParseInt(source_date_epoch, 10, 64)
if err != nil {
panic(fmt.Sprintf("Invalid SOURCE_DATE_EPOCH: %s", err))
}
t = time.Unix(sde, 0)
}
fmt.F... | [
"func",
"(",
"p",
"*",
"Parser",
")",
"WriteManPage",
"(",
"wr",
"io",
".",
"Writer",
")",
"{",
"t",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"source_date_epoch",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"source_date_epoch",
"!... | // WriteManPage writes a basic man page in groff format to the specified
// writer. | [
"WriteManPage",
"writes",
"a",
"basic",
"man",
"page",
"in",
"groff",
"format",
"to",
"the",
"specified",
"writer",
"."
] | c0795c8afcf41dd1d786bebce68636c199b3bb45 | https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/man.go#L178-L215 |
144,549 | jessevdk/go-flags | parser.go | NewNamedParser | func NewNamedParser(appname string, options Options) *Parser {
p := &Parser{
Command: newCommand(appname, "", "", nil),
Options: options,
NamespaceDelimiter: ".",
EnvNamespaceDelimiter: "_",
}
p.Command.parent = p
return p
} | go | func NewNamedParser(appname string, options Options) *Parser {
p := &Parser{
Command: newCommand(appname, "", "", nil),
Options: options,
NamespaceDelimiter: ".",
EnvNamespaceDelimiter: "_",
}
p.Command.parent = p
return p
} | [
"func",
"NewNamedParser",
"(",
"appname",
"string",
",",
"options",
"Options",
")",
"*",
"Parser",
"{",
"p",
":=",
"&",
"Parser",
"{",
"Command",
":",
"newCommand",
"(",
"appname",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
")",
",",
"Options",
":... | // NewNamedParser creates a new parser. The appname is used to display the
// executable name in the built-in help message. Option groups and commands can
// be added to this parser by using AddGroup and AddCommand. | [
"NewNamedParser",
"creates",
"a",
"new",
"parser",
".",
"The",
"appname",
"is",
"used",
"to",
"display",
"the",
"executable",
"name",
"in",
"the",
"built",
"-",
"in",
"help",
"message",
".",
"Option",
"groups",
"and",
"commands",
"can",
"be",
"added",
"to"... | c0795c8afcf41dd1d786bebce68636c199b3bb45 | https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/parser.go#L174-L185 |
144,550 | jessevdk/go-flags | ini.go | ParseFile | func (i *IniParser) ParseFile(filename string) error {
ini, err := readIniFromFile(filename)
if err != nil {
return err
}
return i.parse(ini)
} | go | func (i *IniParser) ParseFile(filename string) error {
ini, err := readIniFromFile(filename)
if err != nil {
return err
}
return i.parse(ini)
} | [
"func",
"(",
"i",
"*",
"IniParser",
")",
"ParseFile",
"(",
"filename",
"string",
")",
"error",
"{",
"ini",
",",
"err",
":=",
"readIniFromFile",
"(",
"filename",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
... | // ParseFile parses flags from an ini formatted file. See Parse for more
// information on the ini file format. The returned errors can be of the type
// flags.Error or flags.IniError. | [
"ParseFile",
"parses",
"flags",
"from",
"an",
"ini",
"formatted",
"file",
".",
"See",
"Parse",
"for",
"more",
"information",
"on",
"the",
"ini",
"file",
"format",
".",
"The",
"returned",
"errors",
"can",
"be",
"of",
"the",
"type",
"flags",
".",
"Error",
... | c0795c8afcf41dd1d786bebce68636c199b3bb45 | https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/ini.go#L100-L108 |
144,551 | jessevdk/go-flags | ini.go | WriteFile | func (i *IniParser) WriteFile(filename string, options IniOptions) error {
return writeIniToFile(i, filename, options)
} | go | func (i *IniParser) WriteFile(filename string, options IniOptions) error {
return writeIniToFile(i, filename, options)
} | [
"func",
"(",
"i",
"*",
"IniParser",
")",
"WriteFile",
"(",
"filename",
"string",
",",
"options",
"IniOptions",
")",
"error",
"{",
"return",
"writeIniToFile",
"(",
"i",
",",
"filename",
",",
"options",
")",
"\n",
"}"
] | // WriteFile writes the flags as ini format into a file. See Write
// for more information. The returned error occurs when the specified file
// could not be opened for writing. | [
"WriteFile",
"writes",
"the",
"flags",
"as",
"ini",
"format",
"into",
"a",
"file",
".",
"See",
"Write",
"for",
"more",
"information",
".",
"The",
"returned",
"error",
"occurs",
"when",
"the",
"specified",
"file",
"could",
"not",
"be",
"opened",
"for",
"wri... | c0795c8afcf41dd1d786bebce68636c199b3bb45 | https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/ini.go#L147-L149 |
144,552 | jessevdk/go-flags | completion.go | Complete | func (f *Filename) Complete(match string) []Completion {
ret, _ := filepath.Glob(match + "*")
if len(ret) == 1 {
if info, err := os.Stat(ret[0]); err == nil && info.IsDir() {
ret[0] = ret[0] + "/"
}
}
return completionsWithoutDescriptions(ret)
} | go | func (f *Filename) Complete(match string) []Completion {
ret, _ := filepath.Glob(match + "*")
if len(ret) == 1 {
if info, err := os.Stat(ret[0]); err == nil && info.IsDir() {
ret[0] = ret[0] + "/"
}
}
return completionsWithoutDescriptions(ret)
} | [
"func",
"(",
"f",
"*",
"Filename",
")",
"Complete",
"(",
"match",
"string",
")",
"[",
"]",
"Completion",
"{",
"ret",
",",
"_",
":=",
"filepath",
".",
"Glob",
"(",
"match",
"+",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"ret",
")",
"==",
"1",
"{"... | // Complete returns a list of existing files with the given
// prefix. | [
"Complete",
"returns",
"a",
"list",
"of",
"existing",
"files",
"with",
"the",
"given",
"prefix",
"."
] | c0795c8afcf41dd1d786bebce68636c199b3bb45 | https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/completion.go#L64-L72 |
144,553 | jessevdk/go-flags | option.go | LongNameWithNamespace | func (option *Option) LongNameWithNamespace() string {
if len(option.LongName) == 0 {
return ""
}
// fetch the namespace delimiter from the parser which is always at the
// end of the group hierarchy
namespaceDelimiter := ""
g := option.group
for {
if p, ok := g.parent.(*Parser); ok {
namespaceDelimiter... | go | func (option *Option) LongNameWithNamespace() string {
if len(option.LongName) == 0 {
return ""
}
// fetch the namespace delimiter from the parser which is always at the
// end of the group hierarchy
namespaceDelimiter := ""
g := option.group
for {
if p, ok := g.parent.(*Parser); ok {
namespaceDelimiter... | [
"func",
"(",
"option",
"*",
"Option",
")",
"LongNameWithNamespace",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"option",
".",
"LongName",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"// fetch the namespace delimiter from the parser which is alw... | // LongNameWithNamespace returns the option's long name with the group namespaces
// prepended by walking up the option's group tree. Namespaces and the long name
// itself are separated by the parser's namespace delimiter. If the long name is
// empty an empty string is returned. | [
"LongNameWithNamespace",
"returns",
"the",
"option",
"s",
"long",
"name",
"with",
"the",
"group",
"namespaces",
"prepended",
"by",
"walking",
"up",
"the",
"option",
"s",
"group",
"tree",
".",
"Namespaces",
"and",
"the",
"long",
"name",
"itself",
"are",
"separa... | c0795c8afcf41dd1d786bebce68636c199b3bb45 | https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/option.go#L95-L140 |
144,554 | jessevdk/go-flags | option.go | EnvKeyWithNamespace | func (option *Option) EnvKeyWithNamespace() string {
if len(option.EnvDefaultKey) == 0 {
return ""
}
// fetch the namespace delimiter from the parser which is always at the
// end of the group hierarchy
namespaceDelimiter := ""
g := option.group
for {
if p, ok := g.parent.(*Parser); ok {
namespaceDelimi... | go | func (option *Option) EnvKeyWithNamespace() string {
if len(option.EnvDefaultKey) == 0 {
return ""
}
// fetch the namespace delimiter from the parser which is always at the
// end of the group hierarchy
namespaceDelimiter := ""
g := option.group
for {
if p, ok := g.parent.(*Parser); ok {
namespaceDelimi... | [
"func",
"(",
"option",
"*",
"Option",
")",
"EnvKeyWithNamespace",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"option",
".",
"EnvDefaultKey",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"// fetch the namespace delimiter from the parser which is ... | // EnvKeyWithNamespace returns the option's env key with the group namespaces
// prepended by walking up the option's group tree. Namespaces and the env key
// itself are separated by the parser's namespace delimiter. If the env key is
// empty an empty string is returned. | [
"EnvKeyWithNamespace",
"returns",
"the",
"option",
"s",
"env",
"key",
"with",
"the",
"group",
"namespaces",
"prepended",
"by",
"walking",
"up",
"the",
"option",
"s",
"group",
"tree",
".",
"Namespaces",
"and",
"the",
"env",
"key",
"itself",
"are",
"separated",
... | c0795c8afcf41dd1d786bebce68636c199b3bb45 | https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/option.go#L146-L191 |
144,555 | jessevdk/go-flags | option.go | String | func (option *Option) String() string {
var s string
var short string
if option.ShortName != 0 {
data := make([]byte, utf8.RuneLen(option.ShortName))
utf8.EncodeRune(data, option.ShortName)
short = string(data)
if len(option.LongName) != 0 {
s = fmt.Sprintf("%s%s, %s%s",
string(defaultShortOptDelimi... | go | func (option *Option) String() string {
var s string
var short string
if option.ShortName != 0 {
data := make([]byte, utf8.RuneLen(option.ShortName))
utf8.EncodeRune(data, option.ShortName)
short = string(data)
if len(option.LongName) != 0 {
s = fmt.Sprintf("%s%s, %s%s",
string(defaultShortOptDelimi... | [
"func",
"(",
"option",
"*",
"Option",
")",
"String",
"(",
")",
"string",
"{",
"var",
"s",
"string",
"\n",
"var",
"short",
"string",
"\n\n",
"if",
"option",
".",
"ShortName",
"!=",
"0",
"{",
"data",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"utf8",
... | // String converts an option to a human friendly readable string describing the
// option. | [
"String",
"converts",
"an",
"option",
"to",
"a",
"human",
"friendly",
"readable",
"string",
"describing",
"the",
"option",
"."
] | c0795c8afcf41dd1d786bebce68636c199b3bb45 | https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/option.go#L195-L216 |
144,556 | jessevdk/go-flags | option.go | set | func (option *Option) set(value *string) error {
kind := option.value.Type().Kind()
if (kind == reflect.Map || kind == reflect.Slice) && !option.isSet {
option.empty()
}
option.isSet = true
option.preventDefault = true
if len(option.Choices) != 0 {
found := false
for _, choice := range option.Choices {
... | go | func (option *Option) set(value *string) error {
kind := option.value.Type().Kind()
if (kind == reflect.Map || kind == reflect.Slice) && !option.isSet {
option.empty()
}
option.isSet = true
option.preventDefault = true
if len(option.Choices) != 0 {
found := false
for _, choice := range option.Choices {
... | [
"func",
"(",
"option",
"*",
"Option",
")",
"set",
"(",
"value",
"*",
"string",
")",
"error",
"{",
"kind",
":=",
"option",
".",
"value",
".",
"Type",
"(",
")",
".",
"Kind",
"(",
")",
"\n\n",
"if",
"(",
"kind",
"==",
"reflect",
".",
"Map",
"||",
... | // Set the value of an option to the specified value. An error will be returned
// if the specified value could not be converted to the corresponding option
// value type. | [
"Set",
"the",
"value",
"of",
"an",
"option",
"to",
"the",
"specified",
"value",
".",
"An",
"error",
"will",
"be",
"returned",
"if",
"the",
"specified",
"value",
"could",
"not",
"be",
"converted",
"to",
"the",
"corresponding",
"option",
"value",
"type",
"."... | c0795c8afcf41dd1d786bebce68636c199b3bb45 | https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/option.go#L241-L281 |
144,557 | jessevdk/go-flags | command.go | AddCommand | func (c *Command) AddCommand(command string, shortDescription string, longDescription string, data interface{}) (*Command, error) {
cmd := newCommand(command, shortDescription, longDescription, data)
cmd.parent = c
if err := cmd.scan(); err != nil {
return nil, err
}
c.commands = append(c.commands, cmd)
retu... | go | func (c *Command) AddCommand(command string, shortDescription string, longDescription string, data interface{}) (*Command, error) {
cmd := newCommand(command, shortDescription, longDescription, data)
cmd.parent = c
if err := cmd.scan(); err != nil {
return nil, err
}
c.commands = append(c.commands, cmd)
retu... | [
"func",
"(",
"c",
"*",
"Command",
")",
"AddCommand",
"(",
"command",
"string",
",",
"shortDescription",
"string",
",",
"longDescription",
"string",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"*",
"Command",
",",
"error",
")",
"{",
"cmd",
":=",
"newCom... | // AddCommand adds a new command to the parser with the given name and data. The
// data needs to be a pointer to a struct from which the fields indicate which
// options are in the command. The provided data can implement the Command and
// Usage interfaces. | [
"AddCommand",
"adds",
"a",
"new",
"command",
"to",
"the",
"parser",
"with",
"the",
"given",
"name",
"and",
"data",
".",
"The",
"data",
"needs",
"to",
"be",
"a",
"pointer",
"to",
"a",
"struct",
"from",
"which",
"the",
"fields",
"indicate",
"which",
"optio... | c0795c8afcf41dd1d786bebce68636c199b3bb45 | https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/command.go#L68-L79 |
144,558 | jessevdk/go-flags | command.go | Find | func (c *Command) Find(name string) *Command {
for _, cc := range c.commands {
if cc.match(name) {
return cc
}
}
return nil
} | go | func (c *Command) Find(name string) *Command {
for _, cc := range c.commands {
if cc.match(name) {
return cc
}
}
return nil
} | [
"func",
"(",
"c",
"*",
"Command",
")",
"Find",
"(",
"name",
"string",
")",
"*",
"Command",
"{",
"for",
"_",
",",
"cc",
":=",
"range",
"c",
".",
"commands",
"{",
"if",
"cc",
".",
"match",
"(",
"name",
")",
"{",
"return",
"cc",
"\n",
"}",
"\n",
... | // Find locates the subcommand with the given name and returns it. If no such
// command can be found Find will return nil. | [
"Find",
"locates",
"the",
"subcommand",
"with",
"the",
"given",
"name",
"and",
"returns",
"it",
".",
"If",
"no",
"such",
"command",
"can",
"be",
"found",
"Find",
"will",
"return",
"nil",
"."
] | c0795c8afcf41dd1d786bebce68636c199b3bb45 | https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/command.go#L104-L112 |
144,559 | jessevdk/go-flags | command.go | Args | func (c *Command) Args() []*Arg {
ret := make([]*Arg, len(c.args))
copy(ret, c.args)
return ret
} | go | func (c *Command) Args() []*Arg {
ret := make([]*Arg, len(c.args))
copy(ret, c.args)
return ret
} | [
"func",
"(",
"c",
"*",
"Command",
")",
"Args",
"(",
")",
"[",
"]",
"*",
"Arg",
"{",
"ret",
":=",
"make",
"(",
"[",
"]",
"*",
"Arg",
",",
"len",
"(",
"c",
".",
"args",
")",
")",
"\n",
"copy",
"(",
"ret",
",",
"c",
".",
"args",
")",
"\n\n",... | // Args returns a list of positional arguments associated with this command. | [
"Args",
"returns",
"a",
"list",
"of",
"positional",
"arguments",
"associated",
"with",
"this",
"command",
"."
] | c0795c8afcf41dd1d786bebce68636c199b3bb45 | https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/command.go#L141-L146 |
144,560 | motemen/ghq | commands.go | mkCommandsTemplate | func mkCommandsTemplate(genTemplate func(commandDoc) string) string {
template := "{{if false}}"
for _, command := range append(commands) {
template = template + fmt.Sprintf("{{else if (eq .Name %q)}}%s", command.Name, genTemplate(commandDocs[command.Name]))
}
return template + "{{end}}"
} | go | func mkCommandsTemplate(genTemplate func(commandDoc) string) string {
template := "{{if false}}"
for _, command := range append(commands) {
template = template + fmt.Sprintf("{{else if (eq .Name %q)}}%s", command.Name, genTemplate(commandDocs[command.Name]))
}
return template + "{{end}}"
} | [
"func",
"mkCommandsTemplate",
"(",
"genTemplate",
"func",
"(",
"commandDoc",
")",
"string",
")",
"string",
"{",
"template",
":=",
"\"",
"\"",
"\n",
"for",
"_",
",",
"command",
":=",
"range",
"append",
"(",
"commands",
")",
"{",
"template",
"=",
"template",... | // Makes template conditionals to generate per-command documents. | [
"Makes",
"template",
"conditionals",
"to",
"generate",
"per",
"-",
"command",
"documents",
"."
] | f311c7108b66c3c94d7730882fdf53a170fd6722 | https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/commands.go#L105-L111 |
144,561 | motemen/ghq | git.go | GitConfigAll | func GitConfigAll(key string) ([]string, error) {
value, err := GitConfig("--get-all", key)
if err != nil {
return nil, err
}
// No results found, return an empty slice
if value == "" {
return nil, nil
}
return strings.Split(value, "\000"), nil
} | go | func GitConfigAll(key string) ([]string, error) {
value, err := GitConfig("--get-all", key)
if err != nil {
return nil, err
}
// No results found, return an empty slice
if value == "" {
return nil, nil
}
return strings.Split(value, "\000"), nil
} | [
"func",
"GitConfigAll",
"(",
"key",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"value",
",",
"err",
":=",
"GitConfig",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
... | // GitConfigAll fetches git-config variable of multiple values. | [
"GitConfigAll",
"fetches",
"git",
"-",
"config",
"variable",
"of",
"multiple",
"values",
"."
] | f311c7108b66c3c94d7730882fdf53a170fd6722 | https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/git.go#L21-L33 |
144,562 | motemen/ghq | git.go | GitConfig | func GitConfig(args ...string) (string, error) {
gitArgs := append([]string{"config", "--path", "--null"}, args...)
cmd := exec.Command("git", gitArgs...)
cmd.Stderr = os.Stderr
buf, err := cmd.Output()
if exitError, ok := err.(*exec.ExitError); ok {
if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); o... | go | func GitConfig(args ...string) (string, error) {
gitArgs := append([]string{"config", "--path", "--null"}, args...)
cmd := exec.Command("git", gitArgs...)
cmd.Stderr = os.Stderr
buf, err := cmd.Output()
if exitError, ok := err.(*exec.ExitError); ok {
if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); o... | [
"func",
"GitConfig",
"(",
"args",
"...",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"gitArgs",
":=",
"append",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"args",
"...",
")",
"\n",
"cmd",
":=... | // GitConfig invokes 'git config' and handles some errors properly. | [
"GitConfig",
"invokes",
"git",
"config",
"and",
"handles",
"some",
"errors",
"properly",
"."
] | f311c7108b66c3c94d7730882fdf53a170fd6722 | https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/git.go#L36-L55 |
144,563 | motemen/ghq | cmdutil/run.go | Run | func Run(command string, args ...string) error {
cmd := exec.Command(command, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return RunCommand(cmd, false)
} | go | func Run(command string, args ...string) error {
cmd := exec.Command(command, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return RunCommand(cmd, false)
} | [
"func",
"Run",
"(",
"command",
"string",
",",
"args",
"...",
"string",
")",
"error",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"command",
",",
"args",
"...",
")",
"\n",
"cmd",
".",
"Stdout",
"=",
"os",
".",
"Stdout",
"\n",
"cmd",
".",
"Stderr"... | // Run the command | [
"Run",
"the",
"command"
] | f311c7108b66c3c94d7730882fdf53a170fd6722 | https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/cmdutil/run.go#L14-L20 |
144,564 | motemen/ghq | cmdutil/run.go | RunSilently | func RunSilently(command string, args ...string) error {
cmd := exec.Command(command, args...)
cmd.Stdout = ioutil.Discard
cmd.Stderr = ioutil.Discard
return RunCommand(cmd, true)
} | go | func RunSilently(command string, args ...string) error {
cmd := exec.Command(command, args...)
cmd.Stdout = ioutil.Discard
cmd.Stderr = ioutil.Discard
return RunCommand(cmd, true)
} | [
"func",
"RunSilently",
"(",
"command",
"string",
",",
"args",
"...",
"string",
")",
"error",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"command",
",",
"args",
"...",
")",
"\n",
"cmd",
".",
"Stdout",
"=",
"ioutil",
".",
"Discard",
"\n",
"cmd",
".... | // RunSilently runs the command silently | [
"RunSilently",
"runs",
"the",
"command",
"silently"
] | f311c7108b66c3c94d7730882fdf53a170fd6722 | https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/cmdutil/run.go#L23-L29 |
144,565 | motemen/ghq | cmdutil/run.go | RunInDir | func RunInDir(dir, command string, args ...string) error {
cmd := exec.Command(command, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Dir = dir
return RunCommand(cmd, false)
} | go | func RunInDir(dir, command string, args ...string) error {
cmd := exec.Command(command, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Dir = dir
return RunCommand(cmd, false)
} | [
"func",
"RunInDir",
"(",
"dir",
",",
"command",
"string",
",",
"args",
"...",
"string",
")",
"error",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"command",
",",
"args",
"...",
")",
"\n",
"cmd",
".",
"Stdout",
"=",
"os",
".",
"Stdout",
"\n",
"cm... | // RunInDir runs the command in the specified directory | [
"RunInDir",
"runs",
"the",
"command",
"in",
"the",
"specified",
"directory"
] | f311c7108b66c3c94d7730882fdf53a170fd6722 | https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/cmdutil/run.go#L32-L39 |
144,566 | motemen/ghq | cmdutil/run.go | RunInDirSilently | func RunInDirSilently(dir, command string, args ...string) error {
cmd := exec.Command(command, args...)
cmd.Stdout = ioutil.Discard
cmd.Stderr = ioutil.Discard
cmd.Dir = dir
return RunCommand(cmd, true)
} | go | func RunInDirSilently(dir, command string, args ...string) error {
cmd := exec.Command(command, args...)
cmd.Stdout = ioutil.Discard
cmd.Stderr = ioutil.Discard
cmd.Dir = dir
return RunCommand(cmd, true)
} | [
"func",
"RunInDirSilently",
"(",
"dir",
",",
"command",
"string",
",",
"args",
"...",
"string",
")",
"error",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"command",
",",
"args",
"...",
")",
"\n",
"cmd",
".",
"Stdout",
"=",
"ioutil",
".",
"Discard",
... | // RunInDirSilently run the command in the specified directory silently | [
"RunInDirSilently",
"run",
"the",
"command",
"in",
"the",
"specified",
"directory",
"silently"
] | f311c7108b66c3c94d7730882fdf53a170fd6722 | https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/cmdutil/run.go#L42-L49 |
144,567 | motemen/ghq | cmdutil/run.go | RunCommand | func RunCommand(cmd *exec.Cmd, silent bool) error {
if !silent {
logger.Log(cmd.Args[0], strings.Join(cmd.Args[1:], " "))
}
err := CommandRunner(cmd)
if err != nil {
if execErr, ok := err.(*exec.Error); ok {
logger.Log("warning", fmt.Sprintf("%q: %s", execErr.Name, execErr.Err))
}
return &RunError{cmd, e... | go | func RunCommand(cmd *exec.Cmd, silent bool) error {
if !silent {
logger.Log(cmd.Args[0], strings.Join(cmd.Args[1:], " "))
}
err := CommandRunner(cmd)
if err != nil {
if execErr, ok := err.(*exec.Error); ok {
logger.Log("warning", fmt.Sprintf("%q: %s", execErr.Name, execErr.Err))
}
return &RunError{cmd, e... | [
"func",
"RunCommand",
"(",
"cmd",
"*",
"exec",
".",
"Cmd",
",",
"silent",
"bool",
")",
"error",
"{",
"if",
"!",
"silent",
"{",
"logger",
".",
"Log",
"(",
"cmd",
".",
"Args",
"[",
"0",
"]",
",",
"strings",
".",
"Join",
"(",
"cmd",
".",
"Args",
"... | // RunCommand run the command | [
"RunCommand",
"run",
"the",
"command"
] | f311c7108b66c3c94d7730882fdf53a170fd6722 | https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/cmdutil/run.go#L60-L73 |
144,568 | motemen/ghq | cmdutil/run.go | Error | func (e *RunError) Error() string {
return fmt.Sprintf("%s: %s", e.Command.Path, e.ExecError)
} | go | func (e *RunError) Error() string {
return fmt.Sprintf("%s: %s", e.Command.Path, e.ExecError)
} | [
"func",
"(",
"e",
"*",
"RunError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"Command",
".",
"Path",
",",
"e",
".",
"ExecError",
")",
"\n",
"}"
] | // Error to implement error interface | [
"Error",
"to",
"implement",
"error",
"interface"
] | f311c7108b66c3c94d7730882fdf53a170fd6722 | https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/cmdutil/run.go#L82-L84 |
144,569 | motemen/ghq | local_repository.go | Matches | func (repo *LocalRepository) Matches(pathQuery string) bool {
for _, p := range repo.Subpaths() {
if p == pathQuery {
return true
}
}
return false
} | go | func (repo *LocalRepository) Matches(pathQuery string) bool {
for _, p := range repo.Subpaths() {
if p == pathQuery {
return true
}
}
return false
} | [
"func",
"(",
"repo",
"*",
"LocalRepository",
")",
"Matches",
"(",
"pathQuery",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"p",
":=",
"range",
"repo",
".",
"Subpaths",
"(",
")",
"{",
"if",
"p",
"==",
"pathQuery",
"{",
"return",
"true",
"\n",
"}",
... | // Matches checks if any subpath of the local repository equals the query. | [
"Matches",
"checks",
"if",
"any",
"subpath",
"of",
"the",
"local",
"repository",
"equals",
"the",
"query",
"."
] | f311c7108b66c3c94d7730882fdf53a170fd6722 | https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/local_repository.go#L112-L120 |
144,570 | openzipkin-contrib/zipkin-go-opentracing | zipkin-recorder.go | annotate | func annotate(span *zipkincore.Span, timestamp time.Time, value string, host *zipkincore.Endpoint) {
if timestamp.IsZero() {
timestamp = time.Now()
}
span.Annotations = append(span.Annotations, &zipkincore.Annotation{
Timestamp: timestamp.UnixNano() / 1e3,
Value: value,
Host: host,
})
} | go | func annotate(span *zipkincore.Span, timestamp time.Time, value string, host *zipkincore.Endpoint) {
if timestamp.IsZero() {
timestamp = time.Now()
}
span.Annotations = append(span.Annotations, &zipkincore.Annotation{
Timestamp: timestamp.UnixNano() / 1e3,
Value: value,
Host: host,
})
} | [
"func",
"annotate",
"(",
"span",
"*",
"zipkincore",
".",
"Span",
",",
"timestamp",
"time",
".",
"Time",
",",
"value",
"string",
",",
"host",
"*",
"zipkincore",
".",
"Endpoint",
")",
"{",
"if",
"timestamp",
".",
"IsZero",
"(",
")",
"{",
"timestamp",
"="... | // annotate annotates the span with the given value. | [
"annotate",
"annotates",
"the",
"span",
"with",
"the",
"given",
"value",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/zipkin-recorder.go#L191-L200 |
144,571 | openzipkin-contrib/zipkin-go-opentracing | examples/cli_with_2_services/svc2/httpclient.go | NewHTTPClient | func NewHTTPClient(tracer opentracing.Tracer, baseURL string) Service {
return &client{
baseURL: baseURL,
httpClient: &http.Client{},
tracer: tracer,
traceRequest: middleware.ToHTTPRequest(tracer),
}
} | go | func NewHTTPClient(tracer opentracing.Tracer, baseURL string) Service {
return &client{
baseURL: baseURL,
httpClient: &http.Client{},
tracer: tracer,
traceRequest: middleware.ToHTTPRequest(tracer),
}
} | [
"func",
"NewHTTPClient",
"(",
"tracer",
"opentracing",
".",
"Tracer",
",",
"baseURL",
"string",
")",
"Service",
"{",
"return",
"&",
"client",
"{",
"baseURL",
":",
"baseURL",
",",
"httpClient",
":",
"&",
"http",
".",
"Client",
"{",
"}",
",",
"tracer",
":"... | // NewHTTPClient returns a new client instance to our svc2 using the HTTP
// transport. | [
"NewHTTPClient",
"returns",
"a",
"new",
"client",
"instance",
"to",
"our",
"svc2",
"using",
"the",
"HTTP",
"transport",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/examples/cli_with_2_services/svc2/httpclient.go#L75-L82 |
144,572 | openzipkin-contrib/zipkin-go-opentracing | logger.go | Log | func (l *wrappedLogger) Log(k ...interface{}) error {
if len(k)%2 == 1 {
k = append(k, ErrMissingValue)
}
o := make([]string, len(k)/2)
for i := 0; i < len(k); i += 2 {
o[i/2] = fmt.Sprintf("%s=%q", k[i], k[i+1])
}
l.l.Println(strings.Join(o, " "))
return nil
} | go | func (l *wrappedLogger) Log(k ...interface{}) error {
if len(k)%2 == 1 {
k = append(k, ErrMissingValue)
}
o := make([]string, len(k)/2)
for i := 0; i < len(k); i += 2 {
o[i/2] = fmt.Sprintf("%s=%q", k[i], k[i+1])
}
l.l.Println(strings.Join(o, " "))
return nil
} | [
"func",
"(",
"l",
"*",
"wrappedLogger",
")",
"Log",
"(",
"k",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"len",
"(",
"k",
")",
"%",
"2",
"==",
"1",
"{",
"k",
"=",
"append",
"(",
"k",
",",
"ErrMissingValue",
")",
"\n",
"}",
"\n",
"... | // Log implements Logger | [
"Log",
"implements",
"Logger"
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/logger.go#L38-L48 |
144,573 | openzipkin-contrib/zipkin-go-opentracing | examples/cli_with_2_services/svc1/httpserver.go | concatHandler | func (s *httpService) concatHandler(w http.ResponseWriter, req *http.Request) {
// parse query parameters
v := req.URL.Query()
result, err := s.service.Concat(req.Context(), v.Get("a"), v.Get("b"))
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
// return the result
w.Write([]byte(... | go | func (s *httpService) concatHandler(w http.ResponseWriter, req *http.Request) {
// parse query parameters
v := req.URL.Query()
result, err := s.service.Concat(req.Context(), v.Get("a"), v.Get("b"))
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
// return the result
w.Write([]byte(... | [
"func",
"(",
"s",
"*",
"httpService",
")",
"concatHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"// parse query parameters",
"v",
":=",
"req",
".",
"URL",
".",
"Query",
"(",
")",
"\n",
"result",
"... | // concatHandler is our HTTP HandlerFunc for a Concat request. | [
"concatHandler",
"is",
"our",
"HTTP",
"HandlerFunc",
"for",
"a",
"Concat",
"request",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/examples/cli_with_2_services/svc1/httpserver.go#L20-L30 |
144,574 | openzipkin-contrib/zipkin-go-opentracing | examples/cli_with_2_services/svc1/httpserver.go | sumHandler | func (s *httpService) sumHandler(w http.ResponseWriter, req *http.Request) {
// parse query parameters
v := req.URL.Query()
a, err := strconv.ParseInt(v.Get("a"), 10, 64)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
b, err := strconv.ParseInt(v.Get("b"), 10, 64)
if err != nil {
... | go | func (s *httpService) sumHandler(w http.ResponseWriter, req *http.Request) {
// parse query parameters
v := req.URL.Query()
a, err := strconv.ParseInt(v.Get("a"), 10, 64)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
b, err := strconv.ParseInt(v.Get("b"), 10, 64)
if err != nil {
... | [
"func",
"(",
"s",
"*",
"httpService",
")",
"sumHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"// parse query parameters",
"v",
":=",
"req",
".",
"URL",
".",
"Query",
"(",
")",
"\n",
"a",
",",
"e... | // sumHandler is our HTTP Handlerfunc for a Sum request. | [
"sumHandler",
"is",
"our",
"HTTP",
"Handlerfunc",
"for",
"a",
"Sum",
"request",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/examples/cli_with_2_services/svc1/httpserver.go#L33-L54 |
144,575 | openzipkin-contrib/zipkin-go-opentracing | examples/cli_with_2_services/svc1/httpserver.go | NewHTTPHandler | func NewHTTPHandler(tracer opentracing.Tracer, service Service) http.Handler {
// Create our HTTP Service.
svc := &httpService{service: service}
// Create the mux.
mux := http.NewServeMux()
// Create the Concat handler.
var concatHandler http.Handler
concatHandler = http.HandlerFunc(svc.concatHandler)
// Wra... | go | func NewHTTPHandler(tracer opentracing.Tracer, service Service) http.Handler {
// Create our HTTP Service.
svc := &httpService{service: service}
// Create the mux.
mux := http.NewServeMux()
// Create the Concat handler.
var concatHandler http.Handler
concatHandler = http.HandlerFunc(svc.concatHandler)
// Wra... | [
"func",
"NewHTTPHandler",
"(",
"tracer",
"opentracing",
".",
"Tracer",
",",
"service",
"Service",
")",
"http",
".",
"Handler",
"{",
"// Create our HTTP Service.",
"svc",
":=",
"&",
"httpService",
"{",
"service",
":",
"service",
"}",
"\n\n",
"// Create the mux.",
... | // NewHTTPHandler returns a new HTTP handler our svc1. | [
"NewHTTPHandler",
"returns",
"a",
"new",
"HTTP",
"handler",
"our",
"svc1",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/examples/cli_with_2_services/svc1/httpserver.go#L57-L84 |
144,576 | openzipkin-contrib/zipkin-go-opentracing | collector-kafka.go | KafkaProducer | func KafkaProducer(p sarama.AsyncProducer) KafkaOption {
return func(c *KafkaCollector) { c.producer = p }
} | go | func KafkaProducer(p sarama.AsyncProducer) KafkaOption {
return func(c *KafkaCollector) { c.producer = p }
} | [
"func",
"KafkaProducer",
"(",
"p",
"sarama",
".",
"AsyncProducer",
")",
"KafkaOption",
"{",
"return",
"func",
"(",
"c",
"*",
"KafkaCollector",
")",
"{",
"c",
".",
"producer",
"=",
"p",
"}",
"\n",
"}"
] | // KafkaProducer sets the producer used to produce to Kafka. | [
"KafkaProducer",
"sets",
"the",
"producer",
"used",
"to",
"produce",
"to",
"Kafka",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/collector-kafka.go#L34-L36 |
144,577 | openzipkin-contrib/zipkin-go-opentracing | collector-scribe.go | ScribeBatchInterval | func ScribeBatchInterval(d time.Duration) ScribeOption {
return func(s *ScribeCollector) { s.batchInterval = d }
} | go | func ScribeBatchInterval(d time.Duration) ScribeOption {
return func(s *ScribeCollector) { s.batchInterval = d }
} | [
"func",
"ScribeBatchInterval",
"(",
"d",
"time",
".",
"Duration",
")",
"ScribeOption",
"{",
"return",
"func",
"(",
"s",
"*",
"ScribeCollector",
")",
"{",
"s",
".",
"batchInterval",
"=",
"d",
"}",
"\n",
"}"
] | // ScribeBatchInterval sets the maximum duration we will buffer traces before
// emitting them to the collector. The default batch interval is 1 second. | [
"ScribeBatchInterval",
"sets",
"the",
"maximum",
"duration",
"we",
"will",
"buffer",
"traces",
"before",
"emitting",
"them",
"to",
"the",
"collector",
".",
"The",
"default",
"batch",
"interval",
"is",
"1",
"second",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/collector-scribe.go#L69-L71 |
144,578 | openzipkin-contrib/zipkin-go-opentracing | tracer.go | WithSampler | func WithSampler(sampler Sampler) TracerOption {
return func(opts *TracerOptions) error {
opts.shouldSample = sampler
return nil
}
} | go | func WithSampler(sampler Sampler) TracerOption {
return func(opts *TracerOptions) error {
opts.shouldSample = sampler
return nil
}
} | [
"func",
"WithSampler",
"(",
"sampler",
"Sampler",
")",
"TracerOption",
"{",
"return",
"func",
"(",
"opts",
"*",
"TracerOptions",
")",
"error",
"{",
"opts",
".",
"shouldSample",
"=",
"sampler",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // WithSampler allows one to add a Sampler function | [
"WithSampler",
"allows",
"one",
"to",
"add",
"a",
"Sampler",
"function"
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/tracer.go#L120-L125 |
144,579 | openzipkin-contrib/zipkin-go-opentracing | tracer.go | DebugMode | func DebugMode(val bool) TracerOption {
return func(opts *TracerOptions) error {
opts.debugMode = val
return nil
}
} | go | func DebugMode(val bool) TracerOption {
return func(opts *TracerOptions) error {
opts.debugMode = val
return nil
}
} | [
"func",
"DebugMode",
"(",
"val",
"bool",
")",
"TracerOption",
"{",
"return",
"func",
"(",
"opts",
"*",
"TracerOptions",
")",
"error",
"{",
"opts",
".",
"debugMode",
"=",
"val",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // DebugMode allows to set the tracer to Zipkin debug mode | [
"DebugMode",
"allows",
"to",
"set",
"the",
"tracer",
"to",
"Zipkin",
"debug",
"mode"
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/tracer.go#L189-L194 |
144,580 | openzipkin-contrib/zipkin-go-opentracing | tracer.go | NewTracer | func NewTracer(recorder SpanRecorder, options ...TracerOption) (opentracing.Tracer, error) {
opts := &TracerOptions{
recorder: recorder,
shouldSample: alwaysSample,
trimUnsampledSpans: false,
newSpanEventListener: func() func(SpanEvent) { return nil },
logger: &nopLogger{}... | go | func NewTracer(recorder SpanRecorder, options ...TracerOption) (opentracing.Tracer, error) {
opts := &TracerOptions{
recorder: recorder,
shouldSample: alwaysSample,
trimUnsampledSpans: false,
newSpanEventListener: func() func(SpanEvent) { return nil },
logger: &nopLogger{}... | [
"func",
"NewTracer",
"(",
"recorder",
"SpanRecorder",
",",
"options",
"...",
"TracerOption",
")",
"(",
"opentracing",
".",
"Tracer",
",",
"error",
")",
"{",
"opts",
":=",
"&",
"TracerOptions",
"{",
"recorder",
":",
"recorder",
",",
"shouldSample",
":",
"alwa... | // NewTracer creates a new OpenTracing compatible Zipkin Tracer. | [
"NewTracer",
"creates",
"a",
"new",
"OpenTracing",
"compatible",
"Zipkin",
"Tracer",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/tracer.go#L224-L250 |
144,581 | openzipkin-contrib/zipkin-go-opentracing | tracer.go | WithObserver | func WithObserver(observer otobserver.Observer) TracerOption {
return func(opts *TracerOptions) error {
opts.observer = observer
return nil
}
} | go | func WithObserver(observer otobserver.Observer) TracerOption {
return func(opts *TracerOptions) error {
opts.observer = observer
return nil
}
} | [
"func",
"WithObserver",
"(",
"observer",
"otobserver",
".",
"Observer",
")",
"TracerOption",
"{",
"return",
"func",
"(",
"opts",
"*",
"TracerOptions",
")",
"error",
"{",
"opts",
".",
"observer",
"=",
"observer",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
... | // WithObserver assigns an initialized observer to opts.observer | [
"WithObserver",
"assigns",
"an",
"initialized",
"observer",
"to",
"opts",
".",
"observer"
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/tracer.go#L435-L440 |
144,582 | openzipkin-contrib/zipkin-go-opentracing | collector-http.go | HTTPTimeout | func HTTPTimeout(duration time.Duration) HTTPOption {
return func(c *HTTPCollector) { c.client.Timeout = duration }
} | go | func HTTPTimeout(duration time.Duration) HTTPOption {
return func(c *HTTPCollector) { c.client.Timeout = duration }
} | [
"func",
"HTTPTimeout",
"(",
"duration",
"time",
".",
"Duration",
")",
"HTTPOption",
"{",
"return",
"func",
"(",
"c",
"*",
"HTTPCollector",
")",
"{",
"c",
".",
"client",
".",
"Timeout",
"=",
"duration",
"}",
"\n",
"}"
] | // HTTPTimeout sets maximum timeout for http request. | [
"HTTPTimeout",
"sets",
"maximum",
"timeout",
"for",
"http",
"request",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/collector-http.go#L53-L55 |
144,583 | openzipkin-contrib/zipkin-go-opentracing | collector-http.go | HTTPBatchInterval | func HTTPBatchInterval(d time.Duration) HTTPOption {
return func(c *HTTPCollector) { c.batchInterval = d }
} | go | func HTTPBatchInterval(d time.Duration) HTTPOption {
return func(c *HTTPCollector) { c.batchInterval = d }
} | [
"func",
"HTTPBatchInterval",
"(",
"d",
"time",
".",
"Duration",
")",
"HTTPOption",
"{",
"return",
"func",
"(",
"c",
"*",
"HTTPCollector",
")",
"{",
"c",
".",
"batchInterval",
"=",
"d",
"}",
"\n",
"}"
] | // HTTPBatchInterval sets the maximum duration we will buffer traces before
// emitting them to the collector. The default batch interval is 1 second. | [
"HTTPBatchInterval",
"sets",
"the",
"maximum",
"duration",
"we",
"will",
"buffer",
"traces",
"before",
"emitting",
"them",
"to",
"the",
"collector",
".",
"The",
"default",
"batch",
"interval",
"is",
"1",
"second",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/collector-http.go#L72-L74 |
144,584 | openzipkin-contrib/zipkin-go-opentracing | collector-http.go | HTTPClient | func HTTPClient(client *http.Client) HTTPOption {
return func(c *HTTPCollector) { c.client = client }
} | go | func HTTPClient(client *http.Client) HTTPOption {
return func(c *HTTPCollector) { c.client = client }
} | [
"func",
"HTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"HTTPOption",
"{",
"return",
"func",
"(",
"c",
"*",
"HTTPCollector",
")",
"{",
"c",
".",
"client",
"=",
"client",
"}",
"\n",
"}"
] | // HTTPClient sets a custom http client to use. | [
"HTTPClient",
"sets",
"a",
"custom",
"http",
"client",
"to",
"use",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/collector-http.go#L77-L79 |
144,585 | openzipkin-contrib/zipkin-go-opentracing | collector-http.go | NewHTTPCollector | func NewHTTPCollector(url string, options ...HTTPOption) (Collector, error) {
c := &HTTPCollector{
logger: NewNopLogger(),
url: url,
client: &http.Client{Timeout: defaultHTTPTimeout},
batchInterval: defaultHTTPBatchInterval * time.Second,
batchSize: defaultHTTPBatchSize,
maxBack... | go | func NewHTTPCollector(url string, options ...HTTPOption) (Collector, error) {
c := &HTTPCollector{
logger: NewNopLogger(),
url: url,
client: &http.Client{Timeout: defaultHTTPTimeout},
batchInterval: defaultHTTPBatchInterval * time.Second,
batchSize: defaultHTTPBatchSize,
maxBack... | [
"func",
"NewHTTPCollector",
"(",
"url",
"string",
",",
"options",
"...",
"HTTPOption",
")",
"(",
"Collector",
",",
"error",
")",
"{",
"c",
":=",
"&",
"HTTPCollector",
"{",
"logger",
":",
"NewNopLogger",
"(",
")",
",",
"url",
":",
"url",
",",
"client",
... | // NewHTTPCollector returns a new HTTP-backend Collector. url should be a http
// url for handle post request. timeout is passed to http client. queueSize control
// the maximum size of buffer of async queue. The logger is used to log errors,
// such as send failures; | [
"NewHTTPCollector",
"returns",
"a",
"new",
"HTTP",
"-",
"backend",
"Collector",
".",
"url",
"should",
"be",
"a",
"http",
"url",
"for",
"handle",
"post",
"request",
".",
"timeout",
"is",
"passed",
"to",
"http",
"client",
".",
"queueSize",
"control",
"the",
... | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/collector-http.go#L91-L112 |
144,586 | openzipkin-contrib/zipkin-go-opentracing | collector-http.go | Collect | func (c *HTTPCollector) Collect(s *zipkincore.Span) error {
select {
case c.spanc <- s:
// Accepted.
case <-c.quit:
// Collector concurrently closed.
default:
c.logger.Log("msg", "queue full, disposing spans.", "size", len(c.spanc))
}
return nil
} | go | func (c *HTTPCollector) Collect(s *zipkincore.Span) error {
select {
case c.spanc <- s:
// Accepted.
case <-c.quit:
// Collector concurrently closed.
default:
c.logger.Log("msg", "queue full, disposing spans.", "size", len(c.spanc))
}
return nil
} | [
"func",
"(",
"c",
"*",
"HTTPCollector",
")",
"Collect",
"(",
"s",
"*",
"zipkincore",
".",
"Span",
")",
"error",
"{",
"select",
"{",
"case",
"c",
".",
"spanc",
"<-",
"s",
":",
"// Accepted.",
"case",
"<-",
"c",
".",
"quit",
":",
"// Collector concurrent... | // Collect implements Collector.
// attempts a non blocking send on the channel. | [
"Collect",
"implements",
"Collector",
".",
"attempts",
"a",
"non",
"blocking",
"send",
"on",
"the",
"channel",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/collector-http.go#L116-L126 |
144,587 | openzipkin-contrib/zipkin-go-opentracing | wire/carrier.go | State | func (p *ProtobufCarrier) State() (traceID types.TraceID, spanID uint64, parentSpanID *uint64, sampled bool, flags flag.Flags) {
traceID.Low = p.TraceId
traceID.High = p.TraceIdHigh
spanID = p.SpanId
sampled = p.Sampled
flags = flag.Flags(p.Flags)
if flags&flag.IsRoot == 0 {
parentSpanID = &p.ParentSpanId
}
r... | go | func (p *ProtobufCarrier) State() (traceID types.TraceID, spanID uint64, parentSpanID *uint64, sampled bool, flags flag.Flags) {
traceID.Low = p.TraceId
traceID.High = p.TraceIdHigh
spanID = p.SpanId
sampled = p.Sampled
flags = flag.Flags(p.Flags)
if flags&flag.IsRoot == 0 {
parentSpanID = &p.ParentSpanId
}
r... | [
"func",
"(",
"p",
"*",
"ProtobufCarrier",
")",
"State",
"(",
")",
"(",
"traceID",
"types",
".",
"TraceID",
",",
"spanID",
"uint64",
",",
"parentSpanID",
"*",
"uint64",
",",
"sampled",
"bool",
",",
"flags",
"flag",
".",
"Flags",
")",
"{",
"traceID",
"."... | // State returns the tracer state. | [
"State",
"returns",
"the",
"tracer",
"state",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/wire/carrier.go#L37-L47 |
144,588 | openzipkin-contrib/zipkin-go-opentracing | wire/carrier.go | SetBaggageItem | func (p *ProtobufCarrier) SetBaggageItem(key, value string) {
if p.BaggageItems == nil {
p.BaggageItems = map[string]string{key: value}
return
}
p.BaggageItems[key] = value
} | go | func (p *ProtobufCarrier) SetBaggageItem(key, value string) {
if p.BaggageItems == nil {
p.BaggageItems = map[string]string{key: value}
return
}
p.BaggageItems[key] = value
} | [
"func",
"(",
"p",
"*",
"ProtobufCarrier",
")",
"SetBaggageItem",
"(",
"key",
",",
"value",
"string",
")",
"{",
"if",
"p",
".",
"BaggageItems",
"==",
"nil",
"{",
"p",
".",
"BaggageItems",
"=",
"map",
"[",
"string",
"]",
"string",
"{",
"key",
":",
"val... | // SetBaggageItem sets a baggage item. | [
"SetBaggageItem",
"sets",
"a",
"baggage",
"item",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/wire/carrier.go#L50-L57 |
144,589 | openzipkin-contrib/zipkin-go-opentracing | examples/middleware/http.go | ToHTTPRequest | func ToHTTPRequest(tracer opentracing.Tracer) RequestFunc {
return func(req *http.Request) *http.Request {
// Retrieve the Span from context.
if span := opentracing.SpanFromContext(req.Context()); span != nil {
// We are going to use this span in a client request, so mark as such.
ext.SpanKindRPCClient.Set(... | go | func ToHTTPRequest(tracer opentracing.Tracer) RequestFunc {
return func(req *http.Request) *http.Request {
// Retrieve the Span from context.
if span := opentracing.SpanFromContext(req.Context()); span != nil {
// We are going to use this span in a client request, so mark as such.
ext.SpanKindRPCClient.Set(... | [
"func",
"ToHTTPRequest",
"(",
"tracer",
"opentracing",
".",
"Tracer",
")",
"RequestFunc",
"{",
"return",
"func",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"*",
"http",
".",
"Request",
"{",
"// Retrieve the Span from context.",
"if",
"span",
":=",
"opentrac... | // ToHTTPRequest returns a RequestFunc that injects an OpenTracing Span found in
// context into the HTTP Headers. If no such Span can be found, the RequestFunc
// is a noop. | [
"ToHTTPRequest",
"returns",
"a",
"RequestFunc",
"that",
"injects",
"an",
"OpenTracing",
"Span",
"found",
"in",
"context",
"into",
"the",
"HTTP",
"Headers",
".",
"If",
"no",
"such",
"Span",
"can",
"be",
"found",
"the",
"RequestFunc",
"is",
"a",
"noop",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/examples/middleware/http.go#L25-L63 |
144,590 | openzipkin-contrib/zipkin-go-opentracing | log-materializers.go | MaterializeWithLogFmt | func MaterializeWithLogFmt(logFields []log.Field) ([]byte, error) {
var (
buffer = bytes.NewBuffer(nil)
encoder = logfmt.NewEncoder(buffer)
)
for _, field := range logFields {
if err := encoder.EncodeKeyval(field.Key(), field.Value()); err != nil {
encoder.EncodeKeyval(field.Key(), err.Error())
}
}
ret... | go | func MaterializeWithLogFmt(logFields []log.Field) ([]byte, error) {
var (
buffer = bytes.NewBuffer(nil)
encoder = logfmt.NewEncoder(buffer)
)
for _, field := range logFields {
if err := encoder.EncodeKeyval(field.Key(), field.Value()); err != nil {
encoder.EncodeKeyval(field.Key(), err.Error())
}
}
ret... | [
"func",
"MaterializeWithLogFmt",
"(",
"logFields",
"[",
"]",
"log",
".",
"Field",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"(",
"buffer",
"=",
"bytes",
".",
"NewBuffer",
"(",
"nil",
")",
"\n",
"encoder",
"=",
"logfmt",
".",
"NewEnco... | // MaterializeWithLogFmt converts log Fields into LogFmt string | [
"MaterializeWithLogFmt",
"converts",
"log",
"Fields",
"into",
"LogFmt",
"string"
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/log-materializers.go#L48-L59 |
144,591 | openzipkin-contrib/zipkin-go-opentracing | log-materializers.go | StrictZipkinMaterializer | func StrictZipkinMaterializer(logFields []log.Field) ([]byte, error) {
for _, field := range logFields {
if field.Key() == "event" {
return []byte(fmt.Sprintf("%+v", field.Value())), nil
}
}
return nil, errEventLogNotFound
} | go | func StrictZipkinMaterializer(logFields []log.Field) ([]byte, error) {
for _, field := range logFields {
if field.Key() == "event" {
return []byte(fmt.Sprintf("%+v", field.Value())), nil
}
}
return nil, errEventLogNotFound
} | [
"func",
"StrictZipkinMaterializer",
"(",
"logFields",
"[",
"]",
"log",
".",
"Field",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"for",
"_",
",",
"field",
":=",
"range",
"logFields",
"{",
"if",
"field",
".",
"Key",
"(",
")",
"==",
"\"",
"\"... | // StrictZipkinMaterializer will only record a log.Field of type "event". | [
"StrictZipkinMaterializer",
"will",
"only",
"record",
"a",
"log",
".",
"Field",
"of",
"type",
"event",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/log-materializers.go#L62-L69 |
144,592 | openzipkin-contrib/zipkin-go-opentracing | recorder.go | GetSpans | func (r *InMemorySpanRecorder) GetSpans() []RawSpan {
r.RLock()
defer r.RUnlock()
spans := make([]RawSpan, len(r.spans))
copy(spans, r.spans)
return spans
} | go | func (r *InMemorySpanRecorder) GetSpans() []RawSpan {
r.RLock()
defer r.RUnlock()
spans := make([]RawSpan, len(r.spans))
copy(spans, r.spans)
return spans
} | [
"func",
"(",
"r",
"*",
"InMemorySpanRecorder",
")",
"GetSpans",
"(",
")",
"[",
"]",
"RawSpan",
"{",
"r",
".",
"RLock",
"(",
")",
"\n",
"defer",
"r",
".",
"RUnlock",
"(",
")",
"\n",
"spans",
":=",
"make",
"(",
"[",
"]",
"RawSpan",
",",
"len",
"(",... | // GetSpans returns a copy of the array of spans accumulated so far. | [
"GetSpans",
"returns",
"a",
"copy",
"of",
"the",
"array",
"of",
"spans",
"accumulated",
"so",
"far",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/recorder.go#L34-L40 |
144,593 | openzipkin-contrib/zipkin-go-opentracing | recorder.go | GetSampledSpans | func (r *InMemorySpanRecorder) GetSampledSpans() []RawSpan {
r.RLock()
defer r.RUnlock()
spans := make([]RawSpan, 0, len(r.spans))
for _, span := range r.spans {
if span.Context.Sampled {
spans = append(spans, span)
}
}
return spans
} | go | func (r *InMemorySpanRecorder) GetSampledSpans() []RawSpan {
r.RLock()
defer r.RUnlock()
spans := make([]RawSpan, 0, len(r.spans))
for _, span := range r.spans {
if span.Context.Sampled {
spans = append(spans, span)
}
}
return spans
} | [
"func",
"(",
"r",
"*",
"InMemorySpanRecorder",
")",
"GetSampledSpans",
"(",
")",
"[",
"]",
"RawSpan",
"{",
"r",
".",
"RLock",
"(",
")",
"\n",
"defer",
"r",
".",
"RUnlock",
"(",
")",
"\n",
"spans",
":=",
"make",
"(",
"[",
"]",
"RawSpan",
",",
"0",
... | // GetSampledSpans returns a slice of spans accumulated so far which were sampled. | [
"GetSampledSpans",
"returns",
"a",
"slice",
"of",
"spans",
"accumulated",
"so",
"far",
"which",
"were",
"sampled",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/recorder.go#L43-L53 |
144,594 | openzipkin-contrib/zipkin-go-opentracing | recorder.go | Reset | func (r *InMemorySpanRecorder) Reset() {
r.Lock()
defer r.Unlock()
r.spans = nil
} | go | func (r *InMemorySpanRecorder) Reset() {
r.Lock()
defer r.Unlock()
r.spans = nil
} | [
"func",
"(",
"r",
"*",
"InMemorySpanRecorder",
")",
"Reset",
"(",
")",
"{",
"r",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"Unlock",
"(",
")",
"\n",
"r",
".",
"spans",
"=",
"nil",
"\n",
"}"
] | // Reset clears the internal array of spans. | [
"Reset",
"clears",
"the",
"internal",
"array",
"of",
"spans",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/recorder.go#L56-L60 |
144,595 | openzipkin-contrib/zipkin-go-opentracing | collector.go | Close | func (c MultiCollector) Close() error {
return c.aggregateErrors(func(coll Collector) error { return coll.Close() })
} | go | func (c MultiCollector) Close() error {
return c.aggregateErrors(func(coll Collector) error { return coll.Close() })
} | [
"func",
"(",
"c",
"MultiCollector",
")",
"Close",
"(",
")",
"error",
"{",
"return",
"c",
".",
"aggregateErrors",
"(",
"func",
"(",
"coll",
"Collector",
")",
"error",
"{",
"return",
"coll",
".",
"Close",
"(",
")",
"}",
")",
"\n",
"}"
] | // Close implements Collector. | [
"Close",
"implements",
"Collector",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/collector.go#L34-L36 |
144,596 | openzipkin-contrib/zipkin-go-opentracing | sample.go | ModuloSampler | func ModuloSampler(mod uint64) Sampler {
if mod < 2 {
return alwaysSample
}
return func(id uint64) bool {
return (id % mod) == 0
}
} | go | func ModuloSampler(mod uint64) Sampler {
if mod < 2 {
return alwaysSample
}
return func(id uint64) bool {
return (id % mod) == 0
}
} | [
"func",
"ModuloSampler",
"(",
"mod",
"uint64",
")",
"Sampler",
"{",
"if",
"mod",
"<",
"2",
"{",
"return",
"alwaysSample",
"\n",
"}",
"\n",
"return",
"func",
"(",
"id",
"uint64",
")",
"bool",
"{",
"return",
"(",
"id",
"%",
"mod",
")",
"==",
"0",
"\n... | // ModuloSampler provides a typical OpenTracing type Sampler. | [
"ModuloSampler",
"provides",
"a",
"typical",
"OpenTracing",
"type",
"Sampler",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/sample.go#L19-L26 |
144,597 | openzipkin-contrib/zipkin-go-opentracing | zipkin-endpoint.go | makeEndpoint | func makeEndpoint(hostport, serviceName string) (ep *zipkincore.Endpoint) {
ep = zipkincore.NewEndpoint()
// Set the ServiceName
ep.ServiceName = serviceName
if strings.IndexByte(hostport, ':') < 0 {
// "<host>" becomes "<host>:0"
hostport = hostport + ":0"
}
// try to parse provided "<host>:<port>"
host,... | go | func makeEndpoint(hostport, serviceName string) (ep *zipkincore.Endpoint) {
ep = zipkincore.NewEndpoint()
// Set the ServiceName
ep.ServiceName = serviceName
if strings.IndexByte(hostport, ':') < 0 {
// "<host>" becomes "<host>:0"
hostport = hostport + ":0"
}
// try to parse provided "<host>:<port>"
host,... | [
"func",
"makeEndpoint",
"(",
"hostport",
",",
"serviceName",
"string",
")",
"(",
"ep",
"*",
"zipkincore",
".",
"Endpoint",
")",
"{",
"ep",
"=",
"zipkincore",
".",
"NewEndpoint",
"(",
")",
"\n\n",
"// Set the ServiceName",
"ep",
".",
"ServiceName",
"=",
"serv... | // makeEndpoint takes the hostport and service name that represent this Zipkin
// service, and returns an endpoint that's embedded into the Zipkin core Span
// type. It will return a nil endpoint if the input parameters are malformed. | [
"makeEndpoint",
"takes",
"the",
"hostport",
"and",
"service",
"name",
"that",
"represent",
"this",
"Zipkin",
"service",
"and",
"returns",
"an",
"endpoint",
"that",
"s",
"embedded",
"into",
"the",
"Zipkin",
"core",
"Span",
"type",
".",
"It",
"will",
"return",
... | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/zipkin-endpoint.go#L15-L72 |
144,598 | openzipkin-contrib/zipkin-go-opentracing | examples/cli_with_2_services/svc2/httpserver.go | NewHTTPHandler | func NewHTTPHandler(tracer opentracing.Tracer, service Service) http.Handler {
// Create our HTTP Service.
svc := &httpService{service: service}
// Create the mux.
mux := http.NewServeMux()
// Create the Sum handler.
var sumHandler http.Handler
sumHandler = http.HandlerFunc(svc.sumHandler)
// Wrap the Sum ha... | go | func NewHTTPHandler(tracer opentracing.Tracer, service Service) http.Handler {
// Create our HTTP Service.
svc := &httpService{service: service}
// Create the mux.
mux := http.NewServeMux()
// Create the Sum handler.
var sumHandler http.Handler
sumHandler = http.HandlerFunc(svc.sumHandler)
// Wrap the Sum ha... | [
"func",
"NewHTTPHandler",
"(",
"tracer",
"opentracing",
".",
"Tracer",
",",
"service",
"Service",
")",
"http",
".",
"Handler",
"{",
"// Create our HTTP Service.",
"svc",
":=",
"&",
"httpService",
"{",
"service",
":",
"service",
"}",
"\n\n",
"// Create the mux.",
... | // NewHTTPHandler returns a new HTTP handler our svc2. | [
"NewHTTPHandler",
"returns",
"a",
"new",
"HTTP",
"handler",
"our",
"svc2",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/examples/cli_with_2_services/svc2/httpserver.go#L44-L63 |
144,599 | openzipkin-contrib/zipkin-go-opentracing | types/traceid.go | ToHex | func (t TraceID) ToHex() string {
if t.High == 0 {
return fmt.Sprintf("%016x", t.Low)
}
return fmt.Sprintf("%016x%016x", t.High, t.Low)
} | go | func (t TraceID) ToHex() string {
if t.High == 0 {
return fmt.Sprintf("%016x", t.Low)
}
return fmt.Sprintf("%016x%016x", t.High, t.Low)
} | [
"func",
"(",
"t",
"TraceID",
")",
"ToHex",
"(",
")",
"string",
"{",
"if",
"t",
".",
"High",
"==",
"0",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"t",
".",
"Low",
")",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\... | // ToHex outputs the 128-bit traceID as hex string. | [
"ToHex",
"outputs",
"the",
"128",
"-",
"bit",
"traceID",
"as",
"hex",
"string",
"."
] | f0f479ad013a498e4cbfb369414e5d3880903779 | https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/types/traceid.go#L28-L33 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.