id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
listlengths 1
418
| pl_tokens
listlengths 22
4.98k
|
---|---|---|---|
19,400 | all-19401 | [
"ListBalancedNics",
"lists",
"balanced",
"nics"
]
| [
"func",
"(",
"c",
"*",
"Client",
")",
"ListBalancedNics",
"(",
"dcid",
",",
"lbalid",
"string",
")",
"(",
"*",
"Nics",
",",
"error",
")",
"{",
"url",
":=",
"balnicColPath",
"(",
"dcid",
",",
"lbalid",
")",
"+",
"`?depth=`",
"+",
"c",
".",
"client",
".",
"depth",
"+",
"`&pretty=`",
"+",
"strconv",
".",
"FormatBool",
"(",
"c",
".",
"client",
".",
"pretty",
")",
"\n",
"ret",
":=",
"&",
"Nics",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"client",
".",
"Get",
"(",
"<mask>",
",",
"ret",
",",
"http",
".",
"StatusOK",
")",
"\n",
"return",
"ret",
",",
"err",
"\n",
"}"
]
|
19,401 | all-19402 | [
"GetProducts",
"returns",
"all",
"products",
"available",
"to",
"the",
"agent",
"."
]
| [
"func",
"(",
"h",
"*",
"Handler",
")",
"GetProducts",
"(",
"tkn",
"string",
")",
"(",
"[",
"]",
"data",
".",
"Product",
",",
"error",
")",
"{",
"logger",
":=",
"h",
".",
"logger",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"if",
"!",
"h",
".",
"token",
".",
"Check",
"(",
"tkn",
")",
"{",
"logger",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
",",
"ErrAccessDenied",
"\n",
"}",
"\n\n",
"result",
",",
"err",
":=",
"h",
".",
"db",
".",
"SelectAllFrom",
"(",
"data",
".",
"ProductTable",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Error",
"(",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"nil",
",",
"ErrInternal",
"\n",
"}",
"\n\n",
"products",
":=",
"<mask>",
"(",
"[",
"]",
"data",
".",
"Product",
",",
"len",
"(",
"result",
")",
")",
"\n",
"for",
"i",
",",
"item",
":=",
"range",
"result",
"{",
"products",
"[",
"i",
"]",
"=",
"*",
"item",
".",
"(",
"*",
"data",
".",
"Product",
")",
"\n",
"}",
"\n\n",
"return",
"products",
",",
"nil",
"\n",
"}"
]
|
19,402 | all-19403 | [
"GetPageIterator",
"returns",
"an",
"iterator",
"which",
"can",
"be",
"used",
"to",
"retrieve",
"pages",
"."
]
| [
"func",
"(",
"cmps",
"*",
"CountryMessagingPriceService",
")",
"GetPageIterator",
"(",
"<mask>",
"url",
".",
"Values",
")",
"*",
"CountryPricePageIterator",
"{",
"iter",
":=",
"NewPageIterator",
"(",
"cmps",
".",
"client",
",",
"data",
",",
"messagingPathPart",
"+",
"\"",
"\"",
")",
"\n",
"return",
"&",
"CountryPricePageIterator",
"{",
"p",
":",
"iter",
",",
"}",
"\n",
"}"
]
|
19,403 | all-19404 | [
"Add",
"records",
"a",
"value",
"in",
"Badger",
"which",
"will",
"eventually",
"be",
"merged",
"by",
"a",
"background",
"routine",
"into",
"the",
"values",
"that",
"were",
"recorded",
"by",
"previous",
"invocations",
"to",
"Add",
"()",
"."
]
| [
"func",
"(",
"op",
"*",
"MergeOperator",
")",
"Add",
"(",
"val",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"op",
".",
"db",
".",
"Update",
"(",
"func",
"(",
"txn",
"*",
"Txn",
")",
"error",
"{",
"return",
"txn",
".",
"<mask>",
"(",
"op",
".",
"key",
",",
"val",
")",
"\n",
"}",
")",
"\n",
"}"
]
|
19,404 | all-19405 | [
"GetBool",
"returns",
"boolean",
"value",
"for",
"the",
"given",
"key",
".",
"true",
"is",
"returned",
"for",
"1",
"t",
"T",
"true",
"TRUE",
"True",
"y",
"yes",
"Y",
"YES",
"Yes",
"otherwise",
"false",
"is",
"returned",
"."
]
| [
"func",
"(",
"a",
"*",
"Args",
")",
"GetBool",
"(",
"<mask>",
"string",
")",
"bool",
"{",
"switch",
"b2s",
"(",
"a",
".",
"Peek",
"(",
"key",
")",
")",
"{",
"// Support the same true cases as strconv.ParseBool",
"// See: https://github.com/golang/go/blob/4e1b11e2c9bdb0ddea1141eed487be1a626ff5be/src/strconv/atob.go#L12",
"// and Y and Yes versions.",
"case",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
":",
"return",
"true",
"\n",
"default",
":",
"return",
"false",
"\n",
"}",
"\n",
"}"
]
|
19,405 | all-19406 | [
"Determine",
"the",
"historic",
"token",
"timestamp",
"representing",
"a",
"full",
"bucket"
]
| [
"func",
"(",
"tb",
"*",
"tokenBucket",
")",
"capacityToken",
"(",
")",
"<mask>",
".",
"Time",
"{",
"return",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"-",
"tb",
".",
"refillDuration",
")",
".",
"Truncate",
"(",
"tb",
".",
"tokenInterval",
")",
"\n",
"}"
]
|
19,406 | all-19407 | [
"transportNew",
"is",
"a",
"modified",
"copy",
"of",
"k8s",
".",
"io",
"/",
"kubernetes",
"/",
"pkg",
"/",
"client",
"/",
"transport",
".",
"New",
".",
"New",
"returns",
"an",
"http",
".",
"RoundTripper",
"that",
"will",
"provide",
"the",
"authentication",
"or",
"transport",
"level",
"security",
"defined",
"by",
"the",
"provided",
"Config",
"."
]
| [
"func",
"transportNew",
"(",
"config",
"*",
"restConfig",
")",
"(",
"http",
".",
"RoundTripper",
",",
"error",
")",
"{",
"// REMOVED: custom config.Transport support.",
"// Set transport level security",
"var",
"(",
"rt",
"http",
".",
"RoundTripper",
"\n",
"err",
"error",
"\n",
")",
"\n\n",
"rt",
",",
"err",
"=",
"tlsCacheGet",
"(",
"config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// REMOVED: HTTPWrappersForConfig(config, rt) in favor of the caller setting HTTP headers itself based on restConfig. Only this inlined check remains.",
"if",
"len",
"(",
"config",
".",
"Username",
")",
"!=",
"0",
"&&",
"len",
"(",
"config",
".",
"BearerToken",
")",
"!=",
"0",
"{",
"return",
"nil",
",",
"<mask>",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"rt",
",",
"nil",
"\n",
"}"
]
|
19,407 | all-19408 | [
"sendChange",
"adds",
"the",
"change",
"to",
"the",
"sendable",
"events",
"queue",
".",
"It",
"triggers",
"the",
"handler",
"s",
"submitTaskEvents",
"async",
"method",
"to",
"submit",
"this",
"change",
"if",
"there",
"s",
"no",
"go",
"routines",
"already",
"sending",
"changes",
"for",
"this",
"event",
"list"
]
| [
"func",
"(",
"taskEvents",
"*",
"taskSendableEvents",
")",
"sendChange",
"(",
"change",
"*",
"sendableEvent",
",",
"client",
"api",
".",
"ECSClient",
",",
"handler",
"*",
"TaskHandler",
")",
"{",
"taskEvents",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"taskEvents",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"// Add event to the queue",
"seelog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"<mask>",
".",
"toString",
"(",
")",
")",
"\n",
"taskEvents",
".",
"events",
".",
"PushBack",
"(",
"change",
")",
"\n\n",
"if",
"!",
"taskEvents",
".",
"sending",
"{",
"// If a send event is not already in progress, trigger the",
"// submitTaskEvents to start sending changes to ECS",
"taskEvents",
".",
"sending",
"=",
"true",
"\n",
"go",
"handler",
".",
"submitTaskEvents",
"(",
"taskEvents",
",",
"client",
",",
"change",
".",
"taskArn",
"(",
")",
")",
"\n",
"}",
"else",
"{",
"seelog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"change",
".",
"toString",
"(",
")",
")",
"\n",
"}",
"\n",
"}"
]
|
19,408 | all-19409 | [
"HasChildren",
"checks",
"to",
"see",
"if",
"a",
"datastore",
"cluster",
"has",
"any",
"child",
"items",
"(",
"datastores",
")",
"and",
"returns",
"true",
"if",
"that",
"is",
"the",
"case",
".",
"This",
"is",
"useful",
"when",
"checking",
"to",
"see",
"if",
"a",
"datastore",
"cluster",
"is",
"safe",
"to",
"delete",
"-",
"destroying",
"a",
"datastore",
"cluster",
"in",
"vSphere",
"destroys",
"*",
"all",
"*",
"children",
"if",
"at",
"all",
"possible",
"(",
"including",
"removing",
"datastores",
")",
"so",
"extra",
"verification",
"is",
"necessary",
"to",
"prevent",
"accidental",
"removal",
"."
]
| [
"func",
"HasChildren",
"(",
"pod",
"*",
"<mask>",
".",
"StoragePod",
")",
"(",
"bool",
",",
"error",
")",
"{",
"return",
"folder",
".",
"HasChildren",
"(",
"pod",
".",
"Folder",
")",
"\n",
"}"
]
|
19,409 | all-19410 | [
"RotateSimple",
"is",
"a",
"wrapper",
"around",
"gdk_pixbuf_rotate_simple",
"()",
"."
]
| [
"func",
"(",
"v",
"*",
"Pixbuf",
")",
"RotateSimple",
"(",
"angle",
"PixbufRotation",
")",
"(",
"*",
"Pixbuf",
",",
"error",
")",
"{",
"c",
":=",
"C",
".",
"gdk_pixbuf_rotate_simple",
"(",
"v",
".",
"native",
"(",
")",
",",
"C",
".",
"GdkPixbufRotation",
"(",
"<mask>",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n\n",
"obj",
":=",
"&",
"glib",
".",
"Object",
"{",
"glib",
".",
"ToGObject",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
"}",
"\n",
"p",
":=",
"&",
"Pixbuf",
"{",
"obj",
"}",
"\n",
"//obj.Ref()",
"runtime",
".",
"SetFinalizer",
"(",
"p",
",",
"func",
"(",
"_",
"interface",
"{",
"}",
")",
"{",
"obj",
".",
"Unref",
"(",
")",
"}",
")",
"\n",
"return",
"p",
",",
"nil",
"\n",
"}"
]
|
19,410 | all-19411 | [
"RemoveContainerReferenceFromImageState",
"removes",
"container",
"reference",
"from",
"the",
"corresponding",
"imageState",
"object"
]
| [
"func",
"(",
"imageManager",
"*",
"dockerImageManager",
")",
"RemoveContainerReferenceFromImageState",
"(",
"container",
"*",
"apicontainer",
".",
"Container",
")",
"error",
"{",
"// the image state has been updated, save the new state",
"defer",
"imageManager",
".",
"saver",
".",
"ForceSave",
"(",
")",
"\n",
"// this lock is for reading image states and finding the one that the container belongs to",
"imageManager",
".",
"updateLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"imageManager",
".",
"updateLock",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"container",
".",
"ImageID",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Find image state that this container is part of, and remove the reference",
"imageState",
",",
"ok",
":=",
"imageManager",
".",
"getImageState",
"(",
"container",
".",
"ImageID",
")",
"\n",
"if",
"!",
"<mask>",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"// Found matching ImageState",
"return",
"imageState",
".",
"RemoveContainerReference",
"(",
"container",
")",
"\n",
"}"
]
|
19,411 | all-19412 | [
"Value",
"converts",
"a",
"value",
"to",
"a",
"database",
"driver",
"value"
]
| [
"func",
"(",
"u",
"IPv4",
")",
"Value",
"(",
")",
"(",
"driver",
".",
"Value",
",",
"error",
")",
"{",
"return",
"<mask>",
".",
"Value",
"(",
"string",
"(",
"u",
")",
")",
",",
"nil",
"\n",
"}"
]
|
19,412 | all-19413 | [
"NewTracer",
"returns",
"a",
"new",
"tracer",
"with",
"the",
"specified",
"root",
"span",
"."
]
| [
"func",
"NewTracer",
"(",
"root",
"opentracing",
".",
"Span",
")",
"*",
"Tracer",
"{",
"return",
"&",
"Tracer",
"{",
"root",
":",
"<mask>",
",",
"spans",
":",
"make",
"(",
"[",
"]",
"opentracing",
".",
"Span",
",",
"0",
",",
"32",
")",
",",
"}",
"\n",
"}"
]
|
19,413 | all-19414 | [
"CheckInt64Bounds",
"verifies",
"that",
"v",
"is",
"within",
"min",
"and",
"max",
"t",
"represents",
"the",
"original",
"type",
"of",
"v",
"."
]
| [
"func",
"CheckInt64Bounds",
"(",
"v",
"int64",
",",
"min",
"int64",
",",
"max",
"uint64",
",",
"t",
"reflect",
".",
"Type",
")",
"(",
"err",
"error",
")",
"{",
"if",
"v",
"<",
"min",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"v",
",",
"min",
",",
"t",
")",
"\n",
"}",
"\n",
"if",
"v",
">",
"0",
"&&",
"uint64",
"(",
"v",
")",
">",
"max",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"v",
",",
"<mask>",
",",
"t",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
]
|
19,414 | all-19415 | [
"Convenience",
"function",
"around",
"Authenticate"
]
| [
"func",
"(",
"d",
"*",
"Daemon",
")",
"checkTrustedClient",
"(",
"r",
"*",
"<mask>",
".",
"Request",
")",
"error",
"{",
"trusted",
",",
"_",
",",
"_",
",",
"err",
":=",
"d",
".",
"Authenticate",
"(",
"r",
")",
"\n",
"if",
"!",
"trusted",
"||",
"err",
"!=",
"nil",
"{",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
|
19,415 | all-19416 | [
"Mutate",
"applies",
"the",
"provided",
"mutators",
"to",
"this",
"builder",
"s",
"payment",
"or",
"operation",
"."
]
| [
"func",
"(",
"b",
"*",
"PaymentBuilder",
")",
"Mutate",
"(",
"muts",
"...",
"interface",
"{",
"}",
")",
"{",
"for",
"_",
",",
"m",
":=",
"<mask>",
"muts",
"{",
"if",
"_",
",",
"ok",
":=",
"m",
".",
"(",
"PayWithPath",
")",
";",
"ok",
"{",
"b",
".",
"PathPayment",
"=",
"true",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"m",
":=",
"range",
"muts",
"{",
"var",
"err",
"error",
"\n",
"switch",
"mut",
":=",
"m",
".",
"(",
"type",
")",
"{",
"case",
"PaymentMutator",
":",
"if",
"b",
".",
"PathPayment",
"{",
"err",
"=",
"mut",
".",
"MutatePayment",
"(",
"&",
"b",
".",
"PP",
")",
"\n",
"}",
"else",
"{",
"err",
"=",
"mut",
".",
"MutatePayment",
"(",
"&",
"b",
".",
"P",
")",
"\n",
"}",
"\n",
"case",
"OperationMutator",
":",
"err",
"=",
"mut",
".",
"MutateOperation",
"(",
"&",
"b",
".",
"O",
")",
"\n",
"default",
":",
"err",
"=",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"b",
".",
"Err",
"=",
"err",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"}"
]
|
19,416 | all-19417 | [
"Call",
"checks",
"the",
"arguments",
"and",
"calls",
"Fn",
"if",
"they",
"are",
"valid"
]
| [
"func",
"(",
"w",
"Wrap",
")",
"Call",
"(",
"c",
"Ctx",
",",
"args",
"...",
"Result",
")",
"(",
"Result",
",",
"error",
")",
"{",
"switch",
"w",
".",
"LastArgOpt",
"{",
"case",
"Optional",
":",
"if",
"len",
"(",
"args",
")",
"==",
"w",
".",
"NArgs",
"||",
"len",
"(",
"args",
")",
"==",
"w",
".",
"NArgs",
"-",
"1",
"{",
"return",
"w",
".",
"Fn",
"(",
"c",
",",
"args",
"...",
")",
"\n",
"}",
"\n",
"case",
"Variadic",
":",
"if",
"len",
"(",
"args",
")",
">=",
"w",
".",
"NArgs",
"-",
"1",
"{",
"return",
"w",
".",
"Fn",
"(",
"c",
",",
"args",
"...",
")",
"\n",
"}",
"\n",
"<mask>",
":",
"if",
"len",
"(",
"args",
")",
"==",
"w",
".",
"NArgs",
"{",
"return",
"w",
".",
"Fn",
"(",
"c",
",",
"args",
"...",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}"
]
|
19,417 | all-19418 | [
"/",
"*",
"Returns",
"a",
"string",
"representing",
"this",
"expression",
"as",
"if",
"it",
"were",
"written",
"in",
"SQL",
".",
"This",
"function",
"assumes",
"that",
"all",
"parameters",
"exist",
"within",
"the",
"same",
"table",
"and",
"that",
"the",
"table",
"essentially",
"represents",
"a",
"serialized",
"object",
"of",
"some",
"sort",
"(",
"e",
".",
"g",
".",
"hibernate",
")",
".",
"If",
"your",
"data",
"model",
"is",
"more",
"normalized",
"you",
"may",
"need",
"to",
"consider",
"iterating",
"through",
"each",
"actual",
"token",
"given",
"by",
"Tokens",
"()",
"to",
"create",
"your",
"query",
"."
]
| [
"func",
"(",
"this",
"EvaluableExpression",
")",
"ToSQLQuery",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"<mask>",
"*",
"tokenStream",
"\n",
"var",
"transactions",
"*",
"expressionOutputStream",
"\n",
"var",
"transaction",
"string",
"\n",
"var",
"err",
"error",
"\n\n",
"stream",
"=",
"newTokenStream",
"(",
"this",
".",
"tokens",
")",
"\n",
"transactions",
"=",
"new",
"(",
"expressionOutputStream",
")",
"\n\n",
"for",
"stream",
".",
"hasNext",
"(",
")",
"{",
"transaction",
",",
"err",
"=",
"this",
".",
"findNextSQLString",
"(",
"stream",
",",
"transactions",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"transactions",
".",
"add",
"(",
"transaction",
")",
"\n",
"}",
"\n\n",
"return",
"transactions",
".",
"createString",
"(",
"\"",
"\"",
")",
",",
"nil",
"\n",
"}"
]
|
19,418 | all-19419 | [
"define",
"an",
"array",
"of",
"normals"
]
| [
"func",
"NormalPointer",
"(",
"xtype",
"uint32",
",",
"stride",
"int32",
",",
"<mask>",
"unsafe",
".",
"Pointer",
")",
"{",
"syscall",
".",
"Syscall",
"(",
"gpNormalPointer",
",",
"3",
",",
"uintptr",
"(",
"xtype",
")",
",",
"uintptr",
"(",
"stride",
")",
",",
"uintptr",
"(",
"pointer",
")",
")",
"\n",
"}"
]
|
19,419 | all-19420 | [
"shouldPrune",
"finds",
"comments",
"left",
"by",
"this",
"plugin",
"."
]
| [
"func",
"shouldPrune",
"(",
"log",
"*",
"logrus",
".",
"Entry",
",",
"botName",
"string",
")",
"func",
"(",
"github",
".",
"IssueComment",
")",
"bool",
"{",
"return",
"func",
"(",
"<mask>",
"github",
".",
"IssueComment",
")",
"bool",
"{",
"if",
"comment",
".",
"User",
".",
"Login",
"!=",
"botName",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"strings",
".",
"Contains",
"(",
"comment",
".",
"Body",
",",
"needsSIGMessage",
")",
"\n",
"}",
"\n",
"}"
]
|
19,420 | all-19421 | [
"SetProjectConfig",
"replaces",
"the",
"configuration",
"of",
"the",
"named",
"project",
"."
]
| [
"func",
"(",
"c",
"*",
"<mask>",
")",
"SetProjectConfig",
"(",
"projectName",
"string",
",",
"config",
"ProjectConfig",
")",
"error",
"{",
"return",
"c",
".",
"put",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"projectName",
",",
"\"",
"\"",
"}",
",",
"config",
",",
"nil",
",",
")",
"\n",
"}"
]
|
19,421 | all-19422 | [
"GetNameOk",
"returns",
"a",
"tuple",
"with",
"the",
"Name",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"l",
"*",
"LogSet",
")",
"GetNameOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"l",
"==",
"nil",
"||",
"l",
".",
"Name",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"l",
".",
"Name",
",",
"<mask>",
"\n",
"}"
]
|
19,422 | all-19423 | [
"/",
"*",
"points",
"can",
"be",
"either",
"CvSeq",
"*",
"or",
"CvMat",
"*"
]
| [
"func",
"FitEllipse2",
"(",
"points",
"unsafe",
".",
"Pointer",
")",
"Box2D",
"{",
"box",
":=",
"C",
".",
"cvFitEllipse2",
"(",
"points",
")",
"\n",
"center",
":=",
"Point2D32f",
"{",
"float32",
"(",
"box",
".",
"center",
".",
"x",
")",
",",
"float32",
"(",
"box",
".",
"<mask>",
".",
"y",
")",
"}",
"\n",
"size",
":=",
"Size2D32f",
"{",
"float32",
"(",
"box",
".",
"size",
".",
"width",
")",
",",
"float32",
"(",
"box",
".",
"size",
".",
"height",
")",
"}",
"\n",
"angle",
":=",
"float32",
"(",
"box",
".",
"angle",
")",
"\n",
"return",
"Box2D",
"{",
"center",
",",
"size",
",",
"angle",
"}",
"\n",
"}"
]
|
19,423 | all-19424 | [
"GetDefaultHost",
"obtains",
"the",
"first",
"IP",
"address",
"of",
"machine",
"from",
"the",
"routing",
"table",
"and",
"returns",
"the",
"IP",
"address",
"as",
"string",
".",
"An",
"IPv4",
"address",
"is",
"preferred",
"to",
"an",
"IPv6",
"address",
"for",
"backward",
"compatibility",
"."
]
| [
"func",
"GetDefaultHost",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"rmsgs",
",",
"rerr",
":=",
"getDefaultRoutes",
"(",
")",
"\n",
"if",
"rerr",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"rerr",
"\n",
"}",
"\n\n",
"// prioritize IPv4",
"if",
"rmsg",
",",
"ok",
":=",
"rmsgs",
"[",
"syscall",
".",
"AF_INET",
"]",
";",
"ok",
"{",
"if",
"host",
",",
"err",
":=",
"chooseHost",
"(",
"syscall",
".",
"AF_INET",
",",
"rmsg",
")",
";",
"host",
"!=",
"\"",
"\"",
"||",
"err",
"!=",
"nil",
"{",
"return",
"host",
",",
"err",
"\n",
"}",
"\n",
"delete",
"(",
"rmsgs",
",",
"syscall",
".",
"AF_INET",
")",
"\n",
"}",
"\n\n",
"// sort so choice is deterministic",
"var",
"families",
"[",
"]",
"int",
"\n",
"for",
"<mask>",
":=",
"range",
"rmsgs",
"{",
"families",
"=",
"append",
"(",
"families",
",",
"int",
"(",
"family",
")",
")",
"\n",
"}",
"\n",
"sort",
".",
"Ints",
"(",
"families",
")",
"\n\n",
"for",
"_",
",",
"f",
":=",
"range",
"families",
"{",
"family",
":=",
"uint8",
"(",
"f",
")",
"\n",
"if",
"host",
",",
"err",
":=",
"chooseHost",
"(",
"family",
",",
"rmsgs",
"[",
"family",
"]",
")",
";",
"host",
"!=",
"\"",
"\"",
"||",
"err",
"!=",
"nil",
"{",
"return",
"host",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"\"",
"\"",
",",
"errNoDefaultHost",
"\n",
"}"
]
|
19,424 | all-19425 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"EventDataCollected",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoTracing9",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
]
|
19,425 | all-19426 | [
"Stability",
":",
"***",
"EXPERIMENTAL",
"***",
"Returns",
"any",
"repository",
"metadata",
"that",
"is",
"useful",
"within",
"Taskcluster",
"related",
"services",
".",
"See",
"#repository"
]
| [
"func",
"(",
"github",
"*",
"Github",
")",
"Repository",
"(",
"owner",
",",
"repo",
"string",
")",
"(",
"*",
"RepositoryResponse",
",",
"error",
")",
"{",
"cd",
":=",
"tcclient",
".",
"Client",
"(",
"*",
"github",
")",
"\n",
"responseObject",
",",
"_",
",",
"err",
":=",
"(",
"&",
"<mask>",
")",
".",
"APICall",
"(",
"nil",
",",
"\"",
"\"",
",",
"\"",
"\"",
"+",
"url",
".",
"QueryEscape",
"(",
"owner",
")",
"+",
"\"",
"\"",
"+",
"url",
".",
"QueryEscape",
"(",
"repo",
")",
",",
"new",
"(",
"RepositoryResponse",
")",
",",
"nil",
")",
"\n",
"return",
"responseObject",
".",
"(",
"*",
"RepositoryResponse",
")",
",",
"err",
"\n",
"}"
]
|
19,426 | all-19427 | [
"/",
"*",
"ExitCode",
"returns",
"the",
"wrapped",
"command",
"s",
"exit",
"code",
".",
"If",
"the",
"command",
"hasn",
"t",
"exited",
"yet",
"ExitCode",
"returns",
"-",
"1",
"."
]
| [
"func",
"(",
"s",
"*",
"Session",
")",
"ExitCode",
"(",
")",
"int",
"{",
"s",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"<mask>",
".",
"Unlock",
"(",
")",
"\n",
"return",
"s",
".",
"exitCode",
"\n",
"}"
]
|
19,427 | all-19428 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"EventAuthRequired",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoFetch9",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
]
|
19,428 | all-19429 | [
"LookupGID",
"looks",
"up",
"a",
"group",
"by",
"group",
"ID",
"."
]
| [
"func",
"LookupGID",
"(",
"gid",
"int",
")",
"(",
"*",
"<mask>",
",",
"error",
")",
"{",
"entries",
",",
"err",
":=",
"LookupInGroup",
"(",
"G_GID",
",",
"gid",
",",
"1",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"entries",
"[",
"0",
"]",
",",
"err",
"\n",
"}"
]
|
19,429 | all-19430 | [
"Receive",
"receives",
"message",
"from",
"the",
"connection",
"."
]
| [
"func",
"(",
"c",
"*",
"Conn",
")",
"receive",
"(",
"<mask>",
"*",
"message",
")",
"error",
"{",
"if",
"!",
"c",
".",
"connected",
".",
"Load",
"(",
")",
".",
"(",
"bool",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"websocket",
".",
"JSON",
".",
"Receive",
"(",
"c",
".",
"ws",
".",
"Load",
"(",
")",
".",
"(",
"*",
"websocket",
".",
"Conn",
")",
",",
"&",
"msg",
")",
"\n",
"}"
]
|
19,430 | all-19431 | [
"Takes",
"an",
"IPv4",
"address",
"string",
"and",
"returns",
"the",
"organization",
"name",
"for",
"that",
"IP",
".",
"Requires",
"the",
"GeoIP",
"organization",
"database",
"."
]
| [
"func",
"(",
"gi",
"*",
"GeoIP",
")",
"GetOrg",
"(",
"ip",
"string",
")",
"string",
"{",
"name",
",",
"_",
":=",
"gi",
".",
"GetName",
"(",
"<mask>",
")",
"\n",
"return",
"name",
"\n",
"}"
]
|
19,431 | all-19432 | [
"Warningf",
"logs",
"provided",
"message",
"with",
"formatting",
"in",
"WARNING",
"level",
"."
]
| [
"func",
"(",
"logger",
"*",
"Logger",
")",
"Warningf",
"(",
"format",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"log",
"(",
"WARNING",
",",
"<mask>",
",",
"a",
"...",
")",
"\n",
"}"
]
|
19,432 | all-19433 | [
"native",
"()",
"returns",
"a",
"pointer",
"to",
"the",
"underlying",
"GSettings",
"."
]
| [
"func",
"(",
"v",
"*",
"Settings",
")",
"native",
"(",
")",
"*",
"C",
".",
"GSettings",
"{",
"if",
"v",
"==",
"nil",
"||",
"v",
".",
"GObject",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"<mask>",
"C",
".",
"toGSettings",
"(",
"unsafe",
".",
"Pointer",
"(",
"v",
".",
"GObject",
")",
")",
"\n",
"}"
]
|
19,433 | all-19434 | [
"DeleteContainerTemplateFile",
"deletes",
"a",
"template",
"file",
"for",
"a",
"container",
"."
]
| [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"DeleteContainerTemplateFile",
"(",
"<mask>",
"string",
",",
"templateName",
"string",
")",
"error",
"{",
"if",
"!",
"r",
".",
"HasExtension",
"(",
"\"",
"\"",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n",
"_",
",",
"_",
",",
"err",
":=",
"r",
".",
"query",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"url",
".",
"QueryEscape",
"(",
"name",
")",
",",
"url",
".",
"QueryEscape",
"(",
"templateName",
")",
")",
",",
"nil",
",",
"\"",
"\"",
")",
"\n",
"return",
"err",
"\n",
"}"
]
|
19,434 | all-19435 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"SearchInResourceReturns",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage15",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"<mask>",
"(",
")",
"\n",
"}"
]
|
19,435 | all-19436 | [
"newArrayBuffer",
"creates",
"OpenGL",
"s",
"buffer",
"object",
"for",
"the",
"array",
"buffer",
"."
]
| [
"func",
"(",
"a",
"*",
"arrayBufferLayout",
")",
"newArrayBuffer",
"(",
"context",
"*",
"<mask>",
")",
"buffer",
"{",
"return",
"context",
".",
"newArrayBuffer",
"(",
"a",
".",
"totalBytes",
"(",
")",
"*",
"graphics",
".",
"IndicesNum",
")",
"\n",
"}"
]
|
19,436 | all-19437 | [
"InsertPage",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_notebook_insert_page",
"()",
"."
]
| [
"func",
"(",
"v",
"*",
"Notebook",
")",
"InsertPage",
"(",
"child",
"IWidget",
",",
"tabLabel",
"IWidget",
",",
"position",
"int",
")",
"int",
"{",
"label",
":=",
"nullableWidget",
"(",
"tabLabel",
")",
"\n",
"c",
":=",
"C",
".",
"gtk_notebook_insert_page",
"(",
"v",
".",
"native",
"(",
")",
",",
"child",
".",
"toWidget",
"(",
")",
",",
"<mask>",
",",
"C",
".",
"gint",
"(",
"position",
")",
")",
"\n\n",
"return",
"int",
"(",
"c",
")",
"\n",
"}"
]
|
19,437 | all-19438 | [
"LoadSingleSecret",
"reads",
"and",
"returns",
"the",
"value",
"of",
"a",
"single",
"file",
"."
]
| [
"func",
"LoadSingleSecret",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"<mask>",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"bytes",
".",
"TrimSpace",
"(",
"b",
")",
",",
"nil",
"\n",
"}"
]
|
19,438 | all-19439 | [
"Match",
"checks",
"whether",
"a",
"zone",
"s",
"set",
"of",
"tags",
"matches",
"the",
"provided",
"tag",
"values"
]
| [
"func",
"(",
"f",
"ZoneTagFilter",
")",
"Match",
"(",
"tagsMap",
"map",
"[",
"string",
"]",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"tagFilter",
":=",
"range",
"f",
".",
"zoneTags",
"{",
"filterParts",
":=",
"strings",
".",
"SplitN",
"(",
"tagFilter",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"<mask>",
"len",
"(",
"filterParts",
")",
"{",
"case",
"1",
":",
"if",
"_",
",",
"hasTag",
":=",
"tagsMap",
"[",
"filterParts",
"[",
"0",
"]",
"]",
";",
"!",
"hasTag",
"{",
"return",
"false",
"\n",
"}",
"\n",
"case",
"2",
":",
"if",
"value",
",",
"hasTag",
":=",
"tagsMap",
"[",
"filterParts",
"[",
"0",
"]",
"]",
";",
"!",
"hasTag",
"||",
"value",
"!=",
"filterParts",
"[",
"1",
"]",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
]
|
19,439 | all-19440 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"RequestMemoryDumpReturns",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoTracing2",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
]
|
19,440 | all-19441 | [
"Handle",
"satisfies",
"hookHandler",
"."
]
| [
"func",
"(",
"b",
"BitbucketHook",
")",
"Handle",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"repo",
"*",
"Repo",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"!",
"b",
".",
"verifyBitbucketIP",
"(",
"r",
".",
"RemoteAddr",
")",
"{",
"return",
"http",
".",
"StatusForbidden",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"r",
".",
"Method",
"!=",
"\"",
"\"",
"{",
"return",
"http",
".",
"StatusMethodNotAllowed",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"body",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"r",
".",
"Body",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"http",
".",
"StatusRequestTimeout",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"event",
":=",
"r",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"event",
"==",
"\"",
"\"",
"{",
"return",
"http",
".",
"StatusBadRequest",
",",
"<mask>",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"switch",
"event",
"{",
"case",
"\"",
"\"",
":",
"err",
"=",
"b",
".",
"handlePush",
"(",
"body",
",",
"repo",
")",
"\n",
"if",
"!",
"hookIgnored",
"(",
"err",
")",
"&&",
"err",
"!=",
"nil",
"{",
"return",
"http",
".",
"StatusBadRequest",
",",
"err",
"\n",
"}",
"\n",
"default",
":",
"// return 400 if we do not handle the event type.",
"return",
"http",
".",
"StatusBadRequest",
",",
"nil",
"\n",
"}",
"\n\n",
"return",
"http",
".",
"StatusOK",
",",
"err",
"\n",
"}"
]
|
19,441 | all-19442 | [
"New",
"creates",
"a",
"StackdriverHook",
"using",
"the",
"provided",
"options",
"that",
"is",
"suitible",
"for",
"using",
"with",
"logrus",
"for",
"logging",
"to",
"Google",
"Stackdriver",
"."
]
| [
"func",
"New",
"(",
"opts",
"...",
"Option",
")",
"(",
"*",
"StackdriverHook",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"sh",
":=",
"&",
"StackdriverHook",
"{",
"levels",
":",
"logrus",
".",
"AllLevels",
",",
"}",
"\n\n",
"// apply opts",
"for",
"_",
",",
"o",
":=",
"range",
"opts",
"{",
"err",
"=",
"o",
"(",
"sh",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"// check service, resource, logName set",
"if",
"sh",
".",
"service",
"==",
"nil",
"&&",
"sh",
".",
"agentClient",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"sh",
".",
"<mask>",
"==",
"nil",
"&&",
"sh",
".",
"agentClient",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"sh",
".",
"projectID",
"==",
"\"",
"\"",
"&&",
"sh",
".",
"agentClient",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// set default project name",
"if",
"sh",
".",
"logName",
"==",
"\"",
"\"",
"{",
"err",
"=",
"LogName",
"(",
"DefaultName",
")",
"(",
"sh",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"// If error reporting log name not set, set it to log name",
"// plus string suffix",
"if",
"sh",
".",
"errorReportingLogName",
"==",
"\"",
"\"",
"{",
"sh",
".",
"errorReportingLogName",
"=",
"sh",
".",
"logName",
"+",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"sh",
",",
"nil",
"\n",
"}"
]
|
19,442 | all-19443 | [
"GetMustShowLatency",
"returns",
"the",
"MustShowLatency",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
]
| [
"func",
"(",
"w",
"*",
"Widget",
")",
"GetMustShowLatency",
"(",
")",
"bool",
"{",
"if",
"w",
"==",
"nil",
"||",
"w",
".",
"MustShowLatency",
"==",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"w",
".",
"MustShowLatency",
"\n",
"}"
]
|
19,443 | all-19444 | [
"URLParamFromCtx",
"returns",
"the",
"url",
"parameter",
"from",
"a",
"http",
".",
"Request",
"Context",
"."
]
| [
"func",
"URLParamFromCtx",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"string",
")",
"string",
"{",
"if",
"rctx",
":=",
"RouteContext",
"(",
"ctx",
")",
";",
"rctx",
"!=",
"nil",
"{",
"return",
"rctx",
".",
"URLParam",
"(",
"<mask>",
")",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
]
|
19,444 | all-19445 | [
"DisablePassiveSvcChecks",
"creates",
"a",
"new",
"DISABLE_PASSIVE_SVC_CHECKS",
"Nagios",
"command",
".",
"Disables",
"passive",
"checks",
"for",
"the",
"specified",
"service",
"."
]
| [
"func",
"DisablePassiveSvcChecks",
"(",
"host_name",
"<mask>",
",",
"service_description",
"string",
",",
")",
"*",
"livestatus",
".",
"Command",
"{",
"return",
"livestatus",
".",
"NewCommand",
"(",
"\"",
"\"",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"host_name",
")",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"service_description",
")",
",",
")",
"\n",
"}"
]
|
19,445 | all-19446 | [
"MustParse",
"is",
"like",
"Parse",
"but",
"panics",
"instead",
"of",
"returning",
"an",
"error",
"."
]
| [
"func",
"MustParse",
"(",
"xp",
"string",
")",
"XPathExec",
"{",
"<mask>",
",",
"err",
":=",
"Parse",
"(",
"xp",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"ret",
"\n",
"}"
]
|
19,446 | all-19447 | [
"Dispose",
"disposes",
"the",
"image",
".",
"After",
"disposing",
"calling",
"the",
"function",
"of",
"the",
"image",
"causes",
"unexpected",
"results",
"."
]
| [
"func",
"(",
"i",
"*",
"Image",
")",
"Dispose",
"(",
")",
"{",
"theImages",
".",
"<mask>",
"(",
"i",
")",
"\n\n",
"i",
".",
"image",
".",
"Dispose",
"(",
")",
"\n",
"i",
".",
"image",
"=",
"nil",
"\n",
"i",
".",
"basePixels",
"=",
"nil",
"\n",
"i",
".",
"drawTrianglesHistory",
"=",
"nil",
"\n",
"i",
".",
"stale",
"=",
"false",
"\n",
"}"
]
|
19,447 | all-19448 | [
"GetEditable",
"is",
"a",
"wrapper",
"around",
"gtk_editable_get_editable",
"()",
"."
]
| [
"func",
"(",
"v",
"*",
"Editable",
")",
"GetEditable",
"(",
")",
"bool",
"{",
"c",
":=",
"C",
".",
"gtk_editable_get_editable",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"<mask>",
"gobool",
"(",
"c",
")",
"\n",
"}"
]
|
19,448 | all-19449 | [
"sweepTask",
"deletes",
"all",
"the",
"containers",
"associated",
"with",
"a",
"task"
]
| [
"func",
"(",
"engine",
"*",
"DockerTaskEngine",
")",
"sweepTask",
"(",
"task",
"*",
"apitask",
".",
"<mask>",
")",
"{",
"for",
"_",
",",
"cont",
":=",
"range",
"task",
".",
"Containers",
"{",
"err",
":=",
"engine",
".",
"removeContainer",
"(",
"task",
",",
"cont",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"seelog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"task",
".",
"Arn",
",",
"cont",
".",
"Name",
",",
"err",
")",
"\n",
"}",
"\n",
"// Internal container(created by ecs-agent) state isn't recorded",
"if",
"cont",
".",
"IsInternal",
"(",
")",
"{",
"continue",
"\n",
"}",
"\n",
"err",
"=",
"engine",
".",
"imageManager",
".",
"RemoveContainerReferenceFromImageState",
"(",
"cont",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"seelog",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"task",
".",
"Arn",
",",
"cont",
".",
"Name",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Clean metadata directory for task",
"if",
"engine",
".",
"cfg",
".",
"ContainerMetadataEnabled",
"{",
"err",
":=",
"engine",
".",
"metadataManager",
".",
"Clean",
"(",
"task",
".",
"Arn",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"seelog",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"task",
".",
"Arn",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"engine",
".",
"saver",
".",
"Save",
"(",
")",
"\n",
"}"
]
|
19,449 | all-19450 | [
"SubstituteRune",
"substitutes",
"string",
"chars",
"with",
"provided",
"rune",
"substitution",
"map",
".",
"One",
"pass",
"."
]
| [
"func",
"SubstituteRune",
"(",
"s",
"string",
",",
"sub",
"map",
"[",
"rune",
"]",
"string",
")",
"string",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"s",
"{",
"if",
"d",
",",
"ok",
":=",
"sub",
"[",
"c",
"]",
";",
"<mask>",
"{",
"buf",
".",
"WriteString",
"(",
"d",
")",
"\n",
"}",
"else",
"{",
"buf",
".",
"WriteRune",
"(",
"c",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"buf",
".",
"String",
"(",
")",
"\n",
"}"
]
|
19,450 | all-19451 | [
"DelAttr",
"removes",
"the",
"named",
"attribute",
"from",
"the",
"rule",
"."
]
| [
"func",
"(",
"r",
"*",
"Rule",
")",
"DelAttr",
"(",
"key",
"string",
")",
"{",
"delete",
"(",
"r",
".",
"attrs",
",",
"key",
")",
"\n",
"r",
".",
"updated",
"=",
"<mask>",
"\n",
"}"
]
|
19,451 | all-19452 | [
"NewKV",
"wraps",
"a",
"KV",
"instance",
"so",
"that",
"all",
"requests",
"are",
"prefixed",
"with",
"a",
"given",
"string",
"."
]
| [
"func",
"NewKV",
"(",
"kv",
"clientv3",
".",
"KV",
",",
"<mask>",
"string",
")",
"clientv3",
".",
"KV",
"{",
"return",
"&",
"kvPrefix",
"{",
"kv",
",",
"prefix",
"}",
"\n",
"}"
]
|
19,452 | all-19453 | [
"Restore",
"from",
"dump",
".",
"path"
]
| [
"func",
"(",
"app",
"*",
"App",
")",
"Restore",
"(",
"storeFunc",
"func",
"(",
"*",
"<mask>",
".",
"Points",
")",
",",
"path",
"string",
",",
"rps",
"int",
")",
"{",
"if",
"rps",
">",
"0",
"{",
"ticker",
":=",
"persister",
".",
"NewThrottleTicker",
"(",
"rps",
")",
"\n",
"defer",
"ticker",
".",
"Stop",
"(",
")",
"\n\n",
"throttledStoreFunc",
":=",
"func",
"(",
"p",
"*",
"points",
".",
"Points",
")",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"p",
".",
"Data",
")",
";",
"i",
"++",
"{",
"<-",
"ticker",
".",
"C",
"\n",
"}",
"\n",
"storeFunc",
"(",
"p",
")",
"\n",
"}",
"\n\n",
"app",
".",
"RestoreFromDir",
"(",
"path",
",",
"throttledStoreFunc",
")",
"\n",
"}",
"else",
"{",
"app",
".",
"RestoreFromDir",
"(",
"path",
",",
"storeFunc",
")",
"\n",
"}",
"\n",
"}"
]
|
19,453 | all-19454 | [
"CmderWithPrependedArgs",
"returns",
"a",
"new",
"Cmder",
"that",
"invokes",
"the",
"provided",
"Cmder",
"but",
"always",
"adds",
"the",
"provided",
"prependedArgs",
"before",
"any",
"user",
"-",
"supplied",
"arguments",
".",
"Note",
"that",
"if",
"the",
"runner",
"being",
"wrapped",
"has",
"a",
"notion",
"of",
"prependedArgs",
"itself",
"those",
"arguments",
"will",
"precede",
"the",
"prependedArgs",
"provided",
"in",
"this",
"method",
"."
]
| [
"func",
"CmderWithPrependedArgs",
"(",
"r",
"Cmder",
",",
"prependedArgs",
"...",
"string",
")",
"Cmder",
"{",
"<mask>",
"&",
"wrappedCmder",
"{",
"inner",
":",
"r",
",",
"prependedArgs",
":",
"prependedArgs",
",",
"}",
"\n",
"}"
]
|
19,454 | all-19455 | [
"IdentifyParams",
"organizes",
"the",
"given",
"params",
"in",
"two",
"groups",
":",
"the",
"payload",
"params",
"and",
"the",
"query",
"params",
"."
]
| [
"func",
"IdentifyParams",
"(",
"a",
"*",
"metadata",
".",
"Action",
",",
"params",
"APIParams",
")",
"(",
"payloadParams",
"APIParams",
",",
"queryParams",
"APIParams",
")",
"{",
"payloadParamNames",
":=",
"a",
".",
"PayloadParamNames",
"(",
")",
"\n",
"payloadParams",
"=",
"make",
"(",
"APIParams",
")",
"\n",
"for",
"_",
",",
"n",
":=",
"range",
"payloadParamNames",
"{",
"if",
"p",
",",
"ok",
":=",
"params",
"[",
"n",
"]",
";",
"ok",
"{",
"payloadParams",
"[",
"n",
"]",
"=",
"p",
"\n",
"}",
"\n",
"}",
"\n",
"queryParamNames",
":=",
"a",
".",
"QueryParamNames",
"(",
")",
"\n",
"queryParams",
"=",
"make",
"(",
"APIParams",
")",
"\n",
"for",
"_",
",",
"n",
":=",
"range",
"queryParamNames",
"{",
"if",
"p",
",",
"<mask>",
":=",
"params",
"[",
"n",
"]",
";",
"ok",
"{",
"queryParams",
"[",
"n",
"]",
"=",
"p",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"payloadParams",
",",
"queryParams",
"\n",
"}"
]
|
19,455 | all-19456 | [
"sync",
"takes",
"a",
"list",
"of",
"potentially",
"duplicated",
"targets",
"deduplicates",
"them",
"starts",
"scrape",
"loops",
"for",
"new",
"targets",
"and",
"stops",
"scrape",
"loops",
"for",
"disappeared",
"targets",
".",
"It",
"returns",
"after",
"all",
"stopped",
"scrape",
"loops",
"terminated",
"."
]
| [
"func",
"(",
"sp",
"*",
"scrapePool",
")",
"sync",
"(",
"targets",
"[",
"]",
"*",
"Target",
")",
"{",
"sp",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"sp",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"<mask>",
"(",
"uniqueTargets",
"=",
"map",
"[",
"uint64",
"]",
"struct",
"{",
"}",
"{",
"}",
"\n",
"interval",
"=",
"time",
".",
"Duration",
"(",
"sp",
".",
"config",
".",
"ScrapeInterval",
")",
"\n",
"timeout",
"=",
"time",
".",
"Duration",
"(",
"sp",
".",
"config",
".",
"ScrapeTimeout",
")",
"\n",
"limit",
"=",
"int",
"(",
"sp",
".",
"config",
".",
"SampleLimit",
")",
"\n",
"honorLabels",
"=",
"sp",
".",
"config",
".",
"HonorLabels",
"\n",
"honorTimestamps",
"=",
"sp",
".",
"config",
".",
"HonorTimestamps",
"\n",
"mrc",
"=",
"sp",
".",
"config",
".",
"MetricRelabelConfigs",
"\n",
")",
"\n\n",
"for",
"_",
",",
"t",
":=",
"range",
"targets",
"{",
"t",
":=",
"t",
"\n",
"hash",
":=",
"t",
".",
"hash",
"(",
")",
"\n",
"uniqueTargets",
"[",
"hash",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n\n",
"if",
"_",
",",
"ok",
":=",
"sp",
".",
"activeTargets",
"[",
"hash",
"]",
";",
"!",
"ok",
"{",
"s",
":=",
"&",
"targetScraper",
"{",
"Target",
":",
"t",
",",
"client",
":",
"sp",
".",
"client",
",",
"timeout",
":",
"timeout",
"}",
"\n",
"l",
":=",
"sp",
".",
"newLoop",
"(",
"scrapeLoopOptions",
"{",
"target",
":",
"t",
",",
"scraper",
":",
"s",
",",
"limit",
":",
"limit",
",",
"honorLabels",
":",
"honorLabels",
",",
"honorTimestamps",
":",
"honorTimestamps",
",",
"mrc",
":",
"mrc",
",",
"}",
")",
"\n\n",
"sp",
".",
"activeTargets",
"[",
"hash",
"]",
"=",
"t",
"\n",
"sp",
".",
"loops",
"[",
"hash",
"]",
"=",
"l",
"\n\n",
"go",
"l",
".",
"run",
"(",
"interval",
",",
"timeout",
",",
"nil",
")",
"\n",
"}",
"else",
"{",
"// Need to keep the most updated labels information",
"// for displaying it in the Service Discovery web page.",
"sp",
".",
"activeTargets",
"[",
"hash",
"]",
".",
"SetDiscoveredLabels",
"(",
"t",
".",
"DiscoveredLabels",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n\n",
"// Stop and remove old targets and scraper loops.",
"for",
"hash",
":=",
"range",
"sp",
".",
"activeTargets",
"{",
"if",
"_",
",",
"ok",
":=",
"uniqueTargets",
"[",
"hash",
"]",
";",
"!",
"ok",
"{",
"wg",
".",
"Add",
"(",
"1",
")",
"\n",
"go",
"func",
"(",
"l",
"loop",
")",
"{",
"l",
".",
"stop",
"(",
")",
"\n\n",
"wg",
".",
"Done",
"(",
")",
"\n",
"}",
"(",
"sp",
".",
"loops",
"[",
"hash",
"]",
")",
"\n\n",
"delete",
"(",
"sp",
".",
"loops",
",",
"hash",
")",
"\n",
"delete",
"(",
"sp",
".",
"activeTargets",
",",
"hash",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Wait for all potentially stopped scrapers to terminate.",
"// This covers the case of flapping targets. If the server is under high load, a new scraper",
"// may be active and tries to insert. The old scraper that didn't terminate yet could still",
"// be inserting a previous sample set.",
"wg",
".",
"Wait",
"(",
")",
"\n",
"}"
]
|
19,456 | all-19457 | [
"DropLast",
"yields",
"all",
"items",
"except",
"for",
"the",
"last",
"n",
"items",
"that",
"it",
"receives",
"."
]
| [
"func",
"DropLast",
"(",
"n",
"int",
")",
"Filter",
"{",
"return",
"FilterFunc",
"(",
"func",
"(",
"arg",
"Arg",
")",
"error",
"{",
"r",
":=",
"newRing",
"(",
"n",
")",
"\n",
"for",
"s",
":=",
"range",
"arg",
".",
"In",
"{",
"if",
"r",
".",
"<mask>",
"(",
")",
"{",
"arg",
".",
"Out",
"<-",
"r",
".",
"popFront",
"(",
")",
"\n",
"}",
"\n",
"r",
".",
"pushBack",
"(",
"s",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
")",
"\n",
"}"
]
|
19,457 | all-19458 | [
"Listen",
"initializes",
"the",
"server"
]
| [
"func",
"(",
"c",
"*",
"Client",
")",
"listen",
"(",
")",
"error",
"{",
"c",
".",
"setDefaultPort",
"(",
"&",
"c",
".",
"ClientHostPort",
",",
"\"",
"\"",
"+",
"<mask>",
".",
"DefaultClientPortHTTP",
")",
"\n",
"c",
".",
"setDefaultPort",
"(",
"&",
"c",
".",
"ServerPort",
",",
"common",
".",
"DefaultServerPort",
")",
"\n\n",
"c",
".",
"mux",
"=",
"http",
".",
"NewServeMux",
"(",
")",
"// Using default mux creates problem in unit tests",
"\n",
"c",
".",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"crossdock",
".",
"Handler",
"(",
"c",
".",
"Behaviors",
",",
"true",
")",
")",
"\n\n",
"listener",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"c",
".",
"ClientHostPort",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"c",
".",
"listener",
"=",
"listener",
"\n",
"c",
".",
"ClientHostPort",
"=",
"listener",
".",
"Addr",
"(",
")",
".",
"String",
"(",
")",
"// override in case it was \":0\"",
"\n",
"return",
"nil",
"\n",
"}"
]
|
19,458 | all-19459 | [
"makeReviews",
"renders",
"review",
"policy",
"into",
"the",
"corresponding",
"GitHub",
"api",
"object",
".",
"Returns",
"nil",
"if",
"the",
"policy",
"is",
"nil",
"or",
"approvals",
"is",
"nil",
"or",
"0",
"."
]
| [
"func",
"makeReviews",
"(",
"rp",
"*",
"branchprotection",
".",
"ReviewPolicy",
")",
"*",
"github",
".",
"RequiredPullRequestReviews",
"{",
"<mask>",
"{",
"case",
"rp",
"==",
"nil",
":",
"return",
"nil",
"\n",
"case",
"rp",
".",
"Approvals",
"==",
"nil",
":",
"logrus",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"case",
"*",
"rp",
".",
"Approvals",
"==",
"0",
":",
"return",
"nil",
"\n",
"}",
"\n",
"rprr",
":=",
"github",
".",
"RequiredPullRequestReviews",
"{",
"DismissStaleReviews",
":",
"makeBool",
"(",
"rp",
".",
"DismissStale",
")",
",",
"RequireCodeOwnerReviews",
":",
"makeBool",
"(",
"rp",
".",
"RequireOwners",
")",
",",
"RequiredApprovingReviewCount",
":",
"*",
"rp",
".",
"Approvals",
",",
"}",
"\n",
"if",
"rp",
".",
"DismissalRestrictions",
"!=",
"nil",
"{",
"rprr",
".",
"DismissalRestrictions",
"=",
"*",
"makeRestrictions",
"(",
"rp",
".",
"DismissalRestrictions",
")",
"\n",
"}",
"\n",
"return",
"&",
"rprr",
"\n",
"}"
]
|
19,459 | all-19460 | [
"FilterProfilePaths",
"produces",
"a",
"new",
"profile",
"that",
"removes",
"either",
"everything",
"matching",
"or",
"everything",
"not",
"matching",
"the",
"provided",
"paths",
"depending",
"on",
"the",
"value",
"of",
"include",
".",
"Paths",
"are",
"interpreted",
"as",
"regular",
"expressions",
".",
"If",
"include",
"is",
"true",
"paths",
"is",
"treated",
"as",
"a",
"whitelist",
";",
"otherwise",
"it",
"is",
"treated",
"as",
"a",
"blacklist",
"."
]
| [
"func",
"FilterProfilePaths",
"(",
"profile",
"[",
"]",
"*",
"cover",
".",
"Profile",
",",
"paths",
"[",
"]",
"string",
",",
"include",
"bool",
")",
"(",
"[",
"]",
"*",
"cover",
".",
"Profile",
",",
"error",
")",
"{",
"parenPaths",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"paths",
")",
")",
"\n",
"for",
"i",
",",
"path",
":=",
"range",
"paths",
"{",
"parenPaths",
"[",
"i",
"]",
"=",
"\"",
"\"",
"+",
"path",
"+",
"\"",
"\"",
"\n",
"}",
"\n",
"joined",
":=",
"strings",
".",
"Join",
"(",
"parenPaths",
",",
"\"",
"\"",
")",
"\n",
"re",
",",
"err",
":=",
"regexp",
".",
"Compile",
"(",
"joined",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"result",
":=",
"make",
"(",
"[",
"]",
"*",
"cover",
".",
"Profile",
",",
"0",
",",
"len",
"(",
"profile",
")",
")",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"<mask>",
"{",
"if",
"re",
".",
"MatchString",
"(",
"p",
".",
"FileName",
")",
"==",
"include",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"p",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"result",
",",
"nil",
"\n",
"}"
]
|
19,460 | all-19461 | [
"Run",
"the",
"stream",
".",
"This",
"calls",
"the",
"underlying",
"grpc",
".",
"ClientStreams",
"methods",
"to",
"send",
"and",
"receive",
"messages",
"over",
"the",
"stream",
".",
"Run",
"returns",
"the",
"error",
"returned",
"by",
"any",
"of",
"those",
"functions",
"or",
"context",
".",
"Canceled",
"if",
"the",
"context",
"is",
"canceled",
"."
]
| [
"func",
"(",
"s",
"*",
"Stream",
")",
"Run",
"(",
")",
"(",
"err",
"error",
")",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"if",
"grpc",
".",
"Code",
"(",
"err",
")",
"==",
"codes",
".",
"Canceled",
"{",
"s",
".",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"err",
"=",
"<mask>",
".",
"Canceled",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"grpc",
".",
"Code",
"(",
"err",
")",
"==",
"codes",
".",
"DeadlineExceeded",
"{",
"s",
".",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"err",
"=",
"context",
".",
"DeadlineExceeded",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"stream",
",",
"err",
":=",
"s",
".",
"setupFunc",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"s",
".",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"recvErr",
":=",
"make",
"(",
"chan",
"error",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"go",
"func",
"(",
")",
"{",
"// empty the recvErr channel on return",
"<-",
"recvErr",
"\n",
"}",
"(",
")",
"\n",
"}",
"(",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"for",
"{",
"var",
"r",
"interface",
"{",
"}",
"\n",
"if",
"s",
".",
"recvFunc",
"!=",
"nil",
"{",
"r",
"=",
"s",
".",
"recvFunc",
"(",
")",
"\n",
"}",
"else",
"{",
"r",
"=",
"new",
"(",
"empty",
".",
"Empty",
")",
"// Generic proto message if not interested in received values",
"\n",
"}",
"\n",
"err",
":=",
"stream",
".",
"RecvMsg",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"s",
".",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"recvErr",
"<-",
"err",
"\n",
"close",
"(",
"recvErr",
")",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"s",
".",
"recvFunc",
"!=",
"nil",
"{",
"s",
".",
"recvMsg",
"(",
"r",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"defer",
"stream",
".",
"CloseSend",
"(",
")",
"\n\n",
"for",
"{",
"select",
"{",
"case",
"err",
":=",
"<-",
"recvErr",
":",
"return",
"err",
"\n",
"case",
"<-",
"stream",
".",
"Context",
"(",
")",
".",
"Done",
"(",
")",
":",
"s",
".",
"log",
".",
"WithError",
"(",
"stream",
".",
"Context",
"(",
")",
".",
"Err",
"(",
")",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"stream",
".",
"Context",
"(",
")",
".",
"Err",
"(",
")",
"\n",
"case",
"msg",
":=",
"<-",
"s",
".",
"sendBuffer",
":",
"if",
"err",
"=",
"stream",
".",
"SendMsg",
"(",
"msg",
")",
";",
"err",
"!=",
"nil",
"{",
"s",
".",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"atomic",
".",
"AddUint64",
"(",
"&",
"s",
".",
"sent",
",",
"1",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
]
|
19,461 | all-19462 | [
"Post",
"API",
"request"
]
| [
"func",
"(",
"a",
"*",
"API",
")",
"Post",
"(",
"reqPath",
"string",
",",
"data",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"a",
".",
"apiRequest",
"(",
"\"",
"\"",
",",
"reqPath",
",",
"<mask>",
")",
"\n",
"}"
]
|
19,462 | all-19463 | [
"Fail",
"marks",
"the",
"task",
"as",
"having",
"failed",
"but",
"continues",
"execution",
"."
]
| [
"func",
"(",
"t",
"*",
"T",
")",
"Fail",
"(",
")",
"{",
"t",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"t",
".",
"<mask>",
"=",
"true",
"\n",
"}"
]
|
19,463 | all-19464 | [
"Start",
"explicitly",
"begins",
"consumption",
"in",
"case",
"the",
"consumer",
"was",
"initialized",
"with",
"NewConsumer",
"instead",
"of",
"StartConsumer",
"."
]
| [
"func",
"(",
"c",
"*",
"Consumer",
")",
"Start",
"(",
")",
"{",
"if",
"c",
".",
"started",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"go",
"c",
".",
"<mask>",
"(",
")",
"\n\n",
"c",
".",
"started",
"=",
"true",
"\n",
"}"
]
|
19,464 | all-19465 | [
"ContinueWithAuth",
"continues",
"a",
"request",
"supplying",
"authChallengeResponse",
"following",
"authRequired",
"event",
".",
"See",
":",
"https",
":",
"//",
"chromedevtools",
".",
"github",
".",
"io",
"/",
"devtools",
"-",
"protocol",
"/",
"tot",
"/",
"Fetch#method",
"-",
"continueWithAuth",
"parameters",
":",
"requestID",
"-",
"An",
"id",
"the",
"client",
"received",
"in",
"authRequired",
"event",
".",
"authChallengeResponse",
"-",
"Response",
"to",
"with",
"an",
"authChallenge",
"."
]
| [
"func",
"ContinueWithAuth",
"(",
"requestID",
"RequestID",
",",
"authChallengeResponse",
"*",
"AuthChallengeResponse",
")",
"*",
"ContinueWithAuthParams",
"{",
"<mask>",
"&",
"ContinueWithAuthParams",
"{",
"RequestID",
":",
"requestID",
",",
"AuthChallengeResponse",
":",
"authChallengeResponse",
",",
"}",
"\n",
"}"
]
|
19,465 | all-19466 | [
"BoolFromPtr",
"creates",
"a",
"new",
"Bool",
"that",
"will",
"be",
"null",
"if",
"f",
"is",
"nil",
"."
]
| [
"func",
"BoolFromPtr",
"(",
"b",
"*",
"bool",
")",
"Bool",
"{",
"if",
"b",
"==",
"nil",
"{",
"return",
"NewBool",
"(",
"<mask>",
",",
"false",
")",
"\n",
"}",
"\n",
"return",
"NewBool",
"(",
"*",
"b",
",",
"true",
")",
"\n",
"}"
]
|
19,466 | all-19467 | [
"NewSourceFromStream",
"returns",
"a",
"tarfile",
".",
"Source",
"for",
"the",
"specified",
"inputStream",
"which",
"can",
"be",
"either",
"compressed",
"or",
"uncompressed",
".",
"The",
"caller",
"can",
"close",
"the",
"inputStream",
"immediately",
"after",
"NewSourceFromFile",
"returns",
"."
]
| [
"func",
"NewSourceFromStream",
"(",
"inputStream",
"io",
".",
"Reader",
")",
"(",
"*",
"Source",
",",
"error",
")",
"{",
"// FIXME: use SystemContext here.",
"// Save inputStream to a temporary file",
"tarCopyFile",
",",
"err",
":=",
"ioutil",
".",
"TempFile",
"(",
"tmpdir",
".",
"TemporaryDirectoryForBigFiles",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"defer",
"tarCopyFile",
".",
"Close",
"(",
")",
"\n\n",
"succeeded",
":=",
"false",
"\n",
"defer",
"func",
"(",
")",
"{",
"if",
"!",
"succeeded",
"{",
"os",
".",
"Remove",
"(",
"tarCopyFile",
".",
"Name",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"// In order to be compatible with docker-load, we need to support",
"// auto-decompression (it's also a nice quality-of-life thing to avoid",
"// giving users really confusing \"invalid tar header\" errors).",
"uncompressedStream",
",",
"_",
",",
"err",
":=",
"compression",
".",
"AutoDecompress",
"(",
"inputStream",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"defer",
"uncompressedStream",
".",
"Close",
"(",
")",
"\n\n",
"// Copy the plain archive to the temporary file.",
"//",
"// TODO: This can take quite some time, and should ideally be cancellable",
"// using a context.Context.",
"if",
"_",
",",
"err",
":=",
"io",
".",
"Copy",
"(",
"tarCopyFile",
",",
"uncompressedStream",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"<mask>",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"tarCopyFile",
".",
"Name",
"(",
")",
")",
"\n",
"}",
"\n",
"succeeded",
"=",
"true",
"\n\n",
"return",
"&",
"Source",
"{",
"tarPath",
":",
"tarCopyFile",
".",
"Name",
"(",
")",
",",
"removeTarPathOnClose",
":",
"true",
",",
"}",
",",
"nil",
"\n",
"}"
]
|
19,467 | all-19468 | [
"Load",
"the",
"ENV",
"variables",
"to",
"the",
"env",
"map"
]
| [
"func",
"loadEnv",
"(",
")",
"{",
"gil",
".",
"Lock",
"(",
")",
"\n",
"defer",
"gil",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"==",
"\"",
"\"",
"{",
"// if the flag \"test.v\" is *defined*, we're running as a unit test. Note that we don't care",
"// about v.Value (verbose test mode); we just want to know if the test environment has defined",
"// it. It's also possible that the flags are not yet fully parsed (i.e. flag.Parsed() == false),",
"// so we could not depend on v.Value anyway.",
"//",
"if",
"v",
":=",
"flag",
".",
"Lookup",
"(",
"\"",
"\"",
")",
";",
"v",
"!=",
"nil",
"{",
"env",
"[",
"\"",
"\"",
"]",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"}",
"\n\n",
"// set the GOPATH if using >= 1.8 and the GOPATH isn't set",
"if",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"==",
"\"",
"\"",
"{",
"out",
",",
"err",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
".",
"Output",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"gp",
":=",
"strings",
".",
"TrimSpace",
"(",
"string",
"(",
"out",
")",
")",
"\n",
"os",
".",
"Setenv",
"(",
"\"",
"\"",
",",
"gp",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"e",
":=",
"<mask>",
"os",
".",
"Environ",
"(",
")",
"{",
"pair",
":=",
"strings",
".",
"Split",
"(",
"e",
",",
"\"",
"\"",
")",
"\n",
"env",
"[",
"pair",
"[",
"0",
"]",
"]",
"=",
"os",
".",
"Getenv",
"(",
"pair",
"[",
"0",
"]",
")",
"\n",
"}",
"\n",
"}"
]
|
19,468 | all-19469 | [
"Curls",
"an",
"app",
"s",
"root",
"endpoint",
"and",
"exit",
"successfully",
"before",
"the",
"default",
"timeout"
]
| [
"func",
"CurlAppRoot",
"(",
"cfg",
"helpersinternal",
".",
"CurlConfig",
",",
"appName",
"string",
")",
"<mask>",
"{",
"appCurler",
":=",
"helpersinternal",
".",
"NewAppCurler",
"(",
"Curl",
",",
"cfg",
")",
"\n",
"return",
"appCurler",
".",
"CurlAndWait",
"(",
"cfg",
",",
"appName",
",",
"\"",
"\"",
",",
"CURL_TIMEOUT",
")",
"\n",
"}"
]
|
19,469 | all-19470 | [
"gotLeader",
"will",
"force",
"update",
"the",
"leadership",
"status",
"to",
"having",
"a",
"leader",
"."
]
| [
"func",
"(",
"l",
"*",
"leader",
")",
"gotLeader",
"(",
")",
"{",
"l",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"<mask>",
"{",
"case",
"<-",
"l",
".",
"leaderc",
":",
"l",
".",
"leaderc",
"=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"default",
":",
"}",
"\n",
"}"
]
|
19,470 | all-19471 | [
"AddEmbedded",
"adds",
"the",
"attachment",
"to",
"the",
"list",
"of",
"attachments",
"the",
"Message",
"has",
"and",
"uses",
"inline",
"instead",
"of",
"attachement",
"property",
"."
]
| [
"func",
"(",
"m",
"*",
"Message",
")",
"AddEmbedded",
"(",
"name",
"string",
",",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"m",
".",
"Attachments",
"=",
"append",
"(",
"m",
".",
"Attachments",
",",
"Attachment",
"{",
"<mask>",
":",
"name",
",",
"Reader",
":",
"r",
",",
"Embedded",
":",
"true",
",",
"}",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
]
|
19,471 | all-19472 | [
"Unmarshal",
"parses",
"a",
"DER",
"-",
"encoded",
"serialised",
"HOTP",
"key",
"value",
"."
]
| [
"func",
"Unmarshal",
"(",
"in",
"[",
"]",
"byte",
")",
"(",
"otp",
"*",
"HOTP",
",",
"err",
"error",
")",
"{",
"var",
"asnHOTP",
"struct",
"{",
"Key",
"[",
"]",
"<mask>",
"\n",
"Counter",
"*",
"big",
".",
"Int",
"\n",
"Digits",
"int",
"\n",
"}",
"\n",
"_",
",",
"err",
"=",
"asn1",
".",
"Unmarshal",
"(",
"in",
",",
"&",
"asnHOTP",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"otp",
"=",
"&",
"HOTP",
"{",
"Key",
":",
"asnHOTP",
".",
"Key",
"[",
":",
"]",
",",
"Digits",
":",
"asnHOTP",
".",
"Digits",
",",
"}",
"\n",
"otp",
".",
"setCounter",
"(",
"asnHOTP",
".",
"Counter",
".",
"Uint64",
"(",
")",
")",
"\n",
"return",
"\n",
"}"
]
|
19,472 | all-19473 | [
"SampleRate",
"sets",
"the",
"sample",
"rate",
"of",
"the",
"Client",
".",
"It",
"allows",
"sending",
"the",
"metrics",
"less",
"often",
"which",
"can",
"be",
"useful",
"for",
"performance",
"intensive",
"code",
"paths",
"."
]
| [
"func",
"SampleRate",
"(",
"rate",
"float32",
")",
"Option",
"{",
"return",
"Option",
"(",
"func",
"(",
"c",
"*",
"config",
")",
"{",
"c",
".",
"<mask>",
".",
"Rate",
"=",
"rate",
"\n",
"}",
")",
"\n",
"}"
]
|
19,473 | all-19474 | [
"CreateAnnotation",
"creates",
"a",
"new",
"annotation",
"."
]
| [
"func",
"(",
"a",
"*",
"API",
")",
"CreateAnnotation",
"(",
"cfg",
"*",
"Annotation",
")",
"(",
"*",
"Annotation",
",",
"error",
")",
"{",
"if",
"cfg",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"jsonCfg",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"cfg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"a",
".",
"Debug",
"{",
"a",
".",
"Log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"string",
"(",
"jsonCfg",
")",
")",
"\n",
"}",
"\n\n",
"<mask>",
",",
"err",
":=",
"a",
".",
"Post",
"(",
"config",
".",
"AnnotationPrefix",
",",
"jsonCfg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"annotation",
":=",
"&",
"Annotation",
"{",
"}",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"result",
",",
"annotation",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"annotation",
",",
"nil",
"\n",
"}"
]
|
19,474 | all-19475 | [
"Stop",
"the",
"rule",
"manager",
"s",
"rule",
"evaluation",
"cycles",
"."
]
| [
"func",
"(",
"m",
"*",
"Manager",
")",
"Stop",
"(",
")",
"{",
"m",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"level",
".",
"Info",
"(",
"m",
".",
"logger",
")",
".",
"Log",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"for",
"_",
",",
"eg",
":=",
"range",
"m",
".",
"groups",
"{",
"eg",
".",
"stop",
"(",
")",
"\n",
"}",
"\n\n",
"level",
".",
"Info",
"(",
"m",
".",
"logger",
")",
".",
"<mask>",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}"
]
|
19,475 | all-19476 | [
"NewPolicy",
"returns",
"a",
"default",
"password",
"policy",
"which",
"can",
"be",
"modified"
]
| [
"func",
"NewPolicy",
"(",
")",
"Policy",
"{",
"p",
":=",
"<mask>",
"{",
"MinLength",
":",
"6",
",",
"MaxLength",
":",
"16",
",",
"MinLowers",
":",
"0",
",",
"MinUppers",
":",
"0",
",",
"MinDigits",
":",
"0",
",",
"MinSpclChars",
":",
"0",
",",
"LowerPool",
":",
"\"",
"\"",
",",
"UpperPool",
":",
"\"",
"\"",
",",
"DigitPool",
":",
"\"",
"\"",
",",
"SpclCharPool",
":",
"\"",
"\"",
",",
"}",
"\n",
"return",
"p",
"\n",
"}"
]
|
19,476 | all-19477 | [
"HasText",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"p",
"*",
"Period",
")",
"HasText",
"(",
")",
"bool",
"{",
"if",
"p",
"!=",
"nil",
"&&",
"p",
".",
"Text",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
]
|
19,477 | all-19478 | [
"EmitInsertedText",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_entry_buffer_emit_inserted_text",
"()",
"."
]
| [
"func",
"(",
"v",
"*",
"EntryBuffer",
")",
"EmitInsertedText",
"(",
"pos",
"uint",
",",
"text",
"string",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"text",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"C",
".",
"gtk_entry_buffer_emit_inserted_text",
"(",
"v",
".",
"native",
"(",
")",
",",
"C",
".",
"guint",
"(",
"pos",
")",
",",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
",",
"C",
".",
"guint",
"(",
"len",
"(",
"<mask>",
")",
")",
")",
"\n",
"}"
]
|
19,478 | all-19479 | [
"Start",
"begins",
"the",
"polling",
"for",
"this",
"runner",
".",
"Any",
"errors",
"that",
"occur",
"will",
"cause",
"this",
"function",
"to",
"push",
"an",
"item",
"onto",
"the",
"runner",
"s",
"error",
"channel",
"and",
"the",
"halt",
"execution",
".",
"This",
"function",
"is",
"blocking",
"and",
"should",
"be",
"called",
"as",
"a",
"goroutine",
"."
]
| [
"func",
"(",
"r",
"*",
"Runner",
")",
"Start",
"(",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n\n",
"// Create the pid before doing anything.",
"if",
"err",
":=",
"r",
".",
"storePid",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"r",
".",
"ErrCh",
"<-",
"err",
"\n",
"return",
"\n",
"}",
"\n\n",
"// Start the de-duplication manager",
"<mask>",
"dedupCh",
"<-",
"chan",
"struct",
"{",
"}",
"\n",
"if",
"r",
".",
"dedup",
"!=",
"nil",
"{",
"if",
"err",
":=",
"r",
".",
"dedup",
".",
"Start",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"r",
".",
"ErrCh",
"<-",
"err",
"\n",
"return",
"\n",
"}",
"\n",
"dedupCh",
"=",
"r",
".",
"dedup",
".",
"UpdateCh",
"(",
")",
"\n",
"}",
"\n\n",
"// Setup the child process exit channel",
"var",
"childExitCh",
"<-",
"chan",
"int",
"\n\n",
"// Fire an initial run to parse all the templates and setup the first-pass",
"// dependencies. This also forces any templates that have no dependencies to",
"// be rendered immediately (since they are already renderable).",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
":=",
"r",
".",
"Run",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"r",
".",
"ErrCh",
"<-",
"err",
"\n",
"return",
"\n",
"}",
"\n\n",
"for",
"{",
"// Enable quiescence for all templates if we have specified wait",
"// intervals.",
"NEXT_Q",
":",
"for",
"_",
",",
"t",
":=",
"range",
"r",
".",
"templates",
"{",
"if",
"_",
",",
"ok",
":=",
"r",
".",
"quiescenceMap",
"[",
"t",
".",
"ID",
"(",
")",
"]",
";",
"ok",
"{",
"continue",
"NEXT_Q",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"c",
":=",
"range",
"r",
".",
"templateConfigsFor",
"(",
"t",
")",
"{",
"if",
"*",
"c",
".",
"Wait",
".",
"Enabled",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"t",
".",
"ID",
"(",
")",
")",
"\n",
"r",
".",
"quiescenceMap",
"[",
"t",
".",
"ID",
"(",
")",
"]",
"=",
"newQuiescence",
"(",
"r",
".",
"quiescenceCh",
",",
"*",
"c",
".",
"Wait",
".",
"Min",
",",
"*",
"c",
".",
"Wait",
".",
"Max",
",",
"t",
")",
"\n",
"continue",
"NEXT_Q",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"*",
"r",
".",
"config",
".",
"Wait",
".",
"Enabled",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"t",
".",
"ID",
"(",
")",
")",
"\n",
"r",
".",
"quiescenceMap",
"[",
"t",
".",
"ID",
"(",
")",
"]",
"=",
"newQuiescence",
"(",
"r",
".",
"quiescenceCh",
",",
"*",
"r",
".",
"config",
".",
"Wait",
".",
"Min",
",",
"*",
"r",
".",
"config",
".",
"Wait",
".",
"Max",
",",
"t",
")",
"\n",
"continue",
"NEXT_Q",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Warn the user if they are watching too many dependencies.",
"if",
"r",
".",
"watcher",
".",
"Size",
"(",
")",
">",
"saneViewLimit",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"r",
".",
"watcher",
".",
"Size",
"(",
")",
")",
"\n",
"}",
"else",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"r",
".",
"watcher",
".",
"Size",
"(",
")",
")",
"\n",
"}",
"\n\n",
"if",
"r",
".",
"allTemplatesRendered",
"(",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n\n",
"// If an exec command was given and a command is not currently running,",
"// spawn the child process for supervision.",
"if",
"config",
".",
"StringPresent",
"(",
"r",
".",
"config",
".",
"Exec",
".",
"Command",
")",
"{",
"// Lock the child because we are about to check if it exists.",
"r",
".",
"childLock",
".",
"Lock",
"(",
")",
"\n\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"r",
".",
"child",
"==",
"nil",
"{",
"env",
":=",
"r",
".",
"config",
".",
"Exec",
".",
"Env",
".",
"Copy",
"(",
")",
"\n",
"env",
".",
"Custom",
"=",
"append",
"(",
"r",
".",
"childEnv",
"(",
")",
",",
"env",
".",
"Custom",
"...",
")",
"\n",
"child",
",",
"err",
":=",
"spawnChild",
"(",
"&",
"spawnChildInput",
"{",
"Stdin",
":",
"r",
".",
"inStream",
",",
"Stdout",
":",
"r",
".",
"outStream",
",",
"Stderr",
":",
"r",
".",
"errStream",
",",
"Command",
":",
"config",
".",
"StringVal",
"(",
"r",
".",
"config",
".",
"Exec",
".",
"Command",
")",
",",
"Env",
":",
"env",
".",
"Env",
"(",
")",
",",
"ReloadSignal",
":",
"config",
".",
"SignalVal",
"(",
"r",
".",
"config",
".",
"Exec",
".",
"ReloadSignal",
")",
",",
"KillSignal",
":",
"config",
".",
"SignalVal",
"(",
"r",
".",
"config",
".",
"Exec",
".",
"KillSignal",
")",
",",
"KillTimeout",
":",
"config",
".",
"TimeDurationVal",
"(",
"r",
".",
"config",
".",
"Exec",
".",
"KillTimeout",
")",
",",
"Splay",
":",
"config",
".",
"TimeDurationVal",
"(",
"r",
".",
"config",
".",
"Exec",
".",
"Splay",
")",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r",
".",
"ErrCh",
"<-",
"err",
"\n",
"r",
".",
"childLock",
".",
"Unlock",
"(",
")",
"\n",
"return",
"\n",
"}",
"\n",
"r",
".",
"child",
"=",
"child",
"\n",
"}",
"\n\n",
"// Unlock the child, we are done now.",
"r",
".",
"childLock",
".",
"Unlock",
"(",
")",
"\n\n",
"// It's possible that we didn't start a process, in which case no",
"// channel is returned. If we did get a new exitCh, that means a child",
"// was spawned, so we need to watch a new exitCh. It is also possible",
"// that during a run, the child process was restarted, which means a",
"// new exit channel should be used.",
"nexitCh",
":=",
"r",
".",
"child",
".",
"ExitCh",
"(",
")",
"\n",
"if",
"nexitCh",
"!=",
"nil",
"{",
"childExitCh",
"=",
"nexitCh",
"\n",
"}",
"\n",
"}",
"\n\n",
"// If we are running in once mode and all our templates are rendered,",
"// then we should exit here.",
"if",
"r",
".",
"once",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"r",
".",
"child",
"!=",
"nil",
"{",
"r",
".",
"stopDedup",
"(",
")",
"\n",
"r",
".",
"stopWatcher",
"(",
")",
"\n\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"select",
"{",
"case",
"c",
":=",
"<-",
"childExitCh",
":",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"r",
".",
"ErrCh",
"<-",
"NewErrChildDied",
"(",
"c",
")",
"\n",
"return",
"\n",
"case",
"<-",
"r",
".",
"DoneCh",
":",
"}",
"\n",
"}",
"\n\n",
"r",
".",
"Stop",
"(",
")",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n\n",
"OUTER",
":",
"select",
"{",
"case",
"view",
":=",
"<-",
"r",
".",
"watcher",
".",
"DataCh",
"(",
")",
":",
"// Receive this update",
"r",
".",
"Receive",
"(",
"view",
".",
"Dependency",
"(",
")",
",",
"view",
".",
"Data",
"(",
")",
")",
"\n\n",
"// Drain all dependency data. Given a large number of dependencies, it is",
"// feasible that we have data for more than one of them. Instead of",
"// wasting CPU cycles rendering templates when we have more dependencies",
"// waiting to be added to the brain, we drain the entire buffered channel",
"// on the watcher and then reports when it is done receiving new data",
"// which the parent select listens for.",
"//",
"// Please see https://github.com/hashicorp/consul-template/issues/168 for",
"// more information about this optimization and the entire backstory.",
"for",
"{",
"select",
"{",
"case",
"view",
":=",
"<-",
"r",
".",
"watcher",
".",
"DataCh",
"(",
")",
":",
"r",
".",
"Receive",
"(",
"view",
".",
"Dependency",
"(",
")",
",",
"view",
".",
"Data",
"(",
")",
")",
"\n",
"default",
":",
"break",
"OUTER",
"\n",
"}",
"\n",
"}",
"\n\n",
"case",
"<-",
"dedupCh",
":",
"// We may get triggered by the de-duplication manager for either a change",
"// in leadership (acquired or lost lock), or an update of data for a template",
"// that we are watching.",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"break",
"OUTER",
"\n\n",
"case",
"err",
":=",
"<-",
"r",
".",
"watcher",
".",
"ErrCh",
"(",
")",
":",
"// Push the error back up the stack",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"r",
".",
"ErrCh",
"<-",
"err",
"\n",
"return",
"\n\n",
"case",
"tmpl",
":=",
"<-",
"r",
".",
"quiescenceCh",
":",
"// Remove the quiescence for this template from the map. This will force",
"// the upcoming Run call to actually evaluate and render the template.",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"tmpl",
".",
"ID",
"(",
")",
")",
"\n",
"delete",
"(",
"r",
".",
"quiescenceMap",
",",
"tmpl",
".",
"ID",
"(",
")",
")",
"\n\n",
"case",
"c",
":=",
"<-",
"childExitCh",
":",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"r",
".",
"ErrCh",
"<-",
"NewErrChildDied",
"(",
"c",
")",
"\n",
"return",
"\n\n",
"case",
"<-",
"r",
".",
"DoneCh",
":",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"// If we got this far, that means we got new data or one of the timers",
"// fired, so attempt to re-render.",
"if",
"err",
":=",
"r",
".",
"Run",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"r",
".",
"ErrCh",
"<-",
"err",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"}"
]
|
19,479 | all-19480 | [
"String",
"returns",
"the",
"name",
"of",
"e"
]
| [
"func",
"(",
"e",
"IpAddrType",
")",
"String",
"(",
")",
"string",
"{",
"<mask>",
",",
"_",
":=",
"ipAddrTypeMap",
"[",
"int32",
"(",
"e",
")",
"]",
"\n",
"return",
"name",
"\n",
"}"
]
|
19,480 | all-19481 | [
"Send",
"relays",
"data",
"into",
"the",
"channel",
"topology",
"via",
"random",
"neighbours",
"."
]
| [
"func",
"(",
"c",
"*",
"gossipChannel",
")",
"Send",
"(",
"data",
"GossipData",
")",
"{",
"c",
".",
"relay",
"(",
"c",
".",
"ourself",
".",
"Name",
",",
"<mask>",
")",
"\n",
"}"
]
|
19,481 | all-19482 | [
"SeekToLast",
"brings",
"us",
"to",
"the",
"last",
"element",
".",
"Valid",
"should",
"return",
"true",
"."
]
| [
"func",
"(",
"itr",
"*",
"blockIterator",
")",
"SeekToLast",
"(",
")",
"{",
"itr",
".",
"<mask>",
"=",
"nil",
"\n",
"for",
"itr",
".",
"Init",
"(",
")",
";",
"itr",
".",
"Valid",
"(",
")",
";",
"itr",
".",
"Next",
"(",
")",
"{",
"}",
"\n",
"itr",
".",
"Prev",
"(",
")",
"\n",
"}"
]
|
19,482 | all-19483 | [
"AppendHTTPDate",
"appends",
"HTTP",
"-",
"compliant",
"(",
"RFC1123",
")",
"representation",
"of",
"date",
"to",
"dst",
"and",
"returns",
"the",
"extended",
"dst",
"."
]
| [
"func",
"AppendHTTPDate",
"(",
"dst",
"[",
"]",
"byte",
",",
"date",
"time",
".",
"Time",
")",
"[",
"]",
"byte",
"{",
"dst",
"=",
"date",
".",
"In",
"(",
"time",
".",
"UTC",
")",
".",
"AppendFormat",
"(",
"dst",
",",
"<mask>",
".",
"RFC1123",
")",
"\n",
"copy",
"(",
"dst",
"[",
"len",
"(",
"dst",
")",
"-",
"3",
":",
"]",
",",
"strGMT",
")",
"\n",
"return",
"dst",
"\n",
"}"
]
|
19,483 | all-19484 | [
"Any",
"returns",
"the",
"position",
"of",
"the",
"end",
"of",
"the",
"current",
"element",
"that",
"begins",
"at",
"pos",
";",
"handles",
"any",
"valid",
"json",
"element"
]
| [
"func",
"Any",
"(",
"in",
"[",
"]",
"byte",
",",
"pos",
"int",
")",
"(",
"int",
",",
"error",
")",
"{",
"pos",
",",
"err",
":=",
"skipSpace",
"(",
"in",
",",
"pos",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"switch",
"in",
"[",
"pos",
"]",
"{",
"case",
"'\"'",
":",
"return",
"String",
"(",
"in",
",",
"pos",
")",
"\n",
"case",
"'{'",
":",
"return",
"Object",
"(",
"in",
",",
"pos",
")",
"\n",
"case",
"'.'",
",",
"'-'",
",",
"'1'",
",",
"'2'",
",",
"'3'",
",",
"'4'",
",",
"'5'",
",",
"'6'",
",",
"'7'",
",",
"'8'",
",",
"'9'",
",",
"'0'",
":",
"return",
"Number",
"(",
"in",
",",
"pos",
")",
"\n",
"case",
"'['",
":",
"return",
"Array",
"(",
"in",
",",
"pos",
")",
"\n",
"case",
"'t'",
",",
"'f'",
":",
"return",
"Boolean",
"(",
"in",
",",
"pos",
")",
"\n",
"case",
"'n'",
":",
"return",
"Null",
"(",
"in",
",",
"pos",
")",
"\n",
"default",
":",
"max",
":=",
"len",
"(",
"in",
")",
"-",
"pos",
"\n",
"if",
"max",
">",
"20",
"{",
"max",
"=",
"20",
"\n",
"}",
"\n\n",
"return",
"0",
",",
"opErr",
"{",
"pos",
":",
"pos",
",",
"<mask>",
":",
"\"",
"\"",
",",
"content",
":",
"string",
"(",
"in",
"[",
"pos",
":",
"pos",
"+",
"max",
"]",
")",
",",
"}",
"\n",
"}",
"\n",
"}"
]
|
19,484 | all-19485 | [
"Stream",
"makes",
"a",
"HTTP",
"request",
"and",
"returns",
"request",
"body",
"as",
"io",
".",
"ReadCloser",
"to",
"be",
"able",
"to",
"read",
"long",
"running",
"responses",
".",
"Returned",
"io",
".",
"ReadCloser",
"must",
"be",
"closed",
"at",
"the",
"end",
"of",
"read",
".",
"To",
"reuse",
"HTTP",
"connection",
"make",
"sure",
"that",
"the",
"whole",
"data",
"is",
"read",
"before",
"closing",
"the",
"reader",
"."
]
| [
"func",
"(",
"c",
"Client",
")",
"Stream",
"(",
"method",
",",
"path",
"string",
",",
"query",
"url",
".",
"Values",
",",
"body",
"<mask>",
".",
"Reader",
",",
"accept",
"[",
"]",
"string",
")",
"(",
"data",
"io",
".",
"ReadCloser",
",",
"contentType",
"string",
",",
"err",
"error",
")",
"{",
"return",
"c",
".",
"StreamContext",
"(",
"nil",
",",
"method",
",",
"path",
",",
"query",
",",
"body",
",",
"accept",
")",
"\n",
"}"
]
|
19,485 | all-19486 | [
"Collect",
"creates",
"constant",
"metrics",
"for",
"each",
"file",
"with",
"last",
"modified",
"time",
"of",
"the",
"file",
"."
]
| [
"func",
"(",
"t",
"*",
"TimestampCollector",
")",
"Collect",
"(",
"ch",
"chan",
"<-",
"prometheus",
".",
"Metric",
")",
"{",
"// New map to dedup filenames.",
"uniqueFiles",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"float64",
")",
"\n",
"t",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"for",
"fileSD",
":=",
"range",
"t",
".",
"discoverers",
"{",
"fileSD",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"for",
"<mask>",
",",
"timestamp",
":=",
"range",
"fileSD",
".",
"timestamps",
"{",
"uniqueFiles",
"[",
"filename",
"]",
"=",
"timestamp",
"\n",
"}",
"\n",
"fileSD",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"}",
"\n",
"t",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"for",
"filename",
",",
"timestamp",
":=",
"range",
"uniqueFiles",
"{",
"ch",
"<-",
"prometheus",
".",
"MustNewConstMetric",
"(",
"t",
".",
"Description",
",",
"prometheus",
".",
"GaugeValue",
",",
"timestamp",
",",
"filename",
",",
")",
"\n",
"}",
"\n",
"}"
]
|
19,486 | all-19487 | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"Targets",
"."
]
| [
"func",
"(",
"<mask>",
"Targets",
")",
"DeepCopy",
"(",
")",
"Targets",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"Targets",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"*",
"out",
"\n",
"}"
]
|
19,487 | all-19488 | [
"PrintDetailedPipelineInfo",
"pretty",
"-",
"prints",
"detailed",
"pipeline",
"info",
"."
]
| [
"func",
"PrintDetailedPipelineInfo",
"(",
"pipelineInfo",
"*",
"PrintablePipelineInfo",
")",
"error",
"{",
"template",
",",
"err",
":=",
"template",
".",
"New",
"(",
"\"",
"\"",
")",
".",
"Funcs",
"(",
"funcMap",
")",
".",
"Parse",
"(",
"`Name: {{.Pipeline.Name}}{{if .Description}}\nDescription: {{.Description}}{{end}}{{if .FullTimestamps }}\nCreated: {{.CreatedAt}}{{ else }}\nCreated: {{prettyAgo .CreatedAt}} {{end}}\nState: {{pipelineState .State}}\nStopped: {{ .Stopped }}\nReason: {{.Reason}}\nParallelism Spec: {{.ParallelismSpec}}\n{{ if .ResourceRequests }}ResourceRequests:\n CPU: {{ .ResourceRequests.Cpu }}\n Memory: {{ .ResourceRequests.Memory }} {{end}}\n{{ if .ResourceLimits }}ResourceLimits:\n CPU: {{ .ResourceLimits.Cpu }}\n Memory: {{ .ResourceLimits.Memory }}\n {{ if .ResourceLimits.Gpu }}GPU:\n Type: {{ .ResourceLimits.Gpu.Type }} \n Number: {{ .ResourceLimits.Gpu.Number }} {{end}} {{end}}\nDatum Timeout: {{.DatumTimeout}}\nJob Timeout: {{.JobTimeout}}\nInput:\n{{pipelineInput .PipelineInfo}}\n{{ if .GithookURL }}Githook URL: {{.GithookURL}} {{end}}\nOutput Branch: {{.OutputBranch}}\nTransform:\n{{prettyTransform .Transform}}\n{{ if .Egress }}Egress: {{.Egress.URL}} {{end}}\n{{if .RecentError}} Recent Error: {{.RecentError}} {{end}}\nJob Counts:\n{{jobCounts .JobCounts}}\n`",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"err",
"=",
"template",
".",
"Execute",
"(",
"<mask>",
".",
"Stdout",
",",
"pipelineInfo",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
|
19,488 | all-19489 | [
"NewXor64Source",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"Xor64Source",
"seeded",
"with",
"the",
"given",
"value",
"."
]
| [
"func",
"NewXor64Source",
"(",
"seed",
"int64",
")",
"*",
"Xor64Source",
"{",
"<mask>",
"s",
"Xor64Source",
"\n",
"s",
".",
"Seed",
"(",
"seed",
")",
"\n",
"return",
"&",
"s",
"\n",
"}"
]
|
19,489 | all-19490 | [
"LastError",
"returns",
"the",
"last",
"error",
"seen",
"by",
"the",
"recording",
"rule",
"."
]
| [
"func",
"(",
"rule",
"*",
"RecordingRule",
")",
"LastError",
"(",
")",
"error",
"{",
"rule",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"<mask>",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"return",
"rule",
".",
"lastError",
"\n",
"}"
]
|
19,490 | all-19491 | [
"PublishWithDetails",
"is",
"used",
"for",
"fine",
"grained",
"control",
"over",
"record",
"publishing"
]
| [
"func",
"(",
"s",
"*",
"Shell",
")",
"PublishWithDetails",
"(",
"contentHash",
",",
"key",
"string",
",",
"lifetime",
",",
"ttl",
"time",
".",
"Duration",
",",
"resolve",
"bool",
")",
"(",
"*",
"PublishResponse",
",",
"error",
")",
"{",
"var",
"pubResp",
"PublishResponse",
"\n",
"req",
":=",
"s",
".",
"<mask>",
"(",
"\"",
"\"",
",",
"contentHash",
")",
".",
"Option",
"(",
"\"",
"\"",
",",
"resolve",
")",
"\n",
"if",
"key",
"!=",
"\"",
"\"",
"{",
"req",
".",
"Option",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"}",
"\n",
"if",
"lifetime",
"!=",
"0",
"{",
"req",
".",
"Option",
"(",
"\"",
"\"",
",",
"lifetime",
")",
"\n",
"}",
"\n",
"if",
"ttl",
".",
"Seconds",
"(",
")",
">",
"0",
"{",
"req",
".",
"Option",
"(",
"\"",
"\"",
",",
"ttl",
")",
"\n",
"}",
"\n",
"err",
":=",
"req",
".",
"Exec",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"pubResp",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"pubResp",
",",
"nil",
"\n",
"}"
]
|
19,491 | all-19492 | [
"<discriminator",
">",
"::",
"=",
"_",
"<",
"(",
"non",
"-",
"negative",
")",
"number",
">"
]
| [
"func",
"(",
"st",
"*",
"state",
")",
"discriminator",
"(",
"a",
"AST",
")",
"AST",
"{",
"if",
"len",
"(",
"st",
".",
"str",
")",
"==",
"0",
"||",
"st",
".",
"str",
"[",
"0",
"]",
"!=",
"'_'",
"{",
"return",
"a",
"\n",
"}",
"\n",
"off",
":=",
"st",
".",
"off",
"\n",
"st",
".",
"advance",
"(",
"1",
")",
"\n",
"d",
":=",
"st",
".",
"<mask>",
"(",
")",
"\n",
"if",
"d",
"<",
"0",
"{",
"st",
".",
"failEarlier",
"(",
"\"",
"\"",
",",
"st",
".",
"off",
"-",
"off",
")",
"\n",
"}",
"\n",
"// We don't currently print out the discriminator, so we don't",
"// save it.",
"return",
"a",
"\n",
"}"
]
|
19,492 | all-19493 | [
"Parameter",
"clientBuffer",
"has",
"type",
"C",
".",
"GLeglClientBufferEXT",
"."
]
| [
"func",
"NamedBufferStorageExternalEXT",
"(",
"buffer",
"uint32",
",",
"offset",
"int",
",",
"size",
"int",
",",
"clientBuffer",
"unsafe",
".",
"Pointer",
",",
"flags",
"uint32",
")",
"{",
"C",
".",
"glowNamedBufferStorageExternalEXT",
"(",
"gpNamedBufferStorageExternalEXT",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"buffer",
")",
",",
"(",
"C",
".",
"GLintptr",
")",
"(",
"offset",
")",
",",
"(",
"C",
".",
"GLsizeiptr",
")",
"(",
"<mask>",
")",
",",
"(",
"C",
".",
"GLeglClientBufferEXT",
")",
"(",
"clientBuffer",
")",
",",
"(",
"C",
".",
"GLbitfield",
")",
"(",
"flags",
")",
")",
"\n",
"}"
]
|
19,493 | all-19494 | [
"MustAssetCode12",
"retrieves",
"the",
"AssetCode12",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
]
| [
"func",
"(",
"u",
"AllowTrustOpAsset",
")",
"MustAssetCode12",
"(",
")",
"[",
"12",
"]",
"byte",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetAssetCode12",
"(",
")",
"\n\n",
"if",
"!",
"<mask>",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"val",
"\n",
"}"
]
|
19,494 | all-19495 | [
"CreateDatacenter",
"creates",
"a",
"data",
"center"
]
| [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateDatacenter",
"(",
"dc",
"Datacenter",
")",
"(",
"*",
"Datacenter",
",",
"error",
")",
"{",
"url",
":=",
"dcColPath",
"(",
")",
"+",
"`?depth=`",
"+",
"c",
".",
"client",
".",
"<mask>",
"+",
"`&pretty=`",
"+",
"strconv",
".",
"FormatBool",
"(",
"c",
".",
"client",
".",
"pretty",
")",
"\n",
"ret",
":=",
"&",
"Datacenter",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"client",
".",
"Post",
"(",
"url",
",",
"dc",
",",
"ret",
",",
"http",
".",
"StatusAccepted",
")",
"\n",
"return",
"ret",
",",
"err",
"\n",
"}"
]
|
19,495 | all-19496 | [
"Items",
"returns",
"a",
"slice",
"of",
"all",
"items",
"in",
"the",
"set",
".",
"Modification",
"to",
"the",
"returned",
"slice",
"does",
"not",
"affect",
"the",
"structure",
"of",
"the",
"set",
".",
"However",
"any",
"item",
"in",
"the",
"set",
"that",
"is",
"a",
"pointer",
"will",
"be",
"affected",
"if",
"modified",
"."
]
| [
"func",
"(",
"s",
"*",
"<mask>",
")",
"Items",
"(",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n",
"items",
":=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"len",
"(",
"s",
".",
"m",
")",
")",
"\n",
"i",
":=",
"0",
"\n",
"for",
"k",
":=",
"range",
"s",
".",
"m",
"{",
"items",
"[",
"i",
"]",
"=",
"k",
"\n",
"i",
"++",
"\n",
"}",
"\n",
"return",
"items",
"\n",
"}"
]
|
19,496 | all-19497 | [
"HasSizeFormat",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"t",
"*",
"TraceServiceDefinition",
")",
"HasSizeFormat",
"(",
")",
"bool",
"{",
"if",
"t",
"!=",
"nil",
"&&",
"t",
".",
"SizeFormat",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
]
|
19,497 | all-19498 | [
"handleConn",
"is",
"used",
"to",
"handle",
"an",
"inbound",
"connection",
"for",
"its",
"lifespan",
".",
"The",
"handler",
"will",
"exit",
"when",
"the",
"passed",
"context",
"is",
"cancelled",
"or",
"the",
"connection",
"is",
"closed",
"."
]
| [
"func",
"(",
"n",
"*",
"NetworkTransport",
")",
"handleConn",
"(",
"connCtx",
"context",
".",
"Context",
",",
"<mask>",
"net",
".",
"Conn",
")",
"{",
"defer",
"conn",
".",
"Close",
"(",
")",
"\n",
"r",
":=",
"bufio",
".",
"NewReader",
"(",
"conn",
")",
"\n",
"w",
":=",
"bufio",
".",
"NewWriter",
"(",
"conn",
")",
"\n",
"dec",
":=",
"codec",
".",
"NewDecoder",
"(",
"r",
",",
"&",
"codec",
".",
"MsgpackHandle",
"{",
"}",
")",
"\n",
"enc",
":=",
"codec",
".",
"NewEncoder",
"(",
"w",
",",
"&",
"codec",
".",
"MsgpackHandle",
"{",
"}",
")",
"\n\n",
"for",
"{",
"select",
"{",
"case",
"<-",
"connCtx",
".",
"Done",
"(",
")",
":",
"n",
".",
"logger",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"default",
":",
"}",
"\n\n",
"if",
"err",
":=",
"n",
".",
"handleCommand",
"(",
"r",
",",
"dec",
",",
"enc",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"err",
"!=",
"io",
".",
"EOF",
"{",
"n",
".",
"logger",
".",
"Printf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"err",
":=",
"w",
".",
"Flush",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"n",
".",
"logger",
".",
"Printf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"}"
]
|
19,498 | all-19499 | [
"Create",
"creates",
"a",
"StoragePod",
"from",
"a",
"supplied",
"folder",
".",
"The",
"resulting",
"StoragePod",
"is",
"returned",
"."
]
| [
"func",
"Create",
"(",
"f",
"*",
"object",
".",
"Folder",
",",
"name",
"string",
")",
"(",
"*",
"object",
".",
"StoragePod",
",",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"f",
".",
"InventoryPath",
",",
"name",
")",
")",
"\n",
"ctx",
",",
"cancel",
":=",
"<mask>",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"provider",
".",
"DefaultAPITimeout",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"pod",
",",
"err",
":=",
"f",
".",
"CreateStoragePod",
"(",
"ctx",
",",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"pod",
",",
"nil",
"\n",
"}"
]
|
19,499 | all-19500 | [
"Convert",
"between",
"function",
"type",
"strings",
"and",
"lists",
"of",
"types",
".",
"Using",
"strings",
"makes",
"this",
"a",
"little",
"harder",
"but",
"it",
"makes",
"a",
"lot",
"of",
"the",
"rest",
"of",
"the",
"code",
"easier",
".",
"This",
"will",
"all",
"go",
"away",
"when",
"we",
"can",
"use",
"go",
"/",
"typechecker",
"directly",
".",
"splitFunc",
"splits",
"func",
"(",
"x",
"y",
"z",
")",
"(",
"a",
"b",
"c",
")",
"into",
"[",
"x",
"y",
"z",
"]",
"and",
"[",
"a",
"b",
"c",
"]",
"."
]
| [
"func",
"splitFunc",
"(",
"s",
"string",
")",
"(",
"in",
",",
"out",
"[",
"]",
"string",
")",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"s",
",",
"\"",
"\"",
")",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"i",
":=",
"len",
"(",
"\"",
"\"",
")",
"// index of beginning of 'in' arguments",
"\n",
"nparen",
":=",
"0",
"\n",
"for",
"j",
":=",
"i",
";",
"j",
"<",
"len",
"(",
"s",
")",
";",
"j",
"++",
"{",
"switch",
"s",
"[",
"j",
"]",
"{",
"case",
"'('",
":",
"nparen",
"++",
"\n",
"<mask>",
"')'",
":",
"nparen",
"--",
"\n",
"if",
"nparen",
"<",
"0",
"{",
"// found end of parameter list",
"out",
":=",
"strings",
".",
"TrimSpace",
"(",
"s",
"[",
"j",
"+",
"1",
":",
"]",
")",
"\n",
"if",
"len",
"(",
"out",
")",
">=",
"2",
"&&",
"out",
"[",
"0",
"]",
"==",
"'('",
"&&",
"out",
"[",
"len",
"(",
"out",
")",
"-",
"1",
"]",
"==",
"')'",
"{",
"out",
"=",
"out",
"[",
"1",
":",
"len",
"(",
"out",
")",
"-",
"1",
"]",
"\n",
"}",
"\n",
"return",
"split",
"(",
"s",
"[",
"i",
":",
"j",
"]",
")",
",",
"split",
"(",
"out",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
",",
"nil",
"\n",
"}"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.