id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
sequencelengths 1
418
| pl_tokens
sequencelengths 22
4.98k
|
---|---|---|---|
14,000 | all-14001 | [
"GetWidth",
"returns",
"the",
"Width",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"s",
"*",
"SyntheticsDevice",
")",
"GetWidth",
"(",
")",
"int",
"{",
"if",
"s",
"==",
"nil",
"||",
"s",
".",
"Width",
"==",
"nil",
"{",
"<mask>",
"0",
"\n",
"}",
"\n",
"return",
"*",
"s",
".",
"Width",
"\n",
"}"
] |
14,001 | all-14002 | [
"GetDevices",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockGPUManager",
")",
"GetDevices",
"(",
")",
"[",
"]",
"*",
"ecs",
".",
"PlatformDevice",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"<mask>",
"[",
"0",
"]",
".",
"(",
"[",
"]",
"*",
"ecs",
".",
"PlatformDevice",
")",
"\n",
"return",
"ret0",
"\n",
"}"
] |
14,002 | all-14003 | [
"GetMatrix",
"is",
"a",
"wrapper",
"around",
"cairo_get_matrix",
"."
] | [
"func",
"(",
"v",
"*",
"Context",
")",
"GetMatrix",
"(",
")",
"*",
"Matrix",
"{",
"<mask>",
"matrix",
"C",
".",
"cairo_matrix_t",
"\n",
"C",
".",
"cairo_get_matrix",
"(",
"v",
".",
"native",
"(",
")",
",",
"&",
"matrix",
")",
"\n",
"return",
"&",
"Matrix",
"{",
"Xx",
":",
"float64",
"(",
"matrix",
".",
"xx",
")",
",",
"Yx",
":",
"float64",
"(",
"matrix",
".",
"yx",
")",
",",
"Xy",
":",
"float64",
"(",
"matrix",
".",
"xy",
")",
",",
"Yy",
":",
"float64",
"(",
"matrix",
".",
"yy",
")",
",",
"X0",
":",
"float64",
"(",
"matrix",
".",
"x0",
")",
",",
"Y0",
":",
"float64",
"(",
"matrix",
".",
"y0",
")",
",",
"}",
"\n",
"}"
] |
14,003 | all-14004 | [
"Add",
"adds",
"a",
"bool",
"tag",
"to",
"the",
"span"
] | [
"func",
"(",
"tag",
"boolTagName",
")",
"Set",
"(",
"span",
"opentracing",
".",
"Span",
",",
"<mask>",
"bool",
")",
"{",
"span",
".",
"SetTag",
"(",
"string",
"(",
"tag",
")",
",",
"value",
")",
"\n",
"}"
] |
14,004 | all-14005 | [
"SetBody",
"is",
"a",
"wrapper",
"around",
"g_notification_set_body",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Notification",
")",
"SetBody",
"(",
"body",
"string",
")",
"{",
"cstr1",
":=",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"C",
".",
"CString",
"(",
"<mask>",
")",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr1",
")",
")",
"\n\n",
"C",
".",
"g_notification_set_body",
"(",
"v",
".",
"native",
"(",
")",
",",
"cstr1",
")",
"\n",
"}"
] |
14,005 | all-14006 | [
"GetFillRule",
"is",
"a",
"wrapper",
"around",
"cairo_get_fill_rule",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"<mask>",
")",
"GetFillRule",
"(",
")",
"FillRule",
"{",
"c",
":=",
"C",
".",
"cairo_get_fill_rule",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"return",
"FillRule",
"(",
"c",
")",
"\n",
"}"
] |
14,006 | all-14007 | [
"simultaneously",
"specify",
"storage",
"for",
"all",
"levels",
"of",
"a",
"two",
"-",
"dimensional",
"or",
"one",
"-",
"dimensional",
"array",
"texture"
] | [
"func",
"TexStorage2D",
"(",
"target",
"uint32",
",",
"levels",
"int32",
",",
"internalformat",
"uint32",
",",
"width",
"int32",
",",
"height",
"int32",
")",
"{",
"C",
".",
"glowTexStorage2D",
"(",
"gpTexStorage2D",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"<mask>",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"levels",
")",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"internalformat",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"width",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"height",
")",
")",
"\n",
"}"
] |
14,007 | all-14008 | [
"UnmarshalJSON",
"overrides",
"the",
"logic",
"for",
"parsing",
"the",
"JSON",
"-",
"encoded",
"ContainerOverrides",
"data",
"This",
"custom",
"unmarshaller",
"is",
"needed",
"because",
"the",
"json",
"sent",
"to",
"us",
"as",
"a",
"string",
"rather",
"than",
"a",
"fully",
"typed",
"object",
".",
"We",
"support",
"both",
"formats",
"in",
"the",
"hopes",
"that",
"one",
"day",
"everything",
"will",
"be",
"fully",
"typed",
"Note",
":",
"the",
"json",
":",
"string",
"tag",
"DOES",
"NOT",
"apply",
"here",
";",
"it",
"DOES",
"NOT",
"work",
"with",
"struct",
"types",
"only",
"ints",
"/",
"floats",
"/",
"etc",
".",
"We",
"re",
"basically",
"doing",
"that",
"though",
"We",
"also",
"intentionally",
"fail",
"if",
"there",
"are",
"any",
"keys",
"we",
"were",
"unable",
"to",
"unmarshal",
"into",
"our",
"struct"
] | [
"func",
"(",
"overrides",
"*",
"ContainerOverrides",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"<mask>",
")",
"error",
"{",
"regular",
":=",
"ContainerOverridesCopy",
"{",
"}",
"\n\n",
"// Try to do it the strongly typed way first",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"b",
",",
"&",
"regular",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"err",
"=",
"utils",
".",
"CompleteJsonUnmarshal",
"(",
"b",
",",
"regular",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"*",
"overrides",
"=",
"ContainerOverrides",
"(",
"regular",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"err",
"=",
"apierrors",
".",
"NewMultiError",
"(",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
",",
"err",
")",
"\n",
"}",
"\n\n",
"// Now the strongly typed way",
"var",
"str",
"string",
"\n",
"err2",
":=",
"json",
".",
"Unmarshal",
"(",
"b",
",",
"&",
"str",
")",
"\n",
"if",
"err2",
"!=",
"nil",
"{",
"return",
"apierrors",
".",
"NewMultiError",
"(",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
",",
"err",
",",
"err2",
")",
"\n",
"}",
"\n\n",
"// We have a string, let's try to unmarshal that into a typed object",
"err3",
":=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"str",
")",
",",
"&",
"regular",
")",
"\n",
"if",
"err3",
"==",
"nil",
"{",
"err3",
"=",
"utils",
".",
"CompleteJsonUnmarshal",
"(",
"[",
"]",
"byte",
"(",
"str",
")",
",",
"regular",
")",
"\n",
"if",
"err3",
"==",
"nil",
"{",
"*",
"overrides",
"=",
"ContainerOverrides",
"(",
"regular",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"err3",
"=",
"apierrors",
".",
"NewMultiError",
"(",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
",",
"err3",
")",
"\n",
"}",
"\n\n",
"return",
"apierrors",
".",
"NewMultiError",
"(",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
",",
"err",
",",
"err2",
",",
"err3",
")",
"\n",
"}"
] |
14,008 | all-14009 | [
"GetHostFiltersOk",
"returns",
"a",
"tuple",
"with",
"the",
"HostFilters",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"i",
"*",
"IntegrationGCPCreateRequest",
")",
"GetHostFiltersOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"i",
"==",
"nil",
"||",
"i",
".",
"HostFilters",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"i",
".",
"HostFilters",
",",
"<mask>",
"\n",
"}"
] |
14,009 | all-14010 | [
"ParseBytes",
"parses",
"Set",
"-",
"Cookie",
"header",
"."
] | [
"func",
"(",
"c",
"*",
"Cookie",
")",
"ParseBytes",
"(",
"src",
"[",
"]",
"byte",
")",
"error",
"{",
"c",
".",
"Reset",
"(",
")",
"\n\n",
"var",
"s",
"cookieScanner",
"\n",
"s",
".",
"b",
"=",
"src",
"\n\n",
"kv",
":=",
"&",
"c",
".",
"bufKV",
"\n",
"if",
"!",
"s",
".",
"next",
"(",
"kv",
")",
"{",
"return",
"errNoCookies",
"\n",
"}",
"\n\n",
"c",
".",
"key",
"=",
"append",
"(",
"c",
".",
"key",
"[",
":",
"0",
"]",
",",
"kv",
".",
"key",
"...",
")",
"\n",
"c",
".",
"value",
"=",
"append",
"(",
"c",
".",
"value",
"[",
":",
"0",
"]",
",",
"kv",
".",
"value",
"...",
")",
"\n\n",
"for",
"s",
".",
"next",
"(",
"kv",
")",
"{",
"if",
"len",
"(",
"kv",
".",
"key",
")",
"!=",
"0",
"{",
"// Case insensitive switch on first char",
"switch",
"kv",
".",
"key",
"[",
"0",
"]",
"|",
"0x20",
"{",
"case",
"'m'",
":",
"if",
"caseInsensitiveCompare",
"(",
"strCookieMaxAge",
",",
"kv",
".",
"key",
")",
"{",
"maxAge",
",",
"err",
":=",
"ParseUint",
"(",
"kv",
".",
"value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"c",
".",
"maxAge",
"=",
"maxAge",
"\n",
"}",
"\n\n",
"case",
"'e'",
":",
"// \"expires\"",
"if",
"caseInsensitiveCompare",
"(",
"strCookieExpires",
",",
"kv",
".",
"key",
")",
"{",
"v",
":=",
"b2s",
"(",
"kv",
".",
"value",
")",
"\n",
"// Try the same two formats as net/http",
"// See: https://github.com/golang/go/blob/00379be17e63a5b75b3237819392d2dc3b313a27/src/net/http/cookie.go#L133-L135",
"exptime",
",",
"err",
":=",
"time",
".",
"ParseInLocation",
"(",
"time",
".",
"RFC1123",
",",
"v",
",",
"time",
".",
"UTC",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"exptime",
",",
"err",
"=",
"time",
".",
"Parse",
"(",
"\"",
"\"",
",",
"v",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"c",
".",
"expire",
"=",
"exptime",
"\n",
"}",
"\n\n",
"case",
"'d'",
":",
"// \"domain\"",
"if",
"caseInsensitiveCompare",
"(",
"strCookieDomain",
",",
"kv",
".",
"key",
")",
"{",
"c",
".",
"domain",
"=",
"<mask>",
"(",
"c",
".",
"domain",
"[",
":",
"0",
"]",
",",
"kv",
".",
"value",
"...",
")",
"\n",
"}",
"\n\n",
"case",
"'p'",
":",
"// \"path\"",
"if",
"caseInsensitiveCompare",
"(",
"strCookiePath",
",",
"kv",
".",
"key",
")",
"{",
"c",
".",
"path",
"=",
"append",
"(",
"c",
".",
"path",
"[",
":",
"0",
"]",
",",
"kv",
".",
"value",
"...",
")",
"\n",
"}",
"\n\n",
"case",
"'s'",
":",
"// \"samesite\"",
"if",
"caseInsensitiveCompare",
"(",
"strCookieSameSite",
",",
"kv",
".",
"key",
")",
"{",
"// Case insensitive switch on first char",
"switch",
"kv",
".",
"value",
"[",
"0",
"]",
"|",
"0x20",
"{",
"case",
"'l'",
":",
"// \"lax\"",
"if",
"caseInsensitiveCompare",
"(",
"strCookieSameSiteLax",
",",
"kv",
".",
"value",
")",
"{",
"c",
".",
"sameSite",
"=",
"CookieSameSiteLaxMode",
"\n",
"}",
"\n",
"case",
"'s'",
":",
"// \"strict\"",
"if",
"caseInsensitiveCompare",
"(",
"strCookieSameSiteStrict",
",",
"kv",
".",
"value",
")",
"{",
"c",
".",
"sameSite",
"=",
"CookieSameSiteStrictMode",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"else",
"if",
"len",
"(",
"kv",
".",
"value",
")",
"!=",
"0",
"{",
"// Case insensitive switch on first char",
"switch",
"kv",
".",
"value",
"[",
"0",
"]",
"|",
"0x20",
"{",
"case",
"'h'",
":",
"// \"httponly\"",
"if",
"caseInsensitiveCompare",
"(",
"strCookieHTTPOnly",
",",
"kv",
".",
"value",
")",
"{",
"c",
".",
"httpOnly",
"=",
"true",
"\n",
"}",
"\n\n",
"case",
"'s'",
":",
"// \"secure\"",
"if",
"caseInsensitiveCompare",
"(",
"strCookieSecure",
",",
"kv",
".",
"value",
")",
"{",
"c",
".",
"secure",
"=",
"true",
"\n",
"}",
"else",
"if",
"caseInsensitiveCompare",
"(",
"strCookieSameSite",
",",
"kv",
".",
"value",
")",
"{",
"c",
".",
"sameSite",
"=",
"CookieSameSiteDefaultMode",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"// else empty or no match",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
14,010 | all-14011 | [
"title",
":",
"plan",
"create",
"path",
":",
"/",
"plans",
"method",
":",
"POST",
"consume",
":",
"application",
"/",
"x",
"-",
"www",
"-",
"form",
"-",
"urlencoded",
"responses",
":",
"201",
":",
"Plan",
"created",
"400",
":",
"Invalid",
"data",
"401",
":",
"Unauthorized",
"409",
":",
"Plan",
"already",
"exists"
] | [
"func",
"addPlan",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"t",
"auth",
".",
"Token",
")",
"(",
"err",
"error",
")",
"{",
"cpuShare",
",",
"_",
":=",
"strconv",
".",
"Atoi",
"(",
"InputValue",
"(",
"r",
",",
"\"",
"\"",
")",
")",
"\n",
"isDefault",
",",
"_",
":=",
"strconv",
".",
"ParseBool",
"(",
"InputValue",
"(",
"r",
",",
"\"",
"\"",
")",
")",
"\n",
"<mask>",
":=",
"getSize",
"(",
"InputValue",
"(",
"r",
",",
"\"",
"\"",
")",
")",
"\n",
"swap",
":=",
"getSize",
"(",
"InputValue",
"(",
"r",
",",
"\"",
"\"",
")",
")",
"\n",
"plan",
":=",
"appTypes",
".",
"Plan",
"{",
"Name",
":",
"InputValue",
"(",
"r",
",",
"\"",
"\"",
")",
",",
"Memory",
":",
"memory",
",",
"Swap",
":",
"swap",
",",
"CpuShare",
":",
"cpuShare",
",",
"Default",
":",
"isDefault",
",",
"}",
"\n",
"allowed",
":=",
"permission",
".",
"Check",
"(",
"t",
",",
"permission",
".",
"PermPlanCreate",
")",
"\n",
"if",
"!",
"allowed",
"{",
"return",
"permission",
".",
"ErrUnauthorized",
"\n",
"}",
"\n",
"evt",
",",
"err",
":=",
"event",
".",
"New",
"(",
"&",
"event",
".",
"Opts",
"{",
"Target",
":",
"event",
".",
"Target",
"{",
"Type",
":",
"event",
".",
"TargetTypePlan",
",",
"Value",
":",
"plan",
".",
"Name",
"}",
",",
"Kind",
":",
"permission",
".",
"PermPlanCreate",
",",
"Owner",
":",
"t",
",",
"CustomData",
":",
"event",
".",
"FormToCustomData",
"(",
"InputFields",
"(",
"r",
")",
")",
",",
"Allowed",
":",
"event",
".",
"Allowed",
"(",
"permission",
".",
"PermPlanReadEvents",
")",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"evt",
".",
"Done",
"(",
"err",
")",
"}",
"(",
")",
"\n",
"err",
"=",
"servicemanager",
".",
"Plan",
".",
"Create",
"(",
"plan",
")",
"\n",
"if",
"err",
"==",
"appTypes",
".",
"ErrPlanAlreadyExists",
"{",
"return",
"&",
"errors",
".",
"HTTP",
"{",
"Code",
":",
"http",
".",
"StatusConflict",
",",
"Message",
":",
"err",
".",
"Error",
"(",
")",
",",
"}",
"\n",
"}",
"\n",
"if",
"err",
"==",
"appTypes",
".",
"ErrLimitOfMemory",
"||",
"err",
"==",
"appTypes",
".",
"ErrLimitOfCpuShare",
"{",
"return",
"&",
"errors",
".",
"HTTP",
"{",
"Code",
":",
"http",
".",
"StatusBadRequest",
",",
"Message",
":",
"err",
".",
"Error",
"(",
")",
",",
"}",
"\n",
"}",
"\n",
"if",
"err",
"==",
"nil",
"{",
"w",
".",
"WriteHeader",
"(",
"http",
".",
"StatusCreated",
")",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] |
14,011 | all-14012 | [
"New",
"creates",
"a",
"new",
"Pool",
"of",
"workers",
"that",
"starts",
"with",
"n",
"workers",
".",
"You",
"must",
"provide",
"a",
"constructor",
"function",
"that",
"creates",
"new",
"Worker",
"types",
"and",
"when",
"you",
"change",
"the",
"size",
"of",
"the",
"pool",
"the",
"constructor",
"will",
"be",
"called",
"to",
"create",
"each",
"new",
"Worker",
"."
] | [
"func",
"New",
"(",
"n",
"int",
",",
"ctor",
"func",
"(",
")",
"Worker",
")",
"*",
"Pool",
"{",
"p",
":=",
"&",
"Pool",
"{",
"ctor",
":",
"ctor",
",",
"reqChan",
":",
"<mask>",
"(",
"chan",
"workRequest",
")",
",",
"}",
"\n",
"p",
".",
"SetSize",
"(",
"n",
")",
"\n\n",
"return",
"p",
"\n",
"}"
] |
14,012 | all-14013 | [
"Restore",
"restores",
"the",
"terminal",
"connected",
"to",
"the",
"given",
"file",
"descriptor",
"to",
"a",
"previous",
"state",
"."
] | [
"func",
"Restore",
"(",
"fd",
"int",
",",
"state",
"*",
"State",
")",
"error",
"{",
"newState",
":=",
"terminal",
".",
"State",
"(",
"*",
"<mask>",
")",
"\n\n",
"return",
"terminal",
".",
"Restore",
"(",
"fd",
",",
"&",
"newState",
")",
"\n",
"}"
] |
14,013 | all-14014 | [
"FullWaveRectifier",
"to",
"make",
"all",
"signal",
"positive",
"See",
"https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Rectifier#Full",
"-",
"wave_rectification"
] | [
"func",
"FullWaveRectifier",
"(",
"buf",
"*",
"audio",
".",
"FloatBuffer",
")",
"error",
"{",
"if",
"buf",
"==",
"nil",
"{",
"return",
"<mask>",
".",
"ErrInvalidBuffer",
"\n",
"}",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"buf",
".",
"Data",
")",
";",
"i",
"++",
"{",
"buf",
".",
"Data",
"[",
"i",
"]",
"=",
"math",
".",
"Abs",
"(",
"buf",
".",
"Data",
"[",
"i",
"]",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
14,014 | all-14015 | [
"acquireSocket",
"acquires",
"a",
"socket",
"from",
"the",
"same",
"server",
"that",
"the",
"iterator",
"cursor",
"was",
"obtained",
"from",
".",
"WARNING",
":",
"This",
"method",
"must",
"not",
"be",
"called",
"with",
"iter",
".",
"m",
"locked",
".",
"Acquiring",
"the",
"socket",
"depends",
"on",
"the",
"cluster",
"sync",
"loop",
"and",
"the",
"cluster",
"sync",
"loop",
"might",
"attempt",
"actions",
"which",
"cause",
"replyFunc",
"to",
"be",
"called",
"inducing",
"a",
"deadlock",
"."
] | [
"func",
"(",
"iter",
"*",
"Iter",
")",
"acquireSocket",
"(",
")",
"(",
"*",
"mongoSocket",
",",
"error",
")",
"{",
"socket",
",",
"err",
":=",
"iter",
".",
"session",
".",
"acquireSocket",
"(",
"true",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"socket",
".",
"Server",
"(",
")",
"!=",
"iter",
".",
"server",
"{",
"// Socket server changed during iteration. This may happen",
"// with Eventual sessions, if a Refresh is done, or if a",
"// monotonic session gets a write and shifts from secondary",
"// to primary. Our cursor is in a specific server, though.",
"iter",
".",
"session",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"sockTimeout",
":=",
"iter",
".",
"session",
".",
"sockTimeout",
"\n",
"iter",
".",
"session",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"socket",
".",
"Release",
"(",
")",
"\n",
"socket",
",",
"_",
",",
"err",
"=",
"iter",
".",
"server",
".",
"AcquireSocket",
"(",
"0",
",",
"sockTimeout",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"err",
":=",
"iter",
".",
"session",
".",
"socketLogin",
"(",
"<mask>",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"socket",
".",
"Release",
"(",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"socket",
",",
"nil",
"\n",
"}"
] |
14,015 | all-14016 | [
"GetBuffer",
"is",
"a",
"wrapper",
"around",
"gtk_text_iter_get_buffer",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"TextIter",
")",
"GetBuffer",
"(",
")",
"*",
"TextBuffer",
"{",
"c",
":=",
"C",
".",
"gtk_text_iter_get_buffer",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"<mask>",
"nil",
"\n",
"}",
"\n",
"return",
"wrapTextBuffer",
"(",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
")",
"\n",
"}"
] |
14,016 | all-14017 | [
"FreeFull",
"acts",
"the",
"same",
"as",
"g_list_free_full",
"()",
".",
"Calling",
"list",
".",
"FreeFull",
"(",
"fn",
")",
"is",
"equivalent",
"to",
"calling",
"list",
".",
"Foreach",
"(",
"fn",
")",
"and",
"list",
".",
"Free",
"()",
"sequentially",
"."
] | [
"func",
"(",
"v",
"*",
"List",
")",
"FreeFull",
"(",
"fn",
"func",
"(",
"<mask>",
"interface",
"{",
"}",
")",
")",
"{",
"v",
".",
"Foreach",
"(",
"fn",
")",
"\n",
"v",
".",
"Free",
"(",
")",
"\n",
"}"
] |
14,017 | all-14018 | [
"Do",
"executes",
"DOM",
".",
"pushNodesByBackendIdsToFrontend",
"against",
"the",
"provided",
"context",
".",
"returns",
":",
"nodeIds",
"-",
"The",
"array",
"of",
"ids",
"of",
"pushed",
"nodes",
"that",
"correspond",
"to",
"the",
"backend",
"ids",
"specified",
"in",
"backendNodeIds",
"."
] | [
"func",
"(",
"p",
"*",
"PushNodesByBackendIdsToFrontendParams",
")",
"Do",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"nodeIds",
"[",
"]",
"cdp",
".",
"NodeID",
",",
"err",
"error",
")",
"{",
"// execute",
"var",
"<mask>",
"PushNodesByBackendIdsToFrontendReturns",
"\n",
"err",
"=",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandPushNodesByBackendIdsToFrontend",
",",
"p",
",",
"&",
"res",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"res",
".",
"NodeIds",
",",
"nil",
"\n",
"}"
] |
14,018 | all-14019 | [
"Is",
"determines",
"if",
"a",
"tuple",
"is",
"a",
"certain",
"type",
"."
] | [
"func",
"(",
"t",
"*",
"Tuple",
")",
"Is",
"(",
"tupleType",
"TupleType",
")",
"bool",
"{",
"return",
"t",
".",
"Header",
".",
"Hash",
"==",
"tupleType",
".",
"Hash",
"&&",
"t",
".",
"<mask>",
".",
"NamespaceHash",
"==",
"tupleType",
".",
"NamespaceHash",
"\n",
"}"
] |
14,019 | all-14020 | [
"AddFlags",
"adds",
"log",
"-",
"authors",
"<authors",
">",
"to",
"the",
"command",
"help"
] | [
"func",
"(",
"a",
"*",
"AuthorLoggerPluginWrapper",
")",
"AddFlags",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
")",
"{",
"cmd",
".",
"Flags",
"(",
")",
".",
"BoolVar",
"(",
"&",
"a",
".",
"<mask>",
",",
"\"",
"\"",
",",
"false",
",",
"\"",
"\"",
")",
"\n",
"}"
] |
14,020 | all-14021 | [
"RenderTemplate",
"executes",
"a",
"named",
"template",
"and",
"returns",
"the",
"string",
"."
] | [
"func",
"(",
"t",
"Templates",
")",
"RenderTemplate",
"(",
"name",
",",
"templateName",
"string",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"s",
"string",
",",
"err",
"error",
")",
"{",
"buf",
":=",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"tpl",
",",
"ok",
":=",
"t",
".",
"templates",
"[",
"name",
"]",
"\n",
"if",
"!",
"<mask>",
"{",
"return",
"\"",
"\"",
",",
"&",
"Error",
"{",
"Err",
":",
"ErrUnknownTemplate",
",",
"Template",
":",
"name",
"}",
"\n",
"}",
"\n",
"if",
"err",
":=",
"tpl",
".",
"ExecuteTemplate",
"(",
"&",
"buf",
",",
"templateName",
",",
"data",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"buf",
".",
"String",
"(",
")",
",",
"nil",
"\n",
"}"
] |
14,021 | all-14022 | [
"freeTo",
"frees",
"the",
"inflights",
"smaller",
"or",
"equal",
"to",
"the",
"given",
"to",
"flight",
"."
] | [
"func",
"(",
"in",
"*",
"inflights",
")",
"freeTo",
"(",
"to",
"uint64",
")",
"{",
"if",
"in",
".",
"count",
"==",
"0",
"||",
"to",
"<",
"in",
".",
"buffer",
"[",
"in",
".",
"start",
"]",
"{",
"// out of the left side of the window",
"return",
"\n",
"}",
"\n\n",
"idx",
":=",
"in",
".",
"start",
"\n",
"<mask>",
"i",
"int",
"\n",
"for",
"i",
"=",
"0",
";",
"i",
"<",
"in",
".",
"count",
";",
"i",
"++",
"{",
"if",
"to",
"<",
"in",
".",
"buffer",
"[",
"idx",
"]",
"{",
"// found the first large inflight",
"break",
"\n",
"}",
"\n\n",
"// increase index and maybe rotate",
"size",
":=",
"in",
".",
"size",
"\n",
"if",
"idx",
"++",
";",
"idx",
">=",
"size",
"{",
"idx",
"-=",
"size",
"\n",
"}",
"\n",
"}",
"\n",
"// free i inflights and set new start index",
"in",
".",
"count",
"-=",
"i",
"\n",
"in",
".",
"start",
"=",
"idx",
"\n",
"if",
"in",
".",
"count",
"==",
"0",
"{",
"// inflights is empty, reset the start index so that we don't grow the",
"// buffer unnecessarily.",
"in",
".",
"start",
"=",
"0",
"\n",
"}",
"\n",
"}"
] |
14,022 | all-14023 | [
"TODO",
":",
"implement",
"packet",
"reordering",
"from",
"multiple",
"TCP",
"connections",
"buffer",
"packets",
"per",
"connection",
"for",
"awhile",
"reorder",
"before",
"transmit",
"-",
"https",
":",
"//",
"github",
".",
"com",
"/",
"etcd",
"-",
"io",
"/",
"etcd",
"/",
"issues",
"/",
"5614",
"-",
"https",
":",
"//",
"github",
".",
"com",
"/",
"etcd",
"-",
"io",
"/",
"etcd",
"/",
"pull",
"/",
"6918#issuecomment",
"-",
"264093034"
] | [
"func",
"(",
"s",
"*",
"server",
")",
"listenAndServe",
"(",
")",
"{",
"defer",
"s",
".",
"closeWg",
".",
"Done",
"(",
")",
"\n\n",
"s",
".",
"lg",
".",
"Info",
"(",
"\"",
"\"",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"s",
".",
"From",
"(",
")",
")",
")",
"\n",
"close",
"(",
"s",
".",
"readyc",
")",
"\n\n",
"for",
"{",
"s",
".",
"pauseAcceptMu",
".",
"Lock",
"(",
")",
"\n",
"pausec",
":=",
"s",
".",
"pauseAcceptc",
"\n",
"s",
".",
"pauseAcceptMu",
".",
"Unlock",
"(",
")",
"\n",
"select",
"{",
"case",
"<-",
"pausec",
":",
"case",
"<-",
"s",
".",
"donec",
":",
"return",
"\n",
"}",
"\n\n",
"s",
".",
"latencyAcceptMu",
".",
"RLock",
"(",
")",
"\n",
"lat",
":=",
"s",
".",
"latencyAccept",
"\n",
"s",
".",
"latencyAcceptMu",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"lat",
">",
"0",
"{",
"select",
"{",
"case",
"<-",
"time",
".",
"After",
"(",
"lat",
")",
":",
"case",
"<-",
"s",
".",
"donec",
":",
"return",
"\n",
"}",
"\n",
"}",
"\n\n",
"s",
".",
"listenerMu",
".",
"RLock",
"(",
")",
"\n",
"ln",
":=",
"s",
".",
"listener",
"\n",
"s",
".",
"listenerMu",
".",
"RUnlock",
"(",
")",
"\n\n",
"in",
",",
"err",
":=",
"ln",
".",
"Accept",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"select",
"{",
"case",
"s",
".",
"errc",
"<-",
"err",
":",
"select",
"{",
"case",
"<-",
"s",
".",
"donec",
":",
"return",
"\n",
"default",
":",
"}",
"\n",
"case",
"<-",
"s",
".",
"donec",
":",
"return",
"\n",
"}",
"\n",
"s",
".",
"lg",
".",
"Debug",
"(",
"\"",
"\"",
",",
"zap",
".",
"<mask>",
"(",
"err",
")",
")",
"\n\n",
"if",
"strings",
".",
"HasSuffix",
"(",
"err",
".",
"Error",
"(",
")",
",",
"\"",
"\"",
")",
"{",
"select",
"{",
"case",
"<-",
"time",
".",
"After",
"(",
"s",
".",
"retryInterval",
")",
":",
"case",
"<-",
"s",
".",
"donec",
":",
"return",
"\n",
"}",
"\n",
"s",
".",
"lg",
".",
"Debug",
"(",
"\"",
"\"",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"s",
".",
"From",
"(",
")",
")",
")",
"\n\n",
"if",
"err",
"=",
"s",
".",
"ResetListener",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"select",
"{",
"case",
"s",
".",
"errc",
"<-",
"err",
":",
"select",
"{",
"case",
"<-",
"s",
".",
"donec",
":",
"return",
"\n",
"default",
":",
"}",
"\n",
"case",
"<-",
"s",
".",
"donec",
":",
"return",
"\n",
"}",
"\n",
"s",
".",
"lg",
".",
"Warn",
"(",
"\"",
"\"",
",",
"zap",
".",
"Error",
"(",
"err",
")",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"continue",
"\n",
"}",
"\n\n",
"var",
"out",
"net",
".",
"Conn",
"\n",
"if",
"!",
"s",
".",
"tlsInfo",
".",
"Empty",
"(",
")",
"{",
"var",
"tp",
"*",
"http",
".",
"Transport",
"\n",
"tp",
",",
"err",
"=",
"transport",
".",
"NewTransport",
"(",
"s",
".",
"tlsInfo",
",",
"s",
".",
"dialTimeout",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"select",
"{",
"case",
"s",
".",
"errc",
"<-",
"err",
":",
"select",
"{",
"case",
"<-",
"s",
".",
"donec",
":",
"return",
"\n",
"default",
":",
"}",
"\n",
"case",
"<-",
"s",
".",
"donec",
":",
"return",
"\n",
"}",
"\n",
"continue",
"\n",
"}",
"\n",
"out",
",",
"err",
"=",
"tp",
".",
"Dial",
"(",
"s",
".",
"to",
".",
"Scheme",
",",
"s",
".",
"to",
".",
"Host",
")",
"\n",
"}",
"else",
"{",
"out",
",",
"err",
"=",
"net",
".",
"Dial",
"(",
"s",
".",
"to",
".",
"Scheme",
",",
"s",
".",
"to",
".",
"Host",
")",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"select",
"{",
"case",
"s",
".",
"errc",
"<-",
"err",
":",
"select",
"{",
"case",
"<-",
"s",
".",
"donec",
":",
"return",
"\n",
"default",
":",
"}",
"\n",
"case",
"<-",
"s",
".",
"donec",
":",
"return",
"\n",
"}",
"\n",
"s",
".",
"lg",
".",
"Debug",
"(",
"\"",
"\"",
",",
"zap",
".",
"Error",
"(",
"err",
")",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"go",
"func",
"(",
")",
"{",
"// read incoming bytes from listener, dispatch to outgoing connection",
"s",
".",
"transmit",
"(",
"out",
",",
"in",
")",
"\n",
"out",
".",
"Close",
"(",
")",
"\n",
"in",
".",
"Close",
"(",
")",
"\n",
"}",
"(",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"// read response from outgoing connection, write back to listener",
"s",
".",
"receive",
"(",
"in",
",",
"out",
")",
"\n",
"in",
".",
"Close",
"(",
")",
"\n",
"out",
".",
"Close",
"(",
")",
"\n",
"}",
"(",
")",
"\n",
"}",
"\n",
"}"
] |
14,023 | all-14024 | [
"NewExponential",
"creates",
"a",
"new",
"backoff",
"using",
"the",
"exponential",
"backoff",
"algorithm",
"."
] | [
"func",
"NewExponential",
"(",
"start",
"time",
".",
"Duration",
",",
"<mask>",
"time",
".",
"Duration",
")",
"*",
"Backoff",
"{",
"return",
"NewBackoff",
"(",
"exponential",
"{",
"}",
",",
"start",
",",
"limit",
")",
"\n",
"}"
] |
14,024 | all-14025 | [
"WithMarginLeft",
"left",
"margin",
"in",
"inches",
".",
"Defaults",
"to",
"1cm",
"(",
"~0",
".",
"4",
"inches",
")",
"."
] | [
"func",
"(",
"p",
"PrintToPDFParams",
")",
"WithMarginLeft",
"(",
"marginLeft",
"float64",
")",
"*",
"PrintToPDFParams",
"{",
"p",
".",
"MarginLeft",
"=",
"marginLeft",
"\n",
"<mask>",
"&",
"p",
"\n",
"}"
] |
14,025 | all-14026 | [
"IssueCommentHandlers",
"returns",
"a",
"map",
"of",
"plugin",
"names",
"to",
"handlers",
"for",
"the",
"repo",
"."
] | [
"func",
"(",
"pa",
"*",
"ConfigAgent",
")",
"IssueCommentHandlers",
"(",
"owner",
",",
"repo",
"string",
")",
"map",
"[",
"string",
"]",
"IssueCommentHandler",
"{",
"pa",
".",
"mut",
".",
"Lock",
"(",
")",
"\n",
"defer",
"<mask>",
".",
"mut",
".",
"Unlock",
"(",
")",
"\n\n",
"hs",
":=",
"map",
"[",
"string",
"]",
"IssueCommentHandler",
"{",
"}",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"pa",
".",
"getPlugins",
"(",
"owner",
",",
"repo",
")",
"{",
"if",
"h",
",",
"ok",
":=",
"issueCommentHandlers",
"[",
"p",
"]",
";",
"ok",
"{",
"hs",
"[",
"p",
"]",
"=",
"h",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"hs",
"\n",
"}"
] |
14,026 | all-14027 | [
"ListenAndServeTLS",
"serves",
"HTTPS",
"requests",
"from",
"the",
"given",
"TCP4",
"addr",
".",
"certFile",
"and",
"keyFile",
"are",
"paths",
"to",
"TLS",
"certificate",
"and",
"key",
"files",
".",
"Pass",
"custom",
"listener",
"to",
"Serve",
"if",
"you",
"need",
"listening",
"on",
"non",
"-",
"TCP4",
"media",
"such",
"as",
"IPv6",
".",
"If",
"the",
"certFile",
"or",
"keyFile",
"has",
"not",
"been",
"provided",
"to",
"the",
"server",
"structure",
"the",
"function",
"will",
"use",
"the",
"previously",
"added",
"TLS",
"configuration",
".",
"Accepted",
"connections",
"are",
"configured",
"to",
"enable",
"TCP",
"keep",
"-",
"alives",
"."
] | [
"func",
"(",
"s",
"*",
"Server",
")",
"ListenAndServeTLS",
"(",
"addr",
",",
"certFile",
",",
"keyFile",
"string",
")",
"error",
"{",
"ln",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"s",
".",
"TCPKeepalive",
"{",
"if",
"tcpln",
",",
"<mask>",
":=",
"ln",
".",
"(",
"*",
"net",
".",
"TCPListener",
")",
";",
"ok",
"{",
"return",
"s",
".",
"ServeTLS",
"(",
"tcpKeepaliveListener",
"{",
"TCPListener",
":",
"tcpln",
",",
"keepalivePeriod",
":",
"s",
".",
"TCPKeepalivePeriod",
",",
"}",
",",
"certFile",
",",
"keyFile",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"s",
".",
"ServeTLS",
"(",
"ln",
",",
"certFile",
",",
"keyFile",
")",
"\n",
"}"
] |
14,027 | all-14028 | [
"SimpleProofsFromMap",
"generates",
"proofs",
"from",
"a",
"map",
".",
"The",
"keys",
"/",
"values",
"of",
"the",
"map",
"will",
"be",
"used",
"as",
"the",
"keys",
"/",
"values",
"in",
"the",
"underlying",
"key",
"-",
"value",
"pairs",
".",
"The",
"keys",
"are",
"sorted",
"before",
"the",
"proofs",
"are",
"computed",
"."
] | [
"func",
"SimpleProofsFromMap",
"(",
"m",
"map",
"[",
"string",
"]",
"Hasher",
")",
"(",
"rootHash",
"[",
"]",
"byte",
",",
"proofs",
"map",
"[",
"string",
"]",
"*",
"SimpleProof",
",",
"keys",
"[",
"]",
"string",
")",
"{",
"sm",
":=",
"newSimpleMap",
"(",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"m",
"{",
"sm",
".",
"Set",
"(",
"k",
",",
"v",
")",
"\n",
"}",
"\n",
"sm",
".",
"Sort",
"(",
")",
"\n",
"kvs",
":=",
"sm",
".",
"kvs",
"\n",
"kvsH",
":=",
"make",
"(",
"[",
"]",
"Hasher",
",",
"0",
",",
"len",
"(",
"kvs",
")",
")",
"\n",
"for",
"_",
",",
"kvp",
":=",
"range",
"kvs",
"{",
"kvsH",
"=",
"append",
"(",
"kvsH",
",",
"KVPair",
"(",
"kvp",
")",
")",
"\n",
"}",
"\n\n",
"rootHash",
",",
"proofList",
":=",
"SimpleProofsFromHashers",
"(",
"kvsH",
")",
"\n",
"proofs",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"SimpleProof",
")",
"\n",
"keys",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"proofList",
")",
")",
"\n",
"for",
"i",
",",
"kvp",
":=",
"range",
"kvs",
"{",
"proofs",
"[",
"string",
"(",
"kvp",
".",
"Key",
")",
"]",
"=",
"proofList",
"[",
"i",
"]",
"\n",
"keys",
"[",
"i",
"]",
"=",
"string",
"(",
"kvp",
".",
"<mask>",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] |
14,028 | all-14029 | [
"SeparatorNew",
"is",
"a",
"wrapper",
"around",
"gtk_separator_new",
"()",
"."
] | [
"func",
"SeparatorNew",
"(",
"orientation",
"Orientation",
")",
"(",
"*",
"Separator",
",",
"<mask>",
")",
"{",
"c",
":=",
"C",
".",
"gtk_separator_new",
"(",
"C",
".",
"GtkOrientation",
"(",
"orientation",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"return",
"wrapSeparator",
"(",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
")",
",",
"nil",
"\n",
"}"
] |
14,029 | all-14030 | [
"TimeDifference",
"pretty",
"-",
"prints",
"the",
"duration",
"of",
"time",
"between",
"from",
"and",
"to",
"as",
"a",
"human",
"-",
"reabable",
"string",
"."
] | [
"func",
"TimeDifference",
"(",
"from",
"*",
"types",
".",
"Timestamp",
",",
"to",
"*",
"types",
".",
"Timestamp",
")",
"string",
"{",
"tFrom",
",",
"_",
":=",
"types",
".",
"TimestampFromProto",
"(",
"from",
")",
"\n",
"tTo",
",",
"_",
":=",
"<mask>",
".",
"TimestampFromProto",
"(",
"to",
")",
"\n",
"return",
"units",
".",
"HumanDuration",
"(",
"tTo",
".",
"Sub",
"(",
"tFrom",
")",
")",
"\n",
"}"
] |
14,030 | all-14031 | [
"Available",
"returns",
"if",
"slave",
"is",
"in",
"working",
"state",
"at",
"moment",
"based",
"on",
"information",
"in",
"slave",
"flags",
"."
] | [
"func",
"(",
"s",
"*",
"Slave",
")",
"Available",
"(",
")",
"bool",
"{",
"return",
"!",
"strings",
".",
"Contains",
"(",
"s",
".",
"flags",
",",
"\"",
"\"",
")",
"&&",
"!",
"strings",
".",
"Contains",
"(",
"s",
".",
"<mask>",
",",
"\"",
"\"",
")",
"\n",
"}"
] |
14,031 | all-14032 | [
"/",
"*",
"Routine",
"which",
"helps",
"us",
"to",
"create",
"global",
"attributelists",
"definition",
"dict",
"."
] | [
"func",
"CreateAttrListDefinition",
"(",
"listName",
"<mask>",
",",
"atl",
"[",
"]",
"AttrTuple",
")",
"[",
"]",
"AttrTuple",
"{",
"ATLName2ATL",
"[",
"listName",
"]",
"=",
"atl",
"\n",
"return",
"atl",
"\n",
"}"
] |
14,032 | all-14033 | [
"typeForRef",
"converts",
"a",
"$ref",
"reference",
"in",
"the",
"swagger",
"definition",
"to",
"a",
"concrete",
"type",
"usually",
"an",
"object",
"."
] | [
"func",
"(",
"a",
"*",
"APIAnalyzer",
")",
"typeForRef",
"(",
"ec",
"EvalCtx",
",",
"r",
"Ref",
")",
"gen",
".",
"DataType",
"{",
"switch",
"r",
".",
"Type",
"(",
")",
"{",
"case",
"\"",
"\"",
":",
"fail",
"(",
"\"",
"\"",
")",
"\n",
"case",
"\"",
"\"",
":",
"def",
":=",
"a",
".",
"Doc",
".",
"Ref",
"(",
"r",
")",
"\n",
"if",
"def",
"==",
"nil",
"{",
"fail",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"}",
"\n",
"dt",
":=",
"a",
".",
"AnalyzeDefinition",
"(",
"ec",
",",
"def",
",",
"r",
".",
"ID",
"(",
")",
")",
"\n",
"if",
"objDT",
",",
"<mask>",
":=",
"dt",
".",
"(",
"*",
"gen",
".",
"ObjectDataType",
")",
";",
"ok",
"{",
"a",
".",
"addType",
"(",
"ec",
",",
"objDT",
",",
"r",
")",
"\n",
"}",
"\n",
"return",
"dt",
"\n",
"}",
"\n",
"return",
"basicType",
"(",
"r",
".",
"Type",
"(",
")",
")",
"\n\n",
"}"
] |
14,033 | all-14034 | [
"NewClientbyToken",
"is",
"a",
"constructor",
"for",
"Client",
"object",
"using",
"bearer",
"tokens",
"for",
"authentication",
"instead",
"of",
"username",
"password"
] | [
"func",
"NewClientbyToken",
"(",
"token",
"string",
")",
"*",
"<mask>",
"{",
"c",
":=",
"newPBRestClientbyToken",
"(",
"token",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"true",
")",
"\n",
"return",
"&",
"Client",
"{",
"token",
":",
"c",
".",
"token",
",",
"client",
":",
"c",
",",
"}",
"\n",
"}"
] |
14,034 | all-14035 | [
"GetAlignment",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_button_get_alignment",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Button",
")",
"GetAlignment",
"(",
")",
"(",
"xalign",
",",
"yalign",
"float32",
")",
"{",
"<mask>",
"x",
",",
"y",
"C",
".",
"gfloat",
"\n",
"C",
".",
"gtk_button_get_alignment",
"(",
"v",
".",
"native",
"(",
")",
",",
"&",
"x",
",",
"&",
"y",
")",
"\n",
"return",
"float32",
"(",
"x",
")",
",",
"float32",
"(",
"y",
")",
"\n",
"}"
] |
14,035 | all-14036 | [
"specifies",
"the",
"parameters",
"for",
"patch",
"primitives"
] | [
"func",
"PatchParameteri",
"(",
"pname",
"uint32",
",",
"<mask>",
"int32",
")",
"{",
"C",
".",
"glowPatchParameteri",
"(",
"gpPatchParameteri",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"pname",
")",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"value",
")",
")",
"\n",
"}"
] |
14,036 | all-14037 | [
"GetUserData",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockHttpClient",
")",
"GetUserData",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"<mask>",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"string",
")",
"\n",
"ret1",
",",
"_",
":=",
"ret",
"[",
"1",
"]",
".",
"(",
"error",
")",
"\n",
"return",
"ret0",
",",
"ret1",
"\n",
"}"
] |
14,037 | all-14038 | [
"BeginningOfHour",
"beginning",
"of",
"hour"
] | [
"func",
"(",
"now",
"*",
"Now",
")",
"BeginningOfHour",
"(",
")",
"time",
".",
"Time",
"{",
"y",
",",
"m",
",",
"d",
":=",
"now",
".",
"Date",
"(",
")",
"\n",
"return",
"time",
".",
"Date",
"(",
"y",
",",
"m",
",",
"d",
",",
"now",
".",
"Time",
".",
"Hour",
"(",
")",
",",
"0",
",",
"0",
",",
"0",
",",
"now",
".",
"Time",
".",
"<mask>",
"(",
")",
")",
"\n",
"}"
] |
14,038 | all-14039 | [
"GetDescriptionOk",
"returns",
"a",
"tuple",
"with",
"the",
"Description",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"b",
"*",
"Board",
")",
"GetDescriptionOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"b",
"==",
"nil",
"||",
"b",
".",
"Description",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"b",
".",
"<mask>",
",",
"true",
"\n",
"}"
] |
14,039 | all-14040 | [
"NewWrappedSystemError",
"defines",
"a",
"new",
"SystemError",
"wrapping",
"an",
"existing",
"error"
] | [
"func",
"NewWrappedSystemError",
"(",
"code",
"SystemErrCode",
",",
"wrapped",
"error",
")",
"error",
"{",
"if",
"se",
",",
"ok",
":=",
"wrapped",
".",
"(",
"SystemError",
")",
";",
"ok",
"{",
"return",
"se",
"\n",
"}",
"\n\n",
"return",
"SystemError",
"{",
"code",
":",
"<mask>",
",",
"msg",
":",
"fmt",
".",
"Sprint",
"(",
"wrapped",
")",
",",
"wrapped",
":",
"wrapped",
"}",
"\n",
"}"
] |
14,040 | all-14041 | [
"CommitOffsets",
"allows",
"to",
"manually",
"commit",
"previously",
"marked",
"offsets",
".",
"By",
"default",
"there",
"is",
"no",
"need",
"to",
"call",
"this",
"function",
"as",
"the",
"consumer",
"will",
"commit",
"offsets",
"automatically",
"using",
"the",
"Config",
".",
"Consumer",
".",
"Offsets",
".",
"CommitInterval",
"setting",
".",
"Please",
"be",
"aware",
"that",
"calling",
"this",
"function",
"during",
"an",
"internal",
"rebalance",
"cycle",
"may",
"return",
"broker",
"errors",
"(",
"e",
".",
"g",
".",
"sarama",
".",
"ErrUnknownMemberId",
"or",
"sarama",
".",
"ErrIllegalGeneration",
")",
"."
] | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"CommitOffsets",
"(",
")",
"error",
"{",
"c",
".",
"commitMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"commitMu",
".",
"Unlock",
"(",
")",
"\n\n",
"memberID",
",",
"generationID",
":=",
"c",
".",
"membership",
"(",
")",
"\n",
"req",
":=",
"&",
"sarama",
".",
"OffsetCommitRequest",
"{",
"Version",
":",
"2",
",",
"ConsumerGroup",
":",
"c",
".",
"groupID",
",",
"ConsumerGroupGeneration",
":",
"generationID",
",",
"ConsumerID",
":",
"memberID",
",",
"RetentionTime",
":",
"-",
"1",
",",
"}",
"\n\n",
"if",
"ns",
":=",
"c",
".",
"client",
".",
"config",
".",
"Consumer",
".",
"Offsets",
".",
"Retention",
";",
"ns",
"!=",
"0",
"{",
"req",
".",
"RetentionTime",
"=",
"int64",
"(",
"ns",
"/",
"time",
".",
"Millisecond",
")",
"\n",
"}",
"\n\n",
"snap",
":=",
"c",
".",
"subs",
".",
"Snapshot",
"(",
")",
"\n",
"dirty",
":=",
"false",
"\n",
"for",
"tp",
",",
"state",
":=",
"range",
"snap",
"{",
"if",
"state",
".",
"Dirty",
"{",
"dirty",
"=",
"true",
"\n",
"req",
".",
"AddBlock",
"(",
"tp",
".",
"Topic",
",",
"tp",
".",
"Partition",
",",
"<mask>",
".",
"Info",
".",
"Offset",
",",
"0",
",",
"state",
".",
"Info",
".",
"Metadata",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"!",
"dirty",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"broker",
",",
"err",
":=",
"c",
".",
"client",
".",
"Coordinator",
"(",
"c",
".",
"groupID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"c",
".",
"closeCoordinator",
"(",
"broker",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"resp",
",",
"err",
":=",
"broker",
".",
"CommitOffset",
"(",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"c",
".",
"closeCoordinator",
"(",
"broker",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"for",
"topic",
",",
"errs",
":=",
"range",
"resp",
".",
"Errors",
"{",
"for",
"partition",
",",
"kerr",
":=",
"range",
"errs",
"{",
"if",
"kerr",
"!=",
"sarama",
".",
"ErrNoError",
"{",
"err",
"=",
"kerr",
"\n",
"}",
"else",
"if",
"state",
",",
"ok",
":=",
"snap",
"[",
"topicPartition",
"{",
"topic",
",",
"partition",
"}",
"]",
";",
"ok",
"{",
"if",
"sub",
":=",
"c",
".",
"subs",
".",
"Fetch",
"(",
"topic",
",",
"partition",
")",
";",
"sub",
"!=",
"nil",
"{",
"sub",
".",
"markCommitted",
"(",
"state",
".",
"Info",
".",
"Offset",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] |
14,041 | all-14042 | [
"GetYOk",
"returns",
"a",
"tuple",
"with",
"the",
"Y",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"w",
"*",
"Widget",
")",
"GetYOk",
"(",
")",
"(",
"int",
",",
"bool",
")",
"{",
"if",
"w",
"==",
"nil",
"||",
"w",
".",
"Y",
"==",
"nil",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"w",
".",
"Y",
",",
"<mask>",
"\n",
"}"
] |
14,042 | all-14043 | [
"RegistryURL",
"returns",
"the",
"deduced",
"base",
"URL",
"of",
"the",
"registry",
"for",
"this",
"image"
] | [
"func",
"(",
"n",
"ImageName",
")",
"RegistryURL",
"(",
")",
"<mask>",
"{",
"reg",
":=",
"n",
".",
"Registry",
"\n",
"if",
"reg",
"==",
"\"",
"\"",
"{",
"reg",
"=",
"defaultRegistry",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"reg",
")",
"\n",
"}"
] |
14,043 | all-14044 | [
"ChangeChannelStatus",
"updates",
"channel",
"state",
"."
] | [
"func",
"(",
"h",
"*",
"Handler",
")",
"ChangeChannelStatus",
"(",
"tkn",
",",
"channel",
",",
"action",
"string",
")",
"error",
"{",
"logger",
":=",
"h",
".",
"logger",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"channel",
",",
"\"",
"\"",
",",
"action",
",",
"\"",
"\"",
",",
"h",
".",
"userRole",
")",
"\n\n",
"if",
"!",
"h",
".",
"token",
".",
"Check",
"(",
"tkn",
")",
"{",
"logger",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"return",
"ErrAccessDenied",
"\n",
"}",
"\n\n",
"<mask>",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"h",
".",
"db",
".",
"Placeholder",
"(",
"1",
")",
")",
"\n\n",
"isAgent",
":=",
"h",
".",
"userRole",
"==",
"data",
".",
"RoleAgent",
"\n\n",
"if",
"!",
"isAgent",
"{",
"condition",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"condition",
",",
"clientChannelsCondition",
")",
"\n",
"}",
"\n\n",
"items",
",",
"err",
":=",
"h",
".",
"selectAllFrom",
"(",
"logger",
",",
"data",
".",
"ChannelTable",
",",
"condition",
",",
"channel",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Error",
"(",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"ErrInternal",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"items",
")",
"!=",
"1",
"{",
"logger",
".",
"Error",
"(",
"ErrChannelNotFound",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"ErrChannelNotFound",
"\n",
"}",
"\n\n",
"switch",
"action",
"{",
"case",
"ChannelPauseAction",
":",
"_",
",",
"err",
"=",
"h",
".",
"processor",
".",
"SuspendChannel",
"(",
"channel",
",",
"data",
".",
"JobUser",
",",
"isAgent",
")",
"\n",
"case",
"ChannelResumeAction",
":",
"_",
",",
"err",
"=",
"h",
".",
"processor",
".",
"ActivateChannel",
"(",
"channel",
",",
"data",
".",
"JobUser",
",",
"isAgent",
")",
"\n",
"case",
"ChannelTerminateAction",
":",
"_",
",",
"err",
"=",
"h",
".",
"processor",
".",
"TerminateChannel",
"(",
"channel",
",",
"data",
".",
"JobUser",
",",
"isAgent",
")",
"\n",
"case",
"ChannelCloseAction",
":",
"if",
"isAgent",
"{",
"logger",
".",
"Error",
"(",
"ErrNotAllowedForAgent",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"ErrNotAllowedForAgent",
"\n",
"}",
"\n",
"if",
"err",
":=",
"h",
".",
"createPreUncooperativeCloseRequest",
"(",
"channel",
",",
"logger",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"ErrInternal",
"\n",
"}",
"\n",
"default",
":",
"logger",
".",
"Warn",
"(",
"ErrBadAction",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"ErrBadAction",
"\n",
"}",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Error",
"(",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"ErrInternal",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
14,044 | all-14045 | [
"GetAlert",
"retrieves",
"an",
"alert",
"by",
"identifier",
"."
] | [
"func",
"(",
"client",
"*",
"Client",
")",
"GetAlert",
"(",
"<mask>",
"int",
")",
"(",
"*",
"Alert",
",",
"error",
")",
"{",
"var",
"out",
"Alert",
"\n",
"if",
"err",
":=",
"client",
".",
"doJsonRequest",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"id",
")",
",",
"nil",
",",
"&",
"out",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"out",
",",
"nil",
"\n",
"}"
] |
14,045 | all-14046 | [
"expandVMwareDVSPortSetting",
"reads",
"certain",
"ResourceData",
"keys",
"and",
"returns",
"a",
"VMwareDVSPortSetting",
"."
] | [
"func",
"expandVMwareDVSPortSetting",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
")",
"*",
"types",
".",
"VMwareDVSPortSetting",
"{",
"obj",
":=",
"&",
"<mask>",
".",
"VMwareDVSPortSetting",
"{",
"DVPortSetting",
":",
"types",
".",
"DVPortSetting",
"{",
"Blocked",
":",
"structure",
".",
"GetBoolPolicy",
"(",
"d",
",",
"\"",
"\"",
")",
",",
"InShapingPolicy",
":",
"expandDVSTrafficShapingPolicyIngress",
"(",
"d",
")",
",",
"OutShapingPolicy",
":",
"expandDVSTrafficShapingPolicyEgress",
"(",
"d",
")",
",",
"VmDirectPathGen2Allowed",
":",
"structure",
".",
"GetBoolPolicy",
"(",
"d",
",",
"\"",
"\"",
")",
",",
"}",
",",
"Vlan",
":",
"expandBaseVmwareDistributedVirtualSwitchVlanSpec",
"(",
"d",
")",
",",
"UplinkTeamingPolicy",
":",
"expandVmwareUplinkPortTeamingPolicy",
"(",
"d",
")",
",",
"SecurityPolicy",
":",
"expandDVSSecurityPolicy",
"(",
"d",
")",
",",
"IpfixEnabled",
":",
"structure",
".",
"GetBoolPolicy",
"(",
"d",
",",
"\"",
"\"",
")",
",",
"TxUplink",
":",
"structure",
".",
"GetBoolPolicy",
"(",
"d",
",",
"\"",
"\"",
")",
",",
"LacpPolicy",
":",
"expandVMwareUplinkLacpPolicy",
"(",
"d",
")",
",",
"}",
"\n\n",
"if",
"structure",
".",
"AllFieldsEmpty",
"(",
"obj",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"obj",
"\n",
"}"
] |
14,046 | all-14047 | [
"prepareRequest",
"build",
"the",
"request"
] | [
"func",
"(",
"c",
"*",
"APIClient",
")",
"prepareRequest",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"method",
"string",
",",
"postBody",
"interface",
"{",
"}",
",",
"headerParams",
"map",
"[",
"string",
"]",
"string",
",",
"queryParams",
"url",
".",
"Values",
",",
"formParams",
"url",
".",
"Values",
",",
"fileName",
"string",
",",
"fileBytes",
"[",
"]",
"byte",
")",
"(",
"localVarRequest",
"*",
"http",
".",
"Request",
",",
"err",
"error",
")",
"{",
"var",
"body",
"*",
"bytes",
".",
"Buffer",
"\n\n",
"// Detect postBody type and post.",
"if",
"postBody",
"!=",
"nil",
"{",
"contentType",
":=",
"headerParams",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"contentType",
"==",
"\"",
"\"",
"{",
"contentType",
"=",
"detectContentType",
"(",
"postBody",
")",
"\n",
"headerParams",
"[",
"\"",
"\"",
"]",
"=",
"contentType",
"\n",
"}",
"\n\n",
"body",
",",
"err",
"=",
"setBody",
"(",
"postBody",
",",
"contentType",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"// add form parameters and file if available.",
"if",
"len",
"(",
"formParams",
")",
">",
"0",
"||",
"(",
"len",
"(",
"fileBytes",
")",
">",
"0",
"&&",
"fileName",
"!=",
"\"",
"\"",
")",
"{",
"if",
"body",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"body",
"=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"w",
":=",
"multipart",
".",
"NewWriter",
"(",
"body",
")",
"\n\n",
"for",
"k",
",",
"v",
":=",
"range",
"formParams",
"{",
"for",
"_",
",",
"iv",
":=",
"range",
"v",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"k",
",",
"\"",
"\"",
")",
"{",
"// file",
"err",
"=",
"addFile",
"(",
"w",
",",
"k",
"[",
"1",
":",
"]",
",",
"iv",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"else",
"{",
"// form value",
"w",
".",
"WriteField",
"(",
"k",
",",
"iv",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"len",
"(",
"fileBytes",
")",
">",
"0",
"&&",
"fileName",
"!=",
"\"",
"\"",
"{",
"w",
".",
"Boundary",
"(",
")",
"\n",
"//_, fileNm := filepath.Split(fileName)",
"part",
",",
"err",
":=",
"w",
".",
"CreateFormFile",
"(",
"\"",
"\"",
",",
"filepath",
".",
"<mask>",
"(",
"fileName",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"_",
",",
"err",
"=",
"part",
".",
"Write",
"(",
"fileBytes",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"// Set the Boundary in the Content-Type",
"headerParams",
"[",
"\"",
"\"",
"]",
"=",
"w",
".",
"FormDataContentType",
"(",
")",
"\n",
"}",
"\n\n",
"// Set Content-Length",
"headerParams",
"[",
"\"",
"\"",
"]",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"body",
".",
"Len",
"(",
")",
")",
"\n",
"w",
".",
"Close",
"(",
")",
"\n",
"}",
"\n\n",
"// Setup path and query parameters",
"url",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Adding Query Param",
"query",
":=",
"url",
".",
"Query",
"(",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"queryParams",
"{",
"for",
"_",
",",
"iv",
":=",
"range",
"v",
"{",
"query",
".",
"Add",
"(",
"k",
",",
"iv",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Encode the parameters.",
"url",
".",
"RawQuery",
"=",
"query",
".",
"Encode",
"(",
")",
"\n\n",
"// Generate a new request",
"if",
"body",
"!=",
"nil",
"{",
"localVarRequest",
",",
"err",
"=",
"http",
".",
"NewRequest",
"(",
"method",
",",
"url",
".",
"String",
"(",
")",
",",
"body",
")",
"\n",
"}",
"else",
"{",
"localVarRequest",
",",
"err",
"=",
"http",
".",
"NewRequest",
"(",
"method",
",",
"url",
".",
"String",
"(",
")",
",",
"nil",
")",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// add header parameters, if any",
"if",
"len",
"(",
"headerParams",
")",
">",
"0",
"{",
"headers",
":=",
"http",
".",
"Header",
"{",
"}",
"\n",
"for",
"h",
",",
"v",
":=",
"range",
"headerParams",
"{",
"headers",
".",
"Set",
"(",
"h",
",",
"v",
")",
"\n",
"}",
"\n",
"localVarRequest",
".",
"Header",
"=",
"headers",
"\n",
"}",
"\n\n",
"// Override request host, if applicable",
"if",
"c",
".",
"cfg",
".",
"Host",
"!=",
"\"",
"\"",
"{",
"localVarRequest",
".",
"Host",
"=",
"c",
".",
"cfg",
".",
"Host",
"\n",
"}",
"\n\n",
"// Add the user agent to the request.",
"localVarRequest",
".",
"Header",
".",
"Add",
"(",
"\"",
"\"",
",",
"c",
".",
"cfg",
".",
"UserAgent",
")",
"\n\n",
"if",
"ctx",
"!=",
"nil",
"{",
"// add context to the request",
"localVarRequest",
"=",
"localVarRequest",
".",
"WithContext",
"(",
"ctx",
")",
"\n\n",
"// Walk through any authentication.",
"// OAuth2 authentication",
"if",
"tok",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ContextOAuth2",
")",
".",
"(",
"oauth2",
".",
"TokenSource",
")",
";",
"ok",
"{",
"// We were able to grab an oauth2 token from the context",
"var",
"latestToken",
"*",
"oauth2",
".",
"Token",
"\n",
"if",
"latestToken",
",",
"err",
"=",
"tok",
".",
"Token",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"latestToken",
".",
"SetAuthHeader",
"(",
"localVarRequest",
")",
"\n",
"}",
"\n\n",
"// Basic HTTP Authentication",
"if",
"auth",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ContextBasicAuth",
")",
".",
"(",
"BasicAuth",
")",
";",
"ok",
"{",
"localVarRequest",
".",
"SetBasicAuth",
"(",
"auth",
".",
"UserName",
",",
"auth",
".",
"Password",
")",
"\n",
"}",
"\n\n",
"// AccessToken Authentication",
"if",
"auth",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ContextAccessToken",
")",
".",
"(",
"string",
")",
";",
"ok",
"{",
"localVarRequest",
".",
"Header",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
"+",
"auth",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"header",
",",
"value",
":=",
"range",
"c",
".",
"cfg",
".",
"DefaultHeader",
"{",
"localVarRequest",
".",
"Header",
".",
"Add",
"(",
"header",
",",
"value",
")",
"\n",
"}",
"\n\n",
"return",
"localVarRequest",
",",
"nil",
"\n",
"}"
] |
14,047 | all-14048 | [
"assertLogEntryEqual",
"compares",
"the",
"2",
"raft",
"Log",
"entries",
"and",
"reports",
"any",
"differences",
"to",
"the",
"supplied",
"testing",
".",
"T",
"instance",
"it",
"return",
"true",
"if",
"the",
"2",
"entries",
"are",
"equal",
"false",
"otherwise",
"."
] | [
"func",
"assertLogEntryEqual",
"(",
"t",
"*",
"testing",
".",
"T",
",",
"node",
"string",
",",
"exp",
"*",
"raft",
".",
"Log",
",",
"act",
"*",
"raft",
".",
"Log",
")",
"bool",
"{",
"res",
":=",
"true",
"\n",
"if",
"exp",
".",
"Term",
"!=",
"act",
".",
"Term",
"{",
"t",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"exp",
".",
"Index",
",",
"node",
",",
"exp",
".",
"Term",
",",
"act",
".",
"Term",
")",
"\n",
"res",
"=",
"false",
"\n",
"}",
"\n",
"if",
"exp",
".",
"Index",
"!=",
"act",
".",
"Index",
"{",
"t",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"node",
",",
"exp",
".",
"Index",
",",
"act",
".",
"Index",
")",
"\n",
"res",
"=",
"false",
"\n",
"}",
"\n",
"if",
"exp",
".",
"Type",
"!=",
"act",
".",
"Type",
"{",
"t",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"node",
",",
"exp",
".",
"Index",
",",
"exp",
".",
"Type",
",",
"act",
".",
"Type",
")",
"\n",
"res",
"=",
"false",
"\n",
"}",
"\n",
"if",
"!",
"bytes",
".",
"Equal",
"(",
"exp",
".",
"Data",
",",
"act",
".",
"Data",
")",
"{",
"t",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"<mask>",
",",
"exp",
".",
"Index",
",",
"exp",
".",
"Data",
",",
"act",
".",
"Data",
")",
"\n",
"res",
"=",
"false",
"\n",
"}",
"\n",
"return",
"res",
"\n",
"}"
] |
14,048 | all-14049 | [
"Do",
"executes",
"Input",
".",
"dispatchKeyEvent",
"against",
"the",
"provided",
"context",
"."
] | [
"func",
"(",
"p",
"*",
"DispatchKeyEventParams",
")",
"Do",
"(",
"ctx",
"context",
".",
"<mask>",
")",
"(",
"err",
"error",
")",
"{",
"return",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandDispatchKeyEvent",
",",
"p",
",",
"nil",
")",
"\n",
"}"
] |
14,049 | all-14050 | [
"Store",
"sends",
"a",
"batch",
"of",
"samples",
"to",
"the",
"HTTP",
"endpoint",
"the",
"request",
"is",
"the",
"proto",
"marshalled",
"and",
"encoded",
"bytes",
"from",
"codec",
".",
"go",
"."
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"Store",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"[",
"]",
"byte",
")",
"error",
"{",
"httpReq",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"c",
".",
"url",
".",
"String",
"(",
")",
",",
"bytes",
".",
"NewReader",
"(",
"req",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Errors from NewRequest are from unparseable URLs, so are not",
"// recoverable.",
"return",
"err",
"\n",
"}",
"\n",
"httpReq",
".",
"Header",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"httpReq",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"httpReq",
".",
"Header",
".",
"<mask>",
"(",
"\"",
"\"",
",",
"userAgent",
")",
"\n",
"httpReq",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"httpReq",
"=",
"httpReq",
".",
"WithContext",
"(",
"ctx",
")",
"\n\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"c",
".",
"timeout",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n\n",
"httpResp",
",",
"err",
":=",
"c",
".",
"client",
".",
"Do",
"(",
"httpReq",
".",
"WithContext",
"(",
"ctx",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Errors from client.Do are from (for example) network errors, so are",
"// recoverable.",
"return",
"recoverableError",
"{",
"err",
"}",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"io",
".",
"Copy",
"(",
"ioutil",
".",
"Discard",
",",
"httpResp",
".",
"Body",
")",
"\n",
"httpResp",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"}",
"(",
")",
"\n\n",
"if",
"httpResp",
".",
"StatusCode",
"/",
"100",
"!=",
"2",
"{",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"io",
".",
"LimitReader",
"(",
"httpResp",
".",
"Body",
",",
"maxErrMsgLen",
")",
")",
"\n",
"line",
":=",
"\"",
"\"",
"\n",
"if",
"scanner",
".",
"Scan",
"(",
")",
"{",
"line",
"=",
"scanner",
".",
"Text",
"(",
")",
"\n",
"}",
"\n",
"err",
"=",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"httpResp",
".",
"Status",
",",
"line",
")",
"\n",
"}",
"\n",
"if",
"httpResp",
".",
"StatusCode",
"/",
"100",
"==",
"5",
"{",
"return",
"recoverableError",
"{",
"err",
"}",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] |
14,050 | all-14051 | [
"DiskCloneValidateOperation",
"takes",
"the",
"VirtualDeviceList",
"which",
"should",
"come",
"from",
"a",
"source",
"VM",
"or",
"template",
"and",
"validates",
"the",
"following",
":",
"*",
"There",
"are",
"at",
"least",
"as",
"many",
"disks",
"defined",
"in",
"the",
"configuration",
"as",
"there",
"are",
"in",
"the",
"source",
"VM",
"or",
"template",
".",
"*",
"All",
"disks",
"survive",
"a",
"disk",
"sub",
"-",
"resource",
"read",
"operation",
".",
"This",
"function",
"is",
"meant",
"to",
"be",
"called",
"during",
"diff",
"customization",
".",
"It",
"is",
"a",
"subset",
"of",
"the",
"normal",
"refresh",
"behaviour",
"as",
"we",
"don",
"t",
"worry",
"about",
"checking",
"existing",
"state",
"."
] | [
"func",
"DiskCloneValidateOperation",
"(",
"d",
"*",
"schema",
".",
"ResourceDiff",
",",
"c",
"*",
"govmomi",
".",
"Client",
",",
"l",
"object",
".",
"VirtualDeviceList",
",",
"linked",
"bool",
")",
"error",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"devices",
":=",
"SelectDisks",
"(",
"l",
",",
"d",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"(",
"int",
")",
")",
"\n",
"// Sort the device list, in case it's not sorted already.",
"devSort",
":=",
"virtualDeviceListSorter",
"{",
"Sort",
":",
"devices",
",",
"DeviceList",
":",
"l",
",",
"}",
"\n",
"<mask>",
".",
"Printf",
"(",
"\"",
"\"",
",",
"DeviceListString",
"(",
"devices",
")",
")",
"\n",
"sort",
".",
"Sort",
"(",
"devSort",
")",
"\n",
"devices",
"=",
"devSort",
".",
"Sort",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"DeviceListString",
"(",
"devices",
")",
")",
"\n",
"// Do the same for our listed disks.",
"curSet",
":=",
"d",
".",
"Get",
"(",
"subresourceTypeDisk",
")",
".",
"(",
"[",
"]",
"interface",
"{",
"}",
")",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"subresourceListString",
"(",
"curSet",
")",
")",
"\n",
"sort",
".",
"Sort",
"(",
"virtualDiskSubresourceSorter",
"(",
"curSet",
")",
")",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"subresourceListString",
"(",
"curSet",
")",
")",
"\n\n",
"// Quickly validate length. If there are more disks in the template than",
"// there is in the configuration, kick out an error.",
"if",
"len",
"(",
"devices",
")",
">",
"len",
"(",
"curSet",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"len",
"(",
"devices",
")",
",",
"len",
"(",
"curSet",
")",
")",
"\n",
"}",
"\n\n",
"// Do test read operations on all disks.",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"for",
"i",
",",
"device",
":=",
"range",
"devices",
"{",
"m",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"vd",
":=",
"device",
".",
"GetVirtualDevice",
"(",
")",
"\n",
"ctlr",
":=",
"l",
".",
"FindByKey",
"(",
"vd",
".",
"ControllerKey",
")",
"\n",
"if",
"ctlr",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"vd",
".",
"Key",
")",
"\n",
"}",
"\n",
"m",
"[",
"\"",
"\"",
"]",
"=",
"int",
"(",
"vd",
".",
"Key",
")",
"\n",
"var",
"err",
"error",
"\n",
"m",
"[",
"\"",
"\"",
"]",
",",
"err",
"=",
"computeDevAddr",
"(",
"vd",
",",
"ctlr",
".",
"(",
"types",
".",
"BaseVirtualController",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"r",
":=",
"NewDiskSubresource",
"(",
"c",
",",
"d",
",",
"m",
",",
"nil",
",",
"i",
")",
"\n",
"if",
"err",
":=",
"r",
".",
"Read",
"(",
"l",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"r",
".",
"Addr",
"(",
")",
",",
"err",
")",
"\n",
"}",
"\n",
"// Load the target resource to do a few comparisons for correctness in config.",
"targetM",
":=",
"curSet",
"[",
"i",
"]",
".",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"tr",
":=",
"NewDiskSubresource",
"(",
"c",
",",
"d",
",",
"targetM",
",",
"nil",
",",
"i",
")",
"\n\n",
"// Do some pre-clone validation. This is mainly to make sure that the disks",
"// clone in a way that is consistent with configuration.",
"targetName",
",",
"err",
":=",
"diskLabelOrName",
"(",
"tr",
".",
"Data",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"tr",
".",
"Addr",
"(",
")",
",",
"err",
")",
"\n",
"}",
"\n",
"targetPath",
":=",
"r",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"(",
"string",
")",
"\n",
"sourceSize",
":=",
"r",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"(",
"int",
")",
"\n",
"targetSize",
":=",
"tr",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"(",
"int",
")",
"\n",
"targetThin",
":=",
"tr",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"(",
"bool",
")",
"\n",
"targetEager",
":=",
"tr",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"(",
"bool",
")",
"\n\n",
"var",
"sourceThin",
",",
"sourceEager",
"bool",
"\n",
"if",
"b",
":=",
"r",
".",
"Get",
"(",
"\"",
"\"",
")",
";",
"b",
"!=",
"nil",
"{",
"sourceThin",
"=",
"b",
".",
"(",
"bool",
")",
"\n",
"}",
"\n",
"if",
"b",
":=",
"r",
".",
"Get",
"(",
"\"",
"\"",
")",
";",
"b",
"!=",
"nil",
"{",
"sourceEager",
"=",
"b",
".",
"(",
"bool",
")",
"\n",
"}",
"\n\n",
"switch",
"{",
"case",
"linked",
":",
"switch",
"{",
"case",
"sourceSize",
"!=",
"targetSize",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"tr",
".",
"Addr",
"(",
")",
",",
"targetName",
",",
"sourceSize",
")",
"\n",
"case",
"sourceThin",
"!=",
"targetThin",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"tr",
".",
"Addr",
"(",
")",
",",
"targetName",
",",
"sourceThin",
")",
"\n",
"case",
"sourceEager",
"!=",
"targetEager",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"tr",
".",
"Addr",
"(",
")",
",",
"targetName",
",",
"sourceEager",
")",
"\n",
"}",
"\n",
"default",
":",
"if",
"sourceSize",
">",
"targetSize",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"tr",
".",
"Addr",
"(",
")",
",",
"targetName",
",",
"sourceSize",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Finally, we don't support non-SCSI (ie: SATA, IDE, NVMe) disks, so kick",
"// back an error if we see one of those.",
"ct",
",",
"_",
",",
"_",
",",
"err",
":=",
"splitDevAddr",
"(",
"r",
".",
"DevAddr",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"tr",
".",
"Addr",
"(",
")",
",",
"targetPath",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"ct",
"!=",
"SubresourceControllerTypeSCSI",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"tr",
".",
"Addr",
"(",
")",
",",
"ct",
",",
"targetPath",
")",
"\n",
"}",
"\n",
"}",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
14,051 | all-14052 | [
"RunRetry",
"runs",
"a",
"retryable",
"function",
"."
] | [
"func",
"(",
"r",
"*",
"Retrier",
")",
"RunRetry",
"(",
")",
"error",
"{",
"// Start signal handler.",
"sigHandler",
":=",
"signals",
".",
"NewSignalHandler",
"(",
"10",
")",
"\n",
"go",
"sigHandler",
".",
"Register",
"(",
")",
"\n\n",
"finish",
":=",
"make",
"(",
"chan",
"bool",
",",
"1",
")",
"\n",
"<mask>",
"func",
"(",
")",
"{",
"select",
"{",
"case",
"<-",
"finish",
":",
"return",
"\n",
"case",
"<-",
"time",
".",
"After",
"(",
"10",
"*",
"time",
".",
"Second",
")",
":",
"return",
"\n",
"default",
":",
"for",
"{",
"if",
"sigHandler",
".",
"GetState",
"(",
")",
"!=",
"0",
"{",
"logger",
".",
"Critical",
"(",
"\"",
"\"",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"r",
".",
"retries",
";",
"i",
"++",
"{",
"err",
":=",
"r",
".",
"retryable",
".",
"Try",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Info",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"time",
".",
"Sleep",
"(",
"time",
".",
"Duration",
"(",
"r",
".",
"sleepSeconds",
")",
"*",
"time",
".",
"Second",
")",
"\n",
"continue",
"\n",
"}",
"\n",
"finish",
"<-",
"true",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"finish",
"<-",
"true",
"\n",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"r",
".",
"retries",
",",
"r",
".",
"sleepSeconds",
")",
"\n",
"}"
] |
14,052 | all-14053 | [
"playNote",
"plays",
"the",
"note",
"at",
"scoreIndex",
"of",
"the",
"score",
"."
] | [
"func",
"playNote",
"(",
"scoreIndex",
"int",
")",
"rune",
"{",
"note",
":=",
"score",
"[",
"scoreIndex",
"]",
"\n\n",
"// If the note is 'rest', play nothing.",
"if",
"note",
"==",
"'R'",
"{",
"return",
"rune",
"(",
"note",
")",
"\n",
"}",
"\n\n",
"freqs",
":=",
"[",
"]",
"float64",
"{",
"freqC",
",",
"freqD",
",",
"freqE",
",",
"freqF",
",",
"freqG",
",",
"freqA",
"*",
"2",
",",
"freqB",
"*",
"2",
"}",
"\n",
"freq",
":=",
"0.0",
"\n",
"switch",
"{",
"case",
"'A'",
"<=",
"note",
"&&",
"note",
"<=",
"'B'",
":",
"freq",
"=",
"freqs",
"[",
"int",
"(",
"note",
")",
"+",
"len",
"(",
"freqs",
")",
"-",
"int",
"(",
"'C'",
")",
"]",
"\n",
"case",
"'C'",
"<=",
"note",
"&&",
"note",
"<=",
"'G'",
":",
"freq",
"=",
"freqs",
"[",
"note",
"-",
"'C'",
"]",
"\n",
"default",
":",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"const",
"vol",
"=",
"1.0",
"/",
"16.0",
"\n",
"size",
":=",
"(",
"ebiten",
".",
"MaxTPS",
"(",
")",
"/",
"2",
"-",
"2",
")",
"*",
"sampleRate",
"/",
"ebiten",
".",
"MaxTPS",
"(",
")",
"\n",
"l",
":=",
"make",
"(",
"[",
"]",
"int16",
",",
"size",
")",
"\n",
"r",
":=",
"make",
"(",
"[",
"]",
"int16",
",",
"size",
")",
"\n",
"square",
"(",
"l",
",",
"vol",
",",
"freq",
",",
"0.25",
")",
"\n",
"square",
"(",
"r",
",",
"vol",
",",
"freq",
",",
"0.25",
")",
"\n\n",
"p",
",",
"_",
":=",
"<mask>",
".",
"NewPlayerFromBytes",
"(",
"audioContext",
",",
"toBytes",
"(",
"l",
",",
"r",
")",
")",
"\n",
"p",
".",
"Play",
"(",
")",
"\n\n",
"return",
"rune",
"(",
"note",
")",
"\n",
"}"
] |
14,053 | all-14054 | [
"CopyTo",
"copies",
"uri",
"contents",
"to",
"dst",
"."
] | [
"func",
"(",
"u",
"*",
"URI",
")",
"CopyTo",
"(",
"dst",
"*",
"URI",
")",
"{",
"dst",
".",
"Reset",
"(",
")",
"\n",
"dst",
".",
"pathOriginal",
"=",
"append",
"(",
"dst",
".",
"pathOriginal",
"[",
":",
"0",
"]",
",",
"u",
".",
"pathOriginal",
"...",
")",
"\n",
"dst",
".",
"scheme",
"=",
"append",
"(",
"dst",
".",
"scheme",
"[",
":",
"0",
"]",
",",
"u",
".",
"scheme",
"...",
")",
"\n",
"dst",
".",
"path",
"=",
"append",
"(",
"dst",
".",
"<mask>",
"[",
":",
"0",
"]",
",",
"u",
".",
"path",
"...",
")",
"\n",
"dst",
".",
"queryString",
"=",
"append",
"(",
"dst",
".",
"queryString",
"[",
":",
"0",
"]",
",",
"u",
".",
"queryString",
"...",
")",
"\n",
"dst",
".",
"hash",
"=",
"append",
"(",
"dst",
".",
"hash",
"[",
":",
"0",
"]",
",",
"u",
".",
"hash",
"...",
")",
"\n",
"dst",
".",
"host",
"=",
"append",
"(",
"dst",
".",
"host",
"[",
":",
"0",
"]",
",",
"u",
".",
"host",
"...",
")",
"\n\n",
"u",
".",
"queryArgs",
".",
"CopyTo",
"(",
"&",
"dst",
".",
"queryArgs",
")",
"\n",
"dst",
".",
"parsedQueryArgs",
"=",
"u",
".",
"parsedQueryArgs",
"\n\n",
"// fullURI and requestURI shouldn't be copied, since they are created",
"// from scratch on each FullURI() and RequestURI() call.",
"dst",
".",
"h",
"=",
"u",
".",
"h",
"\n",
"}"
] |
14,054 | all-14055 | [
"RaftNodeAddress",
"returns",
"the",
"address",
"of",
"the",
"LXD",
"raft",
"node",
"with",
"the",
"given",
"ID",
"if",
"any",
"matching",
"row",
"exists",
"."
] | [
"func",
"(",
"n",
"*",
"NodeTx",
")",
"RaftNodeAddress",
"(",
"id",
"int64",
")",
"(",
"string",
",",
"error",
")",
"{",
"stmt",
":=",
"\"",
"\"",
"\n",
"addresses",
",",
"err",
":=",
"query",
".",
"SelectStrings",
"(",
"n",
".",
"<mask>",
",",
"stmt",
",",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"switch",
"len",
"(",
"addresses",
")",
"{",
"case",
"0",
":",
"return",
"\"",
"\"",
",",
"ErrNoSuchObject",
"\n",
"case",
"1",
":",
"return",
"addresses",
"[",
"0",
"]",
",",
"nil",
"\n",
"default",
":",
"// This should never happen since we have a UNIQUE constraint",
"// on the raft_nodes.id column.",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] |
14,055 | all-14056 | [
"Serialize",
"transforms",
"endpoints",
"labels",
"into",
"a",
"external",
"-",
"dns",
"recognizable",
"format",
"string",
"withQuotes",
"adds",
"additional",
"quotes"
] | [
"func",
"(",
"l",
"Labels",
")",
"Serialize",
"(",
"withQuotes",
"bool",
")",
"string",
"{",
"var",
"tokens",
"[",
"]",
"string",
"\n",
"tokens",
"=",
"append",
"(",
"tokens",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"heritage",
")",
")",
"\n",
"var",
"keys",
"[",
"]",
"string",
"\n",
"for",
"key",
":=",
"range",
"l",
"{",
"keys",
"=",
"append",
"(",
"keys",
",",
"key",
")",
"\n",
"}",
"\n",
"sort",
".",
"Strings",
"(",
"<mask>",
")",
"// sort for consistency",
"\n\n",
"for",
"_",
",",
"key",
":=",
"range",
"keys",
"{",
"tokens",
"=",
"append",
"(",
"tokens",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"heritage",
",",
"key",
",",
"l",
"[",
"key",
"]",
")",
")",
"\n",
"}",
"\n",
"if",
"withQuotes",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"tokens",
",",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"return",
"strings",
".",
"Join",
"(",
"tokens",
",",
"\"",
"\"",
")",
"\n",
"}"
] |
14,056 | all-14057 | [
"GetImage",
"returns",
"an",
"Instance",
"struct",
"where",
"id",
"==",
"imageid"
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetImage",
"(",
"imageid",
"string",
")",
"(",
"*",
"Image",
",",
"error",
")",
"{",
"url",
":=",
"imagePath",
"(",
"imageid",
")",
"\n",
"ret",
":=",
"&",
"Image",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"client",
".",
"Get",
"(",
"url",
",",
"ret",
",",
"http",
".",
"StatusOK",
")",
"\n",
"return",
"<mask>",
",",
"err",
"\n",
"}"
] |
14,057 | all-14058 | [
"HasGrouping",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"c",
"*",
"CheckStatusDefinition",
")",
"HasGrouping",
"(",
")",
"bool",
"{",
"if",
"c",
"!=",
"nil",
"&&",
"c",
".",
"Grouping",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
14,058 | all-14059 | [
"GetSlice",
"is",
"a",
"wrapper",
"around",
"gtk_text_iter_get_slice",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"TextIter",
")",
"GetSlice",
"(",
"end",
"*",
"TextIter",
")",
"string",
"{",
"c",
":=",
"C",
".",
"gtk_text_iter_get_slice",
"(",
"v",
".",
"native",
"(",
")",
",",
"end",
".",
"native",
"(",
")",
")",
"\n",
"return",
"C",
".",
"GoString",
"(",
"(",
"*",
"C",
".",
"<mask>",
")",
"(",
"c",
")",
")",
"\n",
"}"
] |
14,059 | all-14060 | [
"ForwardedResponseIfTargetIsRemote",
"redirects",
"a",
"request",
"to",
"the",
"request",
"has",
"a",
"targetNode",
"parameter",
"pointing",
"to",
"a",
"node",
"which",
"is",
"not",
"the",
"local",
"one",
"."
] | [
"func",
"ForwardedResponseIfTargetIsRemote",
"(",
"d",
"*",
"Daemon",
",",
"request",
"*",
"http",
".",
"Request",
")",
"Response",
"{",
"targetNode",
":=",
"queryParam",
"(",
"request",
",",
"\"",
"\"",
")",
"\n",
"if",
"targetNode",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Figure out the address of the target node (which is possibly",
"// this very same node).",
"address",
",",
"err",
":=",
"cluster",
".",
"ResolveTarget",
"(",
"d",
".",
"cluster",
",",
"targetNode",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"SmartError",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"address",
"!=",
"\"",
"\"",
"{",
"// Forward the response.",
"cert",
":=",
"d",
".",
"endpoints",
".",
"NetworkCert",
"(",
")",
"\n",
"client",
",",
"err",
":=",
"cluster",
".",
"Connect",
"(",
"address",
",",
"cert",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"SmartError",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"ForwardedResponse",
"(",
"client",
",",
"<mask>",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
14,060 | all-14061 | [
"NewArena",
"allocates",
"a",
"new",
"arena",
"of",
"the",
"specified",
"size",
"and",
"returns",
"it",
"."
] | [
"func",
"NewArena",
"(",
"size",
"uint32",
")",
"*",
"Arena",
"{",
"// Don't store data at position 0 in order to reserve offset=0 as a kind",
"// of nil pointer.",
"out",
":=",
"&",
"Arena",
"{",
"n",
":",
"1",
",",
"buf",
":",
"make",
"(",
"[",
"]",
"byte",
",",
"size",
")",
",",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
14,061 | all-14062 | [
"Create",
"logfiles",
"for",
"systemd",
"services",
"in",
"outputDir",
"."
] | [
"func",
"createSystemdLogfiles",
"(",
"outputDir",
"string",
")",
"{",
"services",
":=",
"append",
"(",
"systemdServices",
",",
"nodeSystemdServices",
"...",
")",
"\n",
"for",
"_",
",",
"service",
":=",
"range",
"services",
"{",
"if",
"err",
":=",
"createSystemdLogfile",
"(",
"service",
",",
"\"",
"\"",
",",
"outputDir",
")",
";",
"err",
"!=",
"nil",
"{",
"glog",
".",
"Warningf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"// Service logs specific to VM setup.",
"for",
"_",
",",
"service",
":=",
"range",
"systemdSetupServices",
"{",
"if",
"err",
":=",
"createSystemdLogfile",
"(",
"<mask>",
",",
"\"",
"\"",
",",
"outputDir",
")",
";",
"err",
"!=",
"nil",
"{",
"glog",
".",
"Warningf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"*",
"dumpSystemdJournal",
"{",
"if",
"err",
":=",
"createFullSystemdLogfile",
"(",
"outputDir",
")",
";",
"err",
"!=",
"nil",
"{",
"glog",
".",
"Warningf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
14,062 | all-14063 | [
"GetTransferAllUserComments",
"returns",
"the",
"TransferAllUserComments",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"c",
"*",
"ChannelSlackRequest",
")",
"GetTransferAllUserComments",
"(",
")",
"bool",
"{",
"if",
"c",
"==",
"nil",
"||",
"c",
".",
"TransferAllUserComments",
"==",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"c",
".",
"TransferAllUserComments",
"\n",
"}"
] |
14,063 | all-14064 | [
"HasResource",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"r",
"*",
"reqGetDashboard",
")",
"HasResource",
"(",
")",
"bool",
"{",
"if",
"r",
"!=",
"nil",
"&&",
"r",
".",
"Resource",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
14,064 | all-14065 | [
"computedCropArea",
"retrieve",
"the",
"theorical",
"crop",
"area",
".",
"It",
"is",
"defined",
"by",
"Height",
"Width",
"Mode",
"and"
] | [
"func",
"(",
"c",
"Config",
")",
"computedCropArea",
"(",
"bounds",
"image",
".",
"Rectangle",
",",
"size",
"<mask>",
".",
"Point",
")",
"(",
"r",
"image",
".",
"Rectangle",
")",
"{",
"min",
":=",
"bounds",
".",
"Min",
"\n",
"switch",
"c",
".",
"Mode",
"{",
"case",
"Centered",
":",
"rMin",
":=",
"c",
".",
"centeredMin",
"(",
"bounds",
")",
"\n",
"r",
"=",
"image",
".",
"Rect",
"(",
"rMin",
".",
"X",
"-",
"size",
".",
"X",
"/",
"2",
",",
"rMin",
".",
"Y",
"-",
"size",
".",
"Y",
"/",
"2",
",",
"rMin",
".",
"X",
"-",
"size",
".",
"X",
"/",
"2",
"+",
"size",
".",
"X",
",",
"rMin",
".",
"Y",
"-",
"size",
".",
"Y",
"/",
"2",
"+",
"size",
".",
"Y",
")",
"\n",
"default",
":",
"// TopLeft",
"rMin",
":=",
"image",
".",
"Point",
"{",
"min",
".",
"X",
"+",
"c",
".",
"Anchor",
".",
"X",
",",
"min",
".",
"Y",
"+",
"c",
".",
"Anchor",
".",
"Y",
"}",
"\n",
"r",
"=",
"image",
".",
"Rect",
"(",
"rMin",
".",
"X",
",",
"rMin",
".",
"Y",
",",
"rMin",
".",
"X",
"+",
"size",
".",
"X",
",",
"rMin",
".",
"Y",
"+",
"size",
".",
"Y",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] |
14,065 | all-14066 | [
"Recover",
"ensures",
"data",
"consistency",
"after",
"unexpected",
"controller",
"s",
"exit",
"."
] | [
"func",
"Recover",
"(",
"<mask>",
"*",
"reform",
".",
"DB",
")",
"error",
"{",
"if",
"err",
":=",
"recoverServiceStatuses",
"(",
"db",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
14,066 | all-14067 | [
"Specify",
"the",
"value",
"of",
"a",
"uniform",
"variable",
"for",
"a",
"specified",
"program",
"object"
] | [
"func",
"ProgramUniform1ui",
"(",
"program",
"uint32",
",",
"location",
"int32",
",",
"v0",
"uint32",
")",
"{",
"syscall",
".",
"Syscall",
"(",
"gpProgramUniform1ui",
",",
"3",
",",
"uintptr",
"(",
"<mask>",
")",
",",
"uintptr",
"(",
"location",
")",
",",
"uintptr",
"(",
"v0",
")",
")",
"\n",
"}"
] |
14,067 | all-14068 | [
"Proxy",
"is",
"a",
"proxy",
"between",
"tsuru",
"and",
"the",
"service",
".",
"This",
"method",
"allow",
"customized",
"service",
"methods",
"."
] | [
"func",
"(",
"c",
"*",
"endpointClient",
")",
"Proxy",
"(",
"path",
"string",
",",
"evt",
"*",
"event",
".",
"Event",
",",
"requestID",
"string",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"rawurl",
":=",
"strings",
".",
"TrimRight",
"(",
"c",
".",
"endpoint",
",",
"\"",
"\"",
")",
"+",
"\"",
"\"",
"+",
"strings",
".",
"Trim",
"(",
"path",
",",
"\"",
"\"",
")",
"\n",
"url",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"rawurl",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"rawurl",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"director",
":=",
"func",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"evt",
"!=",
"nil",
"{",
"req",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"evt",
".",
"Owner",
".",
"Name",
")",
"\n",
"req",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"evt",
".",
"UniqueID",
".",
"Hex",
"(",
")",
")",
"\n",
"}",
"\n",
"requestIDHeader",
",",
"err",
":=",
"config",
".",
"GetString",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"==",
"nil",
"&&",
"requestID",
"!=",
"\"",
"\"",
"&&",
"requestIDHeader",
"!=",
"\"",
"\"",
"{",
"req",
".",
"Header",
".",
"Set",
"(",
"requestIDHeader",
",",
"requestID",
")",
"\n",
"}",
"\n",
"req",
".",
"SetBasicAuth",
"(",
"c",
".",
"username",
",",
"c",
".",
"password",
")",
"\n",
"req",
".",
"Host",
"=",
"url",
".",
"Host",
"\n",
"req",
".",
"<mask>",
"=",
"url",
"\n",
"}",
"\n",
"proxy",
":=",
"&",
"httputil",
".",
"ReverseProxy",
"{",
"Director",
":",
"director",
"}",
"\n",
"proxy",
".",
"ServeHTTP",
"(",
"w",
",",
"r",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
14,068 | all-14069 | [
"addPath",
"appends",
"path",
"to",
"paths",
"if",
"path",
"does",
"not",
"already",
"exist",
"in",
"paths",
".",
"Returns",
"the",
"new",
"paths",
"."
] | [
"func",
"addPath",
"(",
"paths",
"[",
"]",
"string",
",",
"path",
"string",
")",
"[",
"]",
"string",
"{",
"for",
"_",
",",
"existingpath",
":=",
"range",
"paths",
"{",
"if",
"path",
"==",
"existingpath",
"{",
"return",
"paths",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"append",
"(",
"paths",
",",
"<mask>",
")",
"\n",
"}"
] |
14,069 | all-14070 | [
"Service",
"OAuth",
"authentication",
"requires",
"no",
"additional",
"headers",
"to",
"be",
"sent",
".",
"The",
"Coinbase",
"Public",
"Certificate",
"is",
"set",
"as",
"a",
"TLS",
"config",
"in",
"the",
"http",
".",
"Client"
] | [
"func",
"(",
"a",
"serviceOAuthAuthentication",
")",
"authenticate",
"(",
"req",
"*",
"<mask>",
".",
"Request",
",",
"endpoint",
"string",
",",
"params",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"nil",
"// No additional headers needed for service OAuth requests",
"\n",
"}"
] |
14,070 | all-14071 | [
"block",
"and",
"wait",
"for",
"a",
"sync",
"object",
"to",
"become",
"signaled"
] | [
"func",
"ClientWaitSync",
"(",
"sync",
"uintptr",
",",
"flags",
"uint32",
",",
"timeout",
"uint64",
")",
"uint32",
"{",
"ret",
",",
"_",
",",
"_",
":=",
"syscall",
".",
"Syscall",
"(",
"gpClientWaitSync",
",",
"3",
",",
"uintptr",
"(",
"sync",
")",
",",
"uintptr",
"(",
"<mask>",
")",
",",
"uintptr",
"(",
"timeout",
")",
")",
"\n",
"return",
"(",
"uint32",
")",
"(",
"ret",
")",
"\n",
"}"
] |
14,071 | all-14072 | [
"Delete",
"deletes",
"a",
"key",
".",
"This",
"is",
"done",
"by",
"adding",
"a",
"delete",
"marker",
"for",
"the",
"key",
"at",
"commit",
"timestamp",
".",
"Any",
"reads",
"happening",
"before",
"this",
"timestamp",
"would",
"be",
"unaffected",
".",
"Any",
"reads",
"after",
"this",
"commit",
"would",
"see",
"the",
"deletion",
".",
"The",
"current",
"transaction",
"keeps",
"a",
"reference",
"to",
"the",
"key",
"byte",
"slice",
"argument",
".",
"Users",
"must",
"not",
"modify",
"the",
"key",
"until",
"the",
"end",
"of",
"the",
"transaction",
"."
] | [
"func",
"(",
"txn",
"*",
"Txn",
")",
"Delete",
"(",
"key",
"[",
"]",
"<mask>",
")",
"error",
"{",
"e",
":=",
"&",
"Entry",
"{",
"Key",
":",
"key",
",",
"meta",
":",
"bitDelete",
",",
"}",
"\n",
"return",
"txn",
".",
"modify",
"(",
"e",
")",
"\n",
"}"
] |
14,072 | all-14073 | [
"HasText",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"f",
"*",
"FreeTextDefinition",
")",
"HasText",
"(",
")",
"bool",
"{",
"if",
"f",
"!=",
"nil",
"&&",
"f",
".",
"Text",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
14,073 | all-14074 | [
"NewStorage",
"instantiates",
"a",
"new",
"Storage",
"with",
"a",
"PersistenceLayer",
"implementation",
"If",
"storage",
"string",
"is",
"not",
"empty",
"it",
"will",
"read",
"resource",
"data",
"from",
"the",
"file"
] | [
"func",
"NewStorage",
"(",
"r",
"<mask>",
".",
"PersistenceLayer",
",",
"storage",
"string",
")",
"(",
"*",
"Storage",
",",
"error",
")",
"{",
"s",
":=",
"&",
"Storage",
"{",
"resources",
":",
"r",
",",
"}",
"\n\n",
"if",
"storage",
"!=",
"\"",
"\"",
"{",
"var",
"data",
"struct",
"{",
"Resources",
"[",
"]",
"common",
".",
"Resource",
"\n",
"}",
"\n",
"buf",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"storage",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"logrus",
".",
"Infof",
"(",
"\"",
"\"",
",",
"string",
"(",
"buf",
")",
")",
"\n",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"buf",
",",
"&",
"data",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"else",
"if",
"!",
"os",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"logrus",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"for",
"_",
",",
"res",
":=",
"range",
"data",
".",
"Resources",
"{",
"if",
"err",
":=",
"s",
".",
"AddResource",
"(",
"res",
")",
";",
"err",
"!=",
"nil",
"{",
"logrus",
".",
"WithError",
"(",
"err",
")",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"res",
".",
"Name",
",",
"res",
".",
"State",
")",
"\n",
"}",
"\n",
"logrus",
".",
"Infof",
"(",
"\"",
"\"",
",",
"res",
".",
"Name",
",",
"res",
".",
"State",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] |
14,074 | all-14075 | [
"One",
"executes",
"the",
"pipeline",
"and",
"unmarshals",
"the",
"first",
"item",
"from",
"the",
"result",
"set",
"into",
"the",
"result",
"parameter",
".",
"It",
"returns",
"ErrNotFound",
"if",
"no",
"items",
"are",
"generated",
"by",
"the",
"pipeline",
"."
] | [
"func",
"(",
"p",
"*",
"Pipe",
")",
"One",
"(",
"<mask>",
"interface",
"{",
"}",
")",
"error",
"{",
"iter",
":=",
"p",
".",
"Iter",
"(",
")",
"\n",
"if",
"iter",
".",
"Next",
"(",
"result",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"err",
":=",
"iter",
".",
"Err",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"ErrNotFound",
"\n",
"}"
] |
14,075 | all-14076 | [
"HasNoGroupHosts",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"h",
"*",
"HostmapDefinition",
")",
"HasNoGroupHosts",
"(",
")",
"bool",
"{",
"if",
"h",
"!=",
"nil",
"&&",
"h",
".",
"NoGroupHosts",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
14,076 | all-14077 | [
"AssistantNew",
"is",
"a",
"wrapper",
"around",
"gtk_assistant_new",
"()",
"."
] | [
"func",
"AssistantNew",
"(",
")",
"(",
"*",
"Assistant",
",",
"error",
")",
"{",
"c",
":=",
"C",
".",
"gtk_assistant_new",
"(",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"obj",
":=",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
"\n",
"<mask>",
"wrapAssistant",
"(",
"obj",
")",
",",
"nil",
"\n",
"}"
] |
14,077 | all-14078 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"PrintToPDFReturns",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"<mask>",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage22",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
14,078 | all-14079 | [
"Concat",
"multiplies",
"a",
"color",
"matrix",
"with",
"the",
"other",
"color",
"matrix",
".",
"This",
"is",
"same",
"as",
"muptiplying",
"the",
"matrix",
"other",
"and",
"the",
"matrix",
"c",
"in",
"this",
"order",
"."
] | [
"func",
"(",
"c",
"*",
"ColorM",
")",
"Concat",
"(",
"other",
"ColorM",
")",
"{",
"c",
".",
"impl",
"=",
"c",
".",
"impl",
".",
"Concat",
"(",
"<mask>",
".",
"impl",
")",
"\n",
"}"
] |
14,079 | all-14080 | [
"GetMonitorsByTags",
"retrieves",
"monitors",
"by",
"a",
"slice",
"of",
"tags"
] | [
"func",
"(",
"self",
"*",
"Client",
")",
"GetMonitorsByTags",
"(",
"<mask>",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"Monitor",
",",
"error",
")",
"{",
"var",
"out",
"reqMonitors",
"\n",
"query",
",",
"err",
":=",
"url",
".",
"ParseQuery",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"tags",
",",
"\"",
"\"",
")",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"self",
".",
"doJsonRequest",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"query",
".",
"Encode",
"(",
")",
")",
",",
"nil",
",",
"&",
"out",
".",
"Monitors",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"out",
".",
"Monitors",
",",
"nil",
"\n",
"}"
] |
14,080 | all-14081 | [
"HasTitle",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"h",
"*",
"HeatmapDefinition",
")",
"HasTitle",
"(",
")",
"bool",
"{",
"if",
"h",
"!=",
"nil",
"&&",
"h",
".",
"Title",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
14,081 | all-14082 | [
"LookupInShadow",
"looks",
"up",
"a",
"shadowed",
"password",
"by",
"the",
"given",
"values",
".",
"The",
"count",
"determines",
"the",
"number",
"of",
"fields",
"to",
"return",
":",
"n",
">",
"0",
":",
"at",
"most",
"n",
"fields",
"n",
"==",
"0",
":",
"the",
"result",
"is",
"nil",
"(",
"zero",
"fields",
")",
"n",
"<",
"0",
":",
"all",
"fields"
] | [
"func",
"LookupInShadow",
"(",
"field",
"shadowField",
",",
"value",
"<mask>",
"{",
"}",
",",
"n",
"int",
")",
"(",
"[",
"]",
"*",
"Shadow",
",",
"error",
")",
"{",
"checkRoot",
"(",
")",
"\n\n",
"iEntries",
",",
"err",
":=",
"lookUp",
"(",
"&",
"Shadow",
"{",
"}",
",",
"field",
",",
"value",
",",
"n",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// == Convert to type shadow",
"valueSlice",
":=",
"reflect",
".",
"ValueOf",
"(",
"iEntries",
")",
"\n",
"entries",
":=",
"make",
"(",
"[",
"]",
"*",
"Shadow",
",",
"valueSlice",
".",
"Len",
"(",
")",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"valueSlice",
".",
"Len",
"(",
")",
";",
"i",
"++",
"{",
"entries",
"[",
"i",
"]",
"=",
"valueSlice",
".",
"Index",
"(",
"i",
")",
".",
"Interface",
"(",
")",
".",
"(",
"*",
"Shadow",
")",
"\n",
"}",
"\n\n",
"return",
"entries",
",",
"err",
"\n",
"}"
] |
14,082 | all-14083 | [
"ListFileF",
"returns",
"info",
"about",
"all",
"files",
"in",
"a",
"Commit",
"under",
"path",
"calling",
"f",
"with",
"each",
"FileInfo",
"."
] | [
"func",
"(",
"c",
"APIClient",
")",
"ListFileF",
"(",
"repoName",
"string",
",",
"commitID",
"string",
",",
"path",
"string",
",",
"history",
"int64",
",",
"f",
"func",
"(",
"fi",
"*",
"pfs",
".",
"FileInfo",
")",
"error",
")",
"error",
"{",
"fs",
",",
"err",
":=",
"c",
".",
"PfsAPIClient",
".",
"ListFileStream",
"(",
"c",
".",
"Ctx",
"(",
")",
",",
"&",
"pfs",
".",
"ListFileRequest",
"{",
"File",
":",
"NewFile",
"(",
"repoName",
",",
"commitID",
",",
"path",
")",
",",
"History",
":",
"<mask>",
",",
"}",
",",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}",
"\n",
"for",
"{",
"fi",
",",
"err",
":=",
"fs",
".",
"Recv",
"(",
")",
"\n",
"if",
"err",
"==",
"io",
".",
"EOF",
"{",
"return",
"nil",
"\n",
"}",
"else",
"if",
"err",
"!=",
"nil",
"{",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"f",
"(",
"fi",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"err",
"==",
"errutil",
".",
"ErrBreak",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
14,083 | all-14084 | [
"Host",
"returns",
"host",
"part",
"i",
".",
"e",
".",
"aaa",
".",
"com",
"of",
"http",
":",
"//",
"aaa",
".",
"com",
"/",
"foo",
"/",
"bar?baz",
"=",
"123#qwe",
".",
"Host",
"is",
"always",
"lowercased",
"."
] | [
"func",
"(",
"u",
"*",
"URI",
")",
"Host",
"(",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"u",
".",
"host",
")",
"==",
"0",
"&&",
"u",
".",
"h",
"!=",
"nil",
"{",
"u",
".",
"host",
"=",
"append",
"(",
"u",
".",
"host",
"[",
":",
"0",
"]",
",",
"u",
".",
"h",
".",
"Host",
"(",
")",
"...",
")",
"\n",
"lowercaseBytes",
"(",
"u",
".",
"<mask>",
")",
"\n",
"u",
".",
"h",
"=",
"nil",
"\n",
"}",
"\n",
"return",
"u",
".",
"host",
"\n",
"}"
] |
14,084 | all-14085 | [
"Hang",
"up",
"an",
"in",
"-",
"progress",
"call",
"."
] | [
"func",
"(",
"c",
"*",
"CallService",
")",
"Hangup",
"(",
"sid",
"string",
")",
"(",
"*",
"Call",
",",
"error",
")",
"{",
"data",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
"<mask>",
".",
"Set",
"(",
"\"",
"\"",
",",
"string",
"(",
"StatusCompleted",
")",
")",
"\n",
"return",
"c",
".",
"Update",
"(",
"context",
".",
"Background",
"(",
")",
",",
"sid",
",",
"data",
")",
"\n",
"}"
] |
14,085 | all-14086 | [
"Execute",
"queries",
"."
] | [
"func",
"internalSQLPost",
"(",
"d",
"*",
"Daemon",
",",
"r",
"*",
"http",
".",
"Request",
")",
"Response",
"{",
"req",
":=",
"&",
"internalSQLQuery",
"{",
"}",
"\n",
"// Parse the request.",
"err",
":=",
"json",
".",
"NewDecoder",
"(",
"r",
".",
"Body",
")",
".",
"Decode",
"(",
"&",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"BadRequest",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"shared",
".",
"StringInSlice",
"(",
"req",
".",
"Database",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
")",
"{",
"return",
"BadRequest",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n\n",
"if",
"req",
".",
"Query",
"==",
"\"",
"\"",
"{",
"return",
"BadRequest",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n\n",
"var",
"db",
"*",
"sql",
".",
"DB",
"\n",
"if",
"req",
".",
"Database",
"==",
"\"",
"\"",
"{",
"db",
"=",
"d",
".",
"cluster",
".",
"DB",
"(",
")",
"\n",
"}",
"else",
"{",
"db",
"=",
"d",
".",
"db",
".",
"DB",
"(",
")",
"\n",
"}",
"\n\n",
"batch",
":=",
"internalSQLBatch",
"{",
"}",
"\n\n",
"if",
"req",
".",
"Query",
"==",
"\"",
"\"",
"{",
"d",
".",
"gateway",
".",
"Sync",
"(",
")",
"\n",
"return",
"SyncResponse",
"(",
"true",
",",
"batch",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"query",
":=",
"range",
"strings",
".",
"Split",
"(",
"req",
".",
"Query",
",",
"\"",
"\"",
")",
"{",
"query",
"=",
"strings",
".",
"TrimLeft",
"(",
"query",
",",
"\"",
"\"",
")",
"\n\n",
"if",
"query",
"==",
"\"",
"\"",
"{",
"continue",
"\n",
"}",
"\n\n",
"result",
":=",
"internalSQLResult",
"{",
"}",
"\n\n",
"tx",
",",
"err",
":=",
"db",
".",
"Begin",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"SmartError",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"strings",
".",
"HasPrefix",
"(",
"strings",
".",
"ToUpper",
"(",
"query",
")",
",",
"\"",
"\"",
")",
"{",
"err",
"=",
"internalSQLSelect",
"(",
"tx",
",",
"query",
",",
"&",
"result",
")",
"\n",
"tx",
".",
"Rollback",
"(",
")",
"\n",
"}",
"else",
"{",
"err",
"=",
"internalSQLExec",
"(",
"tx",
",",
"query",
",",
"&",
"result",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"tx",
".",
"Rollback",
"(",
")",
"\n",
"}",
"else",
"{",
"err",
"=",
"tx",
".",
"Commit",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"SmartError",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"batch",
".",
"Results",
"=",
"append",
"(",
"<mask>",
".",
"Results",
",",
"result",
")",
"\n",
"}",
"\n\n",
"return",
"SyncResponse",
"(",
"true",
",",
"batch",
")",
"\n",
"}"
] |
14,086 | all-14087 | [
"Parse",
"creates",
"a",
"new",
"*",
"Durafmt",
"struct",
"returns",
"error",
"if",
"input",
"is",
"invalid",
"."
] | [
"func",
"Parse",
"(",
"dinput",
"time",
".",
"Duration",
")",
"*",
"Durafmt",
"{",
"input",
":=",
"dinput",
".",
"<mask>",
"(",
")",
"\n",
"return",
"&",
"Durafmt",
"{",
"dinput",
",",
"input",
",",
"false",
"}",
"\n",
"}"
] |
14,087 | all-14088 | [
"Makes",
"a",
"GET",
"call",
"on",
"the",
"given",
"server",
"and",
"returns",
"the",
"current",
"instance",
"of",
"the",
"server",
"."
] | [
"func",
"<mask>",
"(",
"client",
"*",
"cm15",
".",
"API",
",",
"name",
"string",
")",
"*",
"cm15",
".",
"Instance",
"{",
"serverLocator",
":=",
"client",
".",
"ServerLocator",
"(",
"\"",
"\"",
")",
"\n",
"servers",
",",
"err",
":=",
"serverLocator",
".",
"Index",
"(",
"rsapi",
".",
"APIParams",
"{",
"\"",
"\"",
":",
"\"",
"\"",
",",
"\"",
"\"",
":",
"[",
"]",
"string",
"{",
"\"",
"\"",
"+",
"name",
"}",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fail",
"(",
"\"",
"\\n",
"\"",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"servers",
")",
"==",
"0",
"{",
"fail",
"(",
"\"",
"\\n",
"\"",
",",
"name",
")",
"\n",
"}",
"else",
"if",
"len",
"(",
"servers",
")",
"!=",
"1",
"{",
"fail",
"(",
"\"",
"\\n",
"\"",
",",
"name",
")",
"\n",
"}",
"\n",
"return",
"servers",
"[",
"0",
"]",
".",
"CurrentInstance",
"\n",
"}"
] |
14,088 | all-14089 | [
"newDefaultClassifier",
"creates",
"a",
"new",
"classifier",
"for",
"ASCII",
"characters",
"."
] | [
"func",
"newDefaultClassifier",
"(",
")",
"tokenClassifier",
"{",
"t",
":=",
"tokenClassifier",
"{",
"}",
"\n",
"t",
".",
"addRuneClass",
"(",
"spaceRunes",
",",
"spaceRuneClass",
")",
"\n",
"t",
".",
"addRuneClass",
"(",
"escapingQuoteRunes",
",",
"escapingQuoteRuneClass",
")",
"\n",
"t",
".",
"addRuneClass",
"(",
"nonEscapingQuoteRunes",
",",
"nonEscapingQuoteRuneClass",
")",
"\n",
"t",
".",
"addRuneClass",
"(",
"escapeRunes",
",",
"escapeRuneClass",
")",
"\n",
"t",
".",
"addRuneClass",
"(",
"commentRunes",
",",
"commentRuneClass",
")",
"\n",
"<mask>",
"t",
"\n",
"}"
] |
14,089 | all-14090 | [
"RegisterContainerInstance",
"calculates",
"the",
"appropriate",
"resources",
"creates",
"the",
"default",
"cluster",
"if",
"necessary",
"and",
"returns",
"the",
"registered",
"ContainerInstanceARN",
"if",
"successful",
".",
"Supplying",
"a",
"non",
"-",
"empty",
"container",
"instance",
"ARN",
"allows",
"a",
"container",
"instance",
"to",
"update",
"its",
"registered",
"resources",
"."
] | [
"func",
"(",
"client",
"*",
"APIECSClient",
")",
"RegisterContainerInstance",
"(",
"containerInstanceArn",
"string",
",",
"attributes",
"[",
"]",
"*",
"ecs",
".",
"Attribute",
",",
"tags",
"[",
"]",
"*",
"ecs",
".",
"Tag",
",",
"registrationToken",
"string",
",",
"platformDevices",
"[",
"]",
"*",
"ecs",
".",
"PlatformDevice",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"clusterRef",
":=",
"client",
".",
"config",
".",
"Cluster",
"\n",
"// If our clusterRef is empty, we should try to create the default",
"if",
"clusterRef",
"==",
"\"",
"\"",
"{",
"clusterRef",
"=",
"config",
".",
"DefaultClusterName",
"\n",
"defer",
"func",
"(",
")",
"{",
"// Update the config value to reflect the cluster we end up in",
"<mask>",
".",
"config",
".",
"Cluster",
"=",
"clusterRef",
"\n",
"}",
"(",
")",
"\n",
"// Attempt to register without checking existence of the cluster so we don't require",
"// excess permissions in the case where the cluster already exists and is active",
"containerInstanceArn",
",",
"availabilityzone",
",",
"err",
":=",
"client",
".",
"registerContainerInstance",
"(",
"clusterRef",
",",
"containerInstanceArn",
",",
"attributes",
",",
"tags",
",",
"registrationToken",
",",
"platformDevices",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"containerInstanceArn",
",",
"availabilityzone",
",",
"nil",
"\n",
"}",
"\n\n",
"// If trying to register fails because the default cluster doesn't exist, try to create the cluster before calling",
"// register again",
"if",
"apierrors",
".",
"IsClusterNotFoundError",
"(",
"err",
")",
"{",
"clusterRef",
",",
"err",
"=",
"client",
".",
"CreateCluster",
"(",
"clusterRef",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"client",
".",
"registerContainerInstance",
"(",
"clusterRef",
",",
"containerInstanceArn",
",",
"attributes",
",",
"tags",
",",
"registrationToken",
",",
"platformDevices",
")",
"\n",
"}"
] |
14,090 | all-14091 | [
"create",
"texture",
"objects"
] | [
"func",
"CreateTextures",
"(",
"<mask>",
"uint32",
",",
"n",
"int32",
",",
"textures",
"*",
"uint32",
")",
"{",
"C",
".",
"glowCreateTextures",
"(",
"gpCreateTextures",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"target",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"n",
")",
",",
"(",
"*",
"C",
".",
"GLuint",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"textures",
")",
")",
")",
"\n",
"}"
] |
14,091 | all-14092 | [
"Replace",
"a",
"suffix",
"and",
"adjust",
"R1start",
"and",
"R2start",
"as",
"needed",
".",
"If",
"force",
"is",
"false",
"check",
"to",
"make",
"sure",
"the",
"suffix",
"exists",
"first",
"."
] | [
"func",
"(",
"w",
"*",
"SnowballWord",
")",
"ReplaceSuffix",
"(",
"suffix",
",",
"replacement",
"string",
",",
"<mask>",
"bool",
")",
"bool",
"{",
"var",
"(",
"doReplacement",
"bool",
"\n",
"suffixRunes",
"[",
"]",
"rune",
"\n",
")",
"\n",
"if",
"force",
"{",
"doReplacement",
"=",
"true",
"\n",
"suffixRunes",
"=",
"[",
"]",
"rune",
"(",
"suffix",
")",
"\n",
"}",
"else",
"{",
"var",
"foundSuffix",
"string",
"\n",
"foundSuffix",
",",
"suffixRunes",
"=",
"w",
".",
"FirstSuffix",
"(",
"suffix",
")",
"\n",
"if",
"foundSuffix",
"==",
"suffix",
"{",
"doReplacement",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"doReplacement",
"==",
"false",
"{",
"return",
"false",
"\n",
"}",
"\n",
"w",
".",
"ReplaceSuffixRunes",
"(",
"suffixRunes",
",",
"[",
"]",
"rune",
"(",
"replacement",
")",
",",
"true",
")",
"\n",
"return",
"true",
"\n",
"}"
] |
14,092 | all-14093 | [
"The",
"doDemangle",
"function",
"is",
"the",
"entry",
"point",
"into",
"the",
"demangler",
"proper",
"."
] | [
"func",
"doDemangle",
"(",
"name",
"string",
",",
"options",
"...",
"Option",
")",
"(",
"ret",
"AST",
",",
"err",
"error",
")",
"{",
"// When the demangling routines encounter an error, they panic",
"// with a value of type demangleErr.",
"defer",
"func",
"(",
")",
"{",
"if",
"r",
":=",
"recover",
"(",
")",
";",
"r",
"!=",
"nil",
"{",
"if",
"de",
",",
"ok",
":=",
"r",
".",
"(",
"demangleErr",
")",
";",
"ok",
"{",
"ret",
"=",
"nil",
"\n",
"err",
"=",
"de",
"\n",
"return",
"\n",
"}",
"\n",
"panic",
"(",
"r",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"params",
":=",
"true",
"\n",
"clones",
":=",
"true",
"\n",
"verbose",
":=",
"false",
"\n",
"for",
"_",
",",
"o",
":=",
"range",
"options",
"{",
"switch",
"o",
"{",
"case",
"NoParams",
":",
"params",
"=",
"false",
"\n",
"clones",
"=",
"false",
"\n",
"case",
"NoTemplateParams",
":",
"// This is a valid option but only affect printing of the AST.",
"case",
"NoClones",
":",
"clones",
"=",
"false",
"\n",
"<mask>",
"Verbose",
":",
"verbose",
"=",
"true",
"\n",
"default",
":",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"o",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"st",
":=",
"&",
"state",
"{",
"str",
":",
"name",
",",
"verbose",
":",
"verbose",
"}",
"\n",
"a",
":=",
"st",
".",
"encoding",
"(",
"params",
",",
"notForLocalName",
")",
"\n\n",
"// Accept a clone suffix.",
"if",
"clones",
"{",
"for",
"len",
"(",
"st",
".",
"str",
")",
">",
"1",
"&&",
"st",
".",
"str",
"[",
"0",
"]",
"==",
"'.'",
"&&",
"(",
"isLower",
"(",
"st",
".",
"str",
"[",
"1",
"]",
")",
"||",
"st",
".",
"str",
"[",
"1",
"]",
"==",
"'_'",
"||",
"isDigit",
"(",
"st",
".",
"str",
"[",
"1",
"]",
")",
")",
"{",
"a",
"=",
"st",
".",
"cloneSuffix",
"(",
"a",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"clones",
"&&",
"len",
"(",
"st",
".",
"str",
")",
">",
"0",
"{",
"st",
".",
"fail",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"a",
",",
"nil",
"\n",
"}"
] |
14,093 | all-14094 | [
"NewConsumerFromClient",
"initializes",
"a",
"new",
"consumer",
"from",
"an",
"existing",
"client",
".",
"Please",
"note",
"that",
"clients",
"cannot",
"be",
"shared",
"between",
"consumers",
"(",
"due",
"to",
"Kafka",
"internals",
")",
"they",
"can",
"only",
"be",
"re",
"-",
"used",
"which",
"requires",
"the",
"user",
"to",
"call",
"Close",
"()",
"on",
"the",
"first",
"consumer",
"before",
"using",
"this",
"method",
"again",
"to",
"initialize",
"another",
"one",
".",
"Attempts",
"to",
"use",
"a",
"client",
"with",
"more",
"than",
"one",
"consumer",
"at",
"a",
"time",
"will",
"return",
"errors",
"."
] | [
"func",
"NewConsumerFromClient",
"(",
"client",
"*",
"Client",
",",
"groupID",
"string",
",",
"topics",
"[",
"]",
"string",
")",
"(",
"*",
"Consumer",
",",
"error",
")",
"{",
"if",
"!",
"client",
".",
"claim",
"(",
")",
"{",
"return",
"nil",
",",
"errClientInUse",
"\n",
"}",
"\n\n",
"consumer",
",",
"err",
":=",
"sarama",
".",
"NewConsumerFromClient",
"(",
"client",
".",
"Client",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"client",
".",
"release",
"(",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"sort",
".",
"Strings",
"(",
"topics",
")",
"\n",
"c",
":=",
"&",
"Consumer",
"{",
"client",
":",
"client",
",",
"consumer",
":",
"consumer",
",",
"subs",
":",
"newPartitionMap",
"(",
")",
",",
"groupID",
":",
"groupID",
",",
"coreTopics",
":",
"topics",
",",
"dying",
":",
"make",
"(",
"chan",
"none",
")",
",",
"dead",
":",
"make",
"(",
"chan",
"none",
")",
",",
"messages",
":",
"make",
"(",
"chan",
"*",
"sarama",
".",
"ConsumerMessage",
")",
",",
"errors",
":",
"make",
"(",
"chan",
"error",
",",
"client",
".",
"config",
".",
"ChannelBufferSize",
")",
",",
"partitions",
":",
"make",
"(",
"chan",
"PartitionConsumer",
",",
"1",
")",
",",
"notifications",
":",
"make",
"(",
"chan",
"*",
"Notification",
")",
",",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"client",
".",
"RefreshCoordinator",
"(",
"groupID",
")",
";",
"err",
"!=",
"nil",
"{",
"client",
".",
"<mask>",
"(",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"go",
"c",
".",
"mainLoop",
"(",
")",
"\n",
"return",
"c",
",",
"nil",
"\n",
"}"
] |
14,094 | all-14095 | [
"SetUint",
"sets",
"uint",
"value",
"for",
"the",
"given",
"key",
"."
] | [
"func",
"(",
"a",
"*",
"Args",
")",
"SetUint",
"(",
"key",
"string",
",",
"value",
"int",
")",
"{",
"bb",
":=",
"bytebufferpool",
".",
"Get",
"(",
")",
"\n",
"bb",
".",
"B",
"=",
"AppendUint",
"(",
"bb",
".",
"B",
"[",
":",
"0",
"]",
",",
"<mask>",
")",
"\n",
"a",
".",
"SetBytesV",
"(",
"key",
",",
"bb",
".",
"B",
")",
"\n",
"bytebufferpool",
".",
"Put",
"(",
"bb",
")",
"\n",
"}"
] |
14,095 | all-14096 | [
"WriteType",
"writest",
"the",
"type",
"declaration",
"for",
"a",
"resource",
"action",
"arguments",
"."
] | [
"func",
"(",
"c",
"*",
"ClientWriter",
")",
"WriteType",
"(",
"o",
"*",
"gen",
".",
"ObjectDataType",
",",
"w",
"io",
".",
"<mask>",
")",
"{",
"fields",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"o",
".",
"Fields",
")",
")",
"\n",
"for",
"i",
",",
"f",
":=",
"range",
"o",
".",
"Fields",
"{",
"fields",
"[",
"i",
"]",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"strings",
".",
"Title",
"(",
"f",
".",
"VarName",
")",
",",
"f",
".",
"Signature",
"(",
")",
",",
"f",
".",
"Name",
")",
"\n",
"}",
"\n",
"decl",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\\n",
"\"",
",",
"o",
".",
"TypeName",
",",
"strings",
".",
"Join",
"(",
"fields",
",",
"\"",
"\\n",
"\\t",
"\"",
")",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\n",
"\\n",
"\"",
",",
"decl",
")",
"\n",
"}"
] |
14,096 | all-14097 | [
"Decode",
"decodes",
"the",
"provided",
"StrKey",
"into",
"a",
"raw",
"value",
"checking",
"the",
"checksum",
"and",
"ensuring",
"the",
"expected",
"VersionByte",
"(",
"the",
"version",
"parameter",
")",
"is",
"the",
"value",
"actually",
"encoded",
"into",
"the",
"provided",
"src",
"string",
"."
] | [
"func",
"Decode",
"(",
"expected",
"VersionByte",
",",
"src",
"string",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"if",
"err",
":=",
"checkValidVersionByte",
"(",
"expected",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"raw",
",",
"err",
":=",
"base32",
".",
"StdEncoding",
".",
"DecodeString",
"(",
"src",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"raw",
")",
"<",
"3",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"len",
"(",
"raw",
")",
")",
"\n",
"}",
"\n\n",
"// decode into components",
"version",
":=",
"VersionByte",
"(",
"raw",
"[",
"0",
"]",
")",
"\n",
"vp",
":=",
"raw",
"[",
"0",
":",
"len",
"(",
"raw",
")",
"-",
"2",
"]",
"\n",
"payload",
":=",
"raw",
"[",
"1",
":",
"len",
"(",
"raw",
")",
"-",
"2",
"]",
"\n",
"checksum",
":=",
"raw",
"[",
"len",
"(",
"raw",
")",
"-",
"2",
":",
"]",
"\n\n",
"// ensure version byte is expected",
"if",
"version",
"!=",
"expected",
"{",
"return",
"nil",
",",
"ErrInvalidVersionByte",
"\n",
"}",
"\n\n",
"// ensure checksum is valid",
"if",
"err",
":=",
"crc16",
".",
"Validate",
"(",
"vp",
",",
"checksum",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// if we made it through the gaunlet, return the decoded value",
"return",
"payload",
",",
"nil",
"\n",
"}"
] |
14,097 | all-14098 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"EventInspectNodeRequested",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoOverlay19",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
14,098 | all-14099 | [
"PutBlob",
"writes",
"contents",
"of",
"stream",
"and",
"returns",
"data",
"representing",
"the",
"result",
".",
"inputInfo",
".",
"Digest",
"can",
"be",
"optionally",
"provided",
"if",
"known",
";",
"it",
"is",
"not",
"mandatory",
"for",
"the",
"implementation",
"to",
"verify",
"it",
".",
"inputInfo",
".",
"Size",
"is",
"the",
"expected",
"length",
"of",
"stream",
"if",
"known",
".",
"inputInfo",
".",
"MediaType",
"describes",
"the",
"blob",
"format",
"if",
"known",
".",
"May",
"update",
"cache",
".",
"WARNING",
":",
"The",
"contents",
"of",
"stream",
"are",
"being",
"verified",
"on",
"the",
"fly",
".",
"Until",
"stream",
".",
"Read",
"()",
"returns",
"io",
".",
"EOF",
"the",
"contents",
"of",
"the",
"data",
"SHOULD",
"NOT",
"be",
"available",
"to",
"any",
"other",
"readers",
"for",
"download",
"using",
"the",
"supplied",
"digest",
".",
"If",
"stream",
".",
"Read",
"()",
"at",
"any",
"time",
"ESPECIALLY",
"at",
"end",
"of",
"input",
"returns",
"an",
"error",
"PutBlob",
"MUST",
"1",
")",
"fail",
"and",
"2",
")",
"delete",
"any",
"data",
"stored",
"so",
"far",
"."
] | [
"func",
"(",
"d",
"*",
"ostreeImageDestination",
")",
"PutBlob",
"(",
"ctx",
"context",
".",
"<mask>",
",",
"stream",
"io",
".",
"Reader",
",",
"inputInfo",
"types",
".",
"BlobInfo",
",",
"cache",
"types",
".",
"BlobInfoCache",
",",
"isConfig",
"bool",
")",
"(",
"types",
".",
"BlobInfo",
",",
"error",
")",
"{",
"tmpDir",
",",
"err",
":=",
"ioutil",
".",
"TempDir",
"(",
"d",
".",
"tmpDirPath",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"types",
".",
"BlobInfo",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"blobPath",
":=",
"filepath",
".",
"Join",
"(",
"tmpDir",
",",
"\"",
"\"",
")",
"\n",
"blobFile",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"blobPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"types",
".",
"BlobInfo",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"defer",
"blobFile",
".",
"Close",
"(",
")",
"\n\n",
"digester",
":=",
"digest",
".",
"Canonical",
".",
"Digester",
"(",
")",
"\n",
"tee",
":=",
"io",
".",
"TeeReader",
"(",
"stream",
",",
"digester",
".",
"Hash",
"(",
")",
")",
"\n\n",
"// TODO: This can take quite some time, and should ideally be cancellable using ctx.Done().",
"size",
",",
"err",
":=",
"io",
".",
"Copy",
"(",
"blobFile",
",",
"tee",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"types",
".",
"BlobInfo",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"computedDigest",
":=",
"digester",
".",
"Digest",
"(",
")",
"\n",
"if",
"inputInfo",
".",
"Size",
"!=",
"-",
"1",
"&&",
"size",
"!=",
"inputInfo",
".",
"Size",
"{",
"return",
"types",
".",
"BlobInfo",
"{",
"}",
",",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"computedDigest",
",",
"inputInfo",
".",
"Size",
",",
"size",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"blobFile",
".",
"Sync",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"types",
".",
"BlobInfo",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"hash",
":=",
"computedDigest",
".",
"Hex",
"(",
")",
"\n",
"d",
".",
"blobs",
"[",
"hash",
"]",
"=",
"&",
"blobToImport",
"{",
"Size",
":",
"size",
",",
"Digest",
":",
"computedDigest",
",",
"BlobPath",
":",
"blobPath",
"}",
"\n",
"return",
"types",
".",
"BlobInfo",
"{",
"Digest",
":",
"computedDigest",
",",
"Size",
":",
"size",
"}",
",",
"nil",
"\n",
"}"
] |
14,099 | all-14100 | [
"GetTimeoutH",
"returns",
"the",
"TimeoutH",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"o",
"*",
"<mask>",
")",
"GetTimeoutH",
"(",
")",
"int",
"{",
"if",
"o",
"==",
"nil",
"||",
"o",
".",
"TimeoutH",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n",
"return",
"*",
"o",
".",
"TimeoutH",
"\n",
"}"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.