id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
sequencelengths 1
418
| pl_tokens
sequencelengths 22
4.98k
|
---|---|---|---|
12,600 | all-12601 | [
"Get",
"the",
"href",
"of",
"an",
"audit",
"entry",
"from",
"the",
"Links",
"attribute",
"by",
"inspecting",
"the",
"self",
"link"
] | [
"func",
"getHref",
"(",
"entry",
"*",
"cm15",
".",
"AuditEntry",
")",
"string",
"{",
"<mask>",
"href",
"string",
"\n",
"for",
"_",
",",
"link",
":=",
"range",
"entry",
".",
"Links",
"{",
"if",
"link",
"[",
"\"",
"\"",
"]",
"==",
"\"",
"\"",
"{",
"href",
"=",
"link",
"[",
"\"",
"\"",
"]",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"href",
"\n",
"}"
] |
12,601 | all-12602 | [
"copy",
"pixels",
"into",
"a",
"2D",
"texture",
"image"
] | [
"func",
"CopyTexImage2D",
"(",
"target",
"uint32",
",",
"level",
"int32",
",",
"internalformat",
"uint32",
",",
"x",
"int32",
",",
"y",
"int32",
",",
"<mask>",
"int32",
",",
"height",
"int32",
",",
"border",
"int32",
")",
"{",
"syscall",
".",
"Syscall9",
"(",
"gpCopyTexImage2D",
",",
"8",
",",
"uintptr",
"(",
"target",
")",
",",
"uintptr",
"(",
"level",
")",
",",
"uintptr",
"(",
"internalformat",
")",
",",
"uintptr",
"(",
"x",
")",
",",
"uintptr",
"(",
"y",
")",
",",
"uintptr",
"(",
"width",
")",
",",
"uintptr",
"(",
"height",
")",
",",
"uintptr",
"(",
"border",
")",
",",
"0",
")",
"\n",
"}"
] |
12,602 | all-12603 | [
"Logger",
"returns",
"a",
"new",
"logger",
"to",
"be",
"wrapped",
"around",
"your",
"main",
"http",
".",
"Handler"
] | [
"func",
"Logger",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"HandlerFunc",
"{",
"stdlogger",
":=",
"log",
".",
"New",
"(",
"os",
".",
"Stdout",
",",
"\"",
"\"",
",",
"0",
")",
"\n",
"//errlogger := log.New(os.Stderr, \"\", 0)",
"return",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"<mask>",
".",
"Request",
")",
"{",
"// Start timer",
"start",
":=",
"time",
".",
"Now",
"(",
")",
"\n\n",
"// Process request",
"writer",
":=",
"statusWriter",
"{",
"w",
",",
"0",
"}",
"\n",
"next",
".",
"ServeHTTP",
"(",
"&",
"writer",
",",
"r",
")",
"\n\n",
"// Stop timer",
"end",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"latency",
":=",
"end",
".",
"Sub",
"(",
"start",
")",
"\n\n",
"clientIP",
":=",
"r",
".",
"RemoteAddr",
"\n",
"method",
":=",
"r",
".",
"Method",
"\n",
"statusCode",
":=",
"writer",
".",
"status",
"\n",
"statusColor",
":=",
"colorForStatus",
"(",
"statusCode",
")",
"\n",
"methodColor",
":=",
"colorForMethod",
"(",
"method",
")",
"\n\n",
"stdlogger",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"end",
".",
"Format",
"(",
"\"",
"\"",
")",
",",
"statusColor",
",",
"statusCode",
",",
"reset",
",",
"latency",
",",
"clientIP",
",",
"methodColor",
",",
"reset",
",",
"method",
",",
"r",
".",
"URL",
".",
"Path",
",",
")",
"\n",
"}",
"\n",
"}"
] |
12,603 | all-12604 | [
"Main",
"draws",
"a",
"rotated",
"face",
"of",
"the",
"gopher",
".",
"Afterwards",
"it",
"returns",
"the",
"filename",
".",
"This",
"should",
"only",
"be",
"used",
"during",
"testing",
"."
] | [
"func",
"Main",
"(",
"gc",
"draw2d",
".",
"GraphicContext",
",",
"ext",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"gc",
".",
"SetStrokeColor",
"(",
"image",
".",
"Black",
")",
"\n",
"gc",
".",
"SetFillColor",
"(",
"<mask>",
".",
"White",
")",
"\n",
"gc",
".",
"Save",
"(",
")",
"\n",
"// Draw a (partial) gopher",
"gc",
".",
"Translate",
"(",
"-",
"60",
",",
"65",
")",
"\n",
"gc",
".",
"Rotate",
"(",
"-",
"30",
"*",
"(",
"math",
".",
"Pi",
"/",
"180.0",
")",
")",
"\n",
"Draw",
"(",
"gc",
",",
"48",
",",
"48",
",",
"240",
",",
"72",
")",
"\n",
"gc",
".",
"Restore",
"(",
")",
"\n\n",
"// Return the output filename",
"return",
"samples",
".",
"Output",
"(",
"\"",
"\"",
",",
"ext",
")",
",",
"nil",
"\n",
"}"
] |
12,604 | all-12605 | [
"read",
"string"
] | [
"func",
"readstr",
"(",
"pos",
"uint32",
")",
"string",
"{",
"pos2",
":=",
"int64",
"(",
"pos",
")",
"\n",
"var",
"retval",
"string",
"\n",
"lenbyte",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"1",
")",
"\n",
"_",
",",
"err",
":=",
"f",
".",
"ReadAt",
"(",
"lenbyte",
",",
"pos2",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"strlen",
":=",
"lenbyte",
"[",
"0",
"]",
"\n",
"<mask>",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"strlen",
")",
"\n",
"_",
",",
"err",
"=",
"f",
".",
"ReadAt",
"(",
"data",
",",
"pos2",
"+",
"1",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"retval",
"=",
"string",
"(",
"data",
"[",
":",
"strlen",
"]",
")",
"\n",
"return",
"retval",
"\n",
"}"
] |
12,605 | all-12606 | [
"ApplyChanges",
"applies",
"a",
"given",
"set",
"of",
"changes",
"in",
"a",
"given",
"zone",
"."
] | [
"func",
"(",
"p",
"*",
"RcodeZeroProvider",
")",
"ApplyChanges",
"(",
"changes",
"*",
"plan",
".",
"Changes",
")",
"error",
"{",
"combinedChanges",
":=",
"make",
"(",
"[",
"]",
"*",
"rc0",
".",
"RRSetChange",
",",
"0",
",",
"len",
"(",
"<mask>",
".",
"Create",
")",
"+",
"len",
"(",
"changes",
".",
"UpdateNew",
")",
"+",
"len",
"(",
"changes",
".",
"Delete",
")",
")",
"\n\n",
"combinedChanges",
"=",
"append",
"(",
"combinedChanges",
",",
"p",
".",
"NewRcodezeroChanges",
"(",
"rc0",
".",
"ChangeTypeADD",
",",
"changes",
".",
"Create",
")",
"...",
")",
"\n",
"combinedChanges",
"=",
"append",
"(",
"combinedChanges",
",",
"p",
".",
"NewRcodezeroChanges",
"(",
"rc0",
".",
"ChangeTypeUPDATE",
",",
"changes",
".",
"UpdateNew",
")",
"...",
")",
"\n",
"combinedChanges",
"=",
"append",
"(",
"combinedChanges",
",",
"p",
".",
"NewRcodezeroChanges",
"(",
"rc0",
".",
"ChangeTypeDELETE",
",",
"changes",
".",
"Delete",
")",
"...",
")",
"\n\n",
"return",
"p",
".",
"submitChanges",
"(",
"combinedChanges",
")",
"\n",
"}"
] |
12,606 | all-12607 | [
"CVAPI",
"(",
"void",
")",
"cvConvertScale",
"(",
"const",
"CvArr",
"*",
"src",
"CvArr",
"*",
"dst",
"double",
"scale",
"CV_DEFAULT",
"(",
"1",
")",
"double",
"shift",
"CV_DEFAULT",
"(",
"0",
")",
")",
";",
"/",
"*",
"Converts",
"input",
"array",
"pixels",
"from",
"one",
"color",
"space",
"to",
"another"
] | [
"func",
"CvtColor",
"(",
"src",
",",
"dst",
"*",
"IplImage",
",",
"code",
"int",
")",
"{",
"C",
".",
"cvCvtColor",
"(",
"unsafe",
".",
"Pointer",
"(",
"src",
")",
",",
"unsafe",
".",
"Pointer",
"(",
"dst",
")",
",",
"C",
".",
"int",
"(",
"<mask>",
")",
")",
"\n",
"}"
] |
12,607 | all-12608 | [
"GetAWSCreds",
"tries",
"to",
"fetch",
"AWS",
"credentials",
"from",
"a",
"resource"
] | [
"func",
"GetAWSCreds",
"(",
"r",
"*",
"common",
".",
"<mask>",
")",
"(",
"credentials",
".",
"Value",
",",
"error",
")",
"{",
"val",
":=",
"credentials",
".",
"Value",
"{",
"}",
"\n\n",
"if",
"r",
".",
"Type",
"!=",
"ResourceType",
"{",
"return",
"val",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ResourceType",
",",
"r",
".",
"Type",
")",
"\n",
"}",
"\n\n",
"accessKey",
",",
"ok",
":=",
"r",
".",
"UserData",
".",
"Map",
".",
"Load",
"(",
"UserDataAccessIDKey",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"val",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"secretKey",
",",
"ok",
":=",
"r",
".",
"UserData",
".",
"Map",
".",
"Load",
"(",
"UserDataSecretAccessKey",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"val",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"val",
".",
"AccessKeyID",
"=",
"accessKey",
".",
"(",
"string",
")",
"\n",
"val",
".",
"SecretAccessKey",
"=",
"secretKey",
".",
"(",
"string",
")",
"\n\n",
"return",
"val",
",",
"nil",
"\n\n",
"}"
] |
12,608 | all-12609 | [
"AcyclicTransformer",
"returns",
"a",
"Transformer",
"with",
"a",
"filter",
"applied",
"that",
"ensures",
"that",
"the",
"transformer",
"cannot",
"be",
"recursively",
"applied",
"upon",
"its",
"own",
"output",
".",
"An",
"example",
"use",
"case",
"is",
"a",
"transformer",
"that",
"splits",
"a",
"string",
"by",
"lines",
":",
"AcyclicTransformer",
"(",
"SplitLines",
"func",
"(",
"s",
"string",
")",
"[]",
"string",
"{",
"return",
"strings",
".",
"Split",
"(",
"s",
"\\",
"n",
")",
"}",
")",
"Had",
"this",
"been",
"an",
"unfiltered",
"Transformer",
"instead",
"this",
"would",
"result",
"in",
"an",
"infinite",
"cycle",
"converting",
"a",
"string",
"to",
"[]",
"string",
"to",
"[]",
"[]",
"string",
"and",
"so",
"on",
"."
] | [
"func",
"AcyclicTransformer",
"(",
"<mask>",
"string",
",",
"xformFunc",
"interface",
"{",
"}",
")",
"cmp",
".",
"Option",
"{",
"xf",
":=",
"xformFilter",
"{",
"cmp",
".",
"Transformer",
"(",
"name",
",",
"xformFunc",
")",
"}",
"\n",
"return",
"cmp",
".",
"FilterPath",
"(",
"xf",
".",
"filter",
",",
"xf",
".",
"xform",
")",
"\n",
"}"
] |
12,609 | all-12610 | [
"LoadRestClient",
"loads",
"a",
"saved",
"vSphere",
"REST",
"API",
"session",
"from",
"disk",
"previously",
"saved",
"by",
"SaveRestClient",
"checking",
"it",
"for",
"validity",
"before",
"returning",
"it",
".",
"If",
"it",
"s",
"not",
"valid",
"false",
"is",
"returned",
"as",
"the",
"third",
"return",
"value",
"but",
"the",
"client",
"can",
"still",
"be",
"technically",
"used",
"for",
"logging",
"in",
"by",
"calling",
"Login",
"on",
"the",
"client",
"."
] | [
"func",
"(",
"c",
"*",
"Config",
")",
"LoadRestClient",
"(",
"ctx",
"context",
".",
"Context",
",",
"u",
"*",
"<mask>",
".",
"URL",
")",
"(",
"*",
"tags",
".",
"RestClient",
",",
"bool",
",",
"error",
")",
"{",
"id",
",",
"err",
":=",
"c",
".",
"readRestSessionID",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"client",
":=",
"tags",
".",
"NewClientWithSessionID",
"(",
"u",
",",
"c",
".",
"InsecureFlag",
",",
"\"",
"\"",
",",
"id",
")",
"\n\n",
"if",
"id",
"==",
"\"",
"\"",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"client",
",",
"false",
",",
"nil",
"\n",
"}",
"\n\n",
"if",
"!",
"client",
".",
"Valid",
"(",
"ctx",
")",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"client",
",",
"false",
",",
"nil",
"\n",
"}",
"\n\n",
"log",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"client",
",",
"true",
",",
"nil",
"\n",
"}"
] |
12,610 | all-12611 | [
"NewInstanceDiscovery",
"returns",
"a",
"new",
"instance",
"discovery",
"."
] | [
"func",
"newInstanceDiscovery",
"(",
"provider",
"*",
"gophercloud",
".",
"ProviderClient",
",",
"opts",
"*",
"gophercloud",
".",
"AuthOptions",
",",
"port",
"int",
",",
"region",
"string",
",",
"allTenants",
"bool",
",",
"l",
"log",
".",
"Logger",
")",
"*",
"InstanceDiscovery",
"{",
"if",
"l",
"==",
"nil",
"{",
"l",
"=",
"log",
".",
"NewNopLogger",
"(",
")",
"\n",
"}",
"\n",
"return",
"&",
"InstanceDiscovery",
"{",
"provider",
":",
"provider",
",",
"authOpts",
":",
"opts",
",",
"<mask>",
":",
"region",
",",
"port",
":",
"port",
",",
"allTenants",
":",
"allTenants",
",",
"logger",
":",
"l",
"}",
"\n",
"}"
] |
12,611 | all-12612 | [
"UnmarshalJSON",
"implements",
"json",
".",
"Unmarshaler",
"."
] | [
"func",
"(",
"ls",
"*",
"Labels",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"<mask>",
")",
"error",
"{",
"var",
"m",
"map",
"[",
"string",
"]",
"string",
"\n\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"b",
",",
"&",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"ls",
"=",
"FromMap",
"(",
"m",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,612 | all-12613 | [
"==",
"Utility",
"checkGroup",
"indicates",
"if",
"a",
"value",
"is",
"into",
"a",
"group",
"."
] | [
"func",
"checkGroup",
"(",
"group",
"[",
"]",
"string",
",",
"value",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"v",
":=",
"<mask>",
"group",
"{",
"if",
"v",
"==",
"value",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] |
12,613 | all-12614 | [
"BatchUpdate",
"provides",
"a",
"mock",
"function",
"with",
"given",
"fields",
":",
"id",
"data",
"store",
"opts"
] | [
"func",
"(",
"_m",
"*",
"ObjectStore",
")",
"BatchUpdate",
"(",
"<mask>",
"[",
"]",
"interface",
"{",
"}",
",",
"data",
"[",
"]",
"interface",
"{",
"}",
",",
"store",
"string",
",",
"opts",
"gostore",
".",
"ObjectStoreOptions",
")",
"error",
"{",
"ret",
":=",
"_m",
".",
"Called",
"(",
"id",
",",
"data",
",",
"store",
",",
"opts",
")",
"\n\n",
"var",
"r0",
"error",
"\n",
"if",
"rf",
",",
"ok",
":=",
"ret",
".",
"Get",
"(",
"0",
")",
".",
"(",
"func",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"[",
"]",
"interface",
"{",
"}",
",",
"string",
",",
"gostore",
".",
"ObjectStoreOptions",
")",
"error",
")",
";",
"ok",
"{",
"r0",
"=",
"rf",
"(",
"id",
",",
"data",
",",
"store",
",",
"opts",
")",
"\n",
"}",
"else",
"{",
"r0",
"=",
"ret",
".",
"Error",
"(",
"0",
")",
"\n",
"}",
"\n\n",
"return",
"r0",
"\n",
"}"
] |
12,614 | all-12615 | [
"Last",
"yields",
"the",
"last",
"n",
"items",
"that",
"it",
"receives",
"."
] | [
"func",
"Last",
"(",
"n",
"int",
")",
"Filter",
"{",
"return",
"FilterFunc",
"(",
"func",
"(",
"arg",
"Arg",
")",
"error",
"{",
"r",
":=",
"newRing",
"(",
"n",
")",
"\n",
"for",
"s",
":=",
"<mask>",
"arg",
".",
"In",
"{",
"r",
".",
"pushBack",
"(",
"s",
")",
"\n",
"}",
"\n",
"for",
"!",
"r",
".",
"empty",
"(",
")",
"{",
"arg",
".",
"Out",
"<-",
"r",
".",
"popFront",
"(",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
")",
"\n",
"}"
] |
12,615 | all-12616 | [
"subscribedToMessage",
"returns",
"whether",
"we",
"are",
"subscribed",
"to",
"one",
"of",
"the",
"topics",
"of",
"a",
"given",
"message"
] | [
"func",
"(",
"p",
"*",
"PubSub",
")",
"subscribedToMsg",
"(",
"<mask>",
"*",
"pb",
".",
"Message",
")",
"bool",
"{",
"if",
"len",
"(",
"p",
".",
"myTopics",
")",
"==",
"0",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"t",
":=",
"range",
"msg",
".",
"GetTopicIDs",
"(",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"p",
".",
"myTopics",
"[",
"t",
"]",
";",
"ok",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] |
12,616 | all-12617 | [
"MarshalEasyJSON",
"satisfies",
"easyjson",
".",
"Marshaler",
"."
] | [
"func",
"(",
"t",
"Subtype",
")",
"MarshalEasyJSON",
"(",
"out",
"*",
"jwriter",
".",
"Writer",
")",
"{",
"<mask>",
".",
"String",
"(",
"string",
"(",
"t",
")",
")",
"\n",
"}"
] |
12,617 | all-12618 | [
"DestroyServer",
"issues",
"a",
"request",
"to",
"destroy",
"the",
"server"
] | [
"func",
"(",
"c",
"*",
"<mask>",
")",
"DestroyServer",
"(",
"identifier",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"MakeApiRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
"+",
"identifier",
",",
"nil",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,618 | all-12619 | [
"CONTRACT",
":",
"rv",
".",
"CanAddr",
"()",
"is",
"true",
"."
] | [
"func",
"(",
"cdc",
"*",
"Codec",
")",
"decodeReflectBinaryStruct",
"(",
"bz",
"[",
"]",
"byte",
",",
"info",
"*",
"TypeInfo",
",",
"rv",
"reflect",
".",
"Value",
",",
"_",
"FieldOptions",
",",
"bare",
"bool",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"if",
"!",
"rv",
".",
"CanAddr",
"(",
")",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"printLog",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
")",
"\n",
"}",
"(",
")",
"\n",
"}",
"\n",
"_n",
":=",
"0",
"// nolint: ineffassign",
"\n\n",
"// NOTE: The \"Struct\" typ3 doesn't get read here.",
"// It's already implied, either by struct-key or list-element-type-byte.",
"if",
"!",
"bare",
"{",
"// Read byte-length prefixed byteslice.",
"var",
"buf",
",",
"_n",
"=",
"[",
"]",
"byte",
"(",
"nil",
")",
",",
"int",
"(",
"0",
")",
"\n",
"buf",
",",
"_n",
",",
"err",
"=",
"DecodeByteSlice",
"(",
"bz",
")",
"\n",
"if",
"slide",
"(",
"&",
"bz",
",",
"nil",
",",
"_n",
")",
"&&",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"// This is a trick for debuggability -- we slide on &n more later.",
"n",
"+=",
"UvarintSize",
"(",
"uint64",
"(",
"len",
"(",
"buf",
")",
")",
")",
"\n",
"bz",
"=",
"buf",
"\n",
"}",
"\n\n",
"switch",
"info",
".",
"Type",
"{",
"case",
"timeType",
":",
"// Special case: time.Time",
"var",
"t",
"time",
".",
"Time",
"\n",
"t",
",",
"_n",
",",
"err",
"=",
"DecodeTime",
"(",
"bz",
")",
"\n",
"if",
"slide",
"(",
"&",
"bz",
",",
"&",
"n",
",",
"_n",
")",
"&&",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"rv",
".",
"Set",
"(",
"reflect",
".",
"ValueOf",
"(",
"t",
")",
")",
"\n\n",
"default",
":",
"// Track the last seen field number.",
"var",
"lastFieldNum",
"uint32",
"\n",
"// Read each field.",
"for",
"_",
",",
"field",
":=",
"range",
"info",
".",
"Fields",
"{",
"// Get field rv and info.",
"var",
"frv",
"=",
"rv",
".",
"Field",
"(",
"field",
".",
"Index",
")",
"\n",
"var",
"finfo",
"*",
"TypeInfo",
"\n",
"finfo",
",",
"err",
"=",
"cdc",
".",
"getTypeInfo_wlock",
"(",
"<mask>",
".",
"Type",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"// We're done if we've consumed all the bytes.",
"if",
"len",
"(",
"bz",
")",
"==",
"0",
"{",
"frv",
".",
"Set",
"(",
"defaultValue",
"(",
"frv",
".",
"Type",
"(",
")",
")",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"if",
"field",
".",
"UnpackedList",
"{",
"// This is a list that was encoded unpacked, e.g.",
"// with repeated field entries for each list item.",
"_n",
",",
"err",
"=",
"cdc",
".",
"decodeReflectBinary",
"(",
"bz",
",",
"finfo",
",",
"frv",
",",
"field",
".",
"FieldOptions",
",",
"true",
")",
"\n",
"if",
"slide",
"(",
"&",
"bz",
",",
"&",
"n",
",",
"_n",
")",
"&&",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"}",
"else",
"{",
"// Read field key (number and type).",
"var",
"fnum",
",",
"typ",
"=",
"uint32",
"(",
"0",
")",
",",
"Typ3",
"(",
"0x00",
")",
"\n",
"fnum",
",",
"typ",
",",
"_n",
",",
"err",
"=",
"decodeFieldNumberAndTyp3",
"(",
"bz",
")",
"\n",
"if",
"field",
".",
"BinFieldNum",
"<",
"fnum",
"{",
"// Set zero field value.",
"frv",
".",
"Set",
"(",
"defaultValue",
"(",
"frv",
".",
"Type",
"(",
")",
")",
")",
"\n",
"continue",
"\n",
"// Do not slide, we will read it again.",
"}",
"\n",
"if",
"fnum",
"<=",
"lastFieldNum",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
",",
"fnum",
",",
"lastFieldNum",
",",
"bz",
")",
"\n",
"return",
"\n",
"}",
"\n",
"lastFieldNum",
"=",
"fnum",
"\n",
"if",
"slide",
"(",
"&",
"bz",
",",
"&",
"n",
",",
"_n",
")",
"&&",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"// Validate fnum and typ.",
"// NOTE: In the future, we'll support upgradeability.",
"// So in the future, this may not match,",
"// so we will need to remove this sanity check.",
"if",
"field",
".",
"BinFieldNum",
"!=",
"fnum",
"{",
"err",
"=",
"errors",
".",
"New",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"field",
".",
"BinFieldNum",
",",
"info",
".",
"Type",
",",
"fnum",
")",
")",
"\n",
"return",
"\n",
"}",
"\n",
"typWanted",
":=",
"typeToTyp3",
"(",
"finfo",
".",
"Type",
",",
"field",
".",
"FieldOptions",
")",
"\n",
"if",
"typ",
"!=",
"typWanted",
"{",
"err",
"=",
"errors",
".",
"New",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"typWanted",
",",
"fnum",
",",
"info",
".",
"Type",
",",
"typ",
")",
")",
"\n",
"return",
"\n",
"}",
"\n",
"// Decode field into frv.",
"_n",
",",
"err",
"=",
"cdc",
".",
"decodeReflectBinary",
"(",
"bz",
",",
"finfo",
",",
"frv",
",",
"field",
".",
"FieldOptions",
",",
"false",
")",
"\n",
"if",
"slide",
"(",
"&",
"bz",
",",
"&",
"n",
",",
"_n",
")",
"&&",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Consume any remaining fields.",
"var",
"_n",
",",
"fnum",
"=",
"0",
",",
"uint32",
"(",
"0",
")",
"\n",
"var",
"typ3",
"Typ3",
"\n",
"for",
"len",
"(",
"bz",
")",
">",
"0",
"{",
"fnum",
",",
"typ3",
",",
"_n",
",",
"err",
"=",
"decodeFieldNumberAndTyp3",
"(",
"bz",
")",
"\n",
"if",
"slide",
"(",
"&",
"bz",
",",
"&",
"n",
",",
"_n",
")",
"&&",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"if",
"fnum",
"<=",
"lastFieldNum",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
",",
"fnum",
",",
"lastFieldNum",
",",
"bz",
")",
"\n",
"return",
"\n",
"}",
"\n",
"lastFieldNum",
"=",
"fnum",
"\n\n",
"_n",
",",
"err",
"=",
"consumeAny",
"(",
"typ3",
",",
"bz",
")",
"\n",
"if",
"slide",
"(",
"&",
"bz",
",",
"&",
"n",
",",
"_n",
")",
"&&",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] |
12,619 | all-12620 | [
"readTagsForResource",
"reads",
"the",
"tags",
"for",
"a",
"given",
"reference",
"and",
"saves",
"the",
"list",
"in",
"the",
"supplied",
"ResourceData",
".",
"It",
"returns",
"an",
"error",
"if",
"there",
"was",
"an",
"issue",
"reading",
"the",
"tags",
"."
] | [
"func",
"readTagsForResource",
"(",
"client",
"*",
"tags",
".",
"RestClient",
",",
"obj",
"object",
".",
"Reference",
",",
"d",
"*",
"schema",
".",
"ResourceData",
")",
"error",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"obj",
".",
"Reference",
"(",
")",
".",
"Value",
")",
"\n",
"objID",
":=",
"obj",
".",
"Reference",
"(",
")",
".",
"Value",
"\n",
"objType",
",",
"err",
":=",
"tagTypeForObject",
"(",
"obj",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"defaultAPITimeout",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"ids",
",",
"err",
":=",
"client",
".",
"ListAttachedTags",
"(",
"ctx",
",",
"objID",
",",
"objType",
")",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"objID",
",",
"strings",
".",
"Join",
"(",
"ids",
",",
"\"",
"\"",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"err",
":=",
"d",
".",
"<mask>",
"(",
"vSphereTagAttributeKey",
",",
"ids",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,620 | all-12621 | [
"ServerArrayLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | [
"func",
"(",
"api",
"*",
"API",
")",
"ServerArrayLocator",
"(",
"href",
"<mask>",
")",
"*",
"ServerArrayLocator",
"{",
"return",
"&",
"ServerArrayLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] |
12,621 | all-12622 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"EventWebSocketFrameSent",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"<mask>",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoNetwork42",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
12,622 | all-12623 | [
"GenerateImage",
"creates",
"an",
"image",
"from",
"an",
"input",
".",
"It",
"returns",
"the",
"image",
"(",
"[]",
"byte",
")",
"and",
"any",
"error",
"encountered",
"."
] | [
"func",
"GenerateImage",
"(",
"options",
"*",
"ImageOptions",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"arr",
",",
"err",
":=",
"buildParams",
"(",
"options",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"byte",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"options",
".",
"BinaryPath",
"==",
"\"",
"\"",
"{",
"return",
"[",
"]",
"byte",
"{",
"}",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"options",
".",
"BinaryPath",
",",
"arr",
"...",
")",
"\n\n",
"if",
"<mask>",
".",
"Html",
"!=",
"\"",
"\"",
"{",
"cmd",
".",
"Stdin",
"=",
"strings",
".",
"NewReader",
"(",
"options",
".",
"Html",
")",
"\n",
"}",
"\n\n",
"output",
",",
"err",
":=",
"cmd",
".",
"CombinedOutput",
"(",
")",
"\n\n",
"trimmed",
":=",
"cleanupOutput",
"(",
"output",
",",
"options",
".",
"Format",
")",
"\n\n",
"return",
"trimmed",
",",
"err",
"\n",
"}"
] |
12,623 | all-12624 | [
"configure",
"loads",
"config",
"from",
"config",
"file",
"schemas",
".",
"conf",
"aggregation",
".",
"conf"
] | [
"func",
"(",
"app",
"*",
"App",
")",
"configure",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"cfg",
",",
"err",
":=",
"ReadConfig",
"(",
"app",
".",
"ConfigFilename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// carbon-cache prefix",
"if",
"hostname",
",",
"err",
":=",
"os",
".",
"Hostname",
"(",
")",
";",
"err",
"==",
"nil",
"{",
"hostname",
"=",
"strings",
".",
"Replace",
"(",
"hostname",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n",
"cfg",
".",
"Common",
".",
"GraphPrefix",
"=",
"strings",
".",
"Replace",
"(",
"cfg",
".",
"Common",
".",
"GraphPrefix",
",",
"\"",
"\"",
",",
"hostname",
",",
"-",
"1",
")",
"\n",
"}",
"else",
"{",
"cfg",
".",
"Common",
".",
"GraphPrefix",
"=",
"strings",
".",
"Replace",
"(",
"cfg",
".",
"Common",
".",
"GraphPrefix",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n",
"}",
"\n\n",
"if",
"cfg",
".",
"Whisper",
".",
"Enabled",
"{",
"cfg",
".",
"Whisper",
".",
"Schemas",
",",
"err",
"=",
"persister",
".",
"ReadWhisperSchemas",
"(",
"cfg",
".",
"Whisper",
".",
"SchemasFilename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"cfg",
".",
"Whisper",
".",
"AggregationFilename",
"!=",
"\"",
"\"",
"{",
"cfg",
".",
"Whisper",
".",
"Aggregation",
",",
"err",
"=",
"persister",
".",
"ReadWhisperAggregation",
"(",
"cfg",
".",
"Whisper",
".",
"AggregationFilename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"else",
"{",
"cfg",
".",
"Whisper",
".",
"Aggregation",
"=",
"persister",
".",
"NewWhisperAggregation",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"!",
"(",
"cfg",
".",
"Cache",
".",
"WriteStrategy",
"==",
"\"",
"\"",
"||",
"cfg",
".",
"Cache",
".",
"WriteStrategy",
"==",
"\"",
"\"",
"||",
"cfg",
".",
"Cache",
".",
"WriteStrategy",
"==",
"\"",
"\"",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\\\"",
"\\\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"cfg",
".",
"Common",
".",
"MetricEndpoint",
"==",
"\"",
"\"",
"{",
"cfg",
".",
"Common",
".",
"MetricEndpoint",
"=",
"MetricEndpointLocal",
"\n",
"}",
"\n\n",
"if",
"cfg",
".",
"Common",
".",
"MetricEndpoint",
"!=",
"MetricEndpointLocal",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"cfg",
".",
"Common",
".",
"MetricEndpoint",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
".",
"<mask>",
"(",
")",
")",
"\n",
"}",
"\n\n",
"if",
"u",
".",
"Scheme",
"!=",
"\"",
"\"",
"&&",
"u",
".",
"Scheme",
"!=",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"u",
".",
"Scheme",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"app",
".",
"Config",
"=",
"cfg",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
12,624 | all-12625 | [
"Logout",
"removes",
"any",
"established",
"authentication",
"credentials",
"for",
"the",
"database",
"."
] | [
"func",
"(",
"db",
"*",
"Database",
")",
"Logout",
"(",
")",
"{",
"session",
":=",
"db",
".",
"Session",
"\n",
"dbname",
":=",
"db",
".",
"Name",
"\n",
"session",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"found",
":=",
"false",
"\n",
"for",
"i",
",",
"cred",
":=",
"range",
"session",
".",
"creds",
"{",
"if",
"cred",
".",
"Source",
"==",
"dbname",
"{",
"copy",
"(",
"session",
".",
"creds",
"[",
"i",
":",
"]",
",",
"session",
".",
"creds",
"[",
"i",
"+",
"1",
":",
"]",
")",
"\n",
"session",
".",
"creds",
"=",
"session",
".",
"creds",
"[",
":",
"len",
"(",
"session",
".",
"creds",
")",
"-",
"1",
"]",
"\n",
"found",
"=",
"true",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"found",
"{",
"if",
"session",
".",
"masterSocket",
"!=",
"nil",
"{",
"<mask>",
".",
"masterSocket",
".",
"Logout",
"(",
"dbname",
")",
"\n",
"}",
"\n",
"if",
"session",
".",
"slaveSocket",
"!=",
"nil",
"{",
"session",
".",
"slaveSocket",
".",
"Logout",
"(",
"dbname",
")",
"\n",
"}",
"\n",
"}",
"\n",
"session",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"}"
] |
12,625 | all-12626 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"EventResumed",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoDebugger39",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
12,626 | all-12627 | [
"relName",
"returns",
"the",
"name",
"of",
"v",
"relative",
"to",
"i",
".",
"In",
"most",
"cases",
"this",
"is",
"identical",
"to",
"v",
".",
"Name",
"()",
"but",
"references",
"to",
"Functions",
"(",
"including",
"methods",
")",
"and",
"Globals",
"use",
"RelString",
"and",
"all",
"types",
"are",
"displayed",
"with",
"relType",
"so",
"that",
"only",
"cross",
"-",
"package",
"references",
"are",
"package",
"-",
"qualified",
"."
] | [
"func",
"relName",
"(",
"v",
"Value",
",",
"i",
"Instruction",
")",
"string",
"{",
"var",
"from",
"*",
"types",
".",
"Package",
"\n",
"if",
"i",
"!=",
"nil",
"{",
"from",
"=",
"i",
".",
"Parent",
"(",
")",
".",
"pkg",
"(",
")",
"\n",
"}",
"\n",
"switch",
"v",
":=",
"v",
".",
"(",
"type",
")",
"{",
"case",
"Member",
":",
"// *Function or *Global",
"return",
"v",
".",
"RelString",
"(",
"from",
")",
"\n",
"case",
"*",
"Const",
":",
"return",
"v",
".",
"RelString",
"(",
"from",
")",
"\n",
"}",
"\n",
"return",
"v",
".",
"<mask>",
"(",
")",
"\n",
"}"
] |
12,627 | all-12628 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"EventInspectNodeRequested",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoOverlay19",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"<mask>",
"(",
")",
"\n",
"}"
] |
12,628 | all-12629 | [
"Add",
"a",
"router",
"to",
"list"
] | [
"func",
"(",
"rs",
"*",
"Routers",
")",
"Add",
"(",
"r",
"router",
".",
"Router",
",",
"h",
"HandlerFunc",
",",
"v",
"view",
".",
"View",
")",
"{",
"defer",
"rs",
".",
"Unlock",
"(",
")",
"\n",
"<mask>",
".",
"Lock",
"(",
")",
"\n",
"s",
":=",
"struct",
"{",
"r",
"router",
".",
"Router",
"\n",
"v",
"view",
".",
"View",
"\n",
"h",
"HandlerFunc",
"\n",
"}",
"{",
"r",
",",
"v",
",",
"h",
"}",
"\n",
"// simple will full-match the path",
"if",
"sr",
",",
"ok",
":=",
"r",
".",
"(",
"*",
"router",
".",
"Base",
")",
";",
"ok",
"{",
"rs",
".",
"s",
"[",
"sr",
".",
"Path",
"]",
"=",
"s",
"\n",
"return",
"\n",
"}",
"\n",
"rs",
".",
"l",
".",
"PushFront",
"(",
"s",
")",
"\n",
"}"
] |
12,629 | all-12630 | [
"Do",
"executes",
"Memory",
".",
"forciblyPurgeJavaScriptMemory",
"against",
"the",
"provided",
"context",
"."
] | [
"func",
"(",
"p",
"*",
"ForciblyPurgeJavaScriptMemoryParams",
")",
"Do",
"(",
"ctx",
"<mask>",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"return",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandForciblyPurgeJavaScriptMemory",
",",
"nil",
",",
"nil",
")",
"\n",
"}"
] |
12,630 | all-12631 | [
"EncryptAES",
"encrypts",
"plaintext",
"using",
"AES",
"with",
"the",
"given",
"key",
".",
"key",
"should",
"be",
"either",
"16",
"24",
"or",
"32",
"bytes",
"to",
"select",
"AES",
"-",
"128",
"AES",
"-",
"192",
"or",
"AES",
"-",
"256",
".",
"plaintext",
"must",
"not",
"be",
"shorter",
"than",
"key",
"."
] | [
"func",
"EncryptAES",
"(",
"key",
"[",
"]",
"byte",
",",
"plaintext",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"block",
":=",
"AES",
".",
"GetCypher",
"(",
"key",
")",
"\n",
"defer",
"AES",
".",
"ReturnCypher",
"(",
"key",
",",
"block",
")",
"\n\n",
"// The IV needs to be unique, but not secure. Therefore it's common to",
"// include it at the beginning of the ciphertext.",
"ciphertext",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"aes",
".",
"BlockSize",
"+",
"len",
"(",
"plaintext",
")",
")",
"\n",
"iv",
":=",
"ciphertext",
"[",
":",
"aes",
".",
"BlockSize",
"]",
"\n",
"if",
"_",
",",
"err",
":=",
"io",
".",
"ReadFull",
"(",
"rand",
".",
"Reader",
",",
"iv",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"stream",
":=",
"cipher",
".",
"NewCFBEncrypter",
"(",
"block",
",",
"<mask>",
")",
"\n",
"stream",
".",
"XORKeyStream",
"(",
"ciphertext",
"[",
"aes",
".",
"BlockSize",
":",
"]",
",",
"plaintext",
")",
"\n\n",
"return",
"ciphertext",
"\n",
"}"
] |
12,631 | all-12632 | [
"/",
"*",
"Same",
"as",
"Eval",
"but",
"automatically",
"wraps",
"a",
"map",
"of",
"parameters",
"into",
"a",
"govalute",
".",
"Parameters",
"structure",
"."
] | [
"func",
"(",
"this",
"EvaluableExpression",
")",
"Evaluate",
"(",
"parameters",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"<mask>",
"{",
"}",
",",
"error",
")",
"{",
"if",
"parameters",
"==",
"nil",
"{",
"return",
"this",
".",
"Eval",
"(",
"nil",
")",
"\n",
"}",
"\n\n",
"return",
"this",
".",
"Eval",
"(",
"MapParameters",
"(",
"parameters",
")",
")",
"\n",
"}"
] |
12,632 | all-12633 | [
"ServeHTTP",
"is",
"the",
"HTTP",
"Entry",
"point",
"for",
"a",
"Macaron",
"instance",
".",
"Useful",
"if",
"you",
"want",
"to",
"control",
"your",
"own",
"HTTP",
"server",
".",
"Be",
"aware",
"that",
"none",
"of",
"middleware",
"will",
"run",
"without",
"registering",
"any",
"router",
"."
] | [
"func",
"(",
"m",
"*",
"Macaron",
")",
"ServeHTTP",
"(",
"rw",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"m",
".",
"hasURLPrefix",
"{",
"req",
".",
"URL",
".",
"<mask>",
"=",
"strings",
".",
"TrimPrefix",
"(",
"req",
".",
"URL",
".",
"Path",
",",
"m",
".",
"urlPrefix",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"h",
":=",
"range",
"m",
".",
"befores",
"{",
"if",
"h",
"(",
"rw",
",",
"req",
")",
"{",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"m",
".",
"Router",
".",
"ServeHTTP",
"(",
"rw",
",",
"req",
")",
"\n",
"}"
] |
12,633 | all-12634 | [
"Set",
"is",
"required",
"for",
"kingpin",
"interfaces",
"to",
"allow",
"command",
"line",
"params",
"to",
"be",
"set",
"to",
"our",
"map",
"datatype"
] | [
"func",
"(",
"o",
"*",
"ListErrorOption",
")",
"Set",
"(",
"<mask>",
"string",
")",
"error",
"{",
"val",
":=",
"ErrorOption",
"{",
"}",
"\n",
"val",
".",
"Set",
"(",
"value",
")",
"\n",
"*",
"o",
"=",
"append",
"(",
"*",
"o",
",",
"val",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,634 | all-12635 | [
"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",
"(",
"t",
"*",
"TemplateVariable",
")",
"GetNameOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"t",
"==",
"nil",
"||",
"t",
".",
"<mask>",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"t",
".",
"Name",
",",
"true",
"\n",
"}"
] |
12,635 | all-12636 | [
"Validate",
"inspects",
"the",
"fields",
"of",
"the",
"type",
"to",
"determine",
"if",
"they",
"are",
"valid",
"."
] | [
"func",
"(",
"s",
"*",
"InferenceAccelerator",
")",
"Validate",
"(",
")",
"error",
"{",
"invalidParams",
":=",
"request",
".",
"ErrInvalidParams",
"{",
"<mask>",
":",
"\"",
"\"",
"}",
"\n",
"if",
"s",
".",
"DeviceName",
"==",
"nil",
"{",
"invalidParams",
".",
"Add",
"(",
"request",
".",
"NewErrParamRequired",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"DeviceType",
"==",
"nil",
"{",
"invalidParams",
".",
"Add",
"(",
"request",
".",
"NewErrParamRequired",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n\n",
"if",
"invalidParams",
".",
"Len",
"(",
")",
">",
"0",
"{",
"return",
"invalidParams",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,636 | all-12637 | [
"HasTime",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"s",
"*",
"ScatterplotDefinition",
")",
"HasTime",
"(",
")",
"bool",
"{",
"if",
"s",
"!=",
"nil",
"&&",
"s",
".",
"Time",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
12,637 | all-12638 | [
"SetIconFromIconName",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_entry_set_icon_from_icon_name",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"<mask>",
")",
"SetIconFromIconName",
"(",
"iconPos",
"EntryIconPosition",
",",
"name",
"string",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"name",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"C",
".",
"gtk_entry_set_icon_from_icon_name",
"(",
"v",
".",
"native",
"(",
")",
",",
"C",
".",
"GtkEntryIconPosition",
"(",
"iconPos",
")",
",",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
")",
"\n",
"}"
] |
12,638 | all-12639 | [
"MarshalEasyJSON",
"satisfies",
"easyjson",
".",
"Marshaler",
"."
] | [
"func",
"(",
"t",
"PropertyName",
")",
"MarshalEasyJSON",
"(",
"out",
"*",
"jwriter",
".",
"Writer",
")",
"{",
"out",
".",
"<mask>",
"(",
"string",
"(",
"t",
")",
")",
"\n",
"}"
] |
12,639 | all-12640 | [
"GetObjects",
"gets",
"several",
"objects",
"out",
"of",
"the",
"object",
"store",
"by",
"hash",
"."
] | [
"func",
"(",
"c",
"APIClient",
")",
"GetObjects",
"(",
"hashes",
"[",
"]",
"string",
",",
"offset",
"uint64",
",",
"size",
"uint64",
",",
"totalSize",
"uint64",
",",
"writer",
"io",
".",
"Writer",
")",
"error",
"{",
"var",
"objects",
"[",
"]",
"*",
"pfs",
".",
"Object",
"\n",
"for",
"_",
",",
"hash",
":=",
"<mask>",
"hashes",
"{",
"objects",
"=",
"append",
"(",
"objects",
",",
"&",
"pfs",
".",
"Object",
"{",
"Hash",
":",
"hash",
"}",
")",
"\n",
"}",
"\n",
"getObjectsClient",
",",
"err",
":=",
"c",
".",
"ObjectAPIClient",
".",
"GetObjects",
"(",
"c",
".",
"Ctx",
"(",
")",
",",
"&",
"pfs",
".",
"GetObjectsRequest",
"{",
"Objects",
":",
"objects",
",",
"OffsetBytes",
":",
"offset",
",",
"SizeBytes",
":",
"size",
",",
"TotalSize",
":",
"totalSize",
",",
"}",
",",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"grpcutil",
".",
"WriteFromStreamingBytesClient",
"(",
"getObjectsClient",
",",
"writer",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,640 | all-12641 | [
"DescribeSyntaxError",
"describes",
"a",
"syntax",
"error",
"encountered",
"parsing",
"json",
"."
] | [
"func",
"DescribeSyntaxError",
"(",
"originalErr",
"error",
",",
"parsedBuffer",
"bytes",
".",
"Buffer",
")",
"error",
"{",
"sErr",
",",
"ok",
":=",
"originalErr",
".",
"(",
"*",
"json",
".",
"SyntaxError",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"originalErr",
"\n",
"}",
"\n\n",
"buffer",
":=",
"<mask>",
"(",
"[",
"]",
"byte",
",",
"sErr",
".",
"Offset",
")",
"\n",
"parsedBuffer",
".",
"Read",
"(",
"buffer",
")",
"\n\n",
"lineOffset",
":=",
"strings",
".",
"LastIndex",
"(",
"string",
"(",
"buffer",
"[",
":",
"len",
"(",
"buffer",
")",
"-",
"1",
"]",
")",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"if",
"lineOffset",
"==",
"-",
"1",
"{",
"lineOffset",
"=",
"0",
"\n",
"}",
"\n\n",
"lines",
":=",
"strings",
".",
"Split",
"(",
"string",
"(",
"buffer",
"[",
":",
"len",
"(",
"buffer",
")",
"-",
"1",
"]",
")",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"lineNumber",
":=",
"len",
"(",
"lines",
")",
"\n\n",
"descriptiveErrorString",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\\n",
"\\n",
"\\n",
"\"",
",",
"lineNumber",
",",
"string",
"(",
"buffer",
"[",
"lineOffset",
":",
"]",
")",
",",
"strings",
".",
"Repeat",
"(",
"\"",
"\"",
",",
"int",
"(",
"sErr",
".",
"Offset",
")",
"-",
"2",
"-",
"lineOffset",
")",
",",
"originalErr",
",",
")",
"\n\n",
"return",
"errors",
".",
"New",
"(",
"descriptiveErrorString",
")",
"\n",
"}"
] |
12,641 | all-12642 | [
"SetRate",
"of",
"the",
"pool",
"updating",
"each",
"given",
"out",
"reader",
"to",
"respect",
"the",
"newly",
"set",
"rate",
".",
"Returns",
"the",
"old",
"rate",
"."
] | [
"func",
"(",
"pool",
"*",
"ReaderPool",
")",
"SetRate",
"(",
"rate",
"int",
")",
"int",
"{",
"pool",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"old",
":=",
"pool",
".",
"maxRate",
"\n",
"pool",
".",
"maxRate",
"=",
"rate",
"\n",
"pool",
".",
"setSharedRates",
"(",
")",
"\n",
"pool",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"<mask>",
"\n",
"}"
] |
12,642 | all-12643 | [
"WriteJSONFile",
"converts",
"a",
"given",
"data",
"instance",
"to",
"JSON",
"and",
"writes",
"it",
"to",
"file",
"."
] | [
"func",
"WriteJSONFile",
"(",
"name",
",",
"<mask>",
",",
"indent",
"string",
",",
"data",
"interface",
"{",
"}",
")",
"error",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"file",
".",
"Close",
"(",
")",
"\n\n",
"enc",
":=",
"json",
".",
"NewEncoder",
"(",
"file",
")",
"\n",
"enc",
".",
"SetIndent",
"(",
"prefix",
",",
"indent",
")",
"\n",
"return",
"enc",
".",
"Encode",
"(",
"data",
")",
"\n",
"}"
] |
12,643 | all-12644 | [
"LoadClusterConfigs",
"loads",
"rest",
".",
"Configs",
"for",
"creation",
"of",
"clients",
"by",
"using",
"either",
"a",
"normal",
".",
"kube",
"/",
"config",
"file",
"a",
"custom",
"Cluster",
"file",
"or",
"both",
".",
"The",
"configs",
"are",
"returned",
"in",
"a",
"mapping",
"of",
"context",
"--",
">",
"config",
".",
"The",
"default",
"context",
"is",
"included",
"in",
"this",
"mapping",
"and",
"specified",
"as",
"a",
"return",
"vaule",
".",
"Errors",
"are",
"returned",
"if",
".",
"kube",
"/",
"config",
"is",
"specified",
"and",
"invalid",
"or",
"if",
"no",
"valid",
"contexts",
"are",
"found",
"."
] | [
"func",
"LoadClusterConfigs",
"(",
"kubeconfig",
",",
"buildCluster",
"string",
")",
"(",
"<mask>",
"[",
"string",
"]",
"rest",
".",
"Config",
",",
"error",
")",
"{",
"logrus",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n",
"// This will work if we are running inside kubernetes",
"localCfg",
",",
"err",
":=",
"localConfig",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logrus",
".",
"WithError",
"(",
"err",
")",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"kubeCfgs",
",",
"currentContext",
",",
"err",
":=",
"kubeConfigs",
"(",
"kubeconfig",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"// TODO(fejta): drop build-cluster support",
"buildCfgs",
",",
"err",
":=",
"buildConfigs",
"(",
"buildCluster",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"mergeConfigs",
"(",
"localCfg",
",",
"kubeCfgs",
",",
"currentContext",
",",
"buildCfgs",
")",
"\n",
"}"
] |
12,644 | all-12645 | [
"stop",
"shuts",
"down",
"the",
"file",
"watcher",
"."
] | [
"func",
"(",
"d",
"*",
"Discovery",
")",
"stop",
"(",
")",
"{",
"level",
".",
"Debug",
"(",
"d",
".",
"logger",
")",
".",
"Log",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"d",
".",
"paths",
")",
")",
"\n\n",
"done",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"defer",
"close",
"(",
"done",
")",
"\n\n",
"fileSDTimeStamp",
".",
"removeDiscoverer",
"(",
"d",
")",
"\n\n",
"// Closing the watcher will deadlock unless all events and errors are drained.",
"go",
"func",
"(",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"d",
".",
"watcher",
".",
"Errors",
":",
"case",
"<-",
"d",
".",
"watcher",
".",
"Events",
":",
"// Drain all events and errors.",
"case",
"<-",
"done",
":",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"if",
"err",
":=",
"d",
".",
"watcher",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"level",
".",
"Error",
"(",
"d",
".",
"logger",
")",
".",
"Log",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"d",
".",
"paths",
")",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"<mask>",
".",
"Debug",
"(",
"d",
".",
"logger",
")",
".",
"Log",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}"
] |
12,645 | all-12646 | [
"SearchInContent",
"searches",
"for",
"given",
"string",
"in",
"script",
"content",
".",
"See",
":",
"https",
":",
"//",
"chromedevtools",
".",
"github",
".",
"io",
"/",
"devtools",
"-",
"protocol",
"/",
"tot",
"/",
"Debugger#method",
"-",
"searchInContent",
"parameters",
":",
"scriptID",
"-",
"Id",
"of",
"the",
"script",
"to",
"search",
"in",
".",
"query",
"-",
"String",
"to",
"search",
"for",
"."
] | [
"func",
"SearchInContent",
"(",
"scriptID",
"runtime",
".",
"ScriptID",
",",
"query",
"string",
")",
"*",
"SearchInContentParams",
"{",
"return",
"&",
"SearchInContentParams",
"{",
"ScriptID",
":",
"scriptID",
",",
"Query",
":",
"<mask>",
",",
"}",
"\n",
"}"
] |
12,646 | all-12647 | [
"SetJobName",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_print_operation_set_job_name",
"()",
"."
] | [
"func",
"(",
"<mask>",
"*",
"PrintOperation",
")",
"SetJobName",
"(",
"name",
"string",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"name",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"C",
".",
"gtk_print_operation_set_job_name",
"(",
"po",
".",
"native",
"(",
")",
",",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
")",
"\n",
"}"
] |
12,647 | all-12648 | [
"Status",
"returns",
"the",
"status",
"of",
"the",
"current",
"worker",
"."
] | [
"func",
"(",
"a",
"*",
"APIServer",
")",
"Status",
"(",
"ctx",
"context",
".",
"Context",
",",
"_",
"*",
"types",
".",
"Empty",
")",
"(",
"*",
"pps",
".",
"WorkerStatus",
",",
"error",
")",
"{",
"a",
".",
"statusMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"statusMu",
".",
"Unlock",
"(",
")",
"\n",
"started",
",",
"err",
":=",
"types",
".",
"TimestampProto",
"(",
"a",
".",
"started",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"result",
":=",
"&",
"pps",
".",
"WorkerStatus",
"{",
"JobID",
":",
"a",
".",
"jobID",
",",
"WorkerID",
":",
"a",
".",
"workerName",
",",
"Started",
":",
"<mask>",
",",
"Data",
":",
"a",
".",
"datum",
"(",
")",
",",
"QueueSize",
":",
"atomic",
".",
"LoadInt64",
"(",
"&",
"a",
".",
"queueSize",
")",
",",
"}",
"\n",
"return",
"result",
",",
"nil",
"\n",
"}"
] |
12,648 | all-12649 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"ObjectStore",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoIndexeddb7",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
12,649 | all-12650 | [
"ChooseManifestInstanceFromManifestList",
"returns",
"a",
"digest",
"of",
"a",
"manifest",
"appropriate",
"for",
"the",
"current",
"system",
"from",
"the",
"manifest",
"available",
"from",
"src",
"."
] | [
"func",
"ChooseManifestInstanceFromManifestList",
"(",
"ctx",
"context",
".",
"Context",
",",
"sys",
"*",
"types",
".",
"SystemContext",
",",
"src",
"<mask>",
".",
"UnparsedImage",
")",
"(",
"digest",
".",
"Digest",
",",
"error",
")",
"{",
"// For now this only handles manifest.DockerV2ListMediaType; we can generalize it later,",
"// probably along with manifest list editing.",
"blob",
",",
"mt",
",",
"err",
":=",
"src",
".",
"Manifest",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"if",
"mt",
"!=",
"manifest",
".",
"DockerV2ListMediaType",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"mt",
")",
"\n",
"}",
"\n",
"return",
"chooseDigestFromManifestList",
"(",
"sys",
",",
"blob",
")",
"\n",
"}"
] |
12,650 | all-12651 | [
"Set",
"is",
"required",
"for",
"kingpin",
"interfaces",
"to",
"allow",
"command",
"line",
"params",
"to",
"be",
"set",
"to",
"our",
"map",
"datatype"
] | [
"func",
"(",
"o",
"*",
"ListByteOption",
")",
"Set",
"(",
"<mask>",
"string",
")",
"error",
"{",
"val",
":=",
"ByteOption",
"{",
"}",
"\n",
"val",
".",
"Set",
"(",
"value",
")",
"\n",
"*",
"o",
"=",
"append",
"(",
"*",
"o",
",",
"val",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,651 | all-12652 | [
"mkPathDepth",
"makes",
"a",
"path",
"to",
"a",
"key",
"that",
"encodes",
"its",
"directory",
"depth",
"for",
"fast",
"directory",
"listing",
".",
"If",
"a",
"depth",
"is",
"provided",
"it",
"is",
"added",
"to",
"the",
"computed",
"depth",
"."
] | [
"func",
"(",
"s",
"*",
"v2v3Store",
")",
"mkPathDepth",
"(",
"nodePath",
"string",
",",
"depth",
"int",
")",
"string",
"{",
"normalForm",
":=",
"<mask>",
".",
"Clean",
"(",
"path",
".",
"Join",
"(",
"\"",
"\"",
",",
"nodePath",
")",
")",
"\n",
"n",
":=",
"strings",
".",
"Count",
"(",
"normalForm",
",",
"\"",
"\"",
")",
"+",
"depth",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"pfx",
",",
"n",
",",
"normalForm",
")",
"\n",
"}"
] |
12,652 | all-12653 | [
"GetStoragePoolResources",
"gets",
"the",
"resources",
"available",
"to",
"a",
"given",
"storage",
"pool"
] | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"GetStoragePoolResources",
"(",
"name",
"string",
")",
"(",
"*",
"api",
".",
"ResourcesStoragePool",
",",
"error",
")",
"{",
"if",
"!",
"r",
".",
"HasExtension",
"(",
"\"",
"\"",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"res",
":=",
"api",
".",
"ResourcesStoragePool",
"{",
"}",
"\n\n",
"// Fetch the raw value",
"_",
",",
"err",
":=",
"r",
".",
"queryStruct",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"url",
".",
"QueryEscape",
"(",
"name",
")",
")",
",",
"nil",
",",
"\"",
"\"",
",",
"&",
"<mask>",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"res",
",",
"nil",
"\n",
"}"
] |
12,653 | all-12654 | [
"determine",
"if",
"a",
"name",
"corresponds",
"to",
"a",
"sync",
"object"
] | [
"func",
"IsSync",
"(",
"sync",
"uintptr",
")",
"bool",
"{",
"ret",
":=",
"C",
".",
"glowIsSync",
"(",
"gpIsSync",
",",
"(",
"C",
".",
"GLsync",
")",
"(",
"<mask>",
")",
")",
"\n",
"return",
"ret",
"==",
"TRUE",
"\n",
"}"
] |
12,654 | all-12655 | [
"removeOrphanDHCPServers",
"removed",
"the",
"DHCP",
"servers",
"linked",
"to",
"no",
"host",
"-",
"only",
"adapter"
] | [
"func",
"removeOrphanDHCPServers",
"(",
"vbox",
"VBoxManager",
")",
"error",
"{",
"dhcps",
",",
"err",
":=",
"listDHCPServers",
"(",
"vbox",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"dhcps",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"nets",
",",
"err",
":=",
"listHostOnlyAdapters",
"(",
"vbox",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"for",
"name",
":=",
"<mask>",
"dhcps",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"name",
",",
"dhcpPrefix",
")",
"{",
"if",
"_",
",",
"present",
":=",
"nets",
"[",
"name",
"]",
";",
"!",
"present",
"{",
"if",
"err",
":=",
"vbox",
".",
"vbm",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"name",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"name",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
12,655 | all-12656 | [
"NewExpect",
"creates",
"a",
"new",
"process",
"for",
"expect",
"testing",
"."
] | [
"func",
"NewExpect",
"(",
"<mask>",
"string",
",",
"arg",
"...",
"string",
")",
"(",
"ep",
"*",
"ExpectProcess",
",",
"err",
"error",
")",
"{",
"// if env[] is nil, use current system env",
"return",
"NewExpectWithEnv",
"(",
"name",
",",
"arg",
",",
"nil",
")",
"\n",
"}"
] |
12,656 | all-12657 | [
"ensureRoomForWrite",
"is",
"always",
"called",
"serially",
"."
] | [
"func",
"(",
"db",
"*",
"DB",
")",
"ensureRoomForWrite",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"db",
".",
"Lock",
"(",
")",
"\n",
"defer",
"db",
".",
"Unlock",
"(",
")",
"\n",
"if",
"db",
".",
"mt",
".",
"MemSize",
"(",
")",
"<",
"db",
".",
"opt",
".",
"MaxTableSize",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"y",
".",
"AssertTrue",
"(",
"db",
".",
"mt",
"!=",
"nil",
")",
"// A nil mt indicates that DB is being closed.",
"\n",
"select",
"{",
"case",
"db",
".",
"flushChan",
"<-",
"flushTask",
"{",
"mt",
":",
"db",
".",
"mt",
",",
"vptr",
":",
"db",
".",
"vhead",
"}",
":",
"db",
".",
"elog",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"// Ensure value log is synced to disk so this memtable's contents wouldn't be lost.",
"err",
"=",
"db",
".",
"vlog",
".",
"sync",
"(",
"db",
".",
"vhead",
".",
"Fid",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"db",
".",
"elog",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"db",
".",
"mt",
".",
"MemSize",
"(",
")",
",",
"len",
"(",
"db",
".",
"flushChan",
")",
")",
"\n",
"// We manage to push this task. Let's modify imm.",
"db",
".",
"imm",
"=",
"append",
"(",
"db",
".",
"imm",
",",
"db",
".",
"mt",
")",
"\n",
"db",
".",
"mt",
"=",
"skl",
".",
"NewSkiplist",
"(",
"arenaSize",
"(",
"db",
".",
"<mask>",
")",
")",
"\n",
"// New memtable is empty. We certainly have room.",
"return",
"nil",
"\n",
"default",
":",
"// We need to do this to unlock and allow the flusher to modify imm.",
"return",
"errNoRoom",
"\n",
"}",
"\n",
"}"
] |
12,657 | all-12658 | [
"SetText",
"replaces",
"existing",
"content",
"of",
"the",
"control"
] | [
"func",
"(",
"l",
"*",
"TextView",
")",
"SetText",
"(",
"text",
"[",
"]",
"string",
")",
"{",
"l",
".",
"<mask>",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"text",
")",
")",
"\n",
"copy",
"(",
"l",
".",
"lines",
",",
"text",
")",
"\n\n",
"l",
".",
"applyLimit",
"(",
")",
"\n",
"l",
".",
"calculateVirtualSize",
"(",
")",
"\n\n",
"if",
"l",
".",
"autoscroll",
"{",
"l",
".",
"end",
"(",
")",
"\n",
"}",
"\n",
"}"
] |
12,658 | all-12659 | [
"UseAuthTokenCmd",
"returns",
"a",
"cobra",
"command",
"that",
"lets",
"a",
"user",
"get",
"a",
"pachyderm",
"token",
"on",
"behalf",
"of",
"themselves",
"or",
"another",
"user"
] | [
"func",
"UseAuthTokenCmd",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"useAuthToken",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Short",
":",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"Long",
":",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"Run",
":",
"cmdutil",
".",
"RunFixedArgs",
"(",
"0",
",",
"func",
"(",
"args",
"[",
"]",
"string",
")",
"error",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"token",
",",
"err",
":=",
"bufio",
".",
"NewReader",
"(",
"<mask>",
".",
"Stdin",
")",
".",
"ReadString",
"(",
"'\\n'",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"writePachTokenToCfg",
"(",
"strings",
".",
"TrimSpace",
"(",
"token",
")",
")",
"// drop trailing newline",
"\n",
"return",
"nil",
"\n",
"}",
")",
",",
"}",
"\n",
"return",
"cmdutil",
".",
"CreateAlias",
"(",
"useAuthToken",
",",
"\"",
"\"",
")",
"\n",
"}"
] |
12,659 | all-12660 | [
"findOwnersForFile",
"returns",
"the",
"OWNERS",
"file",
"path",
"furthest",
"down",
"the",
"tree",
"for",
"a",
"specified",
"file",
"using",
"ownerMap",
"to",
"check",
"for",
"entries"
] | [
"func",
"findOwnersForFile",
"(",
"log",
"*",
"logrus",
".",
"Entry",
",",
"path",
"string",
",",
"ownerMap",
"map",
"[",
"string",
"]",
"map",
"[",
"*",
"regexp",
".",
"Regexp",
"]",
"sets",
".",
"String",
")",
"string",
"{",
"d",
":=",
"path",
"\n\n",
"for",
";",
"d",
"!=",
"baseDirConvention",
";",
"d",
"=",
"canonicalize",
"(",
"filepath",
".",
"Dir",
"(",
"d",
")",
")",
"{",
"relative",
",",
"err",
":=",
"filepath",
".",
"Rel",
"(",
"d",
",",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"WithField",
"(",
"\"",
"\"",
",",
"path",
")",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"d",
")",
"\n",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"for",
"re",
",",
"n",
":=",
"range",
"ownerMap",
"[",
"d",
"]",
"{",
"if",
"<mask>",
"!=",
"nil",
"&&",
"!",
"re",
".",
"MatchString",
"(",
"relative",
")",
"{",
"continue",
"\n",
"}",
"\n",
"if",
"len",
"(",
"n",
")",
"!=",
"0",
"{",
"return",
"d",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] |
12,660 | all-12661 | [
"getAndClearWrittenDirs",
"retrieves",
"a",
"list",
"of",
"directories",
"that",
"have",
"been",
"modified",
"since",
"the",
"last",
"time",
"getAndClearWrittenDirs",
"was",
"called",
"."
] | [
"func",
"getAndClearWrittenDirs",
"(",
")",
"[",
"]",
"string",
"{",
"dirSetMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"dirSetMutex",
".",
"Unlock",
"(",
")",
"\n",
"dirs",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"dirSet",
")",
")",
"\n",
"for",
"d",
":=",
"<mask>",
"dirSet",
"{",
"dirs",
"=",
"append",
"(",
"dirs",
",",
"d",
")",
"\n",
"}",
"\n",
"dirSet",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
"\n",
"return",
"dirs",
"\n",
"}"
] |
12,661 | all-12662 | [
"Convert",
"Mat",
"which",
"defined",
"by",
"SWIG",
"to",
"*",
"mat64",
".",
"Dense",
".",
"The",
"reason",
"is",
"the",
"latter",
"is",
"much",
"easier",
"to",
"handle",
"in",
"Go",
".",
"GcvMat",
"is",
"assumed",
"to",
"be",
"2",
"-",
"dimensional",
"matrix",
"."
] | [
"func",
"GcvMatToMat64",
"(",
"mat",
"GcvMat",
")",
"*",
"mat64",
".",
"Dense",
"{",
"col",
":=",
"mat",
".",
"GetCols",
"(",
")",
"\n",
"row",
":=",
"mat",
".",
"GetRows",
"(",
")",
"\n\n",
"data",
":=",
"[",
"]",
"float64",
"{",
"}",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"row",
";",
"i",
"++",
"{",
"for",
"j",
":=",
"0",
";",
"j",
"<",
"col",
";",
"j",
"++",
"{",
"if",
"fltPtr",
",",
"ok",
":=",
"mat",
".",
"GcvAtf64",
"(",
"i",
",",
"j",
")",
".",
"(",
"*",
"float64",
")",
";",
"ok",
"{",
"data",
"=",
"append",
"(",
"data",
",",
"*",
"fltPtr",
")",
"\n",
"}",
"else",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"}",
"\n",
"}",
"\n\n",
"return",
"mat64",
".",
"NewDense",
"(",
"<mask>",
",",
"col",
",",
"data",
")",
"\n",
"}"
] |
12,662 | all-12663 | [
"NewCache",
"returns",
"a",
"new",
"Cache",
"given",
"the",
"root",
"directory",
"that",
"should",
"be",
"used",
"on",
"disk",
"for",
"cache",
"storage"
] | [
"func",
"NewCache",
"(",
"diskRoot",
"string",
")",
"*",
"Cache",
"{",
"return",
"&",
"Cache",
"{",
"diskRoot",
":",
"strings",
".",
"TrimSuffix",
"(",
"diskRoot",
",",
"string",
"(",
"<mask>",
".",
"PathListSeparator",
")",
")",
",",
"}",
"\n",
"}"
] |
12,663 | all-12664 | [
"ApplyConfig",
"resets",
"the",
"manager",
"s",
"target",
"providers",
"and",
"job",
"configurations",
"as",
"defined",
"by",
"the",
"new",
"cfg",
"."
] | [
"func",
"(",
"m",
"*",
"Manager",
")",
"ApplyConfig",
"(",
"cfg",
"*",
"config",
".",
"Config",
")",
"error",
"{",
"m",
".",
"mtxScrape",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtxScrape",
".",
"Unlock",
"(",
")",
"\n\n",
"c",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"config",
".",
"ScrapeConfig",
")",
"\n",
"for",
"_",
",",
"scfg",
":=",
"range",
"cfg",
".",
"ScrapeConfigs",
"{",
"c",
"[",
"scfg",
".",
"JobName",
"]",
"=",
"scfg",
"\n",
"}",
"\n",
"m",
".",
"scrapeConfigs",
"=",
"c",
"\n\n",
"if",
"err",
":=",
"m",
".",
"setJitterSeed",
"(",
"cfg",
".",
"GlobalConfig",
".",
"ExternalLabels",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Cleanup and reload pool if the configuration has changed.",
"var",
"failed",
"bool",
"\n",
"for",
"name",
",",
"sp",
":=",
"<mask>",
"m",
".",
"scrapePools",
"{",
"if",
"cfg",
",",
"ok",
":=",
"m",
".",
"scrapeConfigs",
"[",
"name",
"]",
";",
"!",
"ok",
"{",
"sp",
".",
"stop",
"(",
")",
"\n",
"delete",
"(",
"m",
".",
"scrapePools",
",",
"name",
")",
"\n",
"}",
"else",
"if",
"!",
"reflect",
".",
"DeepEqual",
"(",
"sp",
".",
"config",
",",
"cfg",
")",
"{",
"err",
":=",
"sp",
".",
"reload",
"(",
"cfg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"level",
".",
"Error",
"(",
"m",
".",
"logger",
")",
".",
"Log",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"err",
",",
"\"",
"\"",
",",
"name",
")",
"\n",
"failed",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"failed",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,664 | all-12665 | [
"AcceleratorGetLabel",
"is",
"a",
"wrapper",
"around",
"gtk_accelerator_get_label",
"()",
"."
] | [
"func",
"AcceleratorGetLabel",
"(",
"key",
"uint",
",",
"mods",
"gdk",
".",
"ModifierType",
")",
"string",
"{",
"c",
":=",
"C",
".",
"gtk_accelerator_get_label",
"(",
"C",
".",
"guint",
"(",
"key",
")",
",",
"C",
".",
"GdkModifierType",
"(",
"<mask>",
")",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
"\n",
"return",
"C",
".",
"GoString",
"(",
"(",
"*",
"C",
".",
"char",
")",
"(",
"c",
")",
")",
"\n",
"}"
] |
12,665 | all-12666 | [
"ShouldRun",
"determines",
"if",
"the",
"presubmit",
"should",
"run",
"against",
"a",
"specific",
"base",
"ref",
"or",
"in",
"response",
"to",
"a",
"set",
"of",
"changes",
".",
"The",
"latter",
"mechanism",
"is",
"evaluated",
"lazily",
"if",
"necessary",
"."
] | [
"func",
"(",
"ps",
"Presubmit",
")",
"ShouldRun",
"(",
"baseRef",
"string",
",",
"changes",
"ChangedFilesProvider",
",",
"forced",
",",
"defaults",
"bool",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"!",
"ps",
".",
"CouldRun",
"(",
"baseRef",
")",
"{",
"return",
"false",
",",
"nil",
"\n",
"}",
"\n",
"if",
"ps",
".",
"AlwaysRun",
"{",
"return",
"true",
",",
"nil",
"\n",
"}",
"\n",
"if",
"forced",
"{",
"return",
"<mask>",
",",
"nil",
"\n",
"}",
"\n",
"if",
"determined",
",",
"shouldRun",
",",
"err",
":=",
"ps",
".",
"RegexpChangeMatcher",
".",
"ShouldRun",
"(",
"changes",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"else",
"if",
"determined",
"{",
"return",
"shouldRun",
",",
"nil",
"\n",
"}",
"\n",
"return",
"defaults",
",",
"nil",
"\n",
"}"
] |
12,666 | all-12667 | [
"Where",
"creates",
"a",
"reusable",
"means",
"of",
"filtering",
"a",
"stream",
"."
] | [
"func",
"Where",
"(",
"original",
"Enumerable",
",",
"p",
"Predicate",
")",
"Enumerable",
"{",
"return",
"wherer",
"{",
"<mask>",
":",
"original",
",",
"filter",
":",
"p",
",",
"}",
"\n",
"}"
] |
12,667 | all-12668 | [
"Call",
"the",
"parent",
"WriteHeader",
"."
] | [
"func",
"(",
"w",
"*",
"jsonIndentResponseWriter",
")",
"WriteHeader",
"(",
"<mask>",
"int",
")",
"{",
"w",
".",
"ResponseWriter",
".",
"WriteHeader",
"(",
"code",
")",
"\n",
"w",
".",
"wroteHeader",
"=",
"true",
"\n",
"}"
] |
12,668 | all-12669 | [
"Set",
"sets",
"the",
"components",
"of",
"the",
"vector",
"from",
"a",
"string",
"of",
"the",
"form",
"float",
"float"
] | [
"func",
"(",
"v",
"*",
"Vec2",
")",
"Set",
"(",
"s",
"string",
")",
"error",
"{",
"cur",
":=",
"0",
"\n",
"for",
"_",
",",
"ss",
":=",
"<mask>",
"strings",
".",
"Split",
"(",
"s",
",",
"\"",
"\"",
")",
"{",
"f",
",",
"err",
":=",
"strconv",
".",
"ParseFloat",
"(",
"ss",
",",
"32",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ss",
",",
"err",
")",
"\n",
"}",
"\n",
"(",
"*",
"v",
")",
"[",
"cur",
"]",
"=",
"float32",
"(",
"f",
")",
"\n",
"cur",
"++",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,669 | all-12670 | [
"SendNotification",
"is",
"a",
"wrapper",
"around",
"g_application_send_notification",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"<mask>",
")",
"SendNotification",
"(",
"id",
"string",
",",
"notification",
"*",
"Notification",
")",
"{",
"cstr1",
":=",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"C",
".",
"CString",
"(",
"id",
")",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr1",
")",
")",
"\n\n",
"C",
".",
"g_application_send_notification",
"(",
"v",
".",
"native",
"(",
")",
",",
"cstr1",
",",
"notification",
".",
"native",
"(",
")",
")",
"\n",
"}"
] |
12,670 | all-12671 | [
"MutateTransaction",
"for",
"PaymentBuilder",
"causes",
"the",
"underylying",
"PaymentOp",
"or",
"PathPaymentOp",
"to",
"be",
"added",
"to",
"the",
"operation",
"list",
"for",
"the",
"provided",
"transaction"
] | [
"func",
"(",
"m",
"PaymentBuilder",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"error",
"{",
"if",
"m",
".",
"Err",
"!=",
"nil",
"{",
"return",
"m",
".",
"Err",
"\n",
"}",
"\n\n",
"if",
"m",
".",
"PathPayment",
"{",
"m",
".",
"O",
".",
"<mask>",
",",
"m",
".",
"Err",
"=",
"xdr",
".",
"NewOperationBody",
"(",
"xdr",
".",
"OperationTypePathPayment",
",",
"m",
".",
"PP",
")",
"\n",
"o",
".",
"TX",
".",
"Operations",
"=",
"append",
"(",
"o",
".",
"TX",
".",
"Operations",
",",
"m",
".",
"O",
")",
"\n",
"return",
"m",
".",
"Err",
"\n",
"}",
"\n\n",
"m",
".",
"O",
".",
"Body",
",",
"m",
".",
"Err",
"=",
"xdr",
".",
"NewOperationBody",
"(",
"xdr",
".",
"OperationTypePayment",
",",
"m",
".",
"P",
")",
"\n",
"o",
".",
"TX",
".",
"Operations",
"=",
"append",
"(",
"o",
".",
"TX",
".",
"Operations",
",",
"m",
".",
"O",
")",
"\n",
"return",
"m",
".",
"Err",
"\n",
"}"
] |
12,671 | all-12672 | [
"RowTopN",
"creates",
"a",
"TopN",
"query",
"with",
"the",
"given",
"item",
"count",
"and",
"row",
".",
"This",
"variant",
"supports",
"customizing",
"the",
"row",
"query",
"."
] | [
"func",
"(",
"f",
"*",
"Field",
")",
"RowTopN",
"(",
"n",
"uint64",
",",
"<mask>",
"*",
"PQLRowQuery",
")",
"*",
"PQLRowQuery",
"{",
"q",
":=",
"NewPQLRowQuery",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"f",
".",
"name",
",",
"row",
".",
"serialize",
"(",
")",
",",
"n",
")",
",",
"f",
".",
"index",
",",
"nil",
")",
"\n",
"return",
"q",
"\n",
"}"
] |
12,672 | all-12673 | [
"PerformRequest",
"logs",
"the",
"request",
"dumping",
"its",
"content",
"if",
"required",
"then",
"makes",
"the",
"request",
"and",
"logs",
"and",
"dumps",
"the",
"corresponding",
"response",
"."
] | [
"func",
"(",
"a",
"*",
"API",
")",
"PerformRequest",
"(",
"req",
"*",
"http",
".",
"<mask>",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"// Sign last so auth headers don't get printed or logged",
"if",
"a",
".",
"Auth",
"!=",
"nil",
"{",
"if",
"err",
":=",
"a",
".",
"Auth",
".",
"Sign",
"(",
"req",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"resp",
",",
"err",
":=",
"a",
".",
"Client",
".",
"Do",
"(",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"resp",
",",
"err",
"\n",
"}"
] |
12,673 | all-12674 | [
"Succ",
"updates",
"the",
"FollowerStats",
"with",
"a",
"successful",
"send"
] | [
"func",
"(",
"fs",
"*",
"FollowerStats",
")",
"Succ",
"(",
"d",
"time",
".",
"Duration",
")",
"{",
"fs",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fs",
".",
"Unlock",
"(",
")",
"\n\n",
"total",
":=",
"float64",
"(",
"fs",
".",
"Counts",
".",
"Success",
")",
"*",
"fs",
".",
"Latency",
".",
"Average",
"\n",
"totalSquare",
":=",
"float64",
"(",
"fs",
".",
"Counts",
".",
"Success",
")",
"*",
"fs",
".",
"Latency",
".",
"averageSquare",
"\n\n",
"fs",
".",
"Counts",
".",
"Success",
"++",
"\n\n",
"fs",
".",
"Latency",
".",
"Current",
"=",
"float64",
"(",
"d",
")",
"/",
"(",
"1000000.0",
")",
"\n\n",
"if",
"fs",
".",
"Latency",
".",
"Current",
">",
"fs",
".",
"Latency",
".",
"Maximum",
"{",
"fs",
".",
"Latency",
".",
"Maximum",
"=",
"fs",
".",
"Latency",
".",
"Current",
"\n",
"}",
"\n\n",
"if",
"fs",
".",
"Latency",
".",
"Current",
"<",
"fs",
".",
"Latency",
".",
"Minimum",
"{",
"fs",
".",
"Latency",
".",
"Minimum",
"=",
"fs",
".",
"Latency",
".",
"Current",
"\n",
"}",
"\n\n",
"fs",
".",
"Latency",
".",
"Average",
"=",
"(",
"total",
"+",
"fs",
".",
"Latency",
".",
"Current",
")",
"/",
"float64",
"(",
"fs",
".",
"Counts",
".",
"Success",
")",
"\n",
"fs",
".",
"Latency",
".",
"averageSquare",
"=",
"(",
"totalSquare",
"+",
"fs",
".",
"Latency",
".",
"Current",
"*",
"fs",
".",
"Latency",
".",
"Current",
")",
"/",
"float64",
"(",
"<mask>",
".",
"Counts",
".",
"Success",
")",
"\n\n",
"// sdv = sqrt(avg(x^2) - avg(x)^2)",
"fs",
".",
"Latency",
".",
"StandardDeviation",
"=",
"math",
".",
"Sqrt",
"(",
"fs",
".",
"Latency",
".",
"averageSquare",
"-",
"fs",
".",
"Latency",
".",
"Average",
"*",
"fs",
".",
"Latency",
".",
"Average",
")",
"\n",
"}"
] |
12,674 | all-12675 | [
"clean",
"up",
"project",
"returned",
"from",
"API",
"by",
":",
"*",
"url",
"decoding",
"branch",
"names",
"(",
"https",
":",
"//",
"discuss",
".",
"circleci",
".",
"com",
"/",
"t",
"/",
"api",
"-",
"returns",
"-",
"url",
"-",
"encoded",
"-",
"branch",
"-",
"names",
"-",
"in",
"-",
"json",
"-",
"response",
"/",
"18524",
"/",
"5",
")"
] | [
"func",
"cleanupProject",
"(",
"project",
"*",
"<mask>",
")",
"error",
"{",
"if",
"project",
".",
"Branches",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"newBranches",
":=",
"map",
"[",
"string",
"]",
"Branch",
"{",
"}",
"\n",
"for",
"name",
",",
"branch",
":=",
"range",
"project",
".",
"Branches",
"{",
"escapedName",
",",
"err",
":=",
"url",
".",
"QueryUnescape",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"name",
",",
"err",
")",
"\n",
"}",
"\n\n",
"newBranches",
"[",
"escapedName",
"]",
"=",
"branch",
"\n",
"}",
"\n",
"project",
".",
"Branches",
"=",
"newBranches",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
12,675 | all-12676 | [
"GetIsReadOnly",
"returns",
"the",
"IsReadOnly",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"b",
"*",
"Board",
")",
"GetIsReadOnly",
"(",
")",
"bool",
"{",
"if",
"b",
"==",
"nil",
"||",
"b",
".",
"IsReadOnly",
"==",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"b",
".",
"IsReadOnly",
"\n",
"}"
] |
12,676 | all-12677 | [
"GetProductIncome",
"returns",
"total",
"receipt",
"balance",
"from",
"all",
"channels",
"of",
"all",
"offerings",
"with",
"given",
"product",
"id",
"."
] | [
"func",
"(",
"h",
"*",
"<mask>",
")",
"GetProductIncome",
"(",
"tkn",
",",
"productID",
"string",
")",
"(",
"*",
"uint",
",",
"error",
")",
"{",
"logger",
":=",
"h",
".",
"logger",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"productID",
")",
"\n\n",
"return",
"h",
".",
"uintFromQuery",
"(",
"logger",
",",
"tkn",
",",
"`SELECT SUM(channels.receipt_balance)\n\t\t FROM offerings\n\t\t\t JOIN channels\n\t\t\t ON channels.offering=offerings.id\n\t\t \t AND offerings.product=$1`",
",",
"productID",
")",
"\n",
"}"
] |
12,677 | all-12678 | [
"Seed",
"uses",
"the",
"given",
"value",
"to",
"initialize",
"the",
"generator",
".",
"If",
"this",
"value",
"is",
"0",
"a",
"pre",
"-",
"defined",
"seed",
"is",
"used",
"instead",
"since",
"the",
"xorshift",
"algorithm",
"requires",
"at",
"least",
"one",
"bit",
"of",
"the",
"internal",
"state",
"to",
"be",
"set",
"."
] | [
"func",
"(",
"s",
"*",
"Xor64Source",
")",
"Seed",
"(",
"seed",
"int64",
")",
"{",
"if",
"<mask>",
"==",
"0",
"{",
"seed",
"=",
"seed0",
"\n",
"}",
"\n",
"*",
"s",
"=",
"Xor64Source",
"(",
"seed",
")",
"\n",
"}"
] |
12,678 | all-12679 | [
"lexString",
"scans",
"a",
"quoted",
"string",
".",
"The",
"initial",
"quote",
"has",
"already",
"been",
"seen",
"."
] | [
"func",
"lexString",
"(",
"l",
"*",
"lexer",
")",
"stateFn",
"{",
"Loop",
":",
"for",
"{",
"switch",
"l",
".",
"next",
"(",
")",
"{",
"case",
"'\\\\'",
":",
"lexEscape",
"(",
"l",
")",
"\n",
"<mask>",
"utf8",
".",
"RuneError",
":",
"return",
"l",
".",
"errorf",
"(",
"\"",
"\"",
")",
"\n",
"case",
"eof",
",",
"'\\n'",
":",
"return",
"l",
".",
"errorf",
"(",
"\"",
"\"",
")",
"\n",
"case",
"l",
".",
"stringOpen",
":",
"break",
"Loop",
"\n",
"}",
"\n",
"}",
"\n",
"l",
".",
"emit",
"(",
"ItemString",
")",
"\n",
"return",
"lexStatements",
"\n",
"}"
] |
12,679 | all-12680 | [
"PromOutput",
"returns",
"lines",
"of",
"metrics",
"in",
"prom",
"format"
] | [
"func",
"(",
"m",
"*",
"CirconusMetrics",
")",
"PromOutput",
"(",
")",
"(",
"*",
"bytes",
".",
"Buffer",
",",
"error",
")",
"{",
"m",
".",
"lastMetrics",
".",
"metricsmu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"lastMetrics",
".",
"metricsmu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"m",
".",
"lastMetrics",
".",
"metrics",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"var",
"b",
"bytes",
".",
"<mask>",
"\n",
"w",
":=",
"bufio",
".",
"NewWriter",
"(",
"&",
"b",
")",
"\n\n",
"ts",
":=",
"m",
".",
"lastMetrics",
".",
"ts",
".",
"UnixNano",
"(",
")",
"/",
"int64",
"(",
"time",
".",
"Millisecond",
")",
"\n\n",
"for",
"name",
",",
"metric",
":=",
"range",
"*",
"m",
".",
"lastMetrics",
".",
"metrics",
"{",
"switch",
"metric",
".",
"Type",
"{",
"case",
"\"",
"\"",
":",
"if",
"strings",
".",
"HasPrefix",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"metric",
".",
"Value",
")",
",",
"\"",
"\"",
")",
"{",
"continue",
"// circonus histogram != prom \"histogram\" (aka percentile)",
"\n",
"}",
"\n",
"case",
"\"",
"\"",
":",
"continue",
"// text metrics unsupported",
"\n",
"}",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\n",
"\"",
",",
"name",
",",
"metric",
".",
"Value",
",",
"ts",
")",
"\n",
"}",
"\n\n",
"err",
":=",
"w",
".",
"Flush",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"b",
",",
"err",
"\n",
"}"
] |
12,680 | all-12681 | [
"Marshal",
"writes",
"the",
"JSON",
"representation",
"of",
"v",
"to",
"a",
"byte",
"slice",
"returned",
"in",
"b",
"."
] | [
"func",
"Marshal",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"b",
"[",
"]",
"<mask>",
",",
"err",
"error",
")",
"{",
"m",
":=",
"marshalerPool",
".",
"Get",
"(",
")",
".",
"(",
"*",
"marshaler",
")",
"\n",
"m",
".",
"b",
".",
"Truncate",
"(",
"0",
")",
"\n\n",
"if",
"err",
"=",
"(",
"objconv",
".",
"Encoder",
"{",
"Emitter",
":",
"m",
"}",
")",
".",
"Encode",
"(",
"v",
")",
";",
"err",
"==",
"nil",
"{",
"b",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"m",
".",
"b",
".",
"Len",
"(",
")",
")",
"\n",
"copy",
"(",
"b",
",",
"m",
".",
"b",
".",
"Bytes",
"(",
")",
")",
"\n",
"}",
"\n\n",
"marshalerPool",
".",
"Put",
"(",
"m",
")",
"\n",
"return",
"\n",
"}"
] |
12,681 | all-12682 | [
"Update",
"the",
"label",
"color",
"/",
"description"
] | [
"func",
"change",
"(",
"repo",
"string",
",",
"label",
"Label",
")",
"Update",
"{",
"logrus",
".",
"WithField",
"(",
"\"",
"\"",
",",
"repo",
")",
".",
"WithField",
"(",
"\"",
"\"",
",",
"label",
".",
"Name",
")",
".",
"WithField",
"(",
"\"",
"\"",
",",
"label",
".",
"Color",
")",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"return",
"Update",
"{",
"Why",
":",
"\"",
"\"",
",",
"Current",
":",
"&",
"<mask>",
",",
"Wanted",
":",
"&",
"label",
",",
"repo",
":",
"repo",
"}",
"\n",
"}"
] |
12,682 | all-12683 | [
"New",
"makes",
"a",
"new",
"Runner",
"with",
"the",
"given",
"testing",
"T",
"target",
"and",
"the",
"root",
"URL",
"."
] | [
"func",
"New",
"(",
"t",
"T",
",",
"URL",
"string",
")",
"*",
"Runner",
"{",
"r",
":=",
"&",
"Runner",
"{",
"t",
":",
"t",
",",
"rootURL",
":",
"URL",
",",
"vars",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"parse",
".",
"Value",
")",
",",
"DoRequest",
":",
"http",
".",
"DefaultTransport",
".",
"RoundTrip",
",",
"Log",
":",
"func",
"(",
"s",
"string",
")",
"{",
"fmt",
".",
"Println",
"(",
"s",
")",
"\n",
"}",
",",
"Verbose",
":",
"func",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"!",
"testing",
".",
"Verbose",
"(",
")",
"{",
"return",
"\n",
"}",
"\n",
"fmt",
".",
"Println",
"(",
"args",
"...",
")",
"\n",
"}",
",",
"ParseBody",
":",
"ParseJSONBody",
",",
"NewRequest",
":",
"http",
".",
"NewRequest",
",",
"}",
"\n",
"// capture environment variables by default",
"for",
"_",
",",
"e",
":=",
"<mask>",
"os",
".",
"Environ",
"(",
")",
"{",
"pair",
":=",
"strings",
".",
"Split",
"(",
"e",
",",
"\"",
"\"",
")",
"\n",
"r",
".",
"vars",
"[",
"pair",
"[",
"0",
"]",
"]",
"=",
"parse",
".",
"ParseValue",
"(",
"[",
"]",
"byte",
"(",
"pair",
"[",
"1",
"]",
")",
")",
"\n",
"}",
"\n",
"return",
"r",
"\n",
"}"
] |
12,683 | all-12684 | [
"check",
"the",
"completeness",
"status",
"of",
"a",
"framebuffer"
] | [
"func",
"CheckNamedFramebufferStatus",
"(",
"framebuffer",
"uint32",
",",
"<mask>",
"uint32",
")",
"uint32",
"{",
"ret",
":=",
"C",
".",
"glowCheckNamedFramebufferStatus",
"(",
"gpCheckNamedFramebufferStatus",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"framebuffer",
")",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"target",
")",
")",
"\n",
"return",
"(",
"uint32",
")",
"(",
"ret",
")",
"\n",
"}"
] |
12,684 | all-12685 | [
"start",
"prepares",
"and",
"starts",
"raftNode",
"in",
"a",
"new",
"goroutine",
".",
"It",
"is",
"no",
"longer",
"safe",
"to",
"modify",
"the",
"fields",
"after",
"it",
"has",
"been",
"started",
"."
] | [
"func",
"(",
"r",
"*",
"raftNode",
")",
"start",
"(",
"rh",
"*",
"raftReadyHandler",
")",
"{",
"internalTimeout",
":=",
"time",
".",
"Second",
"\n\n",
"go",
"func",
"(",
")",
"{",
"defer",
"r",
".",
"onStop",
"(",
")",
"\n",
"islead",
":=",
"false",
"\n\n",
"for",
"{",
"select",
"{",
"case",
"<-",
"r",
".",
"ticker",
".",
"C",
":",
"r",
".",
"tick",
"(",
")",
"\n",
"case",
"rd",
":=",
"<-",
"r",
".",
"Ready",
"(",
")",
":",
"if",
"rd",
".",
"SoftState",
"!=",
"nil",
"{",
"newLeader",
":=",
"rd",
".",
"SoftState",
".",
"Lead",
"!=",
"raft",
".",
"None",
"&&",
"rh",
".",
"getLead",
"(",
")",
"!=",
"rd",
".",
"SoftState",
".",
"Lead",
"\n",
"if",
"newLeader",
"{",
"leaderChanges",
".",
"Inc",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"rd",
".",
"SoftState",
".",
"Lead",
"==",
"raft",
".",
"None",
"{",
"hasLeader",
".",
"Set",
"(",
"0",
")",
"\n",
"}",
"else",
"{",
"hasLeader",
".",
"Set",
"(",
"1",
")",
"\n",
"}",
"\n\n",
"rh",
".",
"updateLead",
"(",
"rd",
".",
"SoftState",
".",
"Lead",
")",
"\n",
"islead",
"=",
"rd",
".",
"RaftState",
"==",
"raft",
".",
"StateLeader",
"\n",
"if",
"islead",
"{",
"isLeader",
".",
"Set",
"(",
"1",
")",
"\n",
"}",
"else",
"{",
"isLeader",
".",
"Set",
"(",
"0",
")",
"\n",
"}",
"\n",
"rh",
".",
"updateLeadership",
"(",
"newLeader",
")",
"\n",
"r",
".",
"td",
".",
"Reset",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"rd",
".",
"ReadStates",
")",
"!=",
"0",
"{",
"select",
"{",
"case",
"r",
".",
"readStateC",
"<-",
"rd",
".",
"ReadStates",
"[",
"len",
"(",
"rd",
".",
"ReadStates",
")",
"-",
"1",
"]",
":",
"case",
"<-",
"time",
".",
"After",
"(",
"internalTimeout",
")",
":",
"if",
"r",
".",
"lg",
"!=",
"nil",
"{",
"r",
".",
"lg",
".",
"Warn",
"(",
"\"",
"\"",
",",
"zap",
".",
"Duration",
"(",
"\"",
"\"",
",",
"internalTimeout",
")",
")",
"\n",
"}",
"else",
"{",
"plog",
".",
"Warningf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"case",
"<-",
"r",
".",
"stopped",
":",
"return",
"\n",
"}",
"\n",
"}",
"\n\n",
"notifyc",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
",",
"1",
")",
"\n",
"ap",
":=",
"apply",
"{",
"entries",
":",
"rd",
".",
"CommittedEntries",
",",
"snapshot",
":",
"rd",
".",
"Snapshot",
",",
"notifyc",
":",
"notifyc",
",",
"}",
"\n\n",
"updateCommittedIndex",
"(",
"&",
"ap",
",",
"rh",
")",
"\n\n",
"select",
"{",
"case",
"r",
".",
"applyc",
"<-",
"ap",
":",
"<mask>",
"<-",
"r",
".",
"stopped",
":",
"return",
"\n",
"}",
"\n\n",
"// the leader can write to its disk in parallel with replicating to the followers and them",
"// writing to their disks.",
"// For more details, check raft thesis 10.2.1",
"if",
"islead",
"{",
"// gofail: var raftBeforeLeaderSend struct{}",
"r",
".",
"transport",
".",
"Send",
"(",
"r",
".",
"processMessages",
"(",
"rd",
".",
"Messages",
")",
")",
"\n",
"}",
"\n\n",
"// gofail: var raftBeforeSave struct{}",
"if",
"err",
":=",
"r",
".",
"storage",
".",
"Save",
"(",
"rd",
".",
"HardState",
",",
"rd",
".",
"Entries",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"r",
".",
"lg",
"!=",
"nil",
"{",
"r",
".",
"lg",
".",
"Fatal",
"(",
"\"",
"\"",
",",
"zap",
".",
"Error",
"(",
"err",
")",
")",
"\n",
"}",
"else",
"{",
"plog",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"!",
"raft",
".",
"IsEmptyHardState",
"(",
"rd",
".",
"HardState",
")",
"{",
"proposalsCommitted",
".",
"Set",
"(",
"float64",
"(",
"rd",
".",
"HardState",
".",
"Commit",
")",
")",
"\n",
"}",
"\n",
"// gofail: var raftAfterSave struct{}",
"if",
"!",
"raft",
".",
"IsEmptySnap",
"(",
"rd",
".",
"Snapshot",
")",
"{",
"// gofail: var raftBeforeSaveSnap struct{}",
"if",
"err",
":=",
"r",
".",
"storage",
".",
"SaveSnap",
"(",
"rd",
".",
"Snapshot",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"r",
".",
"lg",
"!=",
"nil",
"{",
"r",
".",
"lg",
".",
"Fatal",
"(",
"\"",
"\"",
",",
"zap",
".",
"Error",
"(",
"err",
")",
")",
"\n",
"}",
"else",
"{",
"plog",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"// etcdserver now claim the snapshot has been persisted onto the disk",
"notifyc",
"<-",
"struct",
"{",
"}",
"{",
"}",
"\n\n",
"// gofail: var raftAfterSaveSnap struct{}",
"r",
".",
"raftStorage",
".",
"ApplySnapshot",
"(",
"rd",
".",
"Snapshot",
")",
"\n",
"if",
"r",
".",
"lg",
"!=",
"nil",
"{",
"r",
".",
"lg",
".",
"Info",
"(",
"\"",
"\"",
",",
"zap",
".",
"Uint64",
"(",
"\"",
"\"",
",",
"rd",
".",
"Snapshot",
".",
"Metadata",
".",
"Index",
")",
")",
"\n",
"}",
"else",
"{",
"plog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"rd",
".",
"Snapshot",
".",
"Metadata",
".",
"Index",
")",
"\n",
"}",
"\n",
"// gofail: var raftAfterApplySnap struct{}",
"}",
"\n\n",
"r",
".",
"raftStorage",
".",
"Append",
"(",
"rd",
".",
"Entries",
")",
"\n\n",
"if",
"!",
"islead",
"{",
"// finish processing incoming messages before we signal raftdone chan",
"msgs",
":=",
"r",
".",
"processMessages",
"(",
"rd",
".",
"Messages",
")",
"\n\n",
"// now unblocks 'applyAll' that waits on Raft log disk writes before triggering snapshots",
"notifyc",
"<-",
"struct",
"{",
"}",
"{",
"}",
"\n\n",
"// Candidate or follower needs to wait for all pending configuration",
"// changes to be applied before sending messages.",
"// Otherwise we might incorrectly count votes (e.g. votes from removed members).",
"// Also slow machine's follower raft-layer could proceed to become the leader",
"// on its own single-node cluster, before apply-layer applies the config change.",
"// We simply wait for ALL pending entries to be applied for now.",
"// We might improve this later on if it causes unnecessary long blocking issues.",
"waitApply",
":=",
"false",
"\n",
"for",
"_",
",",
"ent",
":=",
"range",
"rd",
".",
"CommittedEntries",
"{",
"if",
"ent",
".",
"Type",
"==",
"raftpb",
".",
"EntryConfChange",
"{",
"waitApply",
"=",
"true",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"waitApply",
"{",
"// blocks until 'applyAll' calls 'applyWait.Trigger'",
"// to be in sync with scheduled config-change job",
"// (assume notifyc has cap of 1)",
"select",
"{",
"case",
"notifyc",
"<-",
"struct",
"{",
"}",
"{",
"}",
":",
"case",
"<-",
"r",
".",
"stopped",
":",
"return",
"\n",
"}",
"\n",
"}",
"\n\n",
"// gofail: var raftBeforeFollowerSend struct{}",
"r",
".",
"transport",
".",
"Send",
"(",
"msgs",
")",
"\n",
"}",
"else",
"{",
"// leader already processed 'MsgSnap' and signaled",
"notifyc",
"<-",
"struct",
"{",
"}",
"{",
"}",
"\n",
"}",
"\n\n",
"r",
".",
"Advance",
"(",
")",
"\n",
"case",
"<-",
"r",
".",
"stopped",
":",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"}"
] |
12,685 | all-12686 | [
"GetTags",
"returns",
"a",
"slice",
"of",
"Tags",
"that",
"is",
"all",
"characters",
"after",
"rune",
"char",
"up",
"to",
"occurrence",
"of",
"space",
"or",
"another",
"occurrence",
"of",
"rune",
"char",
".",
"Additionally",
"you",
"can",
"provide",
"a",
"coma",
"separated",
"unicode",
"characters",
"to",
"be",
"used",
"as",
"terminating",
"sequence",
"."
] | [
"func",
"GetTags",
"(",
"prefix",
"rune",
",",
"str",
"string",
",",
"terminator",
"...",
"rune",
")",
"(",
"tags",
"[",
"]",
"Tag",
")",
"{",
"// If we have no terminators given, default to only whitespace",
"if",
"len",
"(",
"terminator",
")",
"==",
"0",
"{",
"terminator",
"=",
"[",
"]",
"rune",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"// get list of indexes in our str that is a terminator",
"// Always include the beginning of our str a terminator. This is so we can",
"// detect the first character as a prefix",
"termIndexes",
":=",
"[",
"]",
"int",
"{",
"-",
"1",
"}",
"\n",
"for",
"i",
",",
"char",
":=",
"range",
"str",
"{",
"if",
"isTerminator",
"(",
"char",
",",
"terminator",
"...",
")",
"{",
"termIndexes",
"=",
"append",
"(",
"termIndexes",
",",
"i",
")",
"\n",
"}",
"\n",
"}",
"\n",
"// Always include last character as a terminator",
"termIndexes",
"=",
"append",
"(",
"termIndexes",
",",
"len",
"(",
"str",
")",
")",
"\n\n",
"// check if the character AFTER our term index is our prefix",
"for",
"i",
",",
"t",
":=",
"range",
"termIndexes",
"{",
"// ensure term index is not the last character in str",
"if",
"t",
">=",
"(",
"len",
"(",
"str",
")",
"-",
"1",
")",
"{",
"break",
"\n",
"}",
"\n",
"if",
"str",
"[",
"t",
"+",
"1",
"]",
"==",
"byte",
"(",
"prefix",
")",
"{",
"tagText",
":=",
"strings",
".",
"TrimLeft",
"(",
"str",
"[",
"t",
"+",
"2",
":",
"termIndexes",
"[",
"i",
"+",
"1",
"]",
"]",
",",
"string",
"(",
"prefix",
")",
")",
"\n",
"if",
"tagText",
"==",
"\"",
"\"",
"{",
"continue",
"\n",
"}",
"\n",
"index",
":=",
"t",
"+",
"1",
"\n",
"<mask>",
"=",
"append",
"(",
"tags",
",",
"Tag",
"{",
"prefix",
",",
"tagText",
",",
"index",
"}",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] |
12,686 | all-12687 | [
"StrLenRange",
"param",
"is",
"a",
"string",
"length",
"range",
"is",
"[",
"n",
"m",
"]"
] | [
"func",
"(",
"c",
"*",
"Controller",
")",
"StrLenRange",
"(",
"fieldName",
"string",
",",
"p",
"interface",
"{",
"}",
",",
"n",
"int",
",",
"m",
"int",
")",
"string",
"{",
"if",
"p",
"==",
"nil",
"{",
"p",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"v",
",",
"ok",
":=",
"p",
".",
"(",
"string",
")",
"\n",
"if",
"ok",
"==",
"false",
"{",
"panic",
"(",
"(",
"&",
"ValidationError",
"{",
"}",
")",
".",
"New",
"(",
"fieldName",
"+",
"\"",
"",
"",
"",
"\n",
"}",
"\n",
"length",
":=",
"utf8",
".",
"RuneCountInString",
"(",
"v",
")",
"\n",
"if",
"<mask>",
">",
"m",
"||",
"length",
"<",
"n",
"{",
"panic",
"(",
"(",
"&",
"ValidationError",
"{",
"}",
")",
".",
"New",
"(",
"fieldName",
"+",
"\"",
"v",
"I",
"oa(n) +",
" ",
"\"到\" ",
"+",
" ",
"s",
"r",
"o",
"I",
"o",
"(m)))",
"",
"",
"",
"",
"",
"",
"",
"\n",
"}",
"\n",
"return",
"v",
"\n",
"}"
] |
12,687 | all-12688 | [
"Valid",
"returns",
"false",
"when",
"iteration",
"is",
"done",
"."
] | [
"func",
"(",
"<mask>",
"*",
"Iterator",
")",
"Valid",
"(",
")",
"bool",
"{",
"if",
"it",
".",
"item",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"bytes",
".",
"HasPrefix",
"(",
"it",
".",
"item",
".",
"key",
",",
"it",
".",
"opt",
".",
"Prefix",
")",
"\n",
"}"
] |
12,688 | all-12689 | [
"BalanceClosingHash",
"computes",
"balance",
"message",
"hash",
"."
] | [
"func",
"BalanceClosingHash",
"(",
"clientAddr",
",",
"pscAddr",
"common",
".",
"Address",
",",
"block",
"uint32",
",",
"offeringHash",
"<mask>",
".",
"Hash",
",",
"balance",
"uint64",
")",
"[",
"]",
"byte",
"{",
"blockBytes",
":=",
"data",
".",
"Uint32ToBytes",
"(",
"block",
")",
"\n",
"balanceBytes",
":=",
"data",
".",
"Uint64ToBytes",
"(",
"balance",
")",
"\n",
"return",
"crypto",
".",
"Keccak256",
"(",
"[",
"]",
"byte",
"(",
"\"",
"\\x19",
"\\n",
"\"",
")",
",",
"crypto",
".",
"Keccak256",
"(",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
",",
"clientAddr",
".",
"Bytes",
"(",
")",
",",
"blockBytes",
"[",
":",
"]",
",",
"offeringHash",
".",
"Bytes",
"(",
")",
",",
"balanceBytes",
"[",
":",
"]",
",",
"pscAddr",
".",
"Bytes",
"(",
")",
",",
")",
",",
")",
"\n",
"}"
] |
12,689 | all-12690 | [
"EditOrg",
"will",
"update",
"the",
"metadata",
"for",
"this",
"org",
".",
"https",
":",
"//",
"developer",
".",
"github",
".",
"com",
"/",
"v3",
"/",
"orgs",
"/",
"#edit",
"-",
"an",
"-",
"organization"
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"EditOrg",
"(",
"name",
"string",
",",
"config",
"Organization",
")",
"(",
"*",
"Organization",
",",
"error",
")",
"{",
"c",
".",
"log",
"(",
"\"",
"\"",
",",
"name",
",",
"config",
")",
"\n",
"if",
"c",
".",
"dry",
"{",
"return",
"&",
"config",
",",
"nil",
"\n",
"}",
"\n",
"var",
"retOrg",
"Organization",
"\n",
"_",
",",
"err",
":=",
"c",
".",
"request",
"(",
"&",
"request",
"{",
"method",
":",
"http",
".",
"MethodPatch",
",",
"<mask>",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"name",
")",
",",
"exitCodes",
":",
"[",
"]",
"int",
"{",
"200",
"}",
",",
"requestBody",
":",
"&",
"config",
",",
"}",
",",
"&",
"retOrg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"retOrg",
",",
"nil",
"\n",
"}"
] |
12,690 | all-12691 | [
"Get",
"returns",
"a",
"relay",
"timer",
"that",
"has",
"not",
"started",
".",
"Timers",
"must",
"be",
"started",
"explicitly",
"using",
"the",
"Start",
"function",
"."
] | [
"func",
"(",
"tp",
"*",
"relayTimerPool",
")",
"Get",
"(",
")",
"*",
"relayTimer",
"{",
"timer",
",",
"ok",
":=",
"tp",
".",
"pool",
".",
"Get",
"(",
")",
".",
"(",
"*",
"relayTimer",
")",
"\n",
"if",
"ok",
"{",
"timer",
".",
"released",
"=",
"false",
"\n",
"return",
"timer",
"\n",
"}",
"\n\n",
"rt",
":=",
"&",
"relayTimer",
"{",
"pool",
":",
"tp",
",",
"}",
"\n",
"// Go timers are started by default. However, we need to separate creating",
"// the timer and starting the timer for use in the relay code paths.",
"// To make this work without more locks in the relayTimer, we create a Go timer",
"// with a huge timeout so it doesn't run, then stop it so we can start it later.",
"rt",
".",
"<mask>",
"=",
"time",
".",
"AfterFunc",
"(",
"time",
".",
"Duration",
"(",
"math",
".",
"MaxInt64",
")",
",",
"rt",
".",
"OnTimer",
")",
"\n",
"if",
"!",
"rt",
".",
"timer",
".",
"Stop",
"(",
")",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"rt",
"\n",
"}"
] |
12,691 | all-12692 | [
"NewMultiError",
"creates",
"a",
"new",
"MultErr",
"object"
] | [
"func",
"NewMultiError",
"(",
"errs",
"...",
"error",
")",
"error",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
",",
"len",
"(",
"errs",
")",
")",
"\n",
"for",
"_",
",",
"err",
":=",
"range",
"errs",
"{",
"if",
"err",
"!=",
"nil",
"{",
"errors",
"=",
"append",
"(",
"<mask>",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"MultiErr",
"{",
"errors",
"}",
"\n",
"}"
] |
12,692 | all-12693 | [
"Delete",
"deletes",
"the",
"specified",
"key",
":",
"value",
".",
"Errors",
":",
"InvalidKeyError",
"when",
"requested",
"key",
"could",
"not",
"be",
"found",
"."
] | [
"func",
"(",
"s",
"*",
"Cache",
")",
"Delete",
"(",
"key",
"string",
")",
"error",
"{",
"lckStatus",
":=",
"s",
".",
"removeExpired",
"(",
")",
"\n\n",
"_",
",",
"err",
":=",
"s",
".",
"unsafeGet",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"lckStatus",
"==",
"raiqub",
".",
"ReadLocked",
"{",
"s",
".",
"RUnlock",
"(",
")",
"\n",
"s",
".",
"Lock",
"(",
")",
"\n",
"}",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"<mask>",
"(",
"s",
".",
"values",
",",
"key",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,693 | all-12694 | [
"GetAttachedCdrom",
"gets",
"attached",
"cd",
"roms"
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetAttachedCdrom",
"(",
"dcid",
",",
"srvid",
",",
"cdid",
"string",
")",
"(",
"*",
"Image",
",",
"error",
")",
"{",
"url",
":=",
"serverCdromPath",
"(",
"dcid",
",",
"srvid",
",",
"cdid",
")",
"// + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty)",
"\n",
"ret",
":=",
"&",
"Image",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"<mask>",
".",
"Get",
"(",
"url",
",",
"ret",
",",
"http",
".",
"StatusOK",
")",
"\n",
"return",
"ret",
",",
"err",
"\n",
"}"
] |
12,694 | all-12695 | [
"reset",
"this",
"source",
"back",
"to",
"its",
"initial",
"state",
"it",
"ll",
"generate",
"the",
"same",
"sequence",
"of",
"data",
"it",
"initially",
"did"
] | [
"func",
"(",
"a",
"*",
"applySource",
")",
"<mask>",
"(",
")",
"{",
"a",
".",
"rnd",
"=",
"rand",
".",
"New",
"(",
"rand",
".",
"NewSource",
"(",
"a",
".",
"seed",
")",
")",
"\n",
"}"
] |
12,695 | all-12696 | [
"Funcs",
"set",
"helper",
"functions",
"for",
"template",
"with",
"default",
"application",
"layout",
"."
] | [
"func",
"(",
"render",
"*",
"Render",
")",
"Funcs",
"(",
"funcMap",
"template",
".",
"FuncMap",
")",
"*",
"Template",
"{",
"tmpl",
":=",
"&",
"Template",
"{",
"render",
":",
"<mask>",
",",
"usingDefaultLayout",
":",
"true",
"}",
"\n",
"return",
"tmpl",
".",
"Funcs",
"(",
"funcMap",
")",
"\n",
"}"
] |
12,696 | all-12697 | [
"GetUserAgent",
"returns",
"the",
"UserAgent",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"s",
"*",
"SyntheticsDevice",
")",
"GetUserAgent",
"(",
")",
"string",
"{",
"if",
"s",
"==",
"nil",
"||",
"s",
".",
"UserAgent",
"==",
"nil",
"{",
"<mask>",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"*",
"s",
".",
"UserAgent",
"\n",
"}"
] |
12,697 | all-12698 | [
"GetPachClient",
"returns",
"a",
"pachd",
"client",
"with",
"the",
"same",
"authentication",
"credentials",
"and",
"cancellation",
"as",
"ctx",
"(",
"ensuring",
"that",
"auth",
"credentials",
"are",
"propagated",
"through",
"downstream",
"RPCs",
")",
".",
"Functions",
"that",
"receive",
"RPCs",
"should",
"call",
"this",
"to",
"convert",
"their",
"RPC",
"context",
"to",
"a",
"Pachyderm",
"client",
"and",
"internal",
"Pachyderm",
"calls",
"should",
"accept",
"clients",
"returned",
"by",
"this",
"call",
".",
"(",
"Warning",
")",
"Do",
"not",
"call",
"this",
"function",
"during",
"server",
"setup",
"unless",
"it",
"is",
"in",
"a",
"goroutine",
".",
"A",
"Pachyderm",
"client",
"is",
"not",
"available",
"until",
"the",
"server",
"has",
"been",
"setup",
"."
] | [
"func",
"(",
"env",
"*",
"ServiceEnv",
")",
"GetPachClient",
"(",
"ctx",
"context",
".",
"<mask>",
")",
"*",
"client",
".",
"APIClient",
"{",
"if",
"err",
":=",
"env",
".",
"pachEg",
".",
"Wait",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"// If env can't connect, there's no sensible way to recover",
"\n",
"}",
"\n",
"return",
"env",
".",
"pachClient",
".",
"WithCtx",
"(",
"ctx",
")",
"\n",
"}"
] |
12,698 | all-12699 | [
"Validate",
"implements",
"the",
"fire",
".",
"ValidatableModel",
"interface",
"."
] | [
"func",
"(",
"i",
"*",
"Item",
")",
"Validate",
"(",
")",
"error",
"{",
"// check name",
"if",
"utf8",
".",
"RuneCountInString",
"(",
"i",
".",
"Name",
")",
"<",
"1",
"{",
"return",
"fire",
".",
"E",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// check timestamps",
"if",
"i",
".",
"Created",
".",
"IsZero",
"(",
")",
"||",
"i",
".",
"Updated",
".",
"IsZero",
"(",
")",
"{",
"return",
"<mask>",
".",
"E",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
12,699 | all-12700 | [
"Set",
"a",
"new",
"ext",
"for",
"the",
"sequence"
] | [
"func",
"(",
"s",
"*",
"FileSequence",
")",
"SetExt",
"(",
"ext",
"<mask>",
")",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"ext",
",",
"\"",
"\"",
")",
"{",
"ext",
"=",
"\"",
"\"",
"+",
"ext",
"\n",
"}",
"\n",
"s",
".",
"ext",
"=",
"ext",
"\n",
"}"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.