id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
141,900 | google/go-tspi | tpmclient/tpmclient.go | Extend | func (client *TPMClient) Extend(pcr int, eventtype int, data []byte, event string) error {
var extendData ExtendInput
extendData.Pcr = pcr
extendData.Eventtype = eventtype
extendData.Data = data
extendData.Event = event
request, err := json.Marshal(extendData)
if err != nil {
return fmt.Errorf("Can't constru... | go | func (client *TPMClient) Extend(pcr int, eventtype int, data []byte, event string) error {
var extendData ExtendInput
extendData.Pcr = pcr
extendData.Eventtype = eventtype
extendData.Data = data
extendData.Event = event
request, err := json.Marshal(extendData)
if err != nil {
return fmt.Errorf("Can't constru... | [
"func",
"(",
"client",
"*",
"TPMClient",
")",
"Extend",
"(",
"pcr",
"int",
",",
"eventtype",
"int",
",",
"data",
"[",
"]",
"byte",
",",
"event",
"string",
")",
"error",
"{",
"var",
"extendData",
"ExtendInput",
"\n\n",
"extendData",
".",
"Pcr",
"=",
"pc... | // Extend extends a TPM PCR with the provided data. If event is nil, data must
// be pre-hashed with SHA1 and will be used to extend the PCR directly. If
// event is not nil, data and event will be hashed to generate the extension
// value. Event will then be stored in the TPM event log. | [
"Extend",
"extends",
"a",
"TPM",
"PCR",
"with",
"the",
"provided",
"data",
".",
"If",
"event",
"is",
"nil",
"data",
"must",
"be",
"pre",
"-",
"hashed",
"with",
"SHA1",
"and",
"will",
"be",
"used",
"to",
"extend",
"the",
"PCR",
"directly",
".",
"If",
... | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tpmclient/tpmclient.go#L222-L241 |
141,901 | google/go-tspi | tpmclient/tpmclient.go | GetQuote | func (client *TPMClient) GetQuote(aikpub []byte, aikblob []byte, pcrs []int) (pcrvals [][]byte, log []tspiconst.Log, err error) {
var quoteRequest QuoteData
var response QuoteResponse
nonce := make([]byte, 20)
_, err = rand.Read(nonce)
if err != nil {
return nil, nil, fmt.Errorf("Unable to generate nonce: %s", ... | go | func (client *TPMClient) GetQuote(aikpub []byte, aikblob []byte, pcrs []int) (pcrvals [][]byte, log []tspiconst.Log, err error) {
var quoteRequest QuoteData
var response QuoteResponse
nonce := make([]byte, 20)
_, err = rand.Read(nonce)
if err != nil {
return nil, nil, fmt.Errorf("Unable to generate nonce: %s", ... | [
"func",
"(",
"client",
"*",
"TPMClient",
")",
"GetQuote",
"(",
"aikpub",
"[",
"]",
"byte",
",",
"aikblob",
"[",
"]",
"byte",
",",
"pcrs",
"[",
"]",
"int",
")",
"(",
"pcrvals",
"[",
"]",
"[",
"]",
"byte",
",",
"log",
"[",
"]",
"tspiconst",
".",
... | // GetQuote obtains a PCR quote from the TPM. It takes the aikpub Tspi Key, the
// encrypted AIK blob and a list of PCRs as arguments. The response will
// contain an array of PCR values, an array of log entries and any error. | [
"GetQuote",
"obtains",
"a",
"PCR",
"quote",
"from",
"the",
"TPM",
".",
"It",
"takes",
"the",
"aikpub",
"Tspi",
"Key",
"the",
"encrypted",
"AIK",
"blob",
"and",
"a",
"list",
"of",
"PCRs",
"as",
"arguments",
".",
"The",
"response",
"will",
"contain",
"an",... | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tpmclient/tpmclient.go#L259-L301 |
141,902 | google/go-tspi | tpmclient/tpmclient.go | New | func New(host string, timeout time.Duration) *TPMClient {
return &TPMClient{
host: host,
timeout: timeout,
}
} | go | func New(host string, timeout time.Duration) *TPMClient {
return &TPMClient{
host: host,
timeout: timeout,
}
} | [
"func",
"New",
"(",
"host",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"*",
"TPMClient",
"{",
"return",
"&",
"TPMClient",
"{",
"host",
":",
"host",
",",
"timeout",
":",
"timeout",
",",
"}",
"\n",
"}"
] | // New returns a TPMClient structure configured to connect to the provided
// host with the provided timeout. | [
"New",
"returns",
"a",
"TPMClient",
"structure",
"configured",
"to",
"connect",
"to",
"the",
"provided",
"host",
"with",
"the",
"provided",
"timeout",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tpmclient/tpmclient.go#L305-L310 |
141,903 | PuerkitoBio/rehttp | rehttp.go | NewTransport | func NewTransport(rt http.RoundTripper, retry RetryFn, delay DelayFn) *Transport {
if rt == nil {
rt = http.DefaultTransport
}
return &Transport{
RoundTripper: rt,
retry: toRetryFn(retry, delay),
}
} | go | func NewTransport(rt http.RoundTripper, retry RetryFn, delay DelayFn) *Transport {
if rt == nil {
rt = http.DefaultTransport
}
return &Transport{
RoundTripper: rt,
retry: toRetryFn(retry, delay),
}
} | [
"func",
"NewTransport",
"(",
"rt",
"http",
".",
"RoundTripper",
",",
"retry",
"RetryFn",
",",
"delay",
"DelayFn",
")",
"*",
"Transport",
"{",
"if",
"rt",
"==",
"nil",
"{",
"rt",
"=",
"http",
".",
"DefaultTransport",
"\n",
"}",
"\n",
"return",
"&",
"Tra... | // NewTransport creates a Transport with a retry strategy based on
// retry and delay to control the retry logic. It uses the provided
// RoundTripper to execute the requests. If rt is nil,
// http.DefaultTransport is used. | [
"NewTransport",
"creates",
"a",
"Transport",
"with",
"a",
"retry",
"strategy",
"based",
"on",
"retry",
"and",
"delay",
"to",
"control",
"the",
"retry",
"logic",
".",
"It",
"uses",
"the",
"provided",
"RoundTripper",
"to",
"execute",
"the",
"requests",
".",
"I... | 11cf6ea5d3e9afda34846e1db511aa218049471c | https://github.com/PuerkitoBio/rehttp/blob/11cf6ea5d3e9afda34846e1db511aa218049471c/rehttp.go#L106-L114 |
141,904 | PuerkitoBio/rehttp | rehttp.go | toRetryFn | func toRetryFn(retry RetryFn, delay DelayFn) retryFn {
return func(attempt Attempt) (bool, time.Duration) {
if ok := retry(attempt); !ok {
return false, 0
}
return true, delay(attempt)
}
} | go | func toRetryFn(retry RetryFn, delay DelayFn) retryFn {
return func(attempt Attempt) (bool, time.Duration) {
if ok := retry(attempt); !ok {
return false, 0
}
return true, delay(attempt)
}
} | [
"func",
"toRetryFn",
"(",
"retry",
"RetryFn",
",",
"delay",
"DelayFn",
")",
"retryFn",
"{",
"return",
"func",
"(",
"attempt",
"Attempt",
")",
"(",
"bool",
",",
"time",
".",
"Duration",
")",
"{",
"if",
"ok",
":=",
"retry",
"(",
"attempt",
")",
";",
"!... | // toRetryFn combines retry and delay into a retryFn. | [
"toRetryFn",
"combines",
"retry",
"and",
"delay",
"into",
"a",
"retryFn",
"."
] | 11cf6ea5d3e9afda34846e1db511aa218049471c | https://github.com/PuerkitoBio/rehttp/blob/11cf6ea5d3e9afda34846e1db511aa218049471c/rehttp.go#L117-L124 |
141,905 | PuerkitoBio/rehttp | rehttp.go | RetryAny | func RetryAny(retryFns ...RetryFn) RetryFn {
return func(attempt Attempt) bool {
for _, fn := range retryFns {
if fn(attempt) {
return true
}
}
return false
}
} | go | func RetryAny(retryFns ...RetryFn) RetryFn {
return func(attempt Attempt) bool {
for _, fn := range retryFns {
if fn(attempt) {
return true
}
}
return false
}
} | [
"func",
"RetryAny",
"(",
"retryFns",
"...",
"RetryFn",
")",
"RetryFn",
"{",
"return",
"func",
"(",
"attempt",
"Attempt",
")",
"bool",
"{",
"for",
"_",
",",
"fn",
":=",
"range",
"retryFns",
"{",
"if",
"fn",
"(",
"attempt",
")",
"{",
"return",
"true",
... | // RetryAny returns a RetryFn that allows a retry as long as one of
// the retryFns returns true. If retryFns is empty, it always returns false. | [
"RetryAny",
"returns",
"a",
"RetryFn",
"that",
"allows",
"a",
"retry",
"as",
"long",
"as",
"one",
"of",
"the",
"retryFns",
"returns",
"true",
".",
"If",
"retryFns",
"is",
"empty",
"it",
"always",
"returns",
"false",
"."
] | 11cf6ea5d3e9afda34846e1db511aa218049471c | https://github.com/PuerkitoBio/rehttp/blob/11cf6ea5d3e9afda34846e1db511aa218049471c/rehttp.go#L128-L137 |
141,906 | PuerkitoBio/rehttp | rehttp.go | RetryMaxRetries | func RetryMaxRetries(max int) RetryFn {
return func(attempt Attempt) bool {
// < instead of <= because attempt.Index is 0-based, so if max = 1
// (1 retry), it will return true when attempt.Index == 0 only.
return attempt.Index < max
}
} | go | func RetryMaxRetries(max int) RetryFn {
return func(attempt Attempt) bool {
// < instead of <= because attempt.Index is 0-based, so if max = 1
// (1 retry), it will return true when attempt.Index == 0 only.
return attempt.Index < max
}
} | [
"func",
"RetryMaxRetries",
"(",
"max",
"int",
")",
"RetryFn",
"{",
"return",
"func",
"(",
"attempt",
"Attempt",
")",
"bool",
"{",
"// < instead of <= because attempt.Index is 0-based, so if max = 1",
"// (1 retry), it will return true when attempt.Index == 0 only.",
"return",
"... | // RetryMaxRetries returns a RetryFn that retries if the number of
// retries is less than or equal to max. | [
"RetryMaxRetries",
"returns",
"a",
"RetryFn",
"that",
"retries",
"if",
"the",
"number",
"of",
"retries",
"is",
"less",
"than",
"or",
"equal",
"to",
"max",
"."
] | 11cf6ea5d3e9afda34846e1db511aa218049471c | https://github.com/PuerkitoBio/rehttp/blob/11cf6ea5d3e9afda34846e1db511aa218049471c/rehttp.go#L154-L160 |
141,907 | PuerkitoBio/rehttp | rehttp.go | RetryIsErr | func RetryIsErr(fn func(error) bool) RetryFn {
return func(attempt Attempt) bool {
return fn(attempt.Error)
}
} | go | func RetryIsErr(fn func(error) bool) RetryFn {
return func(attempt Attempt) bool {
return fn(attempt.Error)
}
} | [
"func",
"RetryIsErr",
"(",
"fn",
"func",
"(",
"error",
")",
"bool",
")",
"RetryFn",
"{",
"return",
"func",
"(",
"attempt",
"Attempt",
")",
"bool",
"{",
"return",
"fn",
"(",
"attempt",
".",
"Error",
")",
"\n",
"}",
"\n",
"}"
] | // RetryIsErr returns a RetryFn that retries if the provided
// error predicate - a function that receives an error and returns a
// boolean - returns true for the error associated with the Attempt.
// Note that fn may be called with a nil error. | [
"RetryIsErr",
"returns",
"a",
"RetryFn",
"that",
"retries",
"if",
"the",
"provided",
"error",
"predicate",
"-",
"a",
"function",
"that",
"receives",
"an",
"error",
"and",
"returns",
"a",
"boolean",
"-",
"returns",
"true",
"for",
"the",
"error",
"associated",
... | 11cf6ea5d3e9afda34846e1db511aa218049471c | https://github.com/PuerkitoBio/rehttp/blob/11cf6ea5d3e9afda34846e1db511aa218049471c/rehttp.go#L166-L170 |
141,908 | PuerkitoBio/rehttp | rehttp.go | RetryStatuses | func RetryStatuses(statuses ...int) RetryFn {
return func(attempt Attempt) bool {
if attempt.Response == nil {
return false
}
for _, st := range statuses {
if st == attempt.Response.StatusCode {
return true
}
}
return false
}
} | go | func RetryStatuses(statuses ...int) RetryFn {
return func(attempt Attempt) bool {
if attempt.Response == nil {
return false
}
for _, st := range statuses {
if st == attempt.Response.StatusCode {
return true
}
}
return false
}
} | [
"func",
"RetryStatuses",
"(",
"statuses",
"...",
"int",
")",
"RetryFn",
"{",
"return",
"func",
"(",
"attempt",
"Attempt",
")",
"bool",
"{",
"if",
"attempt",
".",
"Response",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"_",
",",
"st",
... | // RetryStatuses returns a RetryFn that retries if the response's status
// code is one of the provided statuses. | [
"RetryStatuses",
"returns",
"a",
"RetryFn",
"that",
"retries",
"if",
"the",
"response",
"s",
"status",
"code",
"is",
"one",
"of",
"the",
"provided",
"statuses",
"."
] | 11cf6ea5d3e9afda34846e1db511aa218049471c | https://github.com/PuerkitoBio/rehttp/blob/11cf6ea5d3e9afda34846e1db511aa218049471c/rehttp.go#L200-L212 |
141,909 | PuerkitoBio/rehttp | rehttp.go | RetryHTTPMethods | func RetryHTTPMethods(methods ...string) RetryFn {
for i, m := range methods {
methods[i] = strings.ToUpper(m)
}
return func(attempt Attempt) bool {
curMeth := strings.ToUpper(attempt.Request.Method)
for _, m := range methods {
if curMeth == m {
return true
}
}
return false
}
} | go | func RetryHTTPMethods(methods ...string) RetryFn {
for i, m := range methods {
methods[i] = strings.ToUpper(m)
}
return func(attempt Attempt) bool {
curMeth := strings.ToUpper(attempt.Request.Method)
for _, m := range methods {
if curMeth == m {
return true
}
}
return false
}
} | [
"func",
"RetryHTTPMethods",
"(",
"methods",
"...",
"string",
")",
"RetryFn",
"{",
"for",
"i",
",",
"m",
":=",
"range",
"methods",
"{",
"methods",
"[",
"i",
"]",
"=",
"strings",
".",
"ToUpper",
"(",
"m",
")",
"\n",
"}",
"\n\n",
"return",
"func",
"(",
... | // RetryHTTPMethods returns a RetryFn that retries if the request's
// HTTP method is one of the provided methods. It is meant to be used
// in conjunction with another RetryFn such as RetryTemporaryErr combined
// using RetryAll, otherwise this function will retry any successful
// request made with one of the provide... | [
"RetryHTTPMethods",
"returns",
"a",
"RetryFn",
"that",
"retries",
"if",
"the",
"request",
"s",
"HTTP",
"method",
"is",
"one",
"of",
"the",
"provided",
"methods",
".",
"It",
"is",
"meant",
"to",
"be",
"used",
"in",
"conjunction",
"with",
"another",
"RetryFn",... | 11cf6ea5d3e9afda34846e1db511aa218049471c | https://github.com/PuerkitoBio/rehttp/blob/11cf6ea5d3e9afda34846e1db511aa218049471c/rehttp.go#L219-L233 |
141,910 | PuerkitoBio/rehttp | rehttp.go | ConstDelay | func ConstDelay(delay time.Duration) DelayFn {
return func(attempt Attempt) time.Duration {
return delay
}
} | go | func ConstDelay(delay time.Duration) DelayFn {
return func(attempt Attempt) time.Duration {
return delay
}
} | [
"func",
"ConstDelay",
"(",
"delay",
"time",
".",
"Duration",
")",
"DelayFn",
"{",
"return",
"func",
"(",
"attempt",
"Attempt",
")",
"time",
".",
"Duration",
"{",
"return",
"delay",
"\n",
"}",
"\n",
"}"
] | // ConstDelay returns a DelayFn that always returns the same delay. | [
"ConstDelay",
"returns",
"a",
"DelayFn",
"that",
"always",
"returns",
"the",
"same",
"delay",
"."
] | 11cf6ea5d3e9afda34846e1db511aa218049471c | https://github.com/PuerkitoBio/rehttp/blob/11cf6ea5d3e9afda34846e1db511aa218049471c/rehttp.go#L236-L240 |
141,911 | PuerkitoBio/rehttp | rehttp.go | RoundTrip | func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
var attempt int
preventRetry := req.Body != nil && t.PreventRetryWithBody
// get the done cancellation channel for the context, will be nil
// for < go1.7.
done := contextForRequest(req)
// buffer the body if needed
var br *bytes.Reader... | go | func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
var attempt int
preventRetry := req.Body != nil && t.PreventRetryWithBody
// get the done cancellation channel for the context, will be nil
// for < go1.7.
done := contextForRequest(req)
// buffer the body if needed
var br *bytes.Reader... | [
"func",
"(",
"t",
"*",
"Transport",
")",
"RoundTrip",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"var",
"attempt",
"int",
"\n",
"preventRetry",
":=",
"req",
".",
"Body",
"!=",
"nil",
"&&... | // RoundTrip implements http.RoundTripper for the Transport type.
// It calls its underlying http.RoundTripper to execute the request, and
// adds retry logic as per its configuration. | [
"RoundTrip",
"implements",
"http",
".",
"RoundTripper",
"for",
"the",
"Transport",
"type",
".",
"It",
"calls",
"its",
"underlying",
"http",
".",
"RoundTripper",
"to",
"execute",
"the",
"request",
"and",
"adds",
"retry",
"logic",
"as",
"per",
"its",
"configurat... | 11cf6ea5d3e9afda34846e1db511aa218049471c | https://github.com/PuerkitoBio/rehttp/blob/11cf6ea5d3e9afda34846e1db511aa218049471c/rehttp.go#L283-L349 |
141,912 | joyent/triton-go | compute/instances.go | toAPI | func (input ReplaceTagsInput) toAPI() map[string]interface{} {
result := map[string]interface{}{}
for key, value := range input.Tags {
result[key] = value
}
input.CNS.toTags(result)
return result
} | go | func (input ReplaceTagsInput) toAPI() map[string]interface{} {
result := map[string]interface{}{}
for key, value := range input.Tags {
result[key] = value
}
input.CNS.toTags(result)
return result
} | [
"func",
"(",
"input",
"ReplaceTagsInput",
")",
"toAPI",
"(",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"result",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"for",
"key",
",",
"value",
":=",
"range",
"i... | // toAPI is used to join Tags and CNS tags into the same JSON object before
// sending an API request to the API gateway. | [
"toAPI",
"is",
"used",
"to",
"join",
"Tags",
"and",
"CNS",
"tags",
"into",
"the",
"same",
"JSON",
"object",
"before",
"sending",
"an",
"API",
"request",
"to",
"the",
"API",
"gateway",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/compute/instances.go#L514-L521 |
141,913 | joyent/triton-go | compute/instances.go | GetMetadata | func (c *InstancesClient) GetMetadata(ctx context.Context, input *GetMetadataInput) (string, error) {
if input.Key == "" {
return "", fmt.Errorf("Missing metadata Key from input: %s", input.Key)
}
fullPath := path.Join("/", c.client.AccountName, "machines", input.ID, "metadata", input.Key)
reqInputs := client.Re... | go | func (c *InstancesClient) GetMetadata(ctx context.Context, input *GetMetadataInput) (string, error) {
if input.Key == "" {
return "", fmt.Errorf("Missing metadata Key from input: %s", input.Key)
}
fullPath := path.Join("/", c.client.AccountName, "machines", input.ID, "metadata", input.Key)
reqInputs := client.Re... | [
"func",
"(",
"c",
"*",
"InstancesClient",
")",
"GetMetadata",
"(",
"ctx",
"context",
".",
"Context",
",",
"input",
"*",
"GetMetadataInput",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"input",
".",
"Key",
"==",
"\"",
"\"",
"{",
"return",
"\"",
... | // GetMetadata returns a single metadata entry associated with an instance. | [
"GetMetadata",
"returns",
"a",
"single",
"metadata",
"entry",
"associated",
"with",
"an",
"instance",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/compute/instances.go#L626-L656 |
141,914 | joyent/triton-go | compute/instances.go | DeleteMetadata | func (c *InstancesClient) DeleteMetadata(ctx context.Context, input *DeleteMetadataInput) error {
if input.Key == "" {
return fmt.Errorf("Missing metadata Key from input: %s", input.Key)
}
fullPath := path.Join("/", c.client.AccountName, "machines", input.ID, "metadata", input.Key)
reqInputs := client.RequestInp... | go | func (c *InstancesClient) DeleteMetadata(ctx context.Context, input *DeleteMetadataInput) error {
if input.Key == "" {
return fmt.Errorf("Missing metadata Key from input: %s", input.Key)
}
fullPath := path.Join("/", c.client.AccountName, "machines", input.ID, "metadata", input.Key)
reqInputs := client.RequestInp... | [
"func",
"(",
"c",
"*",
"InstancesClient",
")",
"DeleteMetadata",
"(",
"ctx",
"context",
".",
"Context",
",",
"input",
"*",
"DeleteMetadataInput",
")",
"error",
"{",
"if",
"input",
".",
"Key",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
... | // DeleteMetadata deletes a single metadata key from an instance | [
"DeleteMetadata",
"deletes",
"a",
"single",
"metadata",
"key",
"from",
"an",
"instance"
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/compute/instances.go#L728-L747 |
141,915 | joyent/triton-go | compute/instances.go | DeleteAllMetadata | func (c *InstancesClient) DeleteAllMetadata(ctx context.Context, input *DeleteAllMetadataInput) error {
fullPath := path.Join("/", c.client.AccountName, "machines", input.ID, "metadata")
reqInputs := client.RequestInput{
Method: http.MethodDelete,
Path: fullPath,
}
respReader, err := c.client.ExecuteRequest(c... | go | func (c *InstancesClient) DeleteAllMetadata(ctx context.Context, input *DeleteAllMetadataInput) error {
fullPath := path.Join("/", c.client.AccountName, "machines", input.ID, "metadata")
reqInputs := client.RequestInput{
Method: http.MethodDelete,
Path: fullPath,
}
respReader, err := c.client.ExecuteRequest(c... | [
"func",
"(",
"c",
"*",
"InstancesClient",
")",
"DeleteAllMetadata",
"(",
"ctx",
"context",
".",
"Context",
",",
"input",
"*",
"DeleteAllMetadataInput",
")",
"error",
"{",
"fullPath",
":=",
"path",
".",
"Join",
"(",
"\"",
"\"",
",",
"c",
".",
"client",
".... | // DeleteAllMetadata deletes all metadata keys from this instance | [
"DeleteAllMetadata",
"deletes",
"all",
"metadata",
"keys",
"from",
"this",
"instance"
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/compute/instances.go#L754-L769 |
141,916 | joyent/triton-go | compute/instances.go | TagsExtractMeta | func TagsExtractMeta(tags map[string]interface{}) (InstanceCNS, map[string]interface{}) {
nativeCNS := InstanceCNS{}
nativeTags := make(map[string]interface{}, len(tags))
for k, raw := range tags {
if _, found := reservedInstanceCNSTags[k]; found {
switch k {
case CNSTagDisable:
b := raw.(bool)
nativ... | go | func TagsExtractMeta(tags map[string]interface{}) (InstanceCNS, map[string]interface{}) {
nativeCNS := InstanceCNS{}
nativeTags := make(map[string]interface{}, len(tags))
for k, raw := range tags {
if _, found := reservedInstanceCNSTags[k]; found {
switch k {
case CNSTagDisable:
b := raw.(bool)
nativ... | [
"func",
"TagsExtractMeta",
"(",
"tags",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"InstanceCNS",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"nativeCNS",
":=",
"InstanceCNS",
"{",
"}",
"\n",
"nativeTags",
":=",
"m... | // TagsExtractMeta extracts all of the misc parameters from Tags and returns a
// clean CNS and Tags struct. | [
"TagsExtractMeta",
"extracts",
"all",
"of",
"the",
"misc",
"parameters",
"from",
"Tags",
"and",
"returns",
"a",
"clean",
"CNS",
"and",
"Tags",
"struct",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/compute/instances.go#L1131-L1154 |
141,917 | joyent/triton-go | network/client.go | NewClient | func NewClient(config *triton.ClientConfig) (*NetworkClient, error) {
// TODO: Utilize config interface within the function itself
client, err := client.New(
config.TritonURL,
config.MantaURL,
config.AccountName,
config.Signers...,
)
if err != nil {
return nil, err
}
return newNetworkClient(client), nil... | go | func NewClient(config *triton.ClientConfig) (*NetworkClient, error) {
// TODO: Utilize config interface within the function itself
client, err := client.New(
config.TritonURL,
config.MantaURL,
config.AccountName,
config.Signers...,
)
if err != nil {
return nil, err
}
return newNetworkClient(client), nil... | [
"func",
"NewClient",
"(",
"config",
"*",
"triton",
".",
"ClientConfig",
")",
"(",
"*",
"NetworkClient",
",",
"error",
")",
"{",
"// TODO: Utilize config interface within the function itself",
"client",
",",
"err",
":=",
"client",
".",
"New",
"(",
"config",
".",
... | // NewClient returns a new client for working with Network endpoints and
// resources within CloudAPI | [
"NewClient",
"returns",
"a",
"new",
"client",
"for",
"working",
"with",
"Network",
"endpoints",
"and",
"resources",
"within",
"CloudAPI"
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/network/client.go#L30-L42 |
141,918 | joyent/triton-go | errors/errors.go | Error | func (e APIError) Error() string {
return strings.Trim(fmt.Sprintf("%+q", e.Code), `"`) + ": " + strings.Trim(fmt.Sprintf("%+q", e.Message), `"`)
} | go | func (e APIError) Error() string {
return strings.Trim(fmt.Sprintf("%+q", e.Code), `"`) + ": " + strings.Trim(fmt.Sprintf("%+q", e.Message), `"`)
} | [
"func",
"(",
"e",
"APIError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"strings",
".",
"Trim",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"Code",
")",
",",
"`\"`",
")",
"+",
"\"",
"\"",
"+",
"strings",
".",
"Trim",
"(",... | // Error implements interface Error on the APIError type. | [
"Error",
"implements",
"interface",
"Error",
"on",
"the",
"APIError",
"type",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/errors/errors.go#L32-L34 |
141,919 | joyent/triton-go | storage/directory.go | List | func (s *DirectoryClient) List(ctx context.Context, input *ListDirectoryInput) (*ListDirectoryOutput, error) {
absPath := absFileInput(s.client.AccountName, input.DirectoryName)
query := &url.Values{}
if input.Limit != 0 {
query.Set("limit", strconv.FormatUint(input.Limit, 10))
}
if input.Marker != "" {
query... | go | func (s *DirectoryClient) List(ctx context.Context, input *ListDirectoryInput) (*ListDirectoryOutput, error) {
absPath := absFileInput(s.client.AccountName, input.DirectoryName)
query := &url.Values{}
if input.Limit != 0 {
query.Set("limit", strconv.FormatUint(input.Limit, 10))
}
if input.Marker != "" {
query... | [
"func",
"(",
"s",
"*",
"DirectoryClient",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"input",
"*",
"ListDirectoryInput",
")",
"(",
"*",
"ListDirectoryOutput",
",",
"error",
")",
"{",
"absPath",
":=",
"absFileInput",
"(",
"s",
".",
"client",
... | // List lists the contents of a directory on the Triton Object Store service. | [
"List",
"lists",
"the",
"contents",
"of",
"a",
"directory",
"on",
"the",
"Triton",
"Object",
"Store",
"service",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/storage/directory.go#L52-L99 |
141,920 | joyent/triton-go | storage/directory.go | Delete | func (s *DirectoryClient) Delete(ctx context.Context, input *DeleteDirectoryInput) error {
absPath := absFileInput(s.client.AccountName, input.DirectoryName)
if input.ForceDelete {
err := deleteAll(*s, ctx, absPath)
if err != nil {
return err
}
} else {
err := deleteDirectory(*s, ctx, absPath)
if err !... | go | func (s *DirectoryClient) Delete(ctx context.Context, input *DeleteDirectoryInput) error {
absPath := absFileInput(s.client.AccountName, input.DirectoryName)
if input.ForceDelete {
err := deleteAll(*s, ctx, absPath)
if err != nil {
return err
}
} else {
err := deleteDirectory(*s, ctx, absPath)
if err !... | [
"func",
"(",
"s",
"*",
"DirectoryClient",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"input",
"*",
"DeleteDirectoryInput",
")",
"error",
"{",
"absPath",
":=",
"absFileInput",
"(",
"s",
".",
"client",
".",
"AccountName",
",",
"input",
".",
... | // Delete deletes a directory on the Triton Object Storage. The directory must
// be empty. | [
"Delete",
"deletes",
"a",
"directory",
"on",
"the",
"Triton",
"Object",
"Storage",
".",
"The",
"directory",
"must",
"be",
"empty",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/storage/directory.go#L139-L155 |
141,921 | joyent/triton-go | storage/client.go | NewClient | func NewClient(config *triton.ClientConfig) (*StorageClient, error) {
// TODO: Utilize config interface within the function itself
client, err := client.New(
config.TritonURL,
config.MantaURL,
config.AccountName,
config.Signers...,
)
if err != nil {
return nil, err
}
return newStorageClient(client), nil... | go | func NewClient(config *triton.ClientConfig) (*StorageClient, error) {
// TODO: Utilize config interface within the function itself
client, err := client.New(
config.TritonURL,
config.MantaURL,
config.AccountName,
config.Signers...,
)
if err != nil {
return nil, err
}
return newStorageClient(client), nil... | [
"func",
"NewClient",
"(",
"config",
"*",
"triton",
".",
"ClientConfig",
")",
"(",
"*",
"StorageClient",
",",
"error",
")",
"{",
"// TODO: Utilize config interface within the function itself",
"client",
",",
"err",
":=",
"client",
".",
"New",
"(",
"config",
".",
... | // NewClient returns a new client for working with Storage endpoints and
// resources within CloudAPI | [
"NewClient",
"returns",
"a",
"new",
"client",
"for",
"working",
"with",
"Storage",
"endpoints",
"and",
"resources",
"within",
"CloudAPI"
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/storage/client.go#L30-L42 |
141,922 | joyent/triton-go | storage/client.go | SetHeader | func (c *StorageClient) SetHeader(header *http.Header) {
c.Client.RequestHeader = header
} | go | func (c *StorageClient) SetHeader(header *http.Header) {
c.Client.RequestHeader = header
} | [
"func",
"(",
"c",
"*",
"StorageClient",
")",
"SetHeader",
"(",
"header",
"*",
"http",
".",
"Header",
")",
"{",
"c",
".",
"Client",
".",
"RequestHeader",
"=",
"header",
"\n",
"}"
] | // SetHeader allows a consumer of the current client to set a custom header for
// the next backend HTTP request sent to CloudAPI. | [
"SetHeader",
"allows",
"a",
"consumer",
"of",
"the",
"current",
"client",
"to",
"set",
"a",
"custom",
"header",
"for",
"the",
"next",
"backend",
"HTTP",
"request",
"sent",
"to",
"CloudAPI",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/storage/client.go#L46-L48 |
141,923 | joyent/triton-go | services/client.go | NewClient | func NewClient(config *triton.ClientConfig) (*ServiceGroupClient, error) {
// TODO: Utilize config interface within the function itself
client, err := client.New(
config.TritonURL,
config.MantaURL,
config.AccountName,
config.Signers...,
)
if err != nil {
return nil, err
}
return newServiceGroupClient(cl... | go | func NewClient(config *triton.ClientConfig) (*ServiceGroupClient, error) {
// TODO: Utilize config interface within the function itself
client, err := client.New(
config.TritonURL,
config.MantaURL,
config.AccountName,
config.Signers...,
)
if err != nil {
return nil, err
}
return newServiceGroupClient(cl... | [
"func",
"NewClient",
"(",
"config",
"*",
"triton",
".",
"ClientConfig",
")",
"(",
"*",
"ServiceGroupClient",
",",
"error",
")",
"{",
"// TODO: Utilize config interface within the function itself",
"client",
",",
"err",
":=",
"client",
".",
"New",
"(",
"config",
".... | // NewClient returns a new client for working with Service Groups endpoints and
// resources within TSG | [
"NewClient",
"returns",
"a",
"new",
"client",
"for",
"working",
"with",
"Service",
"Groups",
"endpoints",
"and",
"resources",
"within",
"TSG"
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/services/client.go#L30-L42 |
141,924 | joyent/triton-go | storage/snaplink.go | Put | func (s *SnapLinksClient) Put(ctx context.Context, input *PutSnapLinkInput) error {
linkPath := fmt.Sprintf("/%s%s", s.client.AccountName, input.LinkPath)
sourcePath := fmt.Sprintf("/%s%s", s.client.AccountName, input.SourcePath)
headers := &http.Header{}
headers.Set("Content-Type", "application/json; type=link")
... | go | func (s *SnapLinksClient) Put(ctx context.Context, input *PutSnapLinkInput) error {
linkPath := fmt.Sprintf("/%s%s", s.client.AccountName, input.LinkPath)
sourcePath := fmt.Sprintf("/%s%s", s.client.AccountName, input.SourcePath)
headers := &http.Header{}
headers.Set("Content-Type", "application/json; type=link")
... | [
"func",
"(",
"s",
"*",
"SnapLinksClient",
")",
"Put",
"(",
"ctx",
"context",
".",
"Context",
",",
"input",
"*",
"PutSnapLinkInput",
")",
"error",
"{",
"linkPath",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"client",
".",
"AccountName"... | // PutSnapLink creates a SnapLink to an object. | [
"PutSnapLink",
"creates",
"a",
"SnapLink",
"to",
"an",
"object",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/storage/snaplink.go#L31-L54 |
141,925 | joyent/triton-go | account/client.go | NewClient | func NewClient(config *triton.ClientConfig) (*AccountClient, error) {
// TODO: Utilize config interface within the function itself
client, err := client.New(
config.TritonURL,
config.MantaURL,
config.AccountName,
config.Signers...,
)
if err != nil {
return nil, err
}
return newAccountClient(client), nil... | go | func NewClient(config *triton.ClientConfig) (*AccountClient, error) {
// TODO: Utilize config interface within the function itself
client, err := client.New(
config.TritonURL,
config.MantaURL,
config.AccountName,
config.Signers...,
)
if err != nil {
return nil, err
}
return newAccountClient(client), nil... | [
"func",
"NewClient",
"(",
"config",
"*",
"triton",
".",
"ClientConfig",
")",
"(",
"*",
"AccountClient",
",",
"error",
")",
"{",
"// TODO: Utilize config interface within the function itself",
"client",
",",
"err",
":=",
"client",
".",
"New",
"(",
"config",
".",
... | // NewClient returns a new client for working with Account endpoints and
// resources within CloudAPI | [
"NewClient",
"returns",
"a",
"new",
"client",
"for",
"working",
"with",
"Account",
"endpoints",
"and",
"resources",
"within",
"CloudAPI"
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/account/client.go#L30-L42 |
141,926 | joyent/triton-go | version.go | UserAgent | func UserAgent() string {
if Prerelease != "" {
return fmt.Sprintf("triton-go/%s-%s (%s-%s; %s)", Version, Prerelease,
runtime.GOARCH, runtime.GOOS, runtime.Version())
}
return fmt.Sprintf("triton-go/%s (%s-%s; %s)", Version, runtime.GOARCH,
runtime.GOOS, runtime.Version())
} | go | func UserAgent() string {
if Prerelease != "" {
return fmt.Sprintf("triton-go/%s-%s (%s-%s; %s)", Version, Prerelease,
runtime.GOARCH, runtime.GOOS, runtime.Version())
}
return fmt.Sprintf("triton-go/%s (%s-%s; %s)", Version, runtime.GOARCH,
runtime.GOOS, runtime.Version())
} | [
"func",
"UserAgent",
"(",
")",
"string",
"{",
"if",
"Prerelease",
"!=",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"Version",
",",
"Prerelease",
",",
"runtime",
".",
"GOARCH",
",",
"runtime",
".",
"GOOS",
",",
"runtime",
... | // UserAgent returns a Triton-go characteristic string that allows the
// network protocol peers to identify the version, release and runtime
// of the Triton-go client from which the requests originate. | [
"UserAgent",
"returns",
"a",
"Triton",
"-",
"go",
"characteristic",
"string",
"that",
"allows",
"the",
"network",
"protocol",
"peers",
"to",
"identify",
"the",
"version",
"release",
"and",
"runtime",
"of",
"the",
"Triton",
"-",
"go",
"client",
"from",
"which",... | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/version.go#L30-L38 |
141,927 | joyent/triton-go | client/client.go | New | func New(tritonURL string, mantaURL string, accountName string, signers ...authentication.Signer) (*Client, error) {
if accountName == "" {
return nil, ErrAccountName
}
if tritonURL == "" && mantaURL == "" {
return nil, ErrMissingURL
}
cloudURL, err := url.Parse(tritonURL)
if err != nil {
return nil, pkge... | go | func New(tritonURL string, mantaURL string, accountName string, signers ...authentication.Signer) (*Client, error) {
if accountName == "" {
return nil, ErrAccountName
}
if tritonURL == "" && mantaURL == "" {
return nil, ErrMissingURL
}
cloudURL, err := url.Parse(tritonURL)
if err != nil {
return nil, pkge... | [
"func",
"New",
"(",
"tritonURL",
"string",
",",
"mantaURL",
"string",
",",
"accountName",
"string",
",",
"signers",
"...",
"authentication",
".",
"Signer",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"if",
"accountName",
"==",
"\"",
"\"",
"{",
"retu... | // New is used to construct a Client in order to make API
// requests to the Triton API.
//
// At least one signer must be provided - example signers include
// authentication.PrivateKeySigner and authentication.SSHAgentSigner. | [
"New",
"is",
"used",
"to",
"construct",
"a",
"Client",
"in",
"order",
"to",
"make",
"API",
"requests",
"to",
"the",
"Triton",
"API",
".",
"At",
"least",
"one",
"signer",
"must",
"be",
"provided",
"-",
"example",
"signers",
"include",
"authentication",
".",... | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/client/client.go#L100-L169 |
141,928 | joyent/triton-go | client/client.go | InsecureSkipTLSVerify | func (c *Client) InsecureSkipTLSVerify() {
if c.HTTPClient == nil {
return
}
c.HTTPClient.Transport = httpTransport(true)
} | go | func (c *Client) InsecureSkipTLSVerify() {
if c.HTTPClient == nil {
return
}
c.HTTPClient.Transport = httpTransport(true)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"InsecureSkipTLSVerify",
"(",
")",
"{",
"if",
"c",
".",
"HTTPClient",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"c",
".",
"HTTPClient",
".",
"Transport",
"=",
"httpTransport",
"(",
"true",
")",
"\n",
"}"
] | // InsecureSkipTLSVerify turns off TLS verification for the client connection. This
// allows connection to an endpoint with a certificate which was signed by a non-
// trusted CA, such as self-signed certificates. This can be useful when connecting
// to temporary Triton installations such as Triton Cloud-On-A-Laptop. | [
"InsecureSkipTLSVerify",
"turns",
"off",
"TLS",
"verification",
"for",
"the",
"client",
"connection",
".",
"This",
"allows",
"connection",
"to",
"an",
"endpoint",
"with",
"a",
"certificate",
"which",
"was",
"signed",
"by",
"a",
"non",
"-",
"trusted",
"CA",
"su... | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/client/client.go#L197-L203 |
141,929 | joyent/triton-go | client/client.go | httpTransport | func httpTransport(insecureSkipTLSVerify bool) *http.Transport {
return &http.Transport{
Proxy: http.ProxyFromEnvironment,
Dial: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
TLSHandshakeTimeout: 10 * time.Second,
MaxIdleConns: 10,
IdleConnTimeout: 15 * t... | go | func httpTransport(insecureSkipTLSVerify bool) *http.Transport {
return &http.Transport{
Proxy: http.ProxyFromEnvironment,
Dial: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
TLSHandshakeTimeout: 10 * time.Second,
MaxIdleConns: 10,
IdleConnTimeout: 15 * t... | [
"func",
"httpTransport",
"(",
"insecureSkipTLSVerify",
"bool",
")",
"*",
"http",
".",
"Transport",
"{",
"return",
"&",
"http",
".",
"Transport",
"{",
"Proxy",
":",
"http",
".",
"ProxyFromEnvironment",
",",
"Dial",
":",
"(",
"&",
"net",
".",
"Dialer",
"{",
... | // httpTransport is responsible for setting up our HTTP client's transport
// settings | [
"httpTransport",
"is",
"responsible",
"for",
"setting",
"up",
"our",
"HTTP",
"client",
"s",
"transport",
"settings"
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/client/client.go#L207-L221 |
141,930 | joyent/triton-go | client/client.go | DecodeError | func (c *Client) DecodeError(resp *http.Response, requestMethod string) error {
err := &errors.APIError{
StatusCode: resp.StatusCode,
}
if requestMethod != http.MethodHead && resp.Body != nil {
errorDecoder := json.NewDecoder(resp.Body)
if err := errorDecoder.Decode(err); err != nil {
return pkgerrors.Wrap... | go | func (c *Client) DecodeError(resp *http.Response, requestMethod string) error {
err := &errors.APIError{
StatusCode: resp.StatusCode,
}
if requestMethod != http.MethodHead && resp.Body != nil {
errorDecoder := json.NewDecoder(resp.Body)
if err := errorDecoder.Decode(err); err != nil {
return pkgerrors.Wrap... | [
"func",
"(",
"c",
"*",
"Client",
")",
"DecodeError",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"requestMethod",
"string",
")",
"error",
"{",
"err",
":=",
"&",
"errors",
".",
"APIError",
"{",
"StatusCode",
":",
"resp",
".",
"StatusCode",
",",
"}",... | // DecodeError decodes a backend Triton error into a more usable Go error type | [
"DecodeError",
"decodes",
"a",
"backend",
"Triton",
"error",
"into",
"a",
"more",
"usable",
"Go",
"error",
"type"
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/client/client.go#L228-L245 |
141,931 | joyent/triton-go | client/client.go | overrideHeader | func (c *Client) overrideHeader(req *http.Request) {
if c.RequestHeader != nil {
for k := range *c.RequestHeader {
req.Header.Set(k, c.RequestHeader.Get(k))
}
}
} | go | func (c *Client) overrideHeader(req *http.Request) {
if c.RequestHeader != nil {
for k := range *c.RequestHeader {
req.Header.Set(k, c.RequestHeader.Get(k))
}
}
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"overrideHeader",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"c",
".",
"RequestHeader",
"!=",
"nil",
"{",
"for",
"k",
":=",
"range",
"*",
"c",
".",
"RequestHeader",
"{",
"req",
".",
"Header",
".",... | // overrideHeader overrides the header of the passed in HTTP request | [
"overrideHeader",
"overrides",
"the",
"header",
"of",
"the",
"passed",
"in",
"HTTP",
"request"
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/client/client.go#L248-L254 |
141,932 | joyent/triton-go | storage/objects.go | GetInfo | func (s *ObjectsClient) GetInfo(ctx context.Context, input *GetInfoInput) (*GetInfoOutput, error) {
absPath := absFileInput(s.client.AccountName, input.ObjectPath)
headers := &http.Header{}
for key, value := range input.Headers {
headers.Set(key, value)
}
reqInput := client.RequestInput{
Method: http.Method... | go | func (s *ObjectsClient) GetInfo(ctx context.Context, input *GetInfoInput) (*GetInfoOutput, error) {
absPath := absFileInput(s.client.AccountName, input.ObjectPath)
headers := &http.Header{}
for key, value := range input.Headers {
headers.Set(key, value)
}
reqInput := client.RequestInput{
Method: http.Method... | [
"func",
"(",
"s",
"*",
"ObjectsClient",
")",
"GetInfo",
"(",
"ctx",
"context",
".",
"Context",
",",
"input",
"*",
"GetInfoInput",
")",
"(",
"*",
"GetInfoOutput",
",",
"error",
")",
"{",
"absPath",
":=",
"absFileInput",
"(",
"s",
".",
"client",
".",
"Ac... | // GetInfo sends a HEAD request to an object in the Manta service. This function
// does not return a response body. | [
"GetInfo",
"sends",
"a",
"HEAD",
"request",
"to",
"an",
"object",
"in",
"the",
"Manta",
"service",
".",
"This",
"function",
"does",
"not",
"return",
"a",
"response",
"body",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/storage/objects.go#L100-L143 |
141,933 | joyent/triton-go | storage/objects.go | IsDir | func (s *ObjectsClient) IsDir(ctx context.Context, objectPath string) (bool, error) {
info, err := s.GetInfo(ctx, &GetInfoInput{
ObjectPath: objectPath,
})
if err != nil {
return false, err
}
if info != nil {
return strings.HasSuffix(info.ContentType, "type=directory"), nil
}
return false, nil
} | go | func (s *ObjectsClient) IsDir(ctx context.Context, objectPath string) (bool, error) {
info, err := s.GetInfo(ctx, &GetInfoInput{
ObjectPath: objectPath,
})
if err != nil {
return false, err
}
if info != nil {
return strings.HasSuffix(info.ContentType, "type=directory"), nil
}
return false, nil
} | [
"func",
"(",
"s",
"*",
"ObjectsClient",
")",
"IsDir",
"(",
"ctx",
"context",
".",
"Context",
",",
"objectPath",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"info",
",",
"err",
":=",
"s",
".",
"GetInfo",
"(",
"ctx",
",",
"&",
"GetInfoInput",
... | // IsDir is a convenience wrapper around the GetInfo function which takes an
// ObjectPath and returns a boolean whether or not the object is a directory
// type in Manta. Returns an error if GetInfo failed upstream for some reason. | [
"IsDir",
"is",
"a",
"convenience",
"wrapper",
"around",
"the",
"GetInfo",
"function",
"which",
"takes",
"an",
"ObjectPath",
"and",
"returns",
"a",
"boolean",
"whether",
"or",
"not",
"the",
"object",
"is",
"a",
"directory",
"type",
"in",
"Manta",
".",
"Return... | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/storage/objects.go#L148-L159 |
141,934 | joyent/triton-go | storage/objects.go | Delete | func (s *ObjectsClient) Delete(ctx context.Context, input *DeleteObjectInput) error {
absPath := absFileInput(s.client.AccountName, input.ObjectPath)
headers := &http.Header{}
for key, value := range input.Headers {
headers.Set(key, value)
}
reqInput := client.RequestInput{
Method: http.MethodDelete,
Path... | go | func (s *ObjectsClient) Delete(ctx context.Context, input *DeleteObjectInput) error {
absPath := absFileInput(s.client.AccountName, input.ObjectPath)
headers := &http.Header{}
for key, value := range input.Headers {
headers.Set(key, value)
}
reqInput := client.RequestInput{
Method: http.MethodDelete,
Path... | [
"func",
"(",
"s",
"*",
"ObjectsClient",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"input",
"*",
"DeleteObjectInput",
")",
"error",
"{",
"absPath",
":=",
"absFileInput",
"(",
"s",
".",
"client",
".",
"AccountName",
",",
"input",
".",
"Obj... | // DeleteObject deletes an object. | [
"DeleteObject",
"deletes",
"an",
"object",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/storage/objects.go#L235-L257 |
141,935 | joyent/triton-go | identity/client.go | NewClient | func NewClient(config *triton.ClientConfig) (*IdentityClient, error) {
// TODO: Utilize config interface within the function itself
client, err := client.New(
config.TritonURL,
config.MantaURL,
config.AccountName,
config.Signers...,
)
if err != nil {
return nil, err
}
return newIdentityClient(client), n... | go | func NewClient(config *triton.ClientConfig) (*IdentityClient, error) {
// TODO: Utilize config interface within the function itself
client, err := client.New(
config.TritonURL,
config.MantaURL,
config.AccountName,
config.Signers...,
)
if err != nil {
return nil, err
}
return newIdentityClient(client), n... | [
"func",
"NewClient",
"(",
"config",
"*",
"triton",
".",
"ClientConfig",
")",
"(",
"*",
"IdentityClient",
",",
"error",
")",
"{",
"// TODO: Utilize config interface within the function itself",
"client",
",",
"err",
":=",
"client",
".",
"New",
"(",
"config",
".",
... | // NewClient returns a new client for working with Identity endpoints and
// resources within CloudAPI | [
"NewClient",
"returns",
"a",
"new",
"client",
"for",
"working",
"with",
"Identity",
"endpoints",
"and",
"resources",
"within",
"CloudAPI"
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/identity/client.go#L30-L42 |
141,936 | joyent/triton-go | storage/job.go | Create | func (s *JobClient) Create(ctx context.Context, input *CreateJobInput) (*CreateJobOutput, error) {
fullPath := path.Join("/", s.client.AccountName, "jobs")
reqInput := client.RequestInput{
Method: http.MethodPost,
Path: fullPath,
Body: input,
}
respBody, respHeaders, err := s.client.ExecuteRequestStorage... | go | func (s *JobClient) Create(ctx context.Context, input *CreateJobInput) (*CreateJobOutput, error) {
fullPath := path.Join("/", s.client.AccountName, "jobs")
reqInput := client.RequestInput{
Method: http.MethodPost,
Path: fullPath,
Body: input,
}
respBody, respHeaders, err := s.client.ExecuteRequestStorage... | [
"func",
"(",
"s",
"*",
"JobClient",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"input",
"*",
"CreateJobInput",
")",
"(",
"*",
"CreateJobOutput",
",",
"error",
")",
"{",
"fullPath",
":=",
"path",
".",
"Join",
"(",
"\"",
"\"",
",",
"s",... | // CreateJob submits a new job to be executed. This call is not
// idempotent, so calling it twice will create two jobs. | [
"CreateJob",
"submits",
"a",
"new",
"job",
"to",
"be",
"executed",
".",
"This",
"call",
"is",
"not",
"idempotent",
"so",
"calling",
"it",
"twice",
"will",
"create",
"two",
"jobs",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/storage/job.go#L109-L134 |
141,937 | joyent/triton-go | storage/job.go | AddInputs | func (s *JobClient) AddInputs(ctx context.Context, input *AddJobInputsInput) error {
fullPath := path.Join("/", s.client.AccountName, "jobs", input.JobID, "live", "in")
headers := &http.Header{}
headers.Set("Content-Type", "text/plain")
reader := strings.NewReader(strings.Join(input.ObjectPaths, "\n"))
reqInput ... | go | func (s *JobClient) AddInputs(ctx context.Context, input *AddJobInputsInput) error {
fullPath := path.Join("/", s.client.AccountName, "jobs", input.JobID, "live", "in")
headers := &http.Header{}
headers.Set("Content-Type", "text/plain")
reader := strings.NewReader(strings.Join(input.ObjectPaths, "\n"))
reqInput ... | [
"func",
"(",
"s",
"*",
"JobClient",
")",
"AddInputs",
"(",
"ctx",
"context",
".",
"Context",
",",
"input",
"*",
"AddJobInputsInput",
")",
"error",
"{",
"fullPath",
":=",
"path",
".",
"Join",
"(",
"\"",
"\"",
",",
"s",
".",
"client",
".",
"AccountName",... | // AddJobInputs submits inputs to an already created job. | [
"AddJobInputs",
"submits",
"inputs",
"to",
"an",
"already",
"created",
"job",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/storage/job.go#L143-L165 |
141,938 | joyent/triton-go | storage/job.go | EndInput | func (s *JobClient) EndInput(ctx context.Context, input *EndJobInputInput) error {
fullPath := path.Join("/", s.client.AccountName, "jobs", input.JobID, "live", "in", "end")
reqInput := client.RequestNoEncodeInput{
Method: http.MethodPost,
Path: fullPath,
}
respBody, _, err := s.client.ExecuteRequestNoEncode... | go | func (s *JobClient) EndInput(ctx context.Context, input *EndJobInputInput) error {
fullPath := path.Join("/", s.client.AccountName, "jobs", input.JobID, "live", "in", "end")
reqInput := client.RequestNoEncodeInput{
Method: http.MethodPost,
Path: fullPath,
}
respBody, _, err := s.client.ExecuteRequestNoEncode... | [
"func",
"(",
"s",
"*",
"JobClient",
")",
"EndInput",
"(",
"ctx",
"context",
".",
"Context",
",",
"input",
"*",
"EndJobInputInput",
")",
"error",
"{",
"fullPath",
":=",
"path",
".",
"Join",
"(",
"\"",
"\"",
",",
"s",
".",
"client",
".",
"AccountName",
... | // EndJobInput submits inputs to an already created job. | [
"EndJobInput",
"submits",
"inputs",
"to",
"an",
"already",
"created",
"job",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/storage/job.go#L173-L189 |
141,939 | joyent/triton-go | storage/job.go | List | func (s *JobClient) List(ctx context.Context, input *ListJobsInput) (*ListJobsOutput, error) {
fullPath := path.Join("/", s.client.AccountName, "jobs")
query := &url.Values{}
if input.RunningOnly {
query.Set("state", "running")
}
if input.Limit != 0 {
query.Set("limit", strconv.FormatUint(input.Limit, 10))
}
... | go | func (s *JobClient) List(ctx context.Context, input *ListJobsInput) (*ListJobsOutput, error) {
fullPath := path.Join("/", s.client.AccountName, "jobs")
query := &url.Values{}
if input.RunningOnly {
query.Set("state", "running")
}
if input.Limit != 0 {
query.Set("limit", strconv.FormatUint(input.Limit, 10))
}
... | [
"func",
"(",
"s",
"*",
"JobClient",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"input",
"*",
"ListJobsInput",
")",
"(",
"*",
"ListJobsOutput",
",",
"error",
")",
"{",
"fullPath",
":=",
"path",
".",
"Join",
"(",
"\"",
"\"",
",",
"s",
"... | // ListJobs returns the list of jobs you currently have. | [
"ListJobs",
"returns",
"the",
"list",
"of",
"jobs",
"you",
"currently",
"have",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/storage/job.go#L236-L285 |
141,940 | joyent/triton-go | storage/job.go | Get | func (s *JobClient) Get(ctx context.Context, input *GetJobInput) (*GetJobOutput, error) {
fullPath := path.Join("/", s.client.AccountName, "jobs", input.JobID, "live", "status")
reqInput := client.RequestInput{
Method: http.MethodGet,
Path: fullPath,
}
respBody, _, err := s.client.ExecuteRequestStorage(ctx, ... | go | func (s *JobClient) Get(ctx context.Context, input *GetJobInput) (*GetJobOutput, error) {
fullPath := path.Join("/", s.client.AccountName, "jobs", input.JobID, "live", "status")
reqInput := client.RequestInput{
Method: http.MethodGet,
Path: fullPath,
}
respBody, _, err := s.client.ExecuteRequestStorage(ctx, ... | [
"func",
"(",
"s",
"*",
"JobClient",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"input",
"*",
"GetJobInput",
")",
"(",
"*",
"GetJobOutput",
",",
"error",
")",
"{",
"fullPath",
":=",
"path",
".",
"Join",
"(",
"\"",
"\"",
",",
"s",
".",
... | // GetJob returns the list of jobs you currently have. | [
"GetJob",
"returns",
"the",
"list",
"of",
"jobs",
"you",
"currently",
"have",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/storage/job.go#L298-L322 |
141,941 | joyent/triton-go | identity/users.go | ChangeUserPassword | func (c *UsersClient) ChangeUserPassword(ctx context.Context, input *ChangeUserPasswordInput) (*User, error) {
fullPath := path.Join("/", c.Client.AccountName, "users", input.UserID, "change_password")
// Verify both values locally, and save on an unnecessary API call,
// but should the values be different, then re... | go | func (c *UsersClient) ChangeUserPassword(ctx context.Context, input *ChangeUserPasswordInput) (*User, error) {
fullPath := path.Join("/", c.Client.AccountName, "users", input.UserID, "change_password")
// Verify both values locally, and save on an unnecessary API call,
// but should the values be different, then re... | [
"func",
"(",
"c",
"*",
"UsersClient",
")",
"ChangeUserPassword",
"(",
"ctx",
"context",
".",
"Context",
",",
"input",
"*",
"ChangeUserPasswordInput",
")",
"(",
"*",
"User",
",",
"error",
")",
"{",
"fullPath",
":=",
"path",
".",
"Join",
"(",
"\"",
"\"",
... | // ChangeUserPassword updates password for an existing user. Returns updated
// user object, or an error otherwise. | [
"ChangeUserPassword",
"updates",
"password",
"for",
"an",
"existing",
"user",
".",
"Returns",
"updated",
"user",
"object",
"or",
"an",
"error",
"otherwise",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/identity/users.go#L210-L251 |
141,942 | joyent/triton-go | authentication/util.go | formatPublicKeyFingerprint | func formatPublicKeyFingerprint(key ssh.PublicKey, display bool) string {
publicKeyFingerprint := md5.New()
publicKeyFingerprint.Write(key.Marshal())
publicKeyFingerprintString := fmt.Sprintf("%x", publicKeyFingerprint.Sum(nil))
if !display {
return publicKeyFingerprintString
}
formatted := ""
for i := 0; i ... | go | func formatPublicKeyFingerprint(key ssh.PublicKey, display bool) string {
publicKeyFingerprint := md5.New()
publicKeyFingerprint.Write(key.Marshal())
publicKeyFingerprintString := fmt.Sprintf("%x", publicKeyFingerprint.Sum(nil))
if !display {
return publicKeyFingerprintString
}
formatted := ""
for i := 0; i ... | [
"func",
"formatPublicKeyFingerprint",
"(",
"key",
"ssh",
".",
"PublicKey",
",",
"display",
"bool",
")",
"string",
"{",
"publicKeyFingerprint",
":=",
"md5",
".",
"New",
"(",
")",
"\n",
"publicKeyFingerprint",
".",
"Write",
"(",
"key",
".",
"Marshal",
"(",
")"... | // formatPublicKeyFingerprint produces the MD5 fingerprint of the given SSH
// public key. If display is true, the fingerprint is formatted with colons
// between each byte, as per the output of OpenSSL. | [
"formatPublicKeyFingerprint",
"produces",
"the",
"MD5",
"fingerprint",
"of",
"the",
"given",
"SSH",
"public",
"key",
".",
"If",
"display",
"is",
"true",
"the",
"fingerprint",
"is",
"formatted",
"with",
"colons",
"between",
"each",
"byte",
"as",
"per",
"the",
"... | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/authentication/util.go#L22-L37 |
141,943 | joyent/triton-go | compute/client.go | NewClient | func NewClient(config *triton.ClientConfig) (*ComputeClient, error) {
// TODO: Utilize config interface within the function itself
client, err := client.New(
config.TritonURL,
config.MantaURL,
config.AccountName,
config.Signers...,
)
if err != nil {
return nil, err
}
return newComputeClient(client), nil... | go | func NewClient(config *triton.ClientConfig) (*ComputeClient, error) {
// TODO: Utilize config interface within the function itself
client, err := client.New(
config.TritonURL,
config.MantaURL,
config.AccountName,
config.Signers...,
)
if err != nil {
return nil, err
}
return newComputeClient(client), nil... | [
"func",
"NewClient",
"(",
"config",
"*",
"triton",
".",
"ClientConfig",
")",
"(",
"*",
"ComputeClient",
",",
"error",
")",
"{",
"// TODO: Utilize config interface within the function itself",
"client",
",",
"err",
":=",
"client",
".",
"New",
"(",
"config",
".",
... | // NewClient returns a new client for working with Compute endpoints and
// resources within CloudAPI | [
"NewClient",
"returns",
"a",
"new",
"client",
"for",
"working",
"with",
"Compute",
"endpoints",
"and",
"resources",
"within",
"CloudAPI"
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/compute/client.go#L30-L42 |
141,944 | joyent/triton-go | storage/signing.go | SignedURL | func (output *SignURLOutput) SignedURL(scheme string) string {
query := &url.Values{}
query.Set("algorithm", output.Algorithm)
query.Set("expires", output.Expires)
query.Set("keyId", output.KeyID)
query.Set("signature", output.Signature)
sUrl := url.URL{}
sUrl.Scheme = scheme
sUrl.Host = output.host
sUrl.Path... | go | func (output *SignURLOutput) SignedURL(scheme string) string {
query := &url.Values{}
query.Set("algorithm", output.Algorithm)
query.Set("expires", output.Expires)
query.Set("keyId", output.KeyID)
query.Set("signature", output.Signature)
sUrl := url.URL{}
sUrl.Scheme = scheme
sUrl.Host = output.host
sUrl.Path... | [
"func",
"(",
"output",
"*",
"SignURLOutput",
")",
"SignedURL",
"(",
"scheme",
"string",
")",
"string",
"{",
"query",
":=",
"&",
"url",
".",
"Values",
"{",
"}",
"\n",
"query",
".",
"Set",
"(",
"\"",
"\"",
",",
"output",
".",
"Algorithm",
")",
"\n",
... | // SignedURL returns a signed URL for the given scheme. Valid schemes are
// `http` and `https`. | [
"SignedURL",
"returns",
"a",
"signed",
"URL",
"for",
"the",
"given",
"scheme",
".",
"Valid",
"schemes",
"are",
"http",
"and",
"https",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/storage/signing.go#L44-L58 |
141,945 | joyent/triton-go | storage/signing.go | SignURL | func (s *StorageClient) SignURL(input *SignURLInput) (*SignURLOutput, error) {
output := &SignURLOutput{
host: s.Client.MantaURL.Host,
objectPath: fmt.Sprintf("/%s%s", s.Client.AccountName, input.ObjectPath),
Method: input.Method,
Algorithm: strings.ToUpper(s.Client.Authorizers[0].DefaultAlgorithm()... | go | func (s *StorageClient) SignURL(input *SignURLInput) (*SignURLOutput, error) {
output := &SignURLOutput{
host: s.Client.MantaURL.Host,
objectPath: fmt.Sprintf("/%s%s", s.Client.AccountName, input.ObjectPath),
Method: input.Method,
Algorithm: strings.ToUpper(s.Client.Authorizers[0].DefaultAlgorithm()... | [
"func",
"(",
"s",
"*",
"StorageClient",
")",
"SignURL",
"(",
"input",
"*",
"SignURLInput",
")",
"(",
"*",
"SignURLOutput",
",",
"error",
")",
"{",
"output",
":=",
"&",
"SignURLOutput",
"{",
"host",
":",
"s",
".",
"Client",
".",
"MantaURL",
".",
"Host",... | // SignURL creates a time-expiring URL that can be shared with others.
// This is useful to generate HTML links, for example. | [
"SignURL",
"creates",
"a",
"time",
"-",
"expiring",
"URL",
"that",
"can",
"be",
"shared",
"with",
"others",
".",
"This",
"is",
"useful",
"to",
"generate",
"HTML",
"links",
"for",
"example",
"."
] | 51ffac55286911651992b9327fb9c8a7e9aae665 | https://github.com/joyent/triton-go/blob/51ffac55286911651992b9327fb9c8a7e9aae665/storage/signing.go#L62-L90 |
141,946 | rs/xhandler | chain.go | Add | func (c *Chain) Add(f ...interface{}) {
for _, h := range f {
switch v := h.(type) {
case func(http.Handler) http.Handler:
c.Use(v)
case func(HandlerC) HandlerC:
c.UseC(v)
default:
panic("Adding invalid handler to the middleware chain")
}
}
} | go | func (c *Chain) Add(f ...interface{}) {
for _, h := range f {
switch v := h.(type) {
case func(http.Handler) http.Handler:
c.Use(v)
case func(HandlerC) HandlerC:
c.UseC(v)
default:
panic("Adding invalid handler to the middleware chain")
}
}
} | [
"func",
"(",
"c",
"*",
"Chain",
")",
"Add",
"(",
"f",
"...",
"interface",
"{",
"}",
")",
"{",
"for",
"_",
",",
"h",
":=",
"range",
"f",
"{",
"switch",
"v",
":=",
"h",
".",
"(",
"type",
")",
"{",
"case",
"func",
"(",
"http",
".",
"Handler",
... | // Add appends a variable number of additional middleware handlers
// to the middleware chain. Middleware handlers can either be
// context-aware or non-context aware handlers with the appropriate
// function signatures. | [
"Add",
"appends",
"a",
"variable",
"number",
"of",
"additional",
"middleware",
"handlers",
"to",
"the",
"middleware",
"chain",
".",
"Middleware",
"handlers",
"can",
"either",
"be",
"context",
"-",
"aware",
"or",
"non",
"-",
"context",
"aware",
"handlers",
"wit... | 1eb70cf1520d43c307a89c5dabb7a7efd132fccd | https://github.com/rs/xhandler/blob/1eb70cf1520d43c307a89c5dabb7a7efd132fccd/chain.go#L17-L28 |
141,947 | rs/xhandler | chain.go | With | func (c *Chain) With(f ...interface{}) *Chain {
n := make(Chain, len(*c))
copy(n, *c)
n.Add(f...)
return &n
} | go | func (c *Chain) With(f ...interface{}) *Chain {
n := make(Chain, len(*c))
copy(n, *c)
n.Add(f...)
return &n
} | [
"func",
"(",
"c",
"*",
"Chain",
")",
"With",
"(",
"f",
"...",
"interface",
"{",
"}",
")",
"*",
"Chain",
"{",
"n",
":=",
"make",
"(",
"Chain",
",",
"len",
"(",
"*",
"c",
")",
")",
"\n",
"copy",
"(",
"n",
",",
"*",
"c",
")",
"\n",
"n",
".",... | // With creates a new middleware chain from an existing chain,
// extending it with additional middleware. Middleware handlers
// can either be context-aware or non-context aware handlers
// with the appropriate function signatures. | [
"With",
"creates",
"a",
"new",
"middleware",
"chain",
"from",
"an",
"existing",
"chain",
"extending",
"it",
"with",
"additional",
"middleware",
".",
"Middleware",
"handlers",
"can",
"either",
"be",
"context",
"-",
"aware",
"or",
"non",
"-",
"context",
"aware",... | 1eb70cf1520d43c307a89c5dabb7a7efd132fccd | https://github.com/rs/xhandler/blob/1eb70cf1520d43c307a89c5dabb7a7efd132fccd/chain.go#L34-L39 |
141,948 | rs/xhandler | chain.go | UseC | func (c *Chain) UseC(f func(next HandlerC) HandlerC) {
*c = append(*c, f)
} | go | func (c *Chain) UseC(f func(next HandlerC) HandlerC) {
*c = append(*c, f)
} | [
"func",
"(",
"c",
"*",
"Chain",
")",
"UseC",
"(",
"f",
"func",
"(",
"next",
"HandlerC",
")",
"HandlerC",
")",
"{",
"*",
"c",
"=",
"append",
"(",
"*",
"c",
",",
"f",
")",
"\n",
"}"
] | // UseC appends a context-aware handler to the middleware chain. | [
"UseC",
"appends",
"a",
"context",
"-",
"aware",
"handler",
"to",
"the",
"middleware",
"chain",
"."
] | 1eb70cf1520d43c307a89c5dabb7a7efd132fccd | https://github.com/rs/xhandler/blob/1eb70cf1520d43c307a89c5dabb7a7efd132fccd/chain.go#L42-L44 |
141,949 | rs/xhandler | chain.go | HandlerCtx | func (c Chain) HandlerCtx(ctx context.Context, xh HandlerC) http.Handler {
return New(ctx, c.HandlerC(xh))
} | go | func (c Chain) HandlerCtx(ctx context.Context, xh HandlerC) http.Handler {
return New(ctx, c.HandlerC(xh))
} | [
"func",
"(",
"c",
"Chain",
")",
"HandlerCtx",
"(",
"ctx",
"context",
".",
"Context",
",",
"xh",
"HandlerC",
")",
"http",
".",
"Handler",
"{",
"return",
"New",
"(",
"ctx",
",",
"c",
".",
"HandlerC",
"(",
"xh",
")",
")",
"\n",
"}"
] | // HandlerCtx wraps the provided final handler with all the middleware appended to
// the chain and returns a new standard http.Handler instance. | [
"HandlerCtx",
"wraps",
"the",
"provided",
"final",
"handler",
"with",
"all",
"the",
"middleware",
"appended",
"to",
"the",
"chain",
"and",
"returns",
"a",
"new",
"standard",
"http",
".",
"Handler",
"instance",
"."
] | 1eb70cf1520d43c307a89c5dabb7a7efd132fccd | https://github.com/rs/xhandler/blob/1eb70cf1520d43c307a89c5dabb7a7efd132fccd/chain.go#L101-L103 |
141,950 | rs/xhandler | chain.go | HandlerC | func (c Chain) HandlerC(xh HandlerC) HandlerC {
for i := len(c) - 1; i >= 0; i-- {
xh = c[i](xh)
}
return xh
} | go | func (c Chain) HandlerC(xh HandlerC) HandlerC {
for i := len(c) - 1; i >= 0; i-- {
xh = c[i](xh)
}
return xh
} | [
"func",
"(",
"c",
"Chain",
")",
"HandlerC",
"(",
"xh",
"HandlerC",
")",
"HandlerC",
"{",
"for",
"i",
":=",
"len",
"(",
"c",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"xh",
"=",
"c",
"[",
"i",
"]",
"(",
"xh",
")",
"\n",
"}",... | // HandlerC wraps the provided final handler with all the middleware appended to
// the chain and returns a HandlerC instance. | [
"HandlerC",
"wraps",
"the",
"provided",
"final",
"handler",
"with",
"all",
"the",
"middleware",
"appended",
"to",
"the",
"chain",
"and",
"returns",
"a",
"HandlerC",
"instance",
"."
] | 1eb70cf1520d43c307a89c5dabb7a7efd132fccd | https://github.com/rs/xhandler/blob/1eb70cf1520d43c307a89c5dabb7a7efd132fccd/chain.go#L107-L112 |
141,951 | rs/xhandler | new.go | New | func New(ctx context.Context, h HandlerC) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.ServeHTTPC(ctx, w, r.WithContext(ctx))
})
} | go | func New(ctx context.Context, h HandlerC) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.ServeHTTPC(ctx, w, r.WithContext(ctx))
})
} | [
"func",
"New",
"(",
"ctx",
"context",
".",
"Context",
",",
"h",
"HandlerC",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",... | // New creates a conventional http.Handler injecting the provided root
// context to sub handlers. This handler is used as a bridge between conventional
// http.Handler and context aware handlers. | [
"New",
"creates",
"a",
"conventional",
"http",
".",
"Handler",
"injecting",
"the",
"provided",
"root",
"context",
"to",
"sub",
"handlers",
".",
"This",
"handler",
"is",
"used",
"as",
"a",
"bridge",
"between",
"conventional",
"http",
".",
"Handler",
"and",
"c... | 1eb70cf1520d43c307a89c5dabb7a7efd132fccd | https://github.com/rs/xhandler/blob/1eb70cf1520d43c307a89c5dabb7a7efd132fccd/new.go#L15-L19 |
141,952 | rs/xhandler | middleware.go | CloseHandler | func CloseHandler(next HandlerC) HandlerC {
return HandlerFuncC(func(ctx context.Context, w http.ResponseWriter, r *http.Request) {
// Cancel the context if the client closes the connection
if wcn, ok := w.(http.CloseNotifier); ok {
var cancel context.CancelFunc
ctx, cancel = context.WithCancel(ctx)
defer... | go | func CloseHandler(next HandlerC) HandlerC {
return HandlerFuncC(func(ctx context.Context, w http.ResponseWriter, r *http.Request) {
// Cancel the context if the client closes the connection
if wcn, ok := w.(http.CloseNotifier); ok {
var cancel context.CancelFunc
ctx, cancel = context.WithCancel(ctx)
defer... | [
"func",
"CloseHandler",
"(",
"next",
"HandlerC",
")",
"HandlerC",
"{",
"return",
"HandlerFuncC",
"(",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"// Cancel the co... | // CloseHandler returns a Handler, cancelling the context when the client
// connection closes unexpectedly. | [
"CloseHandler",
"returns",
"a",
"Handler",
"cancelling",
"the",
"context",
"when",
"the",
"client",
"connection",
"closes",
"unexpectedly",
"."
] | 1eb70cf1520d43c307a89c5dabb7a7efd132fccd | https://github.com/rs/xhandler/blob/1eb70cf1520d43c307a89c5dabb7a7efd132fccd/middleware.go#L12-L32 |
141,953 | rs/xhandler | middleware.go | If | func If(cond func(ctx context.Context, w http.ResponseWriter, r *http.Request) bool, condNext func(next HandlerC) HandlerC) func(next HandlerC) HandlerC {
return func(next HandlerC) HandlerC {
return HandlerFuncC(func(ctx context.Context, w http.ResponseWriter, r *http.Request) {
if cond(ctx, w, r) {
condNext... | go | func If(cond func(ctx context.Context, w http.ResponseWriter, r *http.Request) bool, condNext func(next HandlerC) HandlerC) func(next HandlerC) HandlerC {
return func(next HandlerC) HandlerC {
return HandlerFuncC(func(ctx context.Context, w http.ResponseWriter, r *http.Request) {
if cond(ctx, w, r) {
condNext... | [
"func",
"If",
"(",
"cond",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"bool",
",",
"condNext",
"func",
"(",
"next",
"HandlerC",
")",
"HandlerC",
")",
"func",
"("... | // If is a special handler that will skip insert the condNext handler only if a condition
// applies at runtime. | [
"If",
"is",
"a",
"special",
"handler",
"that",
"will",
"skip",
"insert",
"the",
"condNext",
"handler",
"only",
"if",
"a",
"condition",
"applies",
"at",
"runtime",
"."
] | 1eb70cf1520d43c307a89c5dabb7a7efd132fccd | https://github.com/rs/xhandler/blob/1eb70cf1520d43c307a89c5dabb7a7efd132fccd/middleware.go#L49-L59 |
141,954 | sha1sum/aws_signing_client | client.go | RoundTrip | func (s *Signer) RoundTrip(req *http.Request) (*http.Response, error) {
if h, ok := req.Header["Authorization"]; ok && len(h) > 0 && strings.HasPrefix(h[0], "AWS4") {
s.logger.Println("Received request to sign that is already signed. Skipping.")
return s.transport.RoundTrip(req)
}
s.logger.Printf("Receiving requ... | go | func (s *Signer) RoundTrip(req *http.Request) (*http.Response, error) {
if h, ok := req.Header["Authorization"]; ok && len(h) > 0 && strings.HasPrefix(h[0], "AWS4") {
s.logger.Println("Received request to sign that is already signed. Skipping.")
return s.transport.RoundTrip(req)
}
s.logger.Printf("Receiving requ... | [
"func",
"(",
"s",
"*",
"Signer",
")",
"RoundTrip",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"if",
"h",
",",
"ok",
":=",
"req",
".",
"Header",
"[",
"\"",
"\"",
"]",
";",
"ok",
"&&... | // RoundTrip implements the http.RoundTripper interface and is used to wrap HTTP requests in order to sign them for AWS
// API calls. The scheme for all requests will be changed to HTTPS. | [
"RoundTrip",
"implements",
"the",
"http",
".",
"RoundTripper",
"interface",
"and",
"is",
"used",
"to",
"wrap",
"HTTP",
"requests",
"in",
"order",
"to",
"sign",
"them",
"for",
"AWS",
"API",
"calls",
".",
"The",
"scheme",
"for",
"all",
"requests",
"will",
"b... | 9088e4c7b34b3174ae879fc975deb18ac62ac8d3 | https://github.com/sha1sum/aws_signing_client/blob/9088e4c7b34b3174ae879fc975deb18ac62ac8d3/client.go#L80-L129 |
141,955 | gogo/status | status.go | Proto | func (s *Status) Proto() *rpc.Status {
if s == nil {
return nil
}
return proto.Clone(s.s).(*rpc.Status)
} | go | func (s *Status) Proto() *rpc.Status {
if s == nil {
return nil
}
return proto.Clone(s.s).(*rpc.Status)
} | [
"func",
"(",
"s",
"*",
"Status",
")",
"Proto",
"(",
")",
"*",
"rpc",
".",
"Status",
"{",
"if",
"s",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"proto",
".",
"Clone",
"(",
"s",
".",
"s",
")",
".",
"(",
"*",
"rpc",
".",
"St... | // Proto returns s's status as an rpc.Status proto message. | [
"Proto",
"returns",
"s",
"s",
"status",
"as",
"an",
"rpc",
".",
"Status",
"proto",
"message",
"."
] | 935308aef7372e7685e8fbee162aae8f7a7e515a | https://github.com/gogo/status/blob/935308aef7372e7685e8fbee162aae8f7a7e515a/status.go#L91-L96 |
141,956 | gogo/status | status.go | New | func New(c codes.Code, msg string) *Status {
return &Status{s: &rpc.Status{Code: int32(c), Message: msg}}
} | go | func New(c codes.Code, msg string) *Status {
return &Status{s: &rpc.Status{Code: int32(c), Message: msg}}
} | [
"func",
"New",
"(",
"c",
"codes",
".",
"Code",
",",
"msg",
"string",
")",
"*",
"Status",
"{",
"return",
"&",
"Status",
"{",
"s",
":",
"&",
"rpc",
".",
"Status",
"{",
"Code",
":",
"int32",
"(",
"c",
")",
",",
"Message",
":",
"msg",
"}",
"}",
"... | // New returns a Status representing c and msg. | [
"New",
"returns",
"a",
"Status",
"representing",
"c",
"and",
"msg",
"."
] | 935308aef7372e7685e8fbee162aae8f7a7e515a | https://github.com/gogo/status/blob/935308aef7372e7685e8fbee162aae8f7a7e515a/status.go#L108-L110 |
141,957 | gogo/status | status.go | FromGRPCStatus | func FromGRPCStatus(st *status.Status) *Status {
p := st.Proto()
pb := &rpc.Status{
Code: p.GetCode(),
Message: p.GetMessage(),
}
for _, detail := range p.GetDetails() {
pb.Details = append(pb.GetDetails(), &types.Any{
TypeUrl: detail.GetTypeUrl(),
Value: detail.GetValue(),
})
}
return FromProt... | go | func FromGRPCStatus(st *status.Status) *Status {
p := st.Proto()
pb := &rpc.Status{
Code: p.GetCode(),
Message: p.GetMessage(),
}
for _, detail := range p.GetDetails() {
pb.Details = append(pb.GetDetails(), &types.Any{
TypeUrl: detail.GetTypeUrl(),
Value: detail.GetValue(),
})
}
return FromProt... | [
"func",
"FromGRPCStatus",
"(",
"st",
"*",
"status",
".",
"Status",
")",
"*",
"Status",
"{",
"p",
":=",
"st",
".",
"Proto",
"(",
")",
"\n",
"pb",
":=",
"&",
"rpc",
".",
"Status",
"{",
"Code",
":",
"p",
".",
"GetCode",
"(",
")",
",",
"Message",
"... | // FromGRPCStatus converts a grpc.Status to gogo.Status. | [
"FromGRPCStatus",
"converts",
"a",
"grpc",
".",
"Status",
"to",
"gogo",
".",
"Status",
"."
] | 935308aef7372e7685e8fbee162aae8f7a7e515a | https://github.com/gogo/status/blob/935308aef7372e7685e8fbee162aae8f7a7e515a/status.go#L151-L164 |
141,958 | gogo/status | status.go | WithDetails | func (s *Status) WithDetails(details ...proto.Message) (*Status, error) {
if s.Code() == codes.OK {
return nil, errors.New("no error details for status with code OK")
}
// s.Code() != OK implies that s.Proto() != nil.
p := s.Proto()
for _, detail := range details {
any, err := types.MarshalAny(detail)
if err... | go | func (s *Status) WithDetails(details ...proto.Message) (*Status, error) {
if s.Code() == codes.OK {
return nil, errors.New("no error details for status with code OK")
}
// s.Code() != OK implies that s.Proto() != nil.
p := s.Proto()
for _, detail := range details {
any, err := types.MarshalAny(detail)
if err... | [
"func",
"(",
"s",
"*",
"Status",
")",
"WithDetails",
"(",
"details",
"...",
"proto",
".",
"Message",
")",
"(",
"*",
"Status",
",",
"error",
")",
"{",
"if",
"s",
".",
"Code",
"(",
")",
"==",
"codes",
".",
"OK",
"{",
"return",
"nil",
",",
"errors",... | // WithDetails returns a new status with the provided details messages appended to the status.
// If any errors are encountered, it returns nil and the first error encountered. | [
"WithDetails",
"returns",
"a",
"new",
"status",
"with",
"the",
"provided",
"details",
"messages",
"appended",
"to",
"the",
"status",
".",
"If",
"any",
"errors",
"are",
"encountered",
"it",
"returns",
"nil",
"and",
"the",
"first",
"error",
"encountered",
"."
] | 935308aef7372e7685e8fbee162aae8f7a7e515a | https://github.com/gogo/status/blob/935308aef7372e7685e8fbee162aae8f7a7e515a/status.go#L175-L189 |
141,959 | gogo/status | status.go | Details | func (s *Status) Details() []interface{} {
if s == nil || s.s == nil {
return nil
}
details := make([]interface{}, 0, len(s.s.Details))
for _, any := range s.s.Details {
detail := &types.DynamicAny{}
if err := types.UnmarshalAny(any, detail); err != nil {
details = append(details, err)
continue
}
de... | go | func (s *Status) Details() []interface{} {
if s == nil || s.s == nil {
return nil
}
details := make([]interface{}, 0, len(s.s.Details))
for _, any := range s.s.Details {
detail := &types.DynamicAny{}
if err := types.UnmarshalAny(any, detail); err != nil {
details = append(details, err)
continue
}
de... | [
"func",
"(",
"s",
"*",
"Status",
")",
"Details",
"(",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"if",
"s",
"==",
"nil",
"||",
"s",
".",
"s",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"details",
":=",
"make",
"(",
"[",
"]",
"interfa... | // Details returns a slice of details messages attached to the status.
// If a detail cannot be decoded, the error is returned in place of the detail. | [
"Details",
"returns",
"a",
"slice",
"of",
"details",
"messages",
"attached",
"to",
"the",
"status",
".",
"If",
"a",
"detail",
"cannot",
"be",
"decoded",
"the",
"error",
"is",
"returned",
"in",
"place",
"of",
"the",
"detail",
"."
] | 935308aef7372e7685e8fbee162aae8f7a7e515a | https://github.com/gogo/status/blob/935308aef7372e7685e8fbee162aae8f7a7e515a/status.go#L193-L207 |
141,960 | gogo/status | status.go | Code | func Code(err error) codes.Code {
// Don't use FromError to avoid allocation of OK status.
if err == nil {
return codes.OK
}
if se, ok := err.(interface{ GRPCStatus() *status.Status }); ok {
return se.GRPCStatus().Code()
}
return codes.Unknown
} | go | func Code(err error) codes.Code {
// Don't use FromError to avoid allocation of OK status.
if err == nil {
return codes.OK
}
if se, ok := err.(interface{ GRPCStatus() *status.Status }); ok {
return se.GRPCStatus().Code()
}
return codes.Unknown
} | [
"func",
"Code",
"(",
"err",
"error",
")",
"codes",
".",
"Code",
"{",
"// Don't use FromError to avoid allocation of OK status.",
"if",
"err",
"==",
"nil",
"{",
"return",
"codes",
".",
"OK",
"\n",
"}",
"\n",
"if",
"se",
",",
"ok",
":=",
"err",
".",
"(",
"... | // Code returns the Code of the error if it is a Status error, codes.OK if err
// is nil, or codes.Unknown otherwise. | [
"Code",
"returns",
"the",
"Code",
"of",
"the",
"error",
"if",
"it",
"is",
"a",
"Status",
"error",
"codes",
".",
"OK",
"if",
"err",
"is",
"nil",
"or",
"codes",
".",
"Unknown",
"otherwise",
"."
] | 935308aef7372e7685e8fbee162aae8f7a7e515a | https://github.com/gogo/status/blob/935308aef7372e7685e8fbee162aae8f7a7e515a/status.go#L211-L220 |
141,961 | 99designs/basicauth-go | basicauth.go | New | func New(realm string, credentials map[string][]string) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
username, password, ok := r.BasicAuth()
if !ok {
unauthorized(w, realm)
return
}
validPas... | go | func New(realm string, credentials map[string][]string) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
username, password, ok := r.BasicAuth()
if !ok {
unauthorized(w, realm)
return
}
validPas... | [
"func",
"New",
"(",
"realm",
"string",
",",
"credentials",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"func",
"(",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
... | // New returns a piece of middleware that will allow access only
// if the provided credentials match within the given service
// otherwise it will return a 401 and not call the next handler. | [
"New",
"returns",
"a",
"piece",
"of",
"middleware",
"that",
"will",
"allow",
"access",
"only",
"if",
"the",
"provided",
"credentials",
"match",
"within",
"the",
"given",
"service",
"otherwise",
"it",
"will",
"return",
"a",
"401",
"and",
"not",
"call",
"the",... | 2a93ba0f464da2a77748a1dc2e9e5bea8bbdd4b9 | https://github.com/99designs/basicauth-go/blob/2a93ba0f464da2a77748a1dc2e9e5bea8bbdd4b9/basicauth.go#L11-L36 |
141,962 | jaschaephraim/lrserver | server.go | New | func New(name string, port uint16) *Server {
// Create router
router := http.NewServeMux()
logPrefix := "[" + name + "] "
// Create server
s := &Server{
name: name,
server: &http.Server{
Handler: router,
ErrorLog: log.New(os.Stderr, logPrefix, 0),
},
connSet: &connSet{conns: make(map[*conn]struc... | go | func New(name string, port uint16) *Server {
// Create router
router := http.NewServeMux()
logPrefix := "[" + name + "] "
// Create server
s := &Server{
name: name,
server: &http.Server{
Handler: router,
ErrorLog: log.New(os.Stderr, logPrefix, 0),
},
connSet: &connSet{conns: make(map[*conn]struc... | [
"func",
"New",
"(",
"name",
"string",
",",
"port",
"uint16",
")",
"*",
"Server",
"{",
"// Create router",
"router",
":=",
"http",
".",
"NewServeMux",
"(",
")",
"\n\n",
"logPrefix",
":=",
"\"",
"\"",
"+",
"name",
"+",
"\"",
"\"",
"\n\n",
"// Create server... | // New creates a new Server instance | [
"New",
"creates",
"a",
"new",
"Server",
"instance"
] | 50d19f603f71e0a914f23eea33124ba9717e7873 | https://github.com/jaschaephraim/lrserver/blob/50d19f603f71e0a914f23eea33124ba9717e7873/server.go#L27-L53 |
141,963 | jaschaephraim/lrserver | server.go | Reload | func (s *Server) Reload(file string) {
s.logStatus("requesting reload: " + file)
for conn := range s.connSet.conns {
conn.reloadChan <- file
}
} | go | func (s *Server) Reload(file string) {
s.logStatus("requesting reload: " + file)
for conn := range s.connSet.conns {
conn.reloadChan <- file
}
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Reload",
"(",
"file",
"string",
")",
"{",
"s",
".",
"logStatus",
"(",
"\"",
"\"",
"+",
"file",
")",
"\n",
"for",
"conn",
":=",
"range",
"s",
".",
"connSet",
".",
"conns",
"{",
"conn",
".",
"reloadChan",
"<-"... | // Reload sends a reload message to the client | [
"Reload",
"sends",
"a",
"reload",
"message",
"to",
"the",
"client"
] | 50d19f603f71e0a914f23eea33124ba9717e7873 | https://github.com/jaschaephraim/lrserver/blob/50d19f603f71e0a914f23eea33124ba9717e7873/server.go#L91-L96 |
141,964 | jaschaephraim/lrserver | server.go | Alert | func (s *Server) Alert(msg string) {
s.logStatus("requesting alert: " + msg)
for conn := range s.connSet.conns {
conn.alertChan <- msg
}
} | go | func (s *Server) Alert(msg string) {
s.logStatus("requesting alert: " + msg)
for conn := range s.connSet.conns {
conn.alertChan <- msg
}
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Alert",
"(",
"msg",
"string",
")",
"{",
"s",
".",
"logStatus",
"(",
"\"",
"\"",
"+",
"msg",
")",
"\n",
"for",
"conn",
":=",
"range",
"s",
".",
"connSet",
".",
"conns",
"{",
"conn",
".",
"alertChan",
"<-",
... | // Alert sends an alert message to the client | [
"Alert",
"sends",
"an",
"alert",
"message",
"to",
"the",
"client"
] | 50d19f603f71e0a914f23eea33124ba9717e7873 | https://github.com/jaschaephraim/lrserver/blob/50d19f603f71e0a914f23eea33124ba9717e7873/server.go#L99-L104 |
141,965 | jaschaephraim/lrserver | server.go | SetErrorLog | func (s *Server) SetErrorLog(l *log.Logger) {
s.server.ErrorLog = l
} | go | func (s *Server) SetErrorLog(l *log.Logger) {
s.server.ErrorLog = l
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"SetErrorLog",
"(",
"l",
"*",
"log",
".",
"Logger",
")",
"{",
"s",
".",
"server",
".",
"ErrorLog",
"=",
"l",
"\n",
"}"
] | // SetErrorLog sets the server's error logger,
// which can be set to nil | [
"SetErrorLog",
"sets",
"the",
"server",
"s",
"error",
"logger",
"which",
"can",
"be",
"set",
"to",
"nil"
] | 50d19f603f71e0a914f23eea33124ba9717e7873 | https://github.com/jaschaephraim/lrserver/blob/50d19f603f71e0a914f23eea33124ba9717e7873/server.go#L146-L148 |
141,966 | go-irc/irc | utils.go | MaskToRegex | func MaskToRegex(rawMask string) (*regexp.Regexp, error) {
input := bytes.NewBufferString(rawMask)
output := &bytes.Buffer{}
output.WriteByte('^')
for {
c, err := input.ReadByte()
if err != nil {
break
}
if c == '\\' {
c, err = input.ReadByte()
if err != nil {
output.WriteString(regexp.Quote... | go | func MaskToRegex(rawMask string) (*regexp.Regexp, error) {
input := bytes.NewBufferString(rawMask)
output := &bytes.Buffer{}
output.WriteByte('^')
for {
c, err := input.ReadByte()
if err != nil {
break
}
if c == '\\' {
c, err = input.ReadByte()
if err != nil {
output.WriteString(regexp.Quote... | [
"func",
"MaskToRegex",
"(",
"rawMask",
"string",
")",
"(",
"*",
"regexp",
".",
"Regexp",
",",
"error",
")",
"{",
"input",
":=",
"bytes",
".",
"NewBufferString",
"(",
"rawMask",
")",
"\n\n",
"output",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
... | // MaskToRegex converts an irc mask to a go Regexp for more convenient
// use. This should never return an error, but we have this here just
// in case. | [
"MaskToRegex",
"converts",
"an",
"irc",
"mask",
"to",
"a",
"go",
"Regexp",
"for",
"more",
"convenient",
"use",
".",
"This",
"should",
"never",
"return",
"an",
"error",
"but",
"we",
"have",
"this",
"here",
"just",
"in",
"case",
"."
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/utils.go#L16-L50 |
141,967 | go-irc/irc | parser.go | ParseTagValue | func ParseTagValue(v string) TagValue {
ret := &bytes.Buffer{}
input := bytes.NewBufferString(v)
for {
c, _, err := input.ReadRune()
if err != nil {
break
}
if c == '\\' {
c2, _, err := input.ReadRune()
// If we got a backslash then the end of the tag value, we should
// just ignore the backs... | go | func ParseTagValue(v string) TagValue {
ret := &bytes.Buffer{}
input := bytes.NewBufferString(v)
for {
c, _, err := input.ReadRune()
if err != nil {
break
}
if c == '\\' {
c2, _, err := input.ReadRune()
// If we got a backslash then the end of the tag value, we should
// just ignore the backs... | [
"func",
"ParseTagValue",
"(",
"v",
"string",
")",
"TagValue",
"{",
"ret",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n\n",
"input",
":=",
"bytes",
".",
"NewBufferString",
"(",
"v",
")",
"\n\n",
"for",
"{",
"c",
",",
"_",
",",
"err",
":=",
"inpu... | // ParseTagValue parses a TagValue from the connection. If you need to
// set a TagValue, you probably want to just set the string itself, so
// it will be encoded properly. | [
"ParseTagValue",
"parses",
"a",
"TagValue",
"from",
"the",
"connection",
".",
"If",
"you",
"need",
"to",
"set",
"a",
"TagValue",
"you",
"probably",
"want",
"to",
"just",
"set",
"the",
"string",
"itself",
"so",
"it",
"will",
"be",
"encoded",
"properly",
"."... | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/parser.go#L49-L80 |
141,968 | go-irc/irc | parser.go | Encode | func (v TagValue) Encode() string {
ret := &bytes.Buffer{}
for _, c := range v {
if replacement, ok := tagEncodeMap[c]; ok {
ret.WriteString(replacement)
} else {
ret.WriteRune(c)
}
}
return ret.String()
} | go | func (v TagValue) Encode() string {
ret := &bytes.Buffer{}
for _, c := range v {
if replacement, ok := tagEncodeMap[c]; ok {
ret.WriteString(replacement)
} else {
ret.WriteRune(c)
}
}
return ret.String()
} | [
"func",
"(",
"v",
"TagValue",
")",
"Encode",
"(",
")",
"string",
"{",
"ret",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n\n",
"for",
"_",
",",
"c",
":=",
"range",
"v",
"{",
"if",
"replacement",
",",
"ok",
":=",
"tagEncodeMap",
"[",
"c",
"]",
... | // Encode converts a TagValue to the format in the connection. | [
"Encode",
"converts",
"a",
"TagValue",
"to",
"the",
"format",
"in",
"the",
"connection",
"."
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/parser.go#L83-L95 |
141,969 | go-irc/irc | parser.go | ParseTags | func ParseTags(line string) Tags {
ret := Tags{}
tags := strings.Split(line, ";")
for _, tag := range tags {
parts := strings.SplitN(tag, "=", 2)
if len(parts) < 2 {
ret[parts[0]] = ""
continue
}
ret[parts[0]] = ParseTagValue(parts[1])
}
return ret
} | go | func ParseTags(line string) Tags {
ret := Tags{}
tags := strings.Split(line, ";")
for _, tag := range tags {
parts := strings.SplitN(tag, "=", 2)
if len(parts) < 2 {
ret[parts[0]] = ""
continue
}
ret[parts[0]] = ParseTagValue(parts[1])
}
return ret
} | [
"func",
"ParseTags",
"(",
"line",
"string",
")",
"Tags",
"{",
"ret",
":=",
"Tags",
"{",
"}",
"\n\n",
"tags",
":=",
"strings",
".",
"Split",
"(",
"line",
",",
"\"",
"\"",
")",
"\n",
"for",
"_",
",",
"tag",
":=",
"range",
"tags",
"{",
"parts",
":="... | // ParseTags takes a tag string and parses it into a tag map. It will
// always return a tag map, even if there are no valid tags. | [
"ParseTags",
"takes",
"a",
"tag",
"string",
"and",
"parses",
"it",
"into",
"a",
"tag",
"map",
".",
"It",
"will",
"always",
"return",
"a",
"tag",
"map",
"even",
"if",
"there",
"are",
"no",
"valid",
"tags",
"."
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/parser.go#L102-L117 |
141,970 | go-irc/irc | parser.go | GetTag | func (t Tags) GetTag(key string) (string, bool) {
ret, ok := t[key]
return string(ret), ok
} | go | func (t Tags) GetTag(key string) (string, bool) {
ret, ok := t[key]
return string(ret), ok
} | [
"func",
"(",
"t",
"Tags",
")",
"GetTag",
"(",
"key",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"ret",
",",
"ok",
":=",
"t",
"[",
"key",
"]",
"\n",
"return",
"string",
"(",
"ret",
")",
",",
"ok",
"\n",
"}"
] | // GetTag is a convenience method to look up a tag in the map. | [
"GetTag",
"is",
"a",
"convenience",
"method",
"to",
"look",
"up",
"a",
"tag",
"in",
"the",
"map",
"."
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/parser.go#L120-L123 |
141,971 | go-irc/irc | parser.go | Copy | func (t Tags) Copy() Tags {
ret := Tags{}
for k, v := range t {
ret[k] = v
}
return ret
} | go | func (t Tags) Copy() Tags {
ret := Tags{}
for k, v := range t {
ret[k] = v
}
return ret
} | [
"func",
"(",
"t",
"Tags",
")",
"Copy",
"(",
")",
"Tags",
"{",
"ret",
":=",
"Tags",
"{",
"}",
"\n\n",
"for",
"k",
",",
"v",
":=",
"range",
"t",
"{",
"ret",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n\n",
"return",
"ret",
"\n",
"}"
] | // Copy will create a new copy of all IRC tags attached to this
// message. | [
"Copy",
"will",
"create",
"a",
"new",
"copy",
"of",
"all",
"IRC",
"tags",
"attached",
"to",
"this",
"message",
"."
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/parser.go#L127-L135 |
141,972 | go-irc/irc | parser.go | ParsePrefix | func ParsePrefix(line string) *Prefix {
// Start by creating an Prefix with nothing but the host
id := &Prefix{
Name: line,
}
uh := strings.SplitN(id.Name, "@", 2)
if len(uh) == 2 {
id.Name, id.Host = uh[0], uh[1]
}
nu := strings.SplitN(id.Name, "!", 2)
if len(nu) == 2 {
id.Name, id.User = nu[0], nu[1]
... | go | func ParsePrefix(line string) *Prefix {
// Start by creating an Prefix with nothing but the host
id := &Prefix{
Name: line,
}
uh := strings.SplitN(id.Name, "@", 2)
if len(uh) == 2 {
id.Name, id.Host = uh[0], uh[1]
}
nu := strings.SplitN(id.Name, "!", 2)
if len(nu) == 2 {
id.Name, id.User = nu[0], nu[1]
... | [
"func",
"ParsePrefix",
"(",
"line",
"string",
")",
"*",
"Prefix",
"{",
"// Start by creating an Prefix with nothing but the host",
"id",
":=",
"&",
"Prefix",
"{",
"Name",
":",
"line",
",",
"}",
"\n\n",
"uh",
":=",
"strings",
".",
"SplitN",
"(",
"id",
".",
"N... | // ParsePrefix takes an identity string and parses it into an
// identity struct. It will always return an Prefix struct and never
// nil. | [
"ParsePrefix",
"takes",
"an",
"identity",
"string",
"and",
"parses",
"it",
"into",
"an",
"identity",
"struct",
".",
"It",
"will",
"always",
"return",
"an",
"Prefix",
"struct",
"and",
"never",
"nil",
"."
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/parser.go#L173-L190 |
141,973 | go-irc/irc | parser.go | Copy | func (p *Prefix) Copy() *Prefix {
if p == nil {
return nil
}
newPrefix := &Prefix{}
*newPrefix = *p
return newPrefix
} | go | func (p *Prefix) Copy() *Prefix {
if p == nil {
return nil
}
newPrefix := &Prefix{}
*newPrefix = *p
return newPrefix
} | [
"func",
"(",
"p",
"*",
"Prefix",
")",
"Copy",
"(",
")",
"*",
"Prefix",
"{",
"if",
"p",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"newPrefix",
":=",
"&",
"Prefix",
"{",
"}",
"\n\n",
"*",
"newPrefix",
"=",
"*",
"p",
"\n\n",
"return",
... | // Copy will create a new copy of an Prefix | [
"Copy",
"will",
"create",
"a",
"new",
"copy",
"of",
"an",
"Prefix"
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/parser.go#L193-L203 |
141,974 | go-irc/irc | parser.go | MustParseMessage | func MustParseMessage(line string) *Message {
m, err := ParseMessage(line)
if err != nil {
panic(err.Error())
}
return m
} | go | func MustParseMessage(line string) *Message {
m, err := ParseMessage(line)
if err != nil {
panic(err.Error())
}
return m
} | [
"func",
"MustParseMessage",
"(",
"line",
"string",
")",
"*",
"Message",
"{",
"m",
",",
"err",
":=",
"ParseMessage",
"(",
"line",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
... | // MustParseMessage calls ParseMessage and either returns the message
// or panics if an error is returned. | [
"MustParseMessage",
"calls",
"ParseMessage",
"and",
"either",
"returns",
"the",
"message",
"or",
"panics",
"if",
"an",
"error",
"is",
"returned",
"."
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/parser.go#L240-L246 |
141,975 | go-irc/irc | parser.go | Trailing | func (m *Message) Trailing() string {
if len(m.Params) < 1 {
return ""
}
return m.Params[len(m.Params)-1]
} | go | func (m *Message) Trailing() string {
if len(m.Params) < 1 {
return ""
}
return m.Params[len(m.Params)-1]
} | [
"func",
"(",
"m",
"*",
"Message",
")",
"Trailing",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"m",
".",
"Params",
")",
"<",
"1",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"m",
".",
"Params",
"[",
"len",
"(",
"m",
".",
"Params",
... | // Trailing returns the last argument in the Message or an empty string
// if there are no args | [
"Trailing",
"returns",
"the",
"last",
"argument",
"in",
"the",
"Message",
"or",
"an",
"empty",
"string",
"if",
"there",
"are",
"no",
"args"
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/parser.go#L320-L326 |
141,976 | go-irc/irc | parser.go | Copy | func (m *Message) Copy() *Message {
// Create a new message
newMessage := &Message{}
// Copy stuff from the old message
*newMessage = *m
// Copy any IRcv3 tags
newMessage.Tags = m.Tags.Copy()
// Copy the Prefix
newMessage.Prefix = m.Prefix.Copy()
// Copy the Params slice
newMessage.Params = append(make([]... | go | func (m *Message) Copy() *Message {
// Create a new message
newMessage := &Message{}
// Copy stuff from the old message
*newMessage = *m
// Copy any IRcv3 tags
newMessage.Tags = m.Tags.Copy()
// Copy the Prefix
newMessage.Prefix = m.Prefix.Copy()
// Copy the Params slice
newMessage.Params = append(make([]... | [
"func",
"(",
"m",
"*",
"Message",
")",
"Copy",
"(",
")",
"*",
"Message",
"{",
"// Create a new message",
"newMessage",
":=",
"&",
"Message",
"{",
"}",
"\n\n",
"// Copy stuff from the old message",
"*",
"newMessage",
"=",
"*",
"m",
"\n\n",
"// Copy any IRcv3 tags... | // Copy will create a new copy of an message | [
"Copy",
"will",
"create",
"a",
"new",
"copy",
"of",
"an",
"message"
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/parser.go#L329-L351 |
141,977 | go-irc/irc | client.go | NewClient | func NewClient(rw io.ReadWriter, config ClientConfig) *Client {
c := &Client{
Conn: NewConn(rw),
config: config,
errChan: make(chan error, 1),
caps: make(map[string]cap),
}
// Replace the writer writeCallback with one of our own
c.Conn.Writer.writeCallback = c.writeCallback
return c
} | go | func NewClient(rw io.ReadWriter, config ClientConfig) *Client {
c := &Client{
Conn: NewConn(rw),
config: config,
errChan: make(chan error, 1),
caps: make(map[string]cap),
}
// Replace the writer writeCallback with one of our own
c.Conn.Writer.writeCallback = c.writeCallback
return c
} | [
"func",
"NewClient",
"(",
"rw",
"io",
".",
"ReadWriter",
",",
"config",
"ClientConfig",
")",
"*",
"Client",
"{",
"c",
":=",
"&",
"Client",
"{",
"Conn",
":",
"NewConn",
"(",
"rw",
")",
",",
"config",
":",
"config",
",",
"errChan",
":",
"make",
"(",
... | // NewClient creates a client given an io stream and a client config. | [
"NewClient",
"creates",
"a",
"client",
"given",
"an",
"io",
"stream",
"and",
"a",
"client",
"config",
"."
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/client.go#L66-L78 |
141,978 | go-irc/irc | client.go | maybeStartLimiter | func (c *Client) maybeStartLimiter(wg *sync.WaitGroup, exiting chan struct{}) {
if c.config.SendLimit == 0 {
return
}
wg.Add(1)
// If SendBurst is 0, this will be unbuffered, so keep that in mind.
c.limiter = make(chan struct{}, c.config.SendBurst)
limitTick := time.NewTicker(c.config.SendLimit)
go func() {... | go | func (c *Client) maybeStartLimiter(wg *sync.WaitGroup, exiting chan struct{}) {
if c.config.SendLimit == 0 {
return
}
wg.Add(1)
// If SendBurst is 0, this will be unbuffered, so keep that in mind.
c.limiter = make(chan struct{}, c.config.SendBurst)
limitTick := time.NewTicker(c.config.SendLimit)
go func() {... | [
"func",
"(",
"c",
"*",
"Client",
")",
"maybeStartLimiter",
"(",
"wg",
"*",
"sync",
".",
"WaitGroup",
",",
"exiting",
"chan",
"struct",
"{",
"}",
")",
"{",
"if",
"c",
".",
"config",
".",
"SendLimit",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"wg"... | // maybeStartLimiter will start a ticker which will limit how quickly messages
// can be written to the connection if the SendLimit is set in the config. | [
"maybeStartLimiter",
"will",
"start",
"a",
"ticker",
"which",
"will",
"limit",
"how",
"quickly",
"messages",
"can",
"be",
"written",
"to",
"the",
"connection",
"if",
"the",
"SendLimit",
"is",
"set",
"in",
"the",
"config",
"."
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/client.go#L94-L125 |
141,979 | go-irc/irc | client.go | maybeStartPingLoop | func (c *Client) maybeStartPingLoop(wg *sync.WaitGroup, exiting chan struct{}) {
if c.config.PingFrequency <= 0 {
return
}
wg.Add(1)
c.incomingPongChan = make(chan string, 5)
go func() {
defer wg.Done()
pingHandlers := make(map[string]chan struct{})
ticker := time.NewTicker(c.config.PingFrequency)
d... | go | func (c *Client) maybeStartPingLoop(wg *sync.WaitGroup, exiting chan struct{}) {
if c.config.PingFrequency <= 0 {
return
}
wg.Add(1)
c.incomingPongChan = make(chan string, 5)
go func() {
defer wg.Done()
pingHandlers := make(map[string]chan struct{})
ticker := time.NewTicker(c.config.PingFrequency)
d... | [
"func",
"(",
"c",
"*",
"Client",
")",
"maybeStartPingLoop",
"(",
"wg",
"*",
"sync",
".",
"WaitGroup",
",",
"exiting",
"chan",
"struct",
"{",
"}",
")",
"{",
"if",
"c",
".",
"config",
".",
"PingFrequency",
"<=",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
... | // maybeStartPingLoop will start a goroutine to send out PING messages at the
// PingFrequency in the config if the frequency is not 0. | [
"maybeStartPingLoop",
"will",
"start",
"a",
"goroutine",
"to",
"send",
"out",
"PING",
"messages",
"at",
"the",
"PingFrequency",
"in",
"the",
"config",
"if",
"the",
"frequency",
"is",
"not",
"0",
"."
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/client.go#L129-L171 |
141,980 | go-irc/irc | client.go | maybeStartCapHandshake | func (c *Client) maybeStartCapHandshake() {
if len(c.caps) <= 0 {
return
}
c.Write("CAP LS")
c.remainingCapResponses = 1 // We count the CAP LS response as a normal response
for key, cap := range c.caps {
if cap.Requested {
c.Writef("CAP REQ :%s", key)
c.remainingCapResponses++
}
}
} | go | func (c *Client) maybeStartCapHandshake() {
if len(c.caps) <= 0 {
return
}
c.Write("CAP LS")
c.remainingCapResponses = 1 // We count the CAP LS response as a normal response
for key, cap := range c.caps {
if cap.Requested {
c.Writef("CAP REQ :%s", key)
c.remainingCapResponses++
}
}
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"maybeStartCapHandshake",
"(",
")",
"{",
"if",
"len",
"(",
"c",
".",
"caps",
")",
"<=",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"c",
".",
"Write",
"(",
"\"",
"\"",
")",
"\n",
"c",
".",
"remainingCapResponses",
... | // maybeStartCapHandshake will run a CAP LS and all the relevant CAP REQ
// commands if there are any CAPs requested. | [
"maybeStartCapHandshake",
"will",
"run",
"a",
"CAP",
"LS",
"and",
"all",
"the",
"relevant",
"CAP",
"REQ",
"commands",
"if",
"there",
"are",
"any",
"CAPs",
"requested",
"."
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/client.go#L193-L206 |
141,981 | go-irc/irc | client.go | CapRequest | func (c *Client) CapRequest(capName string, required bool) {
cap := c.caps[capName]
cap.Requested = true
cap.Required = cap.Required || required
c.caps[capName] = cap
} | go | func (c *Client) CapRequest(capName string, required bool) {
cap := c.caps[capName]
cap.Requested = true
cap.Required = cap.Required || required
c.caps[capName] = cap
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CapRequest",
"(",
"capName",
"string",
",",
"required",
"bool",
")",
"{",
"cap",
":=",
"c",
".",
"caps",
"[",
"capName",
"]",
"\n",
"cap",
".",
"Requested",
"=",
"true",
"\n",
"cap",
".",
"Required",
"=",
"cap... | // CapRequest allows you to request IRCv3 capabilities from the server during
// the handshake. The behavior is undefined if this is called before the
// handshake completes so it is recommended that this be called before Run. If
// the CAP is marked as required, the client will exit if that CAP could not be
// negotia... | [
"CapRequest",
"allows",
"you",
"to",
"request",
"IRCv3",
"capabilities",
"from",
"the",
"server",
"during",
"the",
"handshake",
".",
"The",
"behavior",
"is",
"undefined",
"if",
"this",
"is",
"called",
"before",
"the",
"handshake",
"completes",
"so",
"it",
"is"... | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/client.go#L213-L218 |
141,982 | go-irc/irc | client.go | CapEnabled | func (c *Client) CapEnabled(capName string) bool {
return c.caps[capName].Enabled
} | go | func (c *Client) CapEnabled(capName string) bool {
return c.caps[capName].Enabled
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CapEnabled",
"(",
"capName",
"string",
")",
"bool",
"{",
"return",
"c",
".",
"caps",
"[",
"capName",
"]",
".",
"Enabled",
"\n",
"}"
] | // CapEnabled allows you to check if a CAP is enabled for this connection. Note
// that it will not be populated until after the CAP handshake is done, so it is
// recommended to wait to check this until after a message like 001. | [
"CapEnabled",
"allows",
"you",
"to",
"check",
"if",
"a",
"CAP",
"is",
"enabled",
"for",
"this",
"connection",
".",
"Note",
"that",
"it",
"will",
"not",
"be",
"populated",
"until",
"after",
"the",
"CAP",
"handshake",
"is",
"done",
"so",
"it",
"is",
"recom... | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/client.go#L223-L225 |
141,983 | go-irc/irc | client.go | CapAvailable | func (c *Client) CapAvailable(capName string) bool {
return c.caps[capName].Available
} | go | func (c *Client) CapAvailable(capName string) bool {
return c.caps[capName].Available
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CapAvailable",
"(",
"capName",
"string",
")",
"bool",
"{",
"return",
"c",
".",
"caps",
"[",
"capName",
"]",
".",
"Available",
"\n",
"}"
] | // CapAvailable allows you to check if a CAP is available on this server. Note
// that it will not be populated until after the CAP handshake is done, so it is
// recommended to wait to check this until after a message like 001. | [
"CapAvailable",
"allows",
"you",
"to",
"check",
"if",
"a",
"CAP",
"is",
"available",
"on",
"this",
"server",
".",
"Note",
"that",
"it",
"will",
"not",
"be",
"populated",
"until",
"after",
"the",
"CAP",
"handshake",
"is",
"done",
"so",
"it",
"is",
"recomm... | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/client.go#L230-L232 |
141,984 | go-irc/irc | client.go | RunContext | func (c *Client) RunContext(ctx context.Context) error {
// exiting is used by the main goroutine here to ensure any sub-goroutines
// get closed when exiting.
exiting := make(chan struct{})
var wg sync.WaitGroup
c.maybeStartLimiter(&wg, exiting)
c.maybeStartPingLoop(&wg, exiting)
c.currentNick = c.config.Nick... | go | func (c *Client) RunContext(ctx context.Context) error {
// exiting is used by the main goroutine here to ensure any sub-goroutines
// get closed when exiting.
exiting := make(chan struct{})
var wg sync.WaitGroup
c.maybeStartLimiter(&wg, exiting)
c.maybeStartPingLoop(&wg, exiting)
c.currentNick = c.config.Nick... | [
"func",
"(",
"c",
"*",
"Client",
")",
"RunContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"// exiting is used by the main goroutine here to ensure any sub-goroutines",
"// get closed when exiting.",
"exiting",
":=",
"make",
"(",
"chan",
"struct",
"{"... | // RunContext is the same as Run but a context.Context can be passed in for
// cancelation. | [
"RunContext",
"is",
"the",
"same",
"as",
"Run",
"but",
"a",
"context",
".",
"Context",
"can",
"be",
"passed",
"in",
"for",
"cancelation",
"."
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/client.go#L275-L313 |
141,985 | go-irc/irc | client.go | FromChannel | func (c *Client) FromChannel(m *Message) bool {
if len(m.Params) < 1 {
return false
}
// The first param is the target, so if this doesn't match the current nick,
// the message came from a channel.
return m.Params[0] != c.currentNick
} | go | func (c *Client) FromChannel(m *Message) bool {
if len(m.Params) < 1 {
return false
}
// The first param is the target, so if this doesn't match the current nick,
// the message came from a channel.
return m.Params[0] != c.currentNick
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"FromChannel",
"(",
"m",
"*",
"Message",
")",
"bool",
"{",
"if",
"len",
"(",
"m",
".",
"Params",
")",
"<",
"1",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"// The first param is the target, so if this doesn't match the c... | // FromChannel takes a Message representing a PRIVMSG and returns if that
// message came from a channel or directly from a user. | [
"FromChannel",
"takes",
"a",
"Message",
"representing",
"a",
"PRIVMSG",
"and",
"returns",
"if",
"that",
"message",
"came",
"from",
"a",
"channel",
"or",
"directly",
"from",
"a",
"user",
"."
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/client.go#L323-L331 |
141,986 | go-irc/irc | conn.go | NewConn | func NewConn(rw io.ReadWriter) *Conn {
return &Conn{
NewReader(rw),
NewWriter(rw),
}
} | go | func NewConn(rw io.ReadWriter) *Conn {
return &Conn{
NewReader(rw),
NewWriter(rw),
}
} | [
"func",
"NewConn",
"(",
"rw",
"io",
".",
"ReadWriter",
")",
"*",
"Conn",
"{",
"return",
"&",
"Conn",
"{",
"NewReader",
"(",
"rw",
")",
",",
"NewWriter",
"(",
"rw",
")",
",",
"}",
"\n",
"}"
] | // NewConn creates a new Conn | [
"NewConn",
"creates",
"a",
"new",
"Conn"
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/conn.go#L17-L22 |
141,987 | go-irc/irc | conn.go | Write | func (w *Writer) Write(line string) error {
if w.DebugCallback != nil {
w.DebugCallback(line)
}
return w.writeCallback(w, line)
} | go | func (w *Writer) Write(line string) error {
if w.DebugCallback != nil {
w.DebugCallback(line)
}
return w.writeCallback(w, line)
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Write",
"(",
"line",
"string",
")",
"error",
"{",
"if",
"w",
".",
"DebugCallback",
"!=",
"nil",
"{",
"w",
".",
"DebugCallback",
"(",
"line",
")",
"\n",
"}",
"\n\n",
"return",
"w",
".",
"writeCallback",
"(",
"w... | // Write is a simple function which will write the given line to the
// underlying connection. | [
"Write",
"is",
"a",
"simple",
"function",
"which",
"will",
"write",
"the",
"given",
"line",
"to",
"the",
"underlying",
"connection",
"."
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/conn.go#L47-L53 |
141,988 | go-irc/irc | conn.go | Writef | func (w *Writer) Writef(format string, args ...interface{}) error {
return w.Write(fmt.Sprintf(format, args...))
} | go | func (w *Writer) Writef(format string, args ...interface{}) error {
return w.Write(fmt.Sprintf(format, args...))
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Writef",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"w",
".",
"Write",
"(",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
")",
"\n",
"}"... | // Writef is a wrapper around the connection's Write method and
// fmt.Sprintf. Simply use it to send a message as you would normally
// use fmt.Printf. | [
"Writef",
"is",
"a",
"wrapper",
"around",
"the",
"connection",
"s",
"Write",
"method",
"and",
"fmt",
".",
"Sprintf",
".",
"Simply",
"use",
"it",
"to",
"send",
"a",
"message",
"as",
"you",
"would",
"normally",
"use",
"fmt",
".",
"Printf",
"."
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/conn.go#L58-L60 |
141,989 | go-irc/irc | conn.go | WriteMessage | func (w *Writer) WriteMessage(m *Message) error {
return w.Write(m.String())
} | go | func (w *Writer) WriteMessage(m *Message) error {
return w.Write(m.String())
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"WriteMessage",
"(",
"m",
"*",
"Message",
")",
"error",
"{",
"return",
"w",
".",
"Write",
"(",
"m",
".",
"String",
"(",
")",
")",
"\n",
"}"
] | // WriteMessage writes the given message to the stream | [
"WriteMessage",
"writes",
"the",
"given",
"message",
"to",
"the",
"stream"
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/conn.go#L63-L65 |
141,990 | go-irc/irc | conn.go | NewReader | func NewReader(r io.Reader) *Reader {
return &Reader{
nil,
bufio.NewReader(r),
}
} | go | func NewReader(r io.Reader) *Reader {
return &Reader{
nil,
bufio.NewReader(r),
}
} | [
"func",
"NewReader",
"(",
"r",
"io",
".",
"Reader",
")",
"*",
"Reader",
"{",
"return",
"&",
"Reader",
"{",
"nil",
",",
"bufio",
".",
"NewReader",
"(",
"r",
")",
",",
"}",
"\n",
"}"
] | // NewReader creates an irc.Reader from an io.Reader. Note that once a reader is
// passed into this function, you should no longer use it as it is being used
// inside a bufio.Reader so you cannot rely on only the amount of data for a
// Message being read when you call ReadMessage. | [
"NewReader",
"creates",
"an",
"irc",
".",
"Reader",
"from",
"an",
"io",
".",
"Reader",
".",
"Note",
"that",
"once",
"a",
"reader",
"is",
"passed",
"into",
"this",
"function",
"you",
"should",
"no",
"longer",
"use",
"it",
"as",
"it",
"is",
"being",
"use... | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/conn.go#L83-L88 |
141,991 | go-irc/irc | conn.go | ReadMessage | func (r *Reader) ReadMessage() (*Message, error) {
line, err := r.reader.ReadString('\n')
if err != nil {
return nil, err
}
if r.DebugCallback != nil {
r.DebugCallback(line)
}
// Parse the message from our line
return ParseMessage(line)
} | go | func (r *Reader) ReadMessage() (*Message, error) {
line, err := r.reader.ReadString('\n')
if err != nil {
return nil, err
}
if r.DebugCallback != nil {
r.DebugCallback(line)
}
// Parse the message from our line
return ParseMessage(line)
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"ReadMessage",
"(",
")",
"(",
"*",
"Message",
",",
"error",
")",
"{",
"line",
",",
"err",
":=",
"r",
".",
"reader",
".",
"ReadString",
"(",
"'\\n'",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
... | // ReadMessage returns the next message from the stream or an error. | [
"ReadMessage",
"returns",
"the",
"next",
"message",
"from",
"the",
"stream",
"or",
"an",
"error",
"."
] | f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5 | https://github.com/go-irc/irc/blob/f252a88c7bbe6d60a27cc66f1a8b8211ab9aaab5/conn.go#L91-L103 |
141,992 | spf13/nitro | perf.go | resetTimer | func (b *B) resetTimer() {
if b.timerOn {
runtime.ReadMemStats(&memStats)
b.startAllocs = memStats.Mallocs
b.startBytes = memStats.TotalAlloc
b.start = time.Now()
}
b.duration = 0
b.netAllocs = 0
b.netBytes = 0
} | go | func (b *B) resetTimer() {
if b.timerOn {
runtime.ReadMemStats(&memStats)
b.startAllocs = memStats.Mallocs
b.startBytes = memStats.TotalAlloc
b.start = time.Now()
}
b.duration = 0
b.netAllocs = 0
b.netBytes = 0
} | [
"func",
"(",
"b",
"*",
"B",
")",
"resetTimer",
"(",
")",
"{",
"if",
"b",
".",
"timerOn",
"{",
"runtime",
".",
"ReadMemStats",
"(",
"&",
"memStats",
")",
"\n",
"b",
".",
"startAllocs",
"=",
"memStats",
".",
"Mallocs",
"\n",
"b",
".",
"startBytes",
"... | // ResetTimer sets the elapsed benchmark time to zero.
// It does not affect whether the timer is running. | [
"ResetTimer",
"sets",
"the",
"elapsed",
"benchmark",
"time",
"to",
"zero",
".",
"It",
"does",
"not",
"affect",
"whether",
"the",
"timer",
"is",
"running",
"."
] | 24d7ef30a12da0bdc5e2eb370a79c659ddccf0e8 | https://github.com/spf13/nitro/blob/24d7ef30a12da0bdc5e2eb370a79c659ddccf0e8/perf.go#L84-L94 |
141,993 | spf13/nitro | perf.go | Initialize | func Initialize() *B {
flag.BoolVar(&AnalysisOn, "stepAnalysis", false, "display memory and timing of different steps of the program")
b := &B{}
b.initialTime = time.Now()
runtime.GC()
b.resetTimer()
b.startTimer()
return b
} | go | func Initialize() *B {
flag.BoolVar(&AnalysisOn, "stepAnalysis", false, "display memory and timing of different steps of the program")
b := &B{}
b.initialTime = time.Now()
runtime.GC()
b.resetTimer()
b.startTimer()
return b
} | [
"func",
"Initialize",
"(",
")",
"*",
"B",
"{",
"flag",
".",
"BoolVar",
"(",
"&",
"AnalysisOn",
",",
"\"",
"\"",
",",
"false",
",",
"\"",
"\"",
")",
"\n\n",
"b",
":=",
"&",
"B",
"{",
"}",
"\n",
"b",
".",
"initialTime",
"=",
"time",
".",
"Now",
... | // Call this first to get the performance object
// Should be called at the top of your function. | [
"Call",
"this",
"first",
"to",
"get",
"the",
"performance",
"object",
"Should",
"be",
"called",
"at",
"the",
"top",
"of",
"your",
"function",
"."
] | 24d7ef30a12da0bdc5e2eb370a79c659ddccf0e8 | https://github.com/spf13/nitro/blob/24d7ef30a12da0bdc5e2eb370a79c659ddccf0e8/perf.go#L98-L107 |
141,994 | gosexy/gettext | gettext.go | SetLocale | func SetLocale(category uint, locale string) string {
clocale := C.CString(locale)
defer C.free(unsafe.Pointer(clocale))
return C.GoString(C.setlocale(C.int(category), clocale))
} | go | func SetLocale(category uint, locale string) string {
clocale := C.CString(locale)
defer C.free(unsafe.Pointer(clocale))
return C.GoString(C.setlocale(C.int(category), clocale))
} | [
"func",
"SetLocale",
"(",
"category",
"uint",
",",
"locale",
"string",
")",
"string",
"{",
"clocale",
":=",
"C",
".",
"CString",
"(",
"locale",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"clocale",
")",
")",
"\n\n",
"re... | // SetLocale sets the program's current locale. | [
"SetLocale",
"sets",
"the",
"program",
"s",
"current",
"locale",
"."
] | 74466a0a0c4a62fea38f44aa161d4bbfbe79dd6b | https://github.com/gosexy/gettext/blob/74466a0a0c4a62fea38f44aa161d4bbfbe79dd6b/gettext.go#L79-L84 |
141,995 | gosexy/gettext | gettext.go | BindTextdomain | func BindTextdomain(domainname string, dirname string) string {
cdirname := C.CString(dirname)
defer C.free(unsafe.Pointer(cdirname))
cdomainname := C.CString(domainname)
defer C.free(unsafe.Pointer(cdomainname))
return C.GoString(C.bindtextdomain(cdomainname, cdirname))
} | go | func BindTextdomain(domainname string, dirname string) string {
cdirname := C.CString(dirname)
defer C.free(unsafe.Pointer(cdirname))
cdomainname := C.CString(domainname)
defer C.free(unsafe.Pointer(cdomainname))
return C.GoString(C.bindtextdomain(cdomainname, cdirname))
} | [
"func",
"BindTextdomain",
"(",
"domainname",
"string",
",",
"dirname",
"string",
")",
"string",
"{",
"cdirname",
":=",
"C",
".",
"CString",
"(",
"dirname",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cdirname",
")",
")",
... | // BindTextdomain sets the directory containing message catalogs. | [
"BindTextdomain",
"sets",
"the",
"directory",
"containing",
"message",
"catalogs",
"."
] | 74466a0a0c4a62fea38f44aa161d4bbfbe79dd6b | https://github.com/gosexy/gettext/blob/74466a0a0c4a62fea38f44aa161d4bbfbe79dd6b/gettext.go#L87-L95 |
141,996 | gosexy/gettext | gettext.go | BindTextdomainCodeset | func BindTextdomainCodeset(domainname string, codeset string) string {
cdomainname := C.CString(domainname)
defer C.free(unsafe.Pointer(cdomainname))
ccodeset := C.CString(codeset)
defer C.free(unsafe.Pointer(ccodeset))
return C.GoString(C.bind_textdomain_codeset(cdomainname, ccodeset))
} | go | func BindTextdomainCodeset(domainname string, codeset string) string {
cdomainname := C.CString(domainname)
defer C.free(unsafe.Pointer(cdomainname))
ccodeset := C.CString(codeset)
defer C.free(unsafe.Pointer(ccodeset))
return C.GoString(C.bind_textdomain_codeset(cdomainname, ccodeset))
} | [
"func",
"BindTextdomainCodeset",
"(",
"domainname",
"string",
",",
"codeset",
"string",
")",
"string",
"{",
"cdomainname",
":=",
"C",
".",
"CString",
"(",
"domainname",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cdomainname",
... | // BindTextdomainCodeset sets the output codeset for message catalogs on the
// given domainname. | [
"BindTextdomainCodeset",
"sets",
"the",
"output",
"codeset",
"for",
"message",
"catalogs",
"on",
"the",
"given",
"domainname",
"."
] | 74466a0a0c4a62fea38f44aa161d4bbfbe79dd6b | https://github.com/gosexy/gettext/blob/74466a0a0c4a62fea38f44aa161d4bbfbe79dd6b/gettext.go#L99-L107 |
141,997 | gosexy/gettext | gettext.go | Textdomain | func Textdomain(domainname string) string {
cdomainname := C.CString(domainname)
defer C.free(unsafe.Pointer(cdomainname))
return C.GoString(C.textdomain(cdomainname))
} | go | func Textdomain(domainname string) string {
cdomainname := C.CString(domainname)
defer C.free(unsafe.Pointer(cdomainname))
return C.GoString(C.textdomain(cdomainname))
} | [
"func",
"Textdomain",
"(",
"domainname",
"string",
")",
"string",
"{",
"cdomainname",
":=",
"C",
".",
"CString",
"(",
"domainname",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cdomainname",
")",
")",
"\n\n",
"return",
"C",
... | // Textdomain sets or retrieves the current message domain. | [
"Textdomain",
"sets",
"or",
"retrieves",
"the",
"current",
"message",
"domain",
"."
] | 74466a0a0c4a62fea38f44aa161d4bbfbe79dd6b | https://github.com/gosexy/gettext/blob/74466a0a0c4a62fea38f44aa161d4bbfbe79dd6b/gettext.go#L110-L115 |
141,998 | gosexy/gettext | gettext.go | Gettext | func Gettext(msgid string) string {
cmsgid := C.CString(msgid)
defer C.free(unsafe.Pointer(cmsgid))
return C.GoString(C.gettext(cmsgid))
} | go | func Gettext(msgid string) string {
cmsgid := C.CString(msgid)
defer C.free(unsafe.Pointer(cmsgid))
return C.GoString(C.gettext(cmsgid))
} | [
"func",
"Gettext",
"(",
"msgid",
"string",
")",
"string",
"{",
"cmsgid",
":=",
"C",
".",
"CString",
"(",
"msgid",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cmsgid",
")",
")",
"\n\n",
"return",
"C",
".",
"GoString",
... | // Gettext attempts to translate a text string into the user's system language,
// by looking up the translation in a message catalog. | [
"Gettext",
"attempts",
"to",
"translate",
"a",
"text",
"string",
"into",
"the",
"user",
"s",
"system",
"language",
"by",
"looking",
"up",
"the",
"translation",
"in",
"a",
"message",
"catalog",
"."
] | 74466a0a0c4a62fea38f44aa161d4bbfbe79dd6b | https://github.com/gosexy/gettext/blob/74466a0a0c4a62fea38f44aa161d4bbfbe79dd6b/gettext.go#L119-L124 |
141,999 | gosexy/gettext | gettext.go | NGettext | func NGettext(msgid string, msgidPlural string, n uint64) string {
cmsgid := C.CString(msgid)
defer C.free(unsafe.Pointer(cmsgid))
cmsgidPlural := C.CString(msgidPlural)
defer C.free(unsafe.Pointer(cmsgidPlural))
return C.GoString(C.ngettext(cmsgid, cmsgidPlural, C.ulong(n)))
} | go | func NGettext(msgid string, msgidPlural string, n uint64) string {
cmsgid := C.CString(msgid)
defer C.free(unsafe.Pointer(cmsgid))
cmsgidPlural := C.CString(msgidPlural)
defer C.free(unsafe.Pointer(cmsgidPlural))
return C.GoString(C.ngettext(cmsgid, cmsgidPlural, C.ulong(n)))
} | [
"func",
"NGettext",
"(",
"msgid",
"string",
",",
"msgidPlural",
"string",
",",
"n",
"uint64",
")",
"string",
"{",
"cmsgid",
":=",
"C",
".",
"CString",
"(",
"msgid",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cmsgid",
"... | // NGettext attempts to translate a text string into the user's system
// language, by looking up the appropriate plural form of the translation in a
// message catalog. | [
"NGettext",
"attempts",
"to",
"translate",
"a",
"text",
"string",
"into",
"the",
"user",
"s",
"system",
"language",
"by",
"looking",
"up",
"the",
"appropriate",
"plural",
"form",
"of",
"the",
"translation",
"in",
"a",
"message",
"catalog",
"."
] | 74466a0a0c4a62fea38f44aa161d4bbfbe79dd6b | https://github.com/gosexy/gettext/blob/74466a0a0c4a62fea38f44aa161d4bbfbe79dd6b/gettext.go#L153-L161 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.