id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
sequencelengths 1
418
| pl_tokens
sequencelengths 22
4.98k
|
---|---|---|---|
4,200 | all-4201 | [
"Zones",
"returns",
"the",
"list",
"of",
"hosted",
"zones",
"."
] | [
"func",
"(",
"p",
"*",
"NS1Provider",
")",
"zonesFiltered",
"(",
")",
"(",
"[",
"]",
"*",
"dns",
".",
"Zone",
",",
"error",
")",
"{",
"// TODO handle Header Codes",
"zones",
",",
"_",
",",
"err",
":=",
"p",
".",
"client",
".",
"ListZones",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"toReturn",
":=",
"[",
"]",
"*",
"dns",
".",
"Zone",
"{",
"}",
"\n\n",
"for",
"_",
",",
"z",
":=",
"range",
"zones",
"{",
"if",
"p",
".",
"domainFilter",
".",
"Match",
"(",
"z",
".",
"Zone",
")",
"&&",
"p",
".",
"zoneIDFilter",
".",
"Match",
"(",
"z",
".",
"ID",
")",
"{",
"toReturn",
"=",
"append",
"(",
"toReturn",
",",
"z",
")",
"\n",
"<mask>",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"z",
".",
"Zone",
")",
"\n",
"}",
"else",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"z",
".",
"Zone",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"toReturn",
",",
"nil",
"\n",
"}"
] |
4,201 | all-4202 | [
"Mutate",
"applies",
"the",
"provided",
"mutators",
"to",
"this",
"builder",
"s",
"offer",
"or",
"operation",
"."
] | [
"func",
"(",
"b",
"*",
"ManageOfferBuilder",
")",
"Mutate",
"(",
"muts",
"...",
"interface",
"{",
"}",
")",
"{",
"for",
"_",
",",
"m",
":=",
"range",
"muts",
"{",
"var",
"err",
"error",
"\n",
"switch",
"mut",
":=",
"m",
".",
"(",
"type",
")",
"{",
"case",
"ManageOfferMutator",
":",
"if",
"b",
".",
"PassiveOffer",
"{",
"err",
"=",
"mut",
".",
"MutateManageOffer",
"(",
"&",
"b",
".",
"PO",
")",
"\n",
"}",
"else",
"{",
"err",
"=",
"mut",
".",
"MutateManageOffer",
"(",
"&",
"b",
".",
"MO",
")",
"\n",
"}",
"\n",
"case",
"OperationMutator",
":",
"err",
"=",
"mut",
".",
"MutateOperation",
"(",
"&",
"b",
".",
"O",
")",
"\n",
"default",
":",
"err",
"=",
"<mask>",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"b",
".",
"Err",
"=",
"err",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
4,202 | all-4203 | [
"Append",
"queues",
"a",
"sample",
"to",
"be",
"sent",
"to",
"the",
"remote",
"storage",
".",
"Blocks",
"until",
"all",
"samples",
"are",
"enqueued",
"on",
"their",
"shards",
"or",
"a",
"shutdown",
"signal",
"is",
"received",
"."
] | [
"func",
"(",
"t",
"*",
"QueueManager",
")",
"Append",
"(",
"s",
"[",
"]",
"tsdb",
".",
"RefSample",
")",
"bool",
"{",
"type",
"enqueuable",
"struct",
"{",
"ts",
"prompb",
".",
"TimeSeries",
"\n",
"ref",
"uint64",
"\n",
"}",
"\n\n",
"tempSamples",
":=",
"make",
"(",
"[",
"]",
"enqueuable",
",",
"0",
",",
"len",
"(",
"s",
")",
")",
"\n",
"t",
".",
"seriesMtx",
".",
"Lock",
"(",
")",
"\n",
"for",
"_",
",",
"sample",
":=",
"range",
"s",
"{",
"// If we have no labels for the series, due to relabelling or otherwise, don't send the sample.",
"if",
"_",
",",
"ok",
":=",
"t",
".",
"seriesLabels",
"[",
"sample",
".",
"Ref",
"]",
";",
"!",
"ok",
"{",
"t",
".",
"droppedSamplesTotal",
".",
"Inc",
"(",
")",
"\n",
"t",
".",
"samplesDropped",
".",
"incr",
"(",
"1",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"t",
".",
"droppedSeries",
"[",
"sample",
".",
"Ref",
"]",
";",
"!",
"ok",
"{",
"level",
".",
"Info",
"(",
"t",
".",
"logger",
")",
".",
"Log",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"sample",
".",
"Ref",
")",
"\n",
"}",
"\n",
"continue",
"\n",
"}",
"\n",
"tempSamples",
"=",
"append",
"(",
"tempSamples",
",",
"enqueuable",
"{",
"ts",
":",
"prompb",
".",
"TimeSeries",
"{",
"Labels",
":",
"t",
".",
"seriesLabels",
"[",
"sample",
".",
"Ref",
"]",
",",
"Samples",
":",
"[",
"]",
"prompb",
".",
"Sample",
"{",
"prompb",
".",
"Sample",
"{",
"Value",
":",
"float64",
"(",
"sample",
".",
"V",
")",
",",
"Timestamp",
":",
"sample",
".",
"T",
",",
"}",
",",
"}",
",",
"}",
",",
"ref",
":",
"sample",
".",
"Ref",
",",
"}",
")",
"\n",
"}",
"\n",
"t",
".",
"seriesMtx",
".",
"Unlock",
"(",
")",
"\n\n",
"outer",
":",
"for",
"_",
",",
"sample",
":=",
"range",
"tempSamples",
"{",
"// This will only loop if the queues are being resharded.",
"backoff",
":=",
"t",
".",
"cfg",
".",
"MinBackoff",
"\n",
"for",
"{",
"<mask>",
"{",
"case",
"<-",
"t",
".",
"quit",
":",
"return",
"false",
"\n",
"default",
":",
"}",
"\n\n",
"if",
"t",
".",
"shards",
".",
"enqueue",
"(",
"sample",
".",
"ref",
",",
"sample",
".",
"ts",
")",
"{",
"continue",
"outer",
"\n",
"}",
"\n\n",
"t",
".",
"enqueueRetriesMetric",
".",
"Inc",
"(",
")",
"\n",
"time",
".",
"Sleep",
"(",
"time",
".",
"Duration",
"(",
"backoff",
")",
")",
"\n",
"backoff",
"=",
"backoff",
"*",
"2",
"\n",
"if",
"backoff",
">",
"t",
".",
"cfg",
".",
"MaxBackoff",
"{",
"backoff",
"=",
"t",
".",
"cfg",
".",
"MaxBackoff",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] |
4,203 | all-4204 | [
"Converts",
"options",
"into",
"CORS",
"headers",
"."
] | [
"func",
"(",
"o",
"*",
"Options",
")",
"Header",
"(",
"origin",
"string",
")",
"(",
"headers",
"<mask>",
"[",
"string",
"]",
"string",
")",
"{",
"headers",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"// if origin is not alowed, don't extend the headers",
"// with CORS headers.",
"if",
"!",
"o",
".",
"AllowAllOrigins",
"&&",
"!",
"o",
".",
"IsOriginAllowed",
"(",
"origin",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"// add allow origin",
"if",
"o",
".",
"AllowAllOrigins",
"{",
"headers",
"[",
"headerAllowOrigin",
"]",
"=",
"\"",
"\"",
"\n",
"}",
"else",
"{",
"headers",
"[",
"headerAllowOrigin",
"]",
"=",
"origin",
"\n",
"}",
"\n\n",
"// add allow credentials",
"headers",
"[",
"headerAllowCredentials",
"]",
"=",
"strconv",
".",
"FormatBool",
"(",
"o",
".",
"AllowCredentials",
")",
"\n\n",
"// add allow methods",
"if",
"len",
"(",
"o",
".",
"AllowMethods",
")",
">",
"0",
"{",
"headers",
"[",
"headerAllowMethods",
"]",
"=",
"strings",
".",
"Join",
"(",
"o",
".",
"AllowMethods",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// add allow headers",
"if",
"len",
"(",
"o",
".",
"AllowHeaders",
")",
">",
"0",
"{",
"// TODO: Add default headers",
"headers",
"[",
"headerAllowHeaders",
"]",
"=",
"strings",
".",
"Join",
"(",
"o",
".",
"AllowHeaders",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// add exposed header",
"if",
"len",
"(",
"o",
".",
"ExposeHeaders",
")",
">",
"0",
"{",
"headers",
"[",
"headerExposeHeaders",
"]",
"=",
"strings",
".",
"Join",
"(",
"o",
".",
"ExposeHeaders",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"// add a max age header",
"if",
"o",
".",
"MaxAge",
">",
"time",
".",
"Duration",
"(",
"0",
")",
"{",
"headers",
"[",
"headerMaxAge",
"]",
"=",
"strconv",
".",
"FormatInt",
"(",
"int64",
"(",
"o",
".",
"MaxAge",
"/",
"time",
".",
"Second",
")",
",",
"10",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] |
4,204 | all-4205 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"FrameResourceTree",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage46",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
4,205 | all-4206 | [
"Remove",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockFileSystem",
")",
"Remove",
"(",
"arg0",
"<mask>",
")",
"{",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"}"
] |
4,206 | all-4207 | [
"String",
"returns",
"a",
"human",
"readable",
"string",
"representation",
"of",
"this",
"object"
] | [
"func",
"(",
"c",
"*",
"Container",
")",
"String",
"(",
")",
"string",
"{",
"ret",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"Name",
",",
"c",
".",
"Image",
",",
"c",
".",
"GetKnownStatus",
"(",
")",
".",
"String",
"(",
")",
",",
"c",
".",
"GetDesiredStatus",
"(",
")",
".",
"<mask>",
"(",
")",
")",
"\n",
"if",
"c",
".",
"GetKnownExitCode",
"(",
")",
"!=",
"nil",
"{",
"ret",
"+=",
"\"",
"\"",
"+",
"strconv",
".",
"Itoa",
"(",
"*",
"c",
".",
"GetKnownExitCode",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"ret",
"\n",
"}"
] |
4,207 | all-4208 | [
"TODO",
":",
"Needs",
"gio",
"/",
"GAppInfo",
"implementation",
"first",
"gtk_app_chooser_get_app_info",
"()",
"GetContentType",
"is",
"a",
"wrapper",
"around",
"gtk_app_chooser_get_content_type",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"AppChooser",
")",
"GetContentType",
"(",
")",
"string",
"{",
"cstr",
":=",
"C",
".",
"gtk_app_chooser_get_content_type",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"return",
"C",
".",
"GoString",
"(",
"(",
"*",
"C",
".",
"<mask>",
")",
"(",
"cstr",
")",
")",
"\n",
"}"
] |
4,208 | all-4209 | [
"Add",
"function",
"adds",
"a",
"node",
"to",
"the",
"receiver",
"node",
".",
"If",
"the",
"receiver",
"is",
"not",
"a",
"directory",
"a",
"Not",
"A",
"Directory",
"error",
"will",
"be",
"returned",
".",
"If",
"there",
"is",
"an",
"existing",
"node",
"with",
"the",
"same",
"name",
"under",
"the",
"directory",
"a",
"Already",
"Exist",
"error",
"will",
"be",
"returned"
] | [
"func",
"(",
"n",
"*",
"node",
")",
"Add",
"(",
"<mask>",
"*",
"node",
")",
"*",
"v2error",
".",
"Error",
"{",
"if",
"!",
"n",
".",
"IsDir",
"(",
")",
"{",
"return",
"v2error",
".",
"NewError",
"(",
"v2error",
".",
"EcodeNotDir",
",",
"\"",
"\"",
",",
"n",
".",
"store",
".",
"CurrentIndex",
")",
"\n",
"}",
"\n\n",
"_",
",",
"name",
":=",
"path",
".",
"Split",
"(",
"child",
".",
"Path",
")",
"\n\n",
"if",
"_",
",",
"ok",
":=",
"n",
".",
"Children",
"[",
"name",
"]",
";",
"ok",
"{",
"return",
"v2error",
".",
"NewError",
"(",
"v2error",
".",
"EcodeNodeExist",
",",
"\"",
"\"",
",",
"n",
".",
"store",
".",
"CurrentIndex",
")",
"\n",
"}",
"\n\n",
"n",
".",
"Children",
"[",
"name",
"]",
"=",
"child",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
4,209 | all-4210 | [
"Type",
"gets",
"a",
"type",
"for",
"a",
"Schema",
"reference",
"if",
"it",
"exists"
] | [
"func",
"(",
"r",
"Ref",
")",
"Type",
"(",
")",
"string",
"{",
"if",
"_",
",",
"ok",
":=",
"r",
"[",
"\"",
"\"",
"]",
";",
"<mask>",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"refIF",
",",
"ok",
":=",
"r",
"[",
"\"",
"\"",
"]",
";",
"ok",
"{",
"return",
"refIF",
".",
"(",
"string",
")",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] |
4,210 | all-4211 | [
"native",
"returns",
"a",
"pointer",
"to",
"the",
"underlying",
"GtkDrawingArea",
"."
] | [
"func",
"(",
"v",
"*",
"DrawingArea",
")",
"native",
"(",
")",
"*",
"C",
".",
"GtkDrawingArea",
"{",
"if",
"v",
"==",
"nil",
"||",
"v",
".",
"GObject",
"==",
"nil",
"{",
"<mask>",
"nil",
"\n",
"}",
"\n",
"p",
":=",
"unsafe",
".",
"Pointer",
"(",
"v",
".",
"GObject",
")",
"\n",
"return",
"C",
".",
"toGtkDrawingArea",
"(",
"p",
")",
"\n",
"}"
] |
4,211 | all-4212 | [
"UnmarshalYAML",
"implements",
"the",
"yaml",
".",
"Unmarshaler",
"interface",
"."
] | [
"func",
"(",
"c",
"*",
"GlobalConfig",
")",
"UnmarshalYAML",
"(",
"unmarshal",
"func",
"(",
"interface",
"{",
"}",
")",
"error",
")",
"error",
"{",
"// Create a clean global config as the previous one was already populated",
"// by the default due to the YAML parser behavior for empty blocks.",
"gc",
":=",
"&",
"GlobalConfig",
"{",
"}",
"\n",
"type",
"plain",
"GlobalConfig",
"\n",
"if",
"err",
":=",
"unmarshal",
"(",
"(",
"*",
"plain",
")",
"(",
"gc",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"l",
":=",
"range",
"gc",
".",
"ExternalLabels",
"{",
"if",
"!",
"model",
".",
"LabelName",
"(",
"l",
".",
"Name",
")",
".",
"IsValid",
"(",
")",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"l",
".",
"Name",
")",
"\n",
"}",
"\n",
"if",
"!",
"model",
".",
"LabelValue",
"(",
"l",
".",
"Value",
")",
".",
"IsValid",
"(",
")",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"l",
".",
"Value",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// First set the correct scrape interval, then check that the timeout",
"// (inferred or explicit) is not greater than that.",
"if",
"gc",
".",
"ScrapeInterval",
"==",
"0",
"{",
"gc",
".",
"ScrapeInterval",
"=",
"DefaultGlobalConfig",
".",
"ScrapeInterval",
"\n",
"}",
"\n",
"if",
"gc",
".",
"ScrapeTimeout",
">",
"gc",
".",
"ScrapeInterval",
"{",
"return",
"<mask>",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"gc",
".",
"ScrapeTimeout",
"==",
"0",
"{",
"if",
"DefaultGlobalConfig",
".",
"ScrapeTimeout",
">",
"gc",
".",
"ScrapeInterval",
"{",
"gc",
".",
"ScrapeTimeout",
"=",
"gc",
".",
"ScrapeInterval",
"\n",
"}",
"else",
"{",
"gc",
".",
"ScrapeTimeout",
"=",
"DefaultGlobalConfig",
".",
"ScrapeTimeout",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"gc",
".",
"EvaluationInterval",
"==",
"0",
"{",
"gc",
".",
"EvaluationInterval",
"=",
"DefaultGlobalConfig",
".",
"EvaluationInterval",
"\n",
"}",
"\n",
"*",
"c",
"=",
"*",
"gc",
"\n",
"return",
"nil",
"\n",
"}"
] |
4,212 | all-4213 | [
"SetAddress",
"modifies",
"the",
"receiver",
"setting",
"it",
"s",
"value",
"to",
"the",
"AccountId",
"form",
"of",
"the",
"provided",
"address",
"."
] | [
"func",
"(",
"aid",
"*",
"AccountId",
")",
"SetAddress",
"(",
"address",
"string",
")",
"error",
"{",
"if",
"aid",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"raw",
",",
"err",
":=",
"strkey",
".",
"Decode",
"(",
"strkey",
".",
"VersionByteAccountID",
",",
"address",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"raw",
")",
"!=",
"32",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"<mask>",
"ui",
"Uint256",
"\n",
"copy",
"(",
"ui",
"[",
":",
"]",
",",
"raw",
")",
"\n\n",
"*",
"aid",
",",
"err",
"=",
"NewAccountId",
"(",
"CryptoKeyTypeKeyTypeEd25519",
",",
"ui",
")",
"\n\n",
"return",
"err",
"\n",
"}"
] |
4,213 | all-4214 | [
"GetAllPotentialApprovers",
"returns",
"the",
"people",
"from",
"relevant",
"owners",
"files",
"needed",
"to",
"get",
"the",
"PR",
"approved"
] | [
"func",
"(",
"o",
"Owners",
")",
"GetAllPotentialApprovers",
"(",
")",
"[",
"]",
"string",
"{",
"approversOnly",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"approverList",
":=",
"range",
"o",
".",
"GetLeafApprovers",
"(",
")",
"{",
"for",
"approver",
":=",
"<mask>",
"approverList",
"{",
"approversOnly",
"=",
"append",
"(",
"approversOnly",
",",
"approver",
")",
"\n",
"}",
"\n",
"}",
"\n",
"sort",
".",
"Strings",
"(",
"approversOnly",
")",
"\n",
"if",
"len",
"(",
"approversOnly",
")",
"==",
"0",
"{",
"o",
".",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"approversOnly",
"\n",
"}"
] |
4,214 | all-4215 | [
"GetLabel",
"is",
"a",
"wrapper",
"around",
"gtk_frame_get_label",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Frame",
")",
"GetLabel",
"(",
")",
"<mask>",
"{",
"c",
":=",
"C",
".",
"gtk_frame_get_label",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"return",
"goString",
"(",
"c",
")",
"\n",
"}"
] |
4,215 | all-4216 | [
"childOf",
"returns",
"true",
"if",
"the",
"line",
"is",
"a",
"child",
"of",
"the",
"element",
"."
] | [
"func",
"(",
"l",
"*",
"line",
")",
"childOf",
"(",
"parent",
"element",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"ok",
"bool",
"\n",
"var",
"err",
"error",
"\n\n",
"switch",
"{",
"case",
"l",
".",
"isEmpty",
"(",
")",
":",
"ok",
"=",
"true",
"\n",
"case",
"parent",
".",
"ContainPlainText",
"(",
")",
":",
"switch",
"{",
"case",
"parent",
".",
"Base",
"(",
")",
".",
"ln",
".",
"indent",
"<",
"l",
".",
"indent",
":",
"ok",
"=",
"true",
"\n",
"}",
"\n",
"default",
":",
"switch",
"{",
"case",
"l",
".",
"indent",
"==",
"parent",
".",
"<mask>",
"(",
")",
".",
"ln",
".",
"indent",
"+",
"1",
":",
"ok",
"=",
"true",
"\n",
"case",
"l",
".",
"indent",
">",
"parent",
".",
"Base",
"(",
")",
".",
"ln",
".",
"indent",
"+",
"1",
":",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"l",
".",
"fileName",
"(",
")",
",",
"l",
".",
"no",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"ok",
",",
"err",
"\n",
"}"
] |
4,216 | all-4217 | [
"GBToByte",
"returns",
"n",
"*",
"1000000000",
".",
"The",
"output",
"is",
"returned",
"as",
"int64",
"-",
"if",
"another",
"type",
"is",
"needed",
"it",
"needs",
"to",
"be",
"cast",
".",
"Remember",
"that",
"int32",
"overflows",
"at",
"2GB",
"and",
"uint32",
"will",
"overflow",
"at",
"4GB",
"."
] | [
"func",
"GBToByte",
"(",
"n",
"interface",
"{",
"}",
")",
"int64",
"{",
"switch",
"v",
":=",
"n",
".",
"(",
"type",
")",
"{",
"case",
"int",
":",
"return",
"int64",
"(",
"v",
"*",
"1000000000",
")",
"\n",
"case",
"int32",
":",
"return",
"int64",
"(",
"v",
"*",
"1000000000",
")",
"\n",
"<mask>",
"int64",
":",
"return",
"v",
"*",
"1000000000",
"\n",
"}",
"\n",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"n",
")",
")",
"\n",
"}"
] |
4,217 | all-4218 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"SetFontFamiliesParams",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage10",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
4,218 | all-4219 | [
"BumpMajor",
"increments",
"the",
"Major",
"field",
"by",
"1",
"and",
"resets",
"all",
"other",
"fields",
"to",
"their",
"default",
"values"
] | [
"func",
"(",
"v",
"*",
"<mask>",
")",
"BumpMajor",
"(",
")",
"{",
"v",
".",
"Major",
"+=",
"1",
"\n",
"v",
".",
"Minor",
"=",
"0",
"\n",
"v",
".",
"Patch",
"=",
"0",
"\n",
"v",
".",
"PreRelease",
"=",
"PreRelease",
"(",
"\"",
"\"",
")",
"\n",
"v",
".",
"Metadata",
"=",
"\"",
"\"",
"\n",
"}"
] |
4,219 | all-4220 | [
"GetZone",
"wraps",
"the",
"Get",
"method",
"of",
"the",
"API",
"s",
"Zones",
"service"
] | [
"func",
"(",
"n",
"NS1DomainService",
")",
"GetZone",
"(",
"zone",
"string",
")",
"(",
"*",
"dns",
".",
"Zone",
",",
"*",
"<mask>",
".",
"Response",
",",
"error",
")",
"{",
"return",
"n",
".",
"service",
".",
"Zones",
".",
"Get",
"(",
"zone",
")",
"\n",
"}"
] |
4,220 | all-4221 | [
"String",
"returns",
"the",
"simplified",
"path",
"to",
"a",
"node",
".",
"The",
"simplified",
"path",
"only",
"contains",
"struct",
"field",
"accesses",
".",
"For",
"example",
":",
"MyMap",
".",
"MySlices",
".",
"MyField"
] | [
"func",
"(",
"<mask>",
"Path",
")",
"String",
"(",
")",
"string",
"{",
"var",
"ss",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"s",
":=",
"range",
"pa",
"{",
"if",
"_",
",",
"ok",
":=",
"s",
".",
"(",
"StructField",
")",
";",
"ok",
"{",
"ss",
"=",
"append",
"(",
"ss",
",",
"s",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"strings",
".",
"TrimPrefix",
"(",
"strings",
".",
"Join",
"(",
"ss",
",",
"\"",
"\"",
")",
",",
"\"",
"\"",
")",
"\n",
"}"
] |
4,221 | all-4222 | [
"openEventstream",
"opens",
"but",
"does",
"not",
"consume",
"the",
"docker",
"event",
"stream"
] | [
"func",
"(",
"engine",
"*",
"DockerTaskEngine",
")",
"openEventstream",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"events",
",",
"err",
":=",
"engine",
".",
"client",
".",
"ContainerEvents",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"<mask>",
".",
"events",
"=",
"events",
"\n",
"return",
"nil",
"\n",
"}"
] |
4,222 | all-4223 | [
"Add",
"(",
"Gob",
"-",
"serialized",
")",
"cache",
"items",
"from",
"an",
"io",
".",
"Reader",
"excluding",
"any",
"items",
"with",
"keys",
"that",
"already",
"exist",
"(",
"and",
"haven",
"t",
"expired",
")",
"in",
"the",
"current",
"cache",
".",
"NOTE",
":",
"This",
"method",
"is",
"deprecated",
"in",
"favor",
"of",
"c",
".",
"Items",
"()",
"and",
"NewFrom",
"()",
"(",
"see",
"the",
"documentation",
"for",
"NewFrom",
"()",
".",
")"
] | [
"func",
"(",
"c",
"*",
"cache",
")",
"Load",
"(",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"dec",
":=",
"gob",
".",
"NewDecoder",
"(",
"r",
")",
"\n",
"<mask>",
":=",
"map",
"[",
"string",
"]",
"Item",
"{",
"}",
"\n",
"err",
":=",
"dec",
".",
"Decode",
"(",
"&",
"items",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"items",
"{",
"ov",
",",
"found",
":=",
"c",
".",
"items",
"[",
"k",
"]",
"\n",
"if",
"!",
"found",
"||",
"ov",
".",
"Expired",
"(",
")",
"{",
"c",
".",
"items",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] |
4,223 | all-4224 | [
"specify",
"a",
"three",
"-",
"dimensional",
"texture",
"subimage"
] | [
"func",
"TextureSubImage3D",
"(",
"texture",
"uint32",
",",
"level",
"int32",
",",
"xoffset",
"int32",
",",
"yoffset",
"int32",
",",
"zoffset",
"int32",
",",
"width",
"int32",
",",
"height",
"int32",
",",
"depth",
"int32",
",",
"<mask>",
"uint32",
",",
"xtype",
"uint32",
",",
"pixels",
"unsafe",
".",
"Pointer",
")",
"{",
"C",
".",
"glowTextureSubImage3D",
"(",
"gpTextureSubImage3D",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"texture",
")",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"level",
")",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"xoffset",
")",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"yoffset",
")",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"zoffset",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"width",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"height",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"depth",
")",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"format",
")",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"xtype",
")",
",",
"pixels",
")",
"\n",
"}"
] |
4,224 | all-4225 | [
"NewClient",
"creates",
"a",
"slack",
"client",
"with",
"an",
"API",
"token",
"."
] | [
"func",
"NewClient",
"(",
"tokenGenerator",
"func",
"(",
")",
"[",
"]",
"byte",
")",
"*",
"Client",
"{",
"return",
"&",
"<mask>",
"{",
"logger",
":",
"logrus",
".",
"WithField",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
",",
"tokenGenerator",
":",
"tokenGenerator",
",",
"}",
"\n",
"}"
] |
4,225 | all-4226 | [
"ExprFromValue",
"converts",
"the",
"given",
"Value",
"into",
"an",
"Expr",
"or",
"returns",
"an",
"error",
"."
] | [
"func",
"ExprFromValue",
"(",
"value",
"sqltypes",
".",
"Value",
")",
"(",
"Expr",
",",
"error",
")",
"{",
"// The type checks here follow the rules defined in sqltypes/types.go.",
"switch",
"{",
"case",
"value",
".",
"Type",
"(",
")",
"==",
"sqltypes",
".",
"Null",
":",
"return",
"&",
"NullVal",
"{",
"}",
",",
"nil",
"\n",
"case",
"value",
".",
"IsIntegral",
"(",
")",
":",
"return",
"NewIntVal",
"(",
"value",
".",
"ToBytes",
"(",
")",
")",
",",
"nil",
"\n",
"case",
"value",
".",
"IsFloat",
"(",
")",
"||",
"<mask>",
".",
"Type",
"(",
")",
"==",
"sqltypes",
".",
"Decimal",
":",
"return",
"NewFloatVal",
"(",
"value",
".",
"ToBytes",
"(",
")",
")",
",",
"nil",
"\n",
"case",
"value",
".",
"IsQuoted",
"(",
")",
":",
"return",
"NewStrVal",
"(",
"value",
".",
"ToBytes",
"(",
")",
")",
",",
"nil",
"\n",
"default",
":",
"// We cannot support sqltypes.Expression, or any other invalid type.",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"value",
")",
"\n",
"}",
"\n",
"}"
] |
4,226 | all-4227 | [
"/",
"*",
"BuildWithEnvironment",
"is",
"identical",
"to",
"Build",
"but",
"allows",
"you",
"to",
"specify",
"env",
"vars",
"to",
"be",
"set",
"at",
"build",
"time",
"."
] | [
"func",
"BuildWithEnvironment",
"(",
"packagePath",
"string",
",",
"env",
"[",
"]",
"string",
",",
"args",
"...",
"string",
")",
"(",
"compiledPath",
"string",
",",
"err",
"error",
")",
"{",
"return",
"doBuild",
"(",
"build",
".",
"<mask>",
".",
"GOPATH",
",",
"packagePath",
",",
"env",
",",
"args",
"...",
")",
"\n",
"}"
] |
4,227 | all-4228 | [
"NewEnterpriseServer",
"returns",
"an",
"implementation",
"of",
"ec",
".",
"APIServer",
"."
] | [
"func",
"NewEnterpriseServer",
"(",
"env",
"*",
"serviceenv",
".",
"ServiceEnv",
",",
"etcdPrefix",
"string",
")",
"(",
"ec",
".",
"APIServer",
",",
"error",
")",
"{",
"s",
":=",
"&",
"apiServer",
"{",
"pachLogger",
":",
"log",
".",
"NewLogger",
"(",
"\"",
"\"",
")",
",",
"env",
":",
"env",
",",
"enterpriseToken",
":",
"col",
".",
"NewCollection",
"(",
"env",
".",
"GetEtcdClient",
"(",
")",
",",
"etcdPrefix",
",",
"// only one collection--no extra prefix needed",
"nil",
",",
"&",
"ec",
".",
"EnterpriseRecord",
"{",
"}",
",",
"nil",
",",
"nil",
",",
")",
",",
"}",
"\n",
"s",
".",
"enterpriseExpiration",
".",
"Store",
"(",
"time",
".",
"Time",
"{",
"}",
")",
"\n",
"<mask>",
"s",
".",
"watchEnterpriseToken",
"(",
"etcdPrefix",
")",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] |
4,228 | all-4229 | [
"GetPalette",
"returns",
"the",
"Palette",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"t",
"*",
"TileDefRequestStyle",
")",
"GetPalette",
"(",
")",
"string",
"{",
"if",
"t",
"==",
"nil",
"||",
"t",
".",
"Palette",
"==",
"nil",
"{",
"<mask>",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"*",
"t",
".",
"Palette",
"\n",
"}"
] |
4,229 | all-4230 | [
"SetGroup",
"is",
"a",
"wrapper",
"around",
"gtk_radio_button_set_group",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"RadioButton",
")",
"SetGroup",
"(",
"group",
"*",
"glib",
".",
"SList",
")",
"{",
"C",
".",
"gtk_radio_button_set_group",
"(",
"v",
".",
"native",
"(",
")",
",",
"cGSList",
"(",
"<mask>",
")",
")",
"\n",
"}"
] |
4,230 | all-4231 | [
"ArmForSwitch",
"returns",
"which",
"field",
"name",
"should",
"be",
"used",
"for",
"storing",
"the",
"value",
"for",
"an",
"instance",
"of",
"Memo"
] | [
"func",
"(",
"u",
"Memo",
")",
"ArmForSwitch",
"(",
"sw",
"int32",
")",
"(",
"string",
",",
"bool",
")",
"{",
"switch",
"MemoType",
"(",
"sw",
")",
"{",
"case",
"MemoTypeMemoNone",
":",
"return",
"\"",
"\"",
",",
"true",
"\n",
"<mask>",
"MemoTypeMemoText",
":",
"return",
"\"",
"\"",
",",
"true",
"\n",
"case",
"MemoTypeMemoId",
":",
"return",
"\"",
"\"",
",",
"true",
"\n",
"case",
"MemoTypeMemoHash",
":",
"return",
"\"",
"\"",
",",
"true",
"\n",
"case",
"MemoTypeMemoReturn",
":",
"return",
"\"",
"\"",
",",
"true",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}"
] |
4,231 | all-4232 | [
"Quantize",
"quantizes",
"the",
"audio",
"signal",
"to",
"match",
"the",
"target",
"bitDepth"
] | [
"func",
"Quantize",
"(",
"buf",
"*",
"audio",
".",
"FloatBuffer",
",",
"bitDepth",
"int",
")",
"{",
"if",
"buf",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"<mask>",
":=",
"math",
".",
"Pow",
"(",
"2",
",",
"float64",
"(",
"bitDepth",
")",
")",
"-",
"1",
"\n\n",
"bufLen",
":=",
"len",
"(",
"buf",
".",
"Data",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"bufLen",
";",
"i",
"++",
"{",
"buf",
".",
"Data",
"[",
"i",
"]",
"=",
"round",
"(",
"(",
"buf",
".",
"Data",
"[",
"i",
"]",
"+",
"1",
")",
"*",
"max",
")",
"/",
"max",
"-",
"1.0",
"\n",
"}",
"\n",
"}"
] |
4,232 | all-4233 | [
"GetImageSecret",
"is",
"a",
"helper",
"around",
"CreateImageSecret",
"that",
"returns",
"a",
"secret",
"for",
"the",
"image"
] | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"GetImageSecret",
"(",
"fingerprint",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"op",
",",
"err",
":=",
"r",
".",
"CreateImageSecret",
"(",
"fingerprint",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"<mask>",
"\n",
"}",
"\n",
"opAPI",
":=",
"op",
".",
"Get",
"(",
")",
"\n\n",
"return",
"opAPI",
".",
"Metadata",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
",",
"nil",
"\n",
"}"
] |
4,233 | all-4234 | [
"Tags",
"appends",
"the",
"given",
"tags",
"to",
"the",
"tags",
"sent",
"with",
"every",
"metrics",
".",
"If",
"a",
"tag",
"already",
"exists",
"it",
"is",
"replaced",
".",
"The",
"tags",
"must",
"be",
"set",
"as",
"key",
"-",
"value",
"pairs",
".",
"If",
"the",
"number",
"of",
"tags",
"is",
"not",
"even",
"Tags",
"panics",
".",
"If",
"the",
"format",
"of",
"tags",
"have",
"not",
"been",
"set",
"using",
"the",
"TagsFormat",
"option",
"the",
"tags",
"will",
"be",
"ignored",
"."
] | [
"func",
"Tags",
"(",
"tags",
"...",
"string",
")",
"Option",
"{",
"if",
"len",
"(",
"tags",
")",
"%",
"2",
"!=",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"Option",
"(",
"func",
"(",
"c",
"*",
"config",
")",
"{",
"if",
"len",
"(",
"tags",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"newTags",
":=",
"make",
"(",
"[",
"]",
"tag",
",",
"len",
"(",
"tags",
")",
"/",
"2",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"tags",
")",
"/",
"2",
";",
"i",
"++",
"{",
"newTags",
"[",
"i",
"]",
"=",
"tag",
"{",
"K",
":",
"tags",
"[",
"2",
"*",
"i",
"]",
",",
"V",
":",
"tags",
"[",
"2",
"*",
"i",
"+",
"1",
"]",
"}",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"newTag",
":=",
"range",
"newTags",
"{",
"exists",
":=",
"false",
"\n",
"for",
"_",
",",
"oldTag",
":=",
"range",
"c",
".",
"Client",
".",
"Tags",
"{",
"if",
"newTag",
".",
"K",
"==",
"oldTag",
".",
"K",
"{",
"exists",
"=",
"true",
"\n",
"oldTag",
".",
"V",
"=",
"newTag",
".",
"V",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"!",
"exists",
"{",
"c",
".",
"Client",
".",
"Tags",
"=",
"append",
"(",
"c",
".",
"<mask>",
".",
"Tags",
",",
"tag",
"{",
"K",
":",
"newTag",
".",
"K",
",",
"V",
":",
"newTag",
".",
"V",
",",
"}",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
")",
"\n",
"}"
] |
4,234 | all-4235 | [
"Scan",
"read",
"a",
"value",
"from",
"a",
"database",
"driver"
] | [
"func",
"(",
"u",
"*",
"UUID5",
")",
"Scan",
"(",
"raw",
"interface",
"{",
"}",
")",
"error",
"{",
"<mask>",
"v",
":=",
"raw",
".",
"(",
"type",
")",
"{",
"case",
"[",
"]",
"byte",
":",
"*",
"u",
"=",
"UUID5",
"(",
"string",
"(",
"v",
")",
")",
"\n",
"case",
"string",
":",
"*",
"u",
"=",
"UUID5",
"(",
"v",
")",
"\n",
"default",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"v",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
4,235 | all-4236 | [
"newRecordOperation",
"returns",
"a",
"RecordOperation",
"based",
"on",
"a",
"given",
"endpoint",
"."
] | [
"func",
"newRecordOperation",
"(",
"ep",
"*",
"endpoint",
".",
"Endpoint",
",",
"opType",
"dns",
".",
"RecordOperationOperationEnum",
")",
"dns",
".",
"RecordOperation",
"{",
"targets",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"ep",
".",
"Targets",
")",
")",
"\n",
"<mask>",
"(",
"targets",
",",
"[",
"]",
"string",
"(",
"ep",
".",
"Targets",
")",
")",
"\n",
"if",
"ep",
".",
"RecordType",
"==",
"endpoint",
".",
"RecordTypeCNAME",
"{",
"targets",
"[",
"0",
"]",
"=",
"ensureTrailingDot",
"(",
"targets",
"[",
"0",
"]",
")",
"\n",
"}",
"\n",
"rdata",
":=",
"strings",
".",
"Join",
"(",
"targets",
",",
"\"",
"\"",
")",
"\n\n",
"ttl",
":=",
"ociRecordTTL",
"\n",
"if",
"ep",
".",
"RecordTTL",
".",
"IsConfigured",
"(",
")",
"{",
"ttl",
"=",
"int",
"(",
"ep",
".",
"RecordTTL",
")",
"\n",
"}",
"\n\n",
"return",
"dns",
".",
"RecordOperation",
"{",
"Domain",
":",
"&",
"ep",
".",
"DNSName",
",",
"Rdata",
":",
"&",
"rdata",
",",
"Ttl",
":",
"&",
"ttl",
",",
"Rtype",
":",
"&",
"ep",
".",
"RecordType",
",",
"Operation",
":",
"opType",
",",
"}",
"\n",
"}"
] |
4,236 | all-4237 | [
"GetAggregatorOk",
"returns",
"a",
"tuple",
"with",
"the",
"Aggregator",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"s",
"*",
"ScatterplotRequest",
")",
"GetAggregatorOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"s",
"==",
"nil",
"||",
"s",
".",
"Aggregator",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"s",
".",
"Aggregator",
",",
"true",
"\n",
"}"
] |
4,237 | all-4238 | [
"EndOfWeek",
"end",
"of",
"week"
] | [
"func",
"(",
"now",
"*",
"Now",
")",
"EndOfWeek",
"(",
")",
"time",
".",
"Time",
"{",
"return",
"<mask>",
".",
"BeginningOfWeek",
"(",
")",
".",
"AddDate",
"(",
"0",
",",
"0",
",",
"7",
")",
".",
"Add",
"(",
"-",
"time",
".",
"Nanosecond",
")",
"\n",
"}"
] |
4,238 | all-4239 | [
"TODO",
":",
"gtk_tool_item_get_ellipsize_mode",
"GetIconSize",
"is",
"a",
"wrapper",
"around",
"gtk_tool_item_get_icon_size",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"ToolItem",
")",
"GetIconSize",
"(",
")",
"IconSize",
"{",
"c",
":=",
"C",
".",
"gtk_tool_item_get_icon_size",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"<mask>",
"IconSize",
"(",
"c",
")",
"\n",
"}"
] |
4,239 | all-4240 | [
"Wrappers",
"around",
"Logger",
"interface",
"functions",
"that",
"send",
"a",
"string",
"to",
"the",
"Logger",
"by",
"running",
"it",
"through",
"fmt",
".",
"Sprintf",
"()",
"."
] | [
"func",
"Infof",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"Log",
"!=",
"nil",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
"\n",
"pc",
",",
"fn",
",",
"line",
",",
"_",
":=",
"runtime",
".",
"Caller",
"(",
"1",
")",
"\n",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"fn",
",",
"line",
",",
"runtime",
".",
"FuncForPC",
"(",
"<mask>",
")",
".",
"Name",
"(",
")",
",",
"msg",
")",
"\n",
"Log",
".",
"Info",
"(",
"msg",
")",
"\n",
"}",
"\n",
"}"
] |
4,240 | all-4241 | [
"Rel",
"attempts",
"to",
"compute",
"a",
"relative",
"label",
"from",
"this",
"label",
".",
"If",
"this",
"label",
"is",
"already",
"relative",
"or",
"is",
"in",
"a",
"different",
"package",
"this",
"label",
"may",
"be",
"returned",
"unchanged",
"."
] | [
"func",
"(",
"l",
"Label",
")",
"Rel",
"(",
"repo",
",",
"pkg",
"string",
")",
"Label",
"{",
"if",
"l",
".",
"Relative",
"||",
"l",
".",
"Repo",
"!=",
"repo",
"{",
"return",
"l",
"\n",
"}",
"\n",
"if",
"l",
".",
"Pkg",
"==",
"pkg",
"{",
"return",
"Label",
"{",
"Name",
":",
"l",
".",
"<mask>",
",",
"Relative",
":",
"true",
"}",
"\n",
"}",
"\n",
"return",
"Label",
"{",
"Pkg",
":",
"l",
".",
"Pkg",
",",
"Name",
":",
"l",
".",
"Name",
"}",
"\n",
"}"
] |
4,241 | all-4242 | [
"createSignature",
"creates",
"a",
"new",
"signature",
"of",
"manifest",
"using",
"keyIdentity",
"."
] | [
"func",
"(",
"c",
"*",
"copier",
")",
"createSignature",
"(",
"manifest",
"[",
"]",
"byte",
",",
"keyIdentity",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"mech",
",",
"err",
":=",
"signature",
".",
"NewGPGSigningMechanism",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"<mask>",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"defer",
"mech",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
":=",
"mech",
".",
"SupportsSigning",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"dockerReference",
":=",
"c",
".",
"dest",
".",
"Reference",
"(",
")",
".",
"DockerReference",
"(",
")",
"\n",
"if",
"dockerReference",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"transports",
".",
"ImageName",
"(",
"c",
".",
"dest",
".",
"Reference",
"(",
")",
")",
")",
"\n",
"}",
"\n\n",
"c",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"newSig",
",",
"err",
":=",
"signature",
".",
"SignDockerManifest",
"(",
"manifest",
",",
"dockerReference",
".",
"String",
"(",
")",
",",
"mech",
",",
"keyIdentity",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"newSig",
",",
"nil",
"\n",
"}"
] |
4,242 | all-4243 | [
"fixManifestLayers",
"after",
"validating",
"the",
"supplied",
"manifest",
"(",
"to",
"use",
"correctly",
"-",
"formatted",
"IDs",
"and",
"to",
"not",
"have",
"non",
"-",
"consecutive",
"ID",
"collisions",
"in",
"m",
".",
"History",
")",
"modifies",
"manifest",
"to",
"only",
"have",
"one",
"entry",
"for",
"each",
"layer",
"ID",
"in",
"m",
".",
"History",
"(",
"deleting",
"the",
"older",
"duplicates",
"both",
"from",
"m",
".",
"History",
"and",
"m",
".",
"FSLayers",
")",
".",
"Note",
"that",
"even",
"after",
"this",
"succeeds",
"m",
".",
"FSLayers",
"may",
"contain",
"duplicate",
"entries",
"(",
"for",
"Dockerfile",
"operations",
"which",
"change",
"the",
"configuration",
"but",
"not",
"the",
"filesystem",
")",
"."
] | [
"func",
"(",
"m",
"*",
"Schema1",
")",
"fixManifestLayers",
"(",
")",
"error",
"{",
"// m.initialize() has verified that len(m.FSLayers) == len(m.History)",
"for",
"_",
",",
"compat",
":=",
"range",
"m",
".",
"ExtractedV1Compatibility",
"{",
"if",
"err",
":=",
"validateV1ID",
"(",
"compat",
".",
"ID",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"m",
".",
"ExtractedV1Compatibility",
"[",
"len",
"(",
"m",
".",
"ExtractedV1Compatibility",
")",
"-",
"1",
"]",
".",
"Parent",
"!=",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"// check general duplicates to error instead of a deadlock",
"idmap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
")",
"\n",
"var",
"lastID",
"string",
"\n",
"for",
"_",
",",
"img",
":=",
"range",
"m",
".",
"ExtractedV1Compatibility",
"{",
"// skip IDs that appear after each other, we handle those later",
"if",
"_",
",",
"exists",
":=",
"idmap",
"[",
"img",
".",
"ID",
"]",
";",
"img",
".",
"ID",
"!=",
"lastID",
"&&",
"exists",
"{",
"return",
"<mask>",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"img",
".",
"ID",
")",
"\n",
"}",
"\n",
"lastID",
"=",
"img",
".",
"ID",
"\n",
"idmap",
"[",
"lastID",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n",
"}",
"\n",
"// backwards loop so that we keep the remaining indexes after removing items",
"for",
"i",
":=",
"len",
"(",
"m",
".",
"ExtractedV1Compatibility",
")",
"-",
"2",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"if",
"m",
".",
"ExtractedV1Compatibility",
"[",
"i",
"]",
".",
"ID",
"==",
"m",
".",
"ExtractedV1Compatibility",
"[",
"i",
"+",
"1",
"]",
".",
"ID",
"{",
"// repeated ID. remove and continue",
"m",
".",
"FSLayers",
"=",
"append",
"(",
"m",
".",
"FSLayers",
"[",
":",
"i",
"]",
",",
"m",
".",
"FSLayers",
"[",
"i",
"+",
"1",
":",
"]",
"...",
")",
"\n",
"m",
".",
"History",
"=",
"append",
"(",
"m",
".",
"History",
"[",
":",
"i",
"]",
",",
"m",
".",
"History",
"[",
"i",
"+",
"1",
":",
"]",
"...",
")",
"\n",
"m",
".",
"ExtractedV1Compatibility",
"=",
"append",
"(",
"m",
".",
"ExtractedV1Compatibility",
"[",
":",
"i",
"]",
",",
"m",
".",
"ExtractedV1Compatibility",
"[",
"i",
"+",
"1",
":",
"]",
"...",
")",
"\n",
"}",
"else",
"if",
"m",
".",
"ExtractedV1Compatibility",
"[",
"i",
"]",
".",
"Parent",
"!=",
"m",
".",
"ExtractedV1Compatibility",
"[",
"i",
"+",
"1",
"]",
".",
"ID",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"m",
".",
"ExtractedV1Compatibility",
"[",
"i",
"+",
"1",
"]",
".",
"ID",
",",
"m",
".",
"ExtractedV1Compatibility",
"[",
"i",
"]",
".",
"Parent",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
4,243 | all-4244 | [
"validateContextOverlap",
"ensures",
"that",
"there",
"will",
"be",
"no",
"overlap",
"in",
"contexts",
"between",
"a",
"set",
"of",
"jobs",
"running",
"and",
"a",
"set",
"to",
"skip"
] | [
"func",
"validateContextOverlap",
"(",
"toRun",
",",
"toSkip",
"[",
"]",
"config",
".",
"Presubmit",
")",
"error",
"{",
"requestedContexts",
":=",
"sets",
".",
"NewString",
"(",
")",
"\n",
"for",
"_",
",",
"job",
":=",
"range",
"toRun",
"{",
"requestedContexts",
".",
"Insert",
"(",
"job",
".",
"Context",
")",
"\n",
"}",
"\n",
"skippedContexts",
":=",
"sets",
".",
"NewString",
"(",
")",
"\n",
"for",
"_",
",",
"job",
":=",
"<mask>",
"toSkip",
"{",
"skippedContexts",
".",
"Insert",
"(",
"job",
".",
"Context",
")",
"\n",
"}",
"\n",
"if",
"overlap",
":=",
"requestedContexts",
".",
"Intersection",
"(",
"skippedContexts",
")",
".",
"List",
"(",
")",
";",
"len",
"(",
"overlap",
")",
">",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"overlap",
",",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
4,244 | all-4245 | [
"progressTask",
"tries",
"to",
"step",
"forwards",
"all",
"containers",
"and",
"resources",
"that",
"are",
"able",
"to",
"be",
"transitioned",
"in",
"the",
"task",
"s",
"current",
"state",
".",
"It",
"will",
"continue",
"listening",
"to",
"events",
"from",
"all",
"channels",
"while",
"it",
"does",
"so",
"but",
"none",
"of",
"those",
"changes",
"will",
"be",
"acted",
"upon",
"until",
"this",
"set",
"of",
"requests",
"to",
"docker",
"completes",
".",
"Container",
"changes",
"may",
"also",
"prompt",
"the",
"task",
"status",
"to",
"change",
"as",
"well",
"."
] | [
"func",
"(",
"mtask",
"*",
"managedTask",
")",
"progressTask",
"(",
")",
"{",
"seelog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"mtask",
".",
"Arn",
")",
"\n",
"// max number of transitions length to ensure writes will never block on",
"// these and if we exit early transitions can exit the goroutine and it'll",
"// get GC'd eventually",
"resources",
":=",
"mtask",
".",
"GetResources",
"(",
")",
"\n",
"transitionChange",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
",",
"len",
"(",
"mtask",
".",
"Containers",
")",
"+",
"len",
"(",
"resources",
")",
")",
"\n",
"transitionChangeEntity",
":=",
"make",
"(",
"chan",
"string",
",",
"len",
"(",
"mtask",
".",
"Containers",
")",
"+",
"len",
"(",
"resources",
")",
")",
"\n\n",
"// startResourceTransitions should always be called before startContainerTransitions,",
"// else it might result in a state where none of the containers can transition and",
"// task may be moved to stopped.",
"// anyResourceTransition is set to true when transition function needs to be called or",
"// known status can be changed",
"anyResourceTransition",
",",
"resTransitions",
":=",
"mtask",
".",
"startResourceTransitions",
"(",
"func",
"(",
"resource",
"taskresource",
".",
"TaskResource",
",",
"nextStatus",
"resourcestatus",
".",
"ResourceStatus",
")",
"{",
"mtask",
".",
"transitionResource",
"(",
"resource",
",",
"nextStatus",
")",
"\n",
"transitionChange",
"<-",
"struct",
"{",
"}",
"{",
"}",
"\n",
"transitionChangeEntity",
"<-",
"resource",
".",
"GetName",
"(",
")",
"\n",
"}",
")",
"\n\n",
"anyContainerTransition",
",",
"blockedDependencies",
",",
"contTransitions",
",",
"reasons",
":=",
"mtask",
".",
"startContainerTransitions",
"(",
"func",
"(",
"container",
"*",
"apicontainer",
".",
"<mask>",
",",
"nextStatus",
"apicontainerstatus",
".",
"ContainerStatus",
")",
"{",
"mtask",
".",
"engine",
".",
"transitionContainer",
"(",
"mtask",
".",
"Task",
",",
"container",
",",
"nextStatus",
")",
"\n",
"transitionChange",
"<-",
"struct",
"{",
"}",
"{",
"}",
"\n",
"transitionChangeEntity",
"<-",
"container",
".",
"Name",
"\n",
"}",
")",
"\n\n",
"atLeastOneTransitionStarted",
":=",
"anyResourceTransition",
"||",
"anyContainerTransition",
"\n\n",
"blockedByOrderingDependencies",
":=",
"len",
"(",
"blockedDependencies",
")",
">",
"0",
"\n\n",
"// If no transitions happened and we aren't blocked by ordering dependencies, then we are possibly in a state where",
"// its impossible for containers to move forward. We will do an additional check to see if we are waiting for ACS",
"// execution credentials. If not, then we will abort the task progression.",
"if",
"!",
"atLeastOneTransitionStarted",
"&&",
"!",
"blockedByOrderingDependencies",
"{",
"if",
"!",
"mtask",
".",
"isWaitingForACSExecutionCredentials",
"(",
"reasons",
")",
"{",
"mtask",
".",
"handleContainersUnableToTransitionState",
"(",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}",
"\n\n",
"// If no containers are starting and we are blocked on ordering dependencies, we should watch for the task to change",
"// over time. This will update the containers if they become healthy or stop, which makes it possible for the",
"// conditions \"HEALTHY\" and \"SUCCESS\" to succeed.",
"if",
"!",
"atLeastOneTransitionStarted",
"&&",
"blockedByOrderingDependencies",
"{",
"go",
"mtask",
".",
"engine",
".",
"checkTaskState",
"(",
"mtask",
".",
"Task",
")",
"\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"transitionPollTime",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"for",
"timeout",
":=",
"mtask",
".",
"waitEvent",
"(",
"ctx",
".",
"Done",
"(",
")",
")",
";",
"!",
"timeout",
";",
"{",
"timeout",
"=",
"mtask",
".",
"waitEvent",
"(",
"ctx",
".",
"Done",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}",
"\n\n",
"// combine the resource and container transitions",
"transitions",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"resTransitions",
"{",
"transitions",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"contTransitions",
"{",
"transitions",
"[",
"k",
"]",
"=",
"v",
".",
"String",
"(",
")",
"\n",
"}",
"\n\n",
"// We've kicked off one or more transitions, wait for them to",
"// complete, but keep reading events as we do. in fact, we have to for",
"// transitions to complete",
"mtask",
".",
"waitForTransition",
"(",
"transitions",
",",
"transitionChange",
",",
"transitionChangeEntity",
")",
"\n",
"// update the task status",
"changed",
":=",
"mtask",
".",
"UpdateStatus",
"(",
")",
"\n",
"if",
"changed",
"{",
"seelog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"mtask",
".",
"Arn",
")",
"\n\n",
"// If knownStatus changed, let it be known",
"var",
"taskStateChangeReason",
"string",
"\n",
"if",
"mtask",
".",
"GetKnownStatus",
"(",
")",
".",
"Terminal",
"(",
")",
"{",
"taskStateChangeReason",
"=",
"mtask",
".",
"Task",
".",
"GetTerminalReason",
"(",
")",
"\n",
"}",
"\n",
"mtask",
".",
"emitTaskEvent",
"(",
"mtask",
".",
"Task",
",",
"taskStateChangeReason",
")",
"\n",
"}",
"\n",
"}"
] |
4,245 | all-4246 | [
"Limit",
"returns",
"a",
"new",
"Condition",
"of",
"LIMIT",
"clause",
"."
] | [
"func",
"(",
"db",
"*",
"DB",
")",
"Limit",
"(",
"lim",
"int",
")",
"*",
"Condition",
"{",
"return",
"newCondition",
"(",
"<mask>",
")",
".",
"Limit",
"(",
"lim",
")",
"\n",
"}"
] |
4,246 | all-4247 | [
"ListReviews",
"returns",
"reviews",
"."
] | [
"func",
"(",
"f",
"*",
"FakeClient",
")",
"ListReviews",
"(",
"owner",
",",
"repo",
"string",
",",
"<mask>",
"int",
")",
"(",
"[",
"]",
"github",
".",
"Review",
",",
"error",
")",
"{",
"return",
"append",
"(",
"[",
"]",
"github",
".",
"Review",
"{",
"}",
",",
"f",
".",
"Reviews",
"[",
"number",
"]",
"...",
")",
",",
"nil",
"\n",
"}"
] |
4,247 | all-4248 | [
"render",
"primitives",
"from",
"array",
"data"
] | [
"func",
"DrawElements",
"(",
"mode",
"uint32",
",",
"<mask>",
"int32",
",",
"xtype",
"uint32",
",",
"indices",
"unsafe",
".",
"Pointer",
")",
"{",
"C",
".",
"glowDrawElements",
"(",
"gpDrawElements",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"mode",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"count",
")",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"xtype",
")",
",",
"indices",
")",
"\n",
"}"
] |
4,248 | all-4249 | [
"GetValue",
"returns",
"the",
"Value",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"d",
"*",
"DashboardConditionalFormat",
")",
"GetValue",
"(",
")",
"json",
".",
"Number",
"{",
"if",
"d",
"==",
"nil",
"||",
"d",
".",
"Value",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"*",
"d",
".",
"<mask>",
"\n",
"}"
] |
4,249 | all-4250 | [
"GetDisplayFormat",
"returns",
"the",
"DisplayFormat",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"m",
"*",
"ManageStatusDefinition",
")",
"GetDisplayFormat",
"(",
")",
"string",
"{",
"if",
"m",
"==",
"nil",
"||",
"m",
".",
"DisplayFormat",
"==",
"nil",
"{",
"<mask>",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"*",
"m",
".",
"DisplayFormat",
"\n",
"}"
] |
4,250 | all-4251 | [
"VisitAllCookie",
"calls",
"f",
"for",
"each",
"request",
"cookie",
".",
"f",
"must",
"not",
"retain",
"references",
"to",
"key",
"and",
"/",
"or",
"value",
"after",
"returning",
"."
] | [
"func",
"(",
"h",
"*",
"RequestHeader",
")",
"VisitAllCookie",
"(",
"f",
"func",
"(",
"<mask>",
",",
"value",
"[",
"]",
"byte",
")",
")",
"{",
"h",
".",
"parseRawHeaders",
"(",
")",
"\n",
"h",
".",
"collectCookies",
"(",
")",
"\n",
"visitArgs",
"(",
"h",
".",
"cookies",
",",
"f",
")",
"\n",
"}"
] |
4,251 | all-4252 | [
"Locator",
"returns",
"a",
"locator",
"for",
"the",
"given",
"resource"
] | [
"func",
"(",
"r",
"*",
"IpAddress",
")",
"Locator",
"(",
"api",
"*",
"API",
")",
"*",
"IpAddressLocator",
"{",
"for",
"_",
",",
"l",
":=",
"<mask>",
"r",
".",
"Links",
"{",
"if",
"l",
"[",
"\"",
"\"",
"]",
"==",
"\"",
"\"",
"{",
"return",
"api",
".",
"IpAddressLocator",
"(",
"l",
"[",
"\"",
"\"",
"]",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
4,252 | all-4253 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"Frame",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoCdp2",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"<mask>",
"(",
")",
"\n",
"}"
] |
4,253 | all-4254 | [
"Set",
"a",
"value",
"onto",
"the",
"current",
"session",
".",
"If",
"a",
"value",
"with",
"that",
"name",
"already",
"exists",
"it",
"will",
"be",
"overridden",
"with",
"the",
"new",
"value",
"."
] | [
"func",
"(",
"s",
"*",
"<mask>",
")",
"Set",
"(",
"name",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"s",
".",
"Session",
".",
"Values",
"[",
"name",
"]",
"=",
"value",
"\n",
"}"
] |
4,254 | all-4255 | [
"NewFloodSub",
"returns",
"a",
"new",
"PubSub",
"object",
"using",
"the",
"FloodSubRouter",
"."
] | [
"func",
"NewFloodSub",
"(",
"ctx",
"<mask>",
".",
"Context",
",",
"h",
"host",
".",
"Host",
",",
"opts",
"...",
"Option",
")",
"(",
"*",
"PubSub",
",",
"error",
")",
"{",
"return",
"NewFloodsubWithProtocols",
"(",
"ctx",
",",
"h",
",",
"[",
"]",
"protocol",
".",
"ID",
"{",
"FloodSubID",
"}",
",",
"opts",
"...",
")",
"\n",
"}"
] |
4,255 | all-4256 | [
"Scale",
"is",
"a",
"wrapper",
"around",
"cairo_scale",
"."
] | [
"func",
"(",
"v",
"*",
"<mask>",
")",
"Scale",
"(",
"sx",
",",
"sy",
"float64",
")",
"{",
"C",
".",
"cairo_scale",
"(",
"v",
".",
"native",
"(",
")",
",",
"C",
".",
"double",
"(",
"sx",
")",
",",
"C",
".",
"double",
"(",
"sy",
")",
")",
"\n",
"}"
] |
4,256 | all-4257 | [
"Render",
"renders",
"a",
"template",
"using",
"the",
"provided",
"template",
"and",
"vars",
"struct",
"and",
"returns",
"a",
"response",
"with",
"the",
"rendered",
"template"
] | [
"func",
"RenderTemplateResponse",
"(",
"t",
"*",
"<mask>",
".",
"Template",
",",
"vars",
"interface",
"{",
"}",
")",
"*",
"OkResponse",
"{",
"response",
":=",
"NewResponse",
"(",
")",
"\n",
"response",
".",
"SetContent",
"(",
"RenderTemplate",
"(",
"t",
",",
"vars",
")",
")",
"\n",
"return",
"response",
"\n",
"}"
] |
4,257 | all-4258 | [
"NewMockRoundTripper",
"creates",
"a",
"new",
"mock",
"instance"
] | [
"func",
"NewMockRoundTripper",
"(",
"ctrl",
"*",
"gomock",
".",
"<mask>",
")",
"*",
"MockRoundTripper",
"{",
"mock",
":=",
"&",
"MockRoundTripper",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockRoundTripperMockRecorder",
"{",
"mock",
"}",
"\n",
"return",
"mock",
"\n",
"}"
] |
4,258 | all-4259 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"PushNodesByBackendIdsToFrontendParams",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoDom24",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
4,259 | all-4260 | [
"NewBoskosHandler",
"constructs",
"the",
"boskos",
"handler",
"."
] | [
"func",
"NewBoskosHandler",
"(",
"r",
"*",
"ranch",
".",
"Ranch",
")",
"*",
"<mask>",
".",
"ServeMux",
"{",
"mux",
":=",
"http",
".",
"NewServeMux",
"(",
")",
"\n",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"handleDefault",
"(",
"r",
")",
")",
"\n",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"handleAcquire",
"(",
"r",
")",
")",
"\n",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"handleAcquireByState",
"(",
"r",
")",
")",
"\n",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"handleRelease",
"(",
"r",
")",
")",
"\n",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"handleReset",
"(",
"r",
")",
")",
"\n",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"handleUpdate",
"(",
"r",
")",
")",
"\n",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"handleMetric",
"(",
"r",
")",
")",
"\n",
"return",
"mux",
"\n",
"}"
] |
4,260 | all-4261 | [
"native",
"returns",
"a",
"pointer",
"to",
"the",
"underlying",
"GtkImage",
"."
] | [
"func",
"(",
"v",
"*",
"<mask>",
")",
"native",
"(",
")",
"*",
"C",
".",
"GtkImage",
"{",
"if",
"v",
"==",
"nil",
"||",
"v",
".",
"GObject",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"p",
":=",
"unsafe",
".",
"Pointer",
"(",
"v",
".",
"GObject",
")",
"\n",
"return",
"C",
".",
"toGtkImage",
"(",
"p",
")",
"\n",
"}"
] |
4,261 | all-4262 | [
"ListImages",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockDockerClient",
")",
"ListImages",
"(",
"arg0",
"<mask>",
".",
"Context",
",",
"arg1",
"time",
".",
"Duration",
")",
"dockerapi",
".",
"ListImagesResponse",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
",",
"arg1",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"dockerapi",
".",
"ListImagesResponse",
")",
"\n",
"return",
"ret0",
"\n",
"}"
] |
4,262 | all-4263 | [
"NewConfig",
"creates",
"a",
"default",
"job",
"queue",
"configuration",
"."
] | [
"func",
"NewConfig",
"(",
")",
"*",
"Config",
"{",
"return",
"&",
"Config",
"{",
"CollectJobs",
":",
"100",
",",
"CollectPeriod",
":",
"1000",
",",
"WorkerBufLen",
":",
"10",
",",
"Workers",
":",
"0",
",",
"TypeConfig",
":",
"TypeConfig",
"{",
"TryLimit",
":",
"3",
",",
"TryPeriod",
":",
"60000",
",",
"}",
",",
"<mask>",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"TypeConfig",
")",
",",
"}",
"\n",
"}"
] |
4,263 | all-4264 | [
"RegisterLeaseHandler",
"registers",
"the",
"http",
"handlers",
"for",
"service",
"Lease",
"to",
"mux",
".",
"The",
"handlers",
"forward",
"requests",
"to",
"the",
"grpc",
"endpoint",
"over",
"conn",
"."
] | [
"func",
"RegisterLeaseHandler",
"(",
"ctx",
"context",
".",
"Context",
",",
"mux",
"*",
"runtime",
".",
"ServeMux",
",",
"conn",
"*",
"grpc",
".",
"ClientConn",
")",
"error",
"{",
"return",
"RegisterLeaseHandlerClient",
"(",
"ctx",
",",
"mux",
",",
"etcdserverpb",
".",
"NewLeaseClient",
"(",
"<mask>",
")",
")",
"\n",
"}"
] |
4,264 | all-4265 | [
"------------------------",
"Selection",
"Dialog",
"---------------------"
] | [
"func",
"CreateEditDialog",
"(",
"title",
",",
"<mask>",
",",
"initialText",
"string",
")",
"*",
"SelectDialog",
"{",
"return",
"CreateSelectDialog",
"(",
"title",
",",
"[",
"]",
"string",
"{",
"message",
",",
"initialText",
"}",
",",
"0",
",",
"SelectDialogEdit",
")",
"\n",
"}"
] |
4,265 | all-4266 | [
"SetCopyright",
"is",
"a",
"wrapper",
"around",
"gtk_about_dialog_set_copyright",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"AboutDialog",
")",
"SetCopyright",
"(",
"copyright",
"string",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"copyright",
")",
"\n",
"defer",
"C",
".",
"<mask>",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"C",
".",
"gtk_about_dialog_set_copyright",
"(",
"v",
".",
"native",
"(",
")",
",",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
")",
"\n",
"}"
] |
4,266 | all-4267 | [
"FilteredFirehose",
"streams",
"a",
"filtered",
"set",
"of",
"envelopes",
".",
"It",
"has",
"functionality",
"similar",
"to",
"Firehose",
"."
] | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"FilteredFirehose",
"(",
"subscriptionId",
"string",
",",
"authToken",
"string",
",",
"filter",
"EnvelopeFilter",
",",
")",
"(",
"<-",
"chan",
"*",
"<mask>",
".",
"Envelope",
",",
"<-",
"chan",
"error",
")",
"{",
"return",
"c",
".",
"firehose",
"(",
"newFirehose",
"(",
"subscriptionId",
",",
"authToken",
",",
"WithEnvelopeFilter",
"(",
"filter",
")",
",",
")",
")",
"\n",
"}"
] |
4,267 | all-4268 | [
"After",
"sleeps",
"for",
"the",
"given",
"duration",
"and",
"then",
"writes",
"to",
"to",
"the",
"returned",
"channel"
] | [
"func",
"(",
"*",
"DefaultTime",
")",
"After",
"(",
"d",
"time",
".",
"Duration",
")",
"<-",
"chan",
"time",
".",
"Time",
"{",
"return",
"<mask>",
".",
"After",
"(",
"d",
")",
"\n",
"}"
] |
4,268 | all-4269 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"AttachToTargetParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoTarget29",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"<mask>",
"(",
")",
"\n",
"}"
] |
4,269 | all-4270 | [
"NewExpiringPointsIndex",
"creates",
"new",
"PointIndex",
"that",
"expires",
"the",
"points",
"in",
"each",
"cell",
"after",
"expiration",
"minutes",
"."
] | [
"func",
"NewExpiringPointsIndex",
"(",
"resolution",
"Meters",
",",
"expiration",
"Minutes",
")",
"*",
"PointsIndex",
"{",
"currentPosition",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"Point",
")",
"\n\n",
"newExpiringSet",
":=",
"func",
"(",
")",
"interface",
"{",
"}",
"{",
"set",
":=",
"newExpiringSet",
"(",
"expiration",
")",
"\n\n",
"set",
".",
"OnExpire",
"(",
"func",
"(",
"id",
"string",
",",
"<mask>",
"interface",
"{",
"}",
")",
"{",
"point",
":=",
"value",
".",
"(",
"Point",
")",
"\n",
"delete",
"(",
"currentPosition",
",",
"point",
".",
"Id",
"(",
")",
")",
"\n",
"}",
")",
"\n\n",
"return",
"set",
"\n",
"}",
"\n\n",
"return",
"&",
"PointsIndex",
"{",
"newGeoIndex",
"(",
"resolution",
",",
"newExpiringSet",
")",
",",
"currentPosition",
"}",
"\n",
"}"
] |
4,270 | all-4271 | [
"Copy",
"returns",
"a",
"deep",
"copy",
"of",
"this",
"configuration",
"."
] | [
"func",
"(",
"c",
"*",
"SSLConfig",
")",
"Copy",
"(",
")",
"*",
"SSLConfig",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"var",
"o",
"SSLConfig",
"\n",
"o",
".",
"CaCert",
"=",
"c",
".",
"CaCert",
"\n",
"o",
".",
"CaPath",
"=",
"c",
".",
"CaPath",
"\n",
"o",
".",
"Cert",
"=",
"c",
".",
"Cert",
"\n",
"o",
".",
"Enabled",
"=",
"c",
".",
"Enabled",
"\n",
"o",
".",
"Key",
"=",
"c",
".",
"<mask>",
"\n",
"o",
".",
"ServerName",
"=",
"c",
".",
"ServerName",
"\n",
"o",
".",
"Verify",
"=",
"c",
".",
"Verify",
"\n",
"return",
"&",
"o",
"\n",
"}"
] |
4,271 | all-4272 | [
"DeleteLan",
"deletes",
"a",
"lan",
"where",
"id",
"==",
"lanid"
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteLan",
"(",
"dcid",
",",
"lanid",
"string",
")",
"(",
"*",
"http",
".",
"<mask>",
",",
"error",
")",
"{",
"url",
":=",
"lanPath",
"(",
"dcid",
",",
"lanid",
")",
"\n",
"ret",
":=",
"&",
"http",
".",
"Header",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"client",
".",
"Delete",
"(",
"url",
",",
"ret",
",",
"http",
".",
"StatusAccepted",
")",
"\n",
"return",
"ret",
",",
"err",
"\n",
"}"
] |
4,272 | all-4273 | [
"ServeHTTP",
"records",
"the",
"time",
"for",
"a",
"request",
"and",
"sends",
"the",
"result",
"to",
"statsd"
] | [
"func",
"(",
"sh",
"*",
"StatsdLogHandler",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"requestStartTime",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"sh",
".",
"handler",
".",
"ServeHTTP",
"(",
"w",
",",
"req",
")",
"\n",
"requestDuration",
":=",
"time",
".",
"Now",
"(",
")",
".",
"Sub",
"(",
"requestStartTime",
")",
"\n\n",
"description",
":=",
"sh",
".",
"RequestFormatter",
"(",
"req",
")",
"\n",
"if",
"description",
"!=",
"\"",
"\"",
"{",
"sh",
".",
"statter",
".",
"Counter",
"(",
"1.0",
",",
"sh",
".",
"prefix",
"+",
"\"",
"\"",
"+",
"<mask>",
"+",
"\"",
"\"",
",",
"1",
")",
"\n",
"sh",
".",
"statter",
".",
"Timing",
"(",
"1.0",
",",
"sh",
".",
"prefix",
"+",
"\"",
"\"",
"+",
"description",
"+",
"\"",
"\"",
",",
"requestDuration",
")",
"\n",
"}",
"\n",
"}"
] |
4,273 | all-4274 | [
"NewLeaseTimeToLiveCommand",
"returns",
"the",
"cobra",
"command",
"for",
"lease",
"timetolive",
"."
] | [
"func",
"NewLeaseTimeToLiveCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"lc",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"leaseTimeToLiveCommandFunc",
",",
"}",
"\n",
"lc",
".",
"Flags",
"(",
")",
".",
"BoolVar",
"(",
"&",
"timeToLiveKeys",
",",
"\"",
"\"",
",",
"<mask>",
",",
"\"",
"\"",
")",
"\n\n",
"return",
"lc",
"\n",
"}"
] |
4,274 | all-4275 | [
"Returns",
"the",
"information",
"log",
"for",
"a",
"program",
"object"
] | [
"func",
"GetProgramInfoLog",
"(",
"<mask>",
"uint32",
",",
"bufSize",
"int32",
",",
"length",
"*",
"int32",
",",
"infoLog",
"*",
"uint8",
")",
"{",
"syscall",
".",
"Syscall6",
"(",
"gpGetProgramInfoLog",
",",
"4",
",",
"uintptr",
"(",
"program",
")",
",",
"uintptr",
"(",
"bufSize",
")",
",",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"length",
")",
")",
",",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"infoLog",
")",
")",
",",
"0",
",",
"0",
")",
"\n",
"}"
] |
4,275 | all-4276 | [
"delete",
"named",
"sampler",
"objects"
] | [
"func",
"DeleteSamplers",
"(",
"<mask>",
"int32",
",",
"samplers",
"*",
"uint32",
")",
"{",
"syscall",
".",
"Syscall",
"(",
"gpDeleteSamplers",
",",
"2",
",",
"uintptr",
"(",
"count",
")",
",",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"samplers",
")",
")",
",",
"0",
")",
"\n",
"}"
] |
4,276 | all-4277 | [
"wsHandler",
"handles",
"incoming",
"websocket",
"connections",
"."
] | [
"func",
"(",
"s",
"*",
"Server",
")",
"wsConnHandler",
"(",
"<mask>",
"*",
"websocket",
".",
"Conn",
")",
"{",
"c",
",",
"err",
":=",
"NewConn",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"defer",
"recoverAndLog",
"(",
"c",
",",
"&",
"s",
".",
"wg",
")",
"\n",
"c",
".",
"MiddlewareFunc",
"(",
"s",
".",
"middleware",
"...",
")",
"\n\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
",",
"ws",
".",
"RemoteAddr",
"(",
")",
")",
"\n\n",
"s",
".",
"conns",
".",
"Set",
"(",
"c",
".",
"ID",
",",
"c",
")",
"\n",
"connsCounter",
".",
"Add",
"(",
"1",
")",
"\n",
"c",
".",
"setConn",
"(",
"ws",
")",
"\n",
"c",
".",
"startReceive",
"(",
")",
"\n",
"s",
".",
"conns",
".",
"Delete",
"(",
"c",
".",
"ID",
")",
"\n",
"connsCounter",
".",
"Add",
"(",
"-",
"1",
")",
"\n",
"s",
".",
"disconnHandler",
"(",
"c",
")",
"\n",
"}"
] |
4,277 | all-4278 | [
"title",
":",
"service",
"doc",
"path",
":",
"/",
"services",
"/",
"{",
"name",
"}",
"/",
"doc",
"method",
":",
"GET",
"responses",
":",
"200",
":",
"OK",
"401",
":",
"Unauthorized",
"404",
":",
"Not",
"found"
] | [
"func",
"serviceDoc",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"t",
"auth",
".",
"Token",
")",
"error",
"{",
"serviceName",
":=",
"r",
".",
"<mask>",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"s",
",",
"err",
":=",
"getService",
"(",
"serviceName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"s",
".",
"IsRestricted",
"{",
"allowed",
":=",
"permission",
".",
"Check",
"(",
"t",
",",
"permission",
".",
"PermServiceReadDoc",
",",
"contextsForService",
"(",
"&",
"s",
")",
"...",
",",
")",
"\n",
"if",
"!",
"allowed",
"{",
"return",
"permission",
".",
"ErrUnauthorized",
"\n",
"}",
"\n",
"}",
"\n",
"w",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"s",
".",
"Doc",
")",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
4,278 | all-4279 | [
"RadioButtonNewWithLabel",
"is",
"a",
"wrapper",
"around",
"gtk_radio_button_new_with_label",
"()",
"."
] | [
"func",
"RadioButtonNewWithLabel",
"(",
"group",
"*",
"glib",
".",
"SList",
",",
"label",
"string",
")",
"(",
"*",
"RadioButton",
",",
"error",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"label",
")",
"\n",
"defer",
"C",
".",
"<mask>",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"c",
":=",
"C",
".",
"gtk_radio_button_new_with_label",
"(",
"cGSList",
"(",
"group",
")",
",",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"return",
"wrapRadioButton",
"(",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
")",
",",
"nil",
"\n",
"}"
] |
4,279 | all-4280 | [
"NewSidecarAPIServer",
"creates",
"an",
"APIServer",
"that",
"has",
"limited",
"functionalities",
"and",
"is",
"meant",
"to",
"be",
"run",
"as",
"a",
"worker",
"sidecar",
".",
"It",
"cannot",
"for",
"instance",
"create",
"pipelines",
"."
] | [
"func",
"NewSidecarAPIServer",
"(",
"env",
"*",
"serviceenv",
".",
"ServiceEnv",
",",
"etcdPrefix",
"string",
",",
"iamRole",
"string",
",",
"reporter",
"*",
"metrics",
".",
"Reporter",
",",
"workerGrpcPort",
"uint16",
",",
"pprofPort",
"uint16",
",",
"httpPort",
"uint16",
",",
"peerPort",
"uint16",
",",
")",
"(",
"ppsclient",
".",
"APIServer",
",",
"error",
")",
"{",
"apiServer",
":=",
"&",
"apiServer",
"{",
"Logger",
":",
"<mask>",
".",
"NewLogger",
"(",
"\"",
"\"",
")",
",",
"env",
":",
"env",
",",
"etcdPrefix",
":",
"etcdPrefix",
",",
"iamRole",
":",
"iamRole",
",",
"reporter",
":",
"reporter",
",",
"workerUsesRoot",
":",
"true",
",",
"pipelines",
":",
"ppsdb",
".",
"Pipelines",
"(",
"env",
".",
"GetEtcdClient",
"(",
")",
",",
"etcdPrefix",
")",
",",
"jobs",
":",
"ppsdb",
".",
"Jobs",
"(",
"env",
".",
"GetEtcdClient",
"(",
")",
",",
"etcdPrefix",
")",
",",
"workerGrpcPort",
":",
"workerGrpcPort",
",",
"pprofPort",
":",
"pprofPort",
",",
"httpPort",
":",
"httpPort",
",",
"peerPort",
":",
"peerPort",
",",
"}",
"\n",
"return",
"apiServer",
",",
"nil",
"\n",
"}"
] |
4,280 | all-4281 | [
"map",
"all",
"of",
"a",
"buffer",
"object",
"s",
"data",
"store",
"into",
"the",
"client",
"s",
"address",
"space"
] | [
"func",
"MapBuffer",
"(",
"target",
"uint32",
",",
"access",
"uint32",
")",
"unsafe",
".",
"Pointer",
"{",
"<mask>",
",",
"_",
",",
"_",
":=",
"syscall",
".",
"Syscall",
"(",
"gpMapBuffer",
",",
"2",
",",
"uintptr",
"(",
"target",
")",
",",
"uintptr",
"(",
"access",
")",
",",
"0",
")",
"\n",
"return",
"(",
"unsafe",
".",
"Pointer",
")",
"(",
"ret",
")",
"\n",
"}"
] |
4,281 | all-4282 | [
"PathTransform",
"scales",
"a",
"path",
"differently",
"in",
"horizontal",
"and",
"vertical",
"direction",
"."
] | [
"func",
"PathTransform",
"(",
"gc",
"draw2d",
".",
"GraphicContext",
",",
"x",
",",
"y",
",",
"<mask>",
",",
"height",
"float64",
")",
"{",
"gc",
".",
"Save",
"(",
")",
"\n",
"gc",
".",
"SetLineWidth",
"(",
"width",
"/",
"10",
")",
"\n",
"gc",
".",
"Translate",
"(",
"x",
"+",
"width",
"/",
"2",
",",
"y",
"+",
"height",
"/",
"2",
")",
"\n",
"gc",
".",
"Scale",
"(",
"1",
",",
"4",
")",
"\n",
"gc",
".",
"ArcTo",
"(",
"0",
",",
"0",
",",
"width",
"/",
"8",
",",
"height",
"/",
"8",
",",
"0",
",",
"math",
".",
"Pi",
"*",
"2",
")",
"\n",
"gc",
".",
"Close",
"(",
")",
"\n",
"gc",
".",
"Stroke",
"(",
")",
"\n",
"gc",
".",
"Restore",
"(",
")",
"\n",
"}"
] |
4,282 | all-4283 | [
"borrowed",
"from",
"cespare"
] | [
"func",
"round64",
"(",
"h",
",",
"v",
"uint64",
")",
"uint64",
"{",
"h",
"+=",
"v",
"*",
"prime64x2",
"\n",
"h",
"=",
"rotl64_31",
"(",
"h",
")",
"\n",
"h",
"*=",
"prime64x1",
"\n",
"<mask>",
"h",
"\n",
"}"
] |
4,283 | all-4284 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"UndoParams",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoDom",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
4,284 | all-4285 | [
"isMain",
"returns",
"whether",
"the",
"given",
"function",
"declaration",
"is",
"a",
"main",
"function",
".",
"Such",
"a",
"function",
"must",
"be",
"called",
"main",
"not",
"have",
"a",
"receiver",
"and",
"have",
"no",
"arguments",
"or",
"return",
"types",
"."
] | [
"func",
"isMain",
"(",
"f",
"*",
"ast",
".",
"FuncDecl",
")",
"bool",
"{",
"ft",
":=",
"f",
".",
"Type",
"\n",
"return",
"f",
".",
"Name",
".",
"<mask>",
"==",
"\"",
"\"",
"&&",
"f",
".",
"Recv",
"==",
"nil",
"&&",
"ft",
".",
"Params",
".",
"NumFields",
"(",
")",
"==",
"0",
"&&",
"ft",
".",
"Results",
".",
"NumFields",
"(",
")",
"==",
"0",
"\n",
"}"
] |
4,285 | all-4286 | [
"DefaultGrantStrategy",
"grants",
"only",
"empty",
"scopes",
"."
] | [
"func",
"DefaultGrantStrategy",
"(",
"scope",
"oauth2",
".",
"Scope",
",",
"_",
"<mask>",
",",
"_",
"ResourceOwner",
")",
"(",
"oauth2",
".",
"Scope",
",",
"error",
")",
"{",
"// check scope",
"if",
"!",
"scope",
".",
"Empty",
"(",
")",
"{",
"return",
"nil",
",",
"ErrInvalidScope",
"\n",
"}",
"\n\n",
"return",
"scope",
",",
"nil",
"\n",
"}"
] |
4,286 | all-4287 | [
"NewDeriveScale",
"creates",
"a",
"new",
"derive",
"instruments",
"with",
"the",
"given",
"unit",
"."
] | [
"func",
"NewDeriveScale",
"(",
"v",
"float64",
",",
"d",
"time",
".",
"Duration",
")",
"*",
"Derive",
"{",
"return",
"&",
"Derive",
"{",
"value",
":",
"math",
".",
"Float64bits",
"(",
"v",
")",
",",
"<mask>",
":",
"Rate",
"{",
"time",
":",
"time",
".",
"Now",
"(",
")",
".",
"UnixNano",
"(",
")",
",",
"unit",
":",
"d",
".",
"Seconds",
"(",
")",
",",
"}",
",",
"}",
"\n",
"}"
] |
4,287 | all-4288 | [
"The",
"assumption",
"that",
"bucket",
"counts",
"increase",
"monotonically",
"with",
"increasing",
"upperBound",
"may",
"be",
"violated",
"during",
":",
"*",
"Recording",
"rule",
"evaluation",
"of",
"histogram_quantile",
"especially",
"when",
"rate",
"()",
"has",
"been",
"applied",
"to",
"the",
"underlying",
"bucket",
"timeseries",
".",
"*",
"Evaluation",
"of",
"histogram_quantile",
"computed",
"over",
"federated",
"bucket",
"timeseries",
"especially",
"when",
"rate",
"()",
"has",
"been",
"applied",
".",
"This",
"is",
"because",
"scraped",
"data",
"is",
"not",
"made",
"available",
"to",
"rule",
"evaluation",
"or",
"federation",
"atomically",
"so",
"some",
"buckets",
"are",
"computed",
"with",
"data",
"from",
"the",
"most",
"recent",
"scrapes",
"but",
"the",
"other",
"buckets",
"are",
"missing",
"data",
"from",
"the",
"most",
"recent",
"scrape",
".",
"Monotonicity",
"is",
"usually",
"guaranteed",
"because",
"if",
"a",
"bucket",
"with",
"upper",
"bound",
"u1",
"has",
"count",
"c1",
"then",
"any",
"bucket",
"with",
"a",
"higher",
"upper",
"bound",
"u",
">",
"u1",
"must",
"have",
"counted",
"all",
"c1",
"observations",
"and",
"perhaps",
"more",
"so",
"that",
"c",
">",
"=",
"c1",
".",
"Randomly",
"interspersed",
"partial",
"sampling",
"breaks",
"that",
"guarantee",
"and",
"rate",
"()",
"exacerbates",
"it",
".",
"Specifically",
"suppose",
"bucket",
"le",
"=",
"1000",
"has",
"a",
"count",
"of",
"10",
"from",
"4",
"samples",
"but",
"the",
"bucket",
"with",
"le",
"=",
"2000",
"has",
"a",
"count",
"of",
"7",
"from",
"3",
"samples",
".",
"The",
"monotonicity",
"is",
"broken",
".",
"It",
"is",
"exacerbated",
"by",
"rate",
"()",
"because",
"under",
"normal",
"operation",
"cumulative",
"counting",
"of",
"buckets",
"will",
"cause",
"the",
"bucket",
"counts",
"to",
"diverge",
"such",
"that",
"small",
"differences",
"from",
"missing",
"samples",
"are",
"not",
"a",
"problem",
".",
"rate",
"()",
"removes",
"this",
"divergence",
".",
")",
"bucketQuantile",
"depends",
"on",
"that",
"monotonicity",
"to",
"do",
"a",
"binary",
"search",
"for",
"the",
"bucket",
"with",
"the",
"φ",
"-",
"quantile",
"count",
"so",
"breaking",
"the",
"monotonicity",
"guarantee",
"causes",
"bucketQuantile",
"()",
"to",
"return",
"undefined",
"(",
"nonsense",
")",
"results",
".",
"As",
"a",
"somewhat",
"hacky",
"solution",
"until",
"ingestion",
"is",
"atomic",
"per",
"scrape",
"we",
"calculate",
"the",
"envelope",
"of",
"the",
"histogram",
"buckets",
"essentially",
"removing",
"any",
"decreases",
"in",
"the",
"count",
"between",
"successive",
"buckets",
"."
] | [
"func",
"ensureMonotonic",
"(",
"buckets",
"buckets",
")",
"{",
"max",
":=",
"buckets",
"[",
"0",
"]",
".",
"count",
"\n",
"for",
"i",
":=",
"range",
"buckets",
"[",
"1",
":",
"]",
"{",
"switch",
"{",
"case",
"buckets",
"[",
"i",
"]",
".",
"count",
">",
"max",
":",
"max",
"=",
"buckets",
"[",
"i",
"]",
".",
"count",
"\n",
"case",
"buckets",
"[",
"i",
"]",
".",
"count",
"<",
"max",
":",
"buckets",
"[",
"i",
"]",
".",
"count",
"=",
"<mask>",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
4,288 | all-4289 | [
"ZeroValue",
"returns",
"the",
"literal",
"representing",
"the",
"zero",
"value",
"for",
"this",
"field",
".",
"The",
"type",
"code",
"of",
"the",
"field",
"must",
"be",
"TypeColumn",
"."
] | [
"func",
"(",
"f",
"*",
"Field",
")",
"ZeroValue",
"(",
")",
"string",
"{",
"if",
"f",
".",
"Type",
".",
"Code",
"!=",
"TypeColumn",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"switch",
"f",
".",
"Type",
".",
"Name",
"{",
"case",
"\"",
"\"",
":",
"return",
"`\"\"`",
"\n",
"<mask>",
"\"",
"\"",
":",
"// FIXME: we use -1 since at the moment integer criteria are",
"// required to be positive.",
"return",
"\"",
"\"",
"\n",
"default",
":",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] |
4,289 | all-4290 | [
"FillString",
"draws",
"a",
"filled",
"and",
"stroked",
"string",
".",
"And",
"filles",
"/",
"stroked",
"path",
"created",
"from",
"string",
".",
"Which",
"may",
"have",
"different",
"-",
"unselectable",
"-",
"output",
"in",
"non",
"raster",
"gc",
"implementations",
"."
] | [
"func",
"FillString",
"(",
"gc",
"draw2d",
".",
"GraphicContext",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
"float64",
")",
"{",
"sx",
",",
"sy",
":=",
"width",
"/",
"100",
",",
"height",
"/",
"100",
"\n",
"gc",
".",
"Save",
"(",
")",
"\n",
"gc",
".",
"SetStrokeColor",
"(",
"image",
".",
"Black",
")",
"\n",
"gc",
".",
"SetLineWidth",
"(",
"1",
")",
"\n",
"draw2dkit",
".",
"RoundedRectangle",
"(",
"gc",
",",
"x",
"+",
"sx",
"*",
"5",
",",
"y",
"+",
"sy",
"*",
"5",
",",
"x",
"+",
"sx",
"*",
"95",
",",
"y",
"+",
"sy",
"*",
"95",
",",
"sx",
"*",
"10",
",",
"sy",
"*",
"10",
")",
"\n",
"gc",
".",
"FillStroke",
"(",
")",
"\n",
"gc",
".",
"SetFillColor",
"(",
"image",
".",
"Black",
")",
"\n",
"gc",
".",
"SetFontSize",
"(",
"height",
"/",
"6",
")",
"\n",
"gc",
".",
"Translate",
"(",
"x",
"+",
"sx",
"*",
"6",
",",
"y",
"+",
"sy",
"*",
"52",
")",
"\n",
"gc",
".",
"SetFontData",
"(",
"draw2d",
".",
"FontData",
"{",
"Name",
":",
"\"",
"\"",
",",
"Family",
":",
"draw2d",
".",
"FontFamilyMono",
",",
"Style",
":",
"draw2d",
".",
"FontStyleBold",
"|",
"draw2d",
".",
"FontStyleItalic",
",",
"}",
")",
"\n",
"w",
":=",
"gc",
".",
"FillString",
"(",
"\"",
"\"",
")",
"\n",
"gc",
".",
"Translate",
"(",
"w",
"+",
"sx",
",",
"0",
")",
"\n",
"left",
",",
"top",
",",
"right",
",",
"bottom",
":=",
"gc",
".",
"GetStringBounds",
"(",
"\"",
"\"",
")",
"\n",
"gc",
".",
"SetStrokeColor",
"(",
"color",
".",
"NRGBA",
"{",
"255",
",",
"0x33",
",",
"0x33",
",",
"0x80",
"}",
")",
"\n",
"draw2dkit",
".",
"Rectangle",
"(",
"gc",
",",
"<mask>",
",",
"top",
",",
"right",
",",
"bottom",
")",
"\n",
"gc",
".",
"SetLineWidth",
"(",
"height",
"/",
"50",
")",
"\n",
"gc",
".",
"Stroke",
"(",
")",
"\n",
"gc",
".",
"SetFillColor",
"(",
"color",
".",
"NRGBA",
"{",
"0x33",
",",
"0x33",
",",
"0xff",
",",
"0xff",
"}",
")",
"\n",
"gc",
".",
"SetStrokeColor",
"(",
"color",
".",
"NRGBA",
"{",
"0x33",
",",
"0x33",
",",
"0xff",
",",
"0xff",
"}",
")",
"\n",
"gc",
".",
"SetLineWidth",
"(",
"height",
"/",
"100",
")",
"\n",
"gc",
".",
"StrokeString",
"(",
"\"",
"\"",
")",
"\n\n",
"gc",
".",
"Translate",
"(",
"-",
"(",
"w",
"+",
"sx",
")",
",",
"sy",
"*",
"24",
")",
"\n",
"w",
"=",
"gc",
".",
"CreateStringPath",
"(",
"\"",
"\"",
",",
"0",
",",
"0",
")",
"\n",
"gc",
".",
"Fill",
"(",
")",
"\n",
"gc",
".",
"Translate",
"(",
"w",
"+",
"sx",
",",
"0",
")",
"\n",
"gc",
".",
"CreateStringPath",
"(",
"\"",
"\"",
",",
"0",
",",
"0",
")",
"\n",
"path",
":=",
"gc",
".",
"GetPath",
"(",
")",
"\n",
"gc",
".",
"Stroke",
"(",
"(",
"&",
"path",
")",
".",
"VerticalFlip",
"(",
")",
")",
"\n",
"gc",
".",
"Restore",
"(",
")",
"\n",
"}"
] |
4,290 | all-4291 | [
"scrollLine",
"scrolls",
"a",
"line",
"horizontally",
"starting",
"at",
"the",
"provided",
"position",
"by",
"a",
"number",
"of",
"columns",
"."
] | [
"func",
"(",
"h",
"*",
"windowsAnsiEventHandler",
")",
"scrollLine",
"(",
"columns",
"int",
",",
"position",
"COORD",
",",
"info",
"*",
"CONSOLE_SCREEN_BUFFER_INFO",
")",
"error",
"{",
"// Copy from and clip to the scroll region (full buffer width)",
"scrollRect",
":=",
"SMALL_RECT",
"{",
"Top",
":",
"position",
".",
"Y",
",",
"Bottom",
":",
"position",
".",
"Y",
",",
"Left",
":",
"position",
".",
"X",
",",
"Right",
":",
"info",
".",
"Size",
".",
"X",
"-",
"1",
",",
"}",
"\n\n",
"// Origin to which area should be copied",
"destOrigin",
":=",
"COORD",
"{",
"X",
":",
"position",
".",
"X",
"-",
"int16",
"(",
"columns",
")",
",",
"Y",
":",
"<mask>",
".",
"Y",
",",
"}",
"\n\n",
"char",
":=",
"CHAR_INFO",
"{",
"UnicodeChar",
":",
"' '",
",",
"Attributes",
":",
"h",
".",
"attributes",
",",
"}",
"\n\n",
"if",
"err",
":=",
"ScrollConsoleScreenBuffer",
"(",
"h",
".",
"fd",
",",
"scrollRect",
",",
"scrollRect",
",",
"destOrigin",
",",
"char",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
4,291 | all-4292 | [
"LastScrape",
"returns",
"the",
"time",
"of",
"the",
"last",
"scrape",
"."
] | [
"func",
"(",
"t",
"*",
"Target",
")",
"LastScrape",
"(",
")",
"<mask>",
".",
"Time",
"{",
"t",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"t",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"t",
".",
"lastScrape",
"\n",
"}"
] |
4,292 | all-4293 | [
"Log",
"writes",
"std",
"log",
"event"
] | [
"func",
"<mask>",
"(",
"val",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"glg",
".",
"out",
"(",
"LOG",
",",
"blankFormat",
"(",
"len",
"(",
"val",
")",
")",
",",
"val",
"...",
")",
"\n",
"}"
] |
4,293 | all-4294 | [
"isZero",
"returns",
"true",
"iff",
"the",
"global",
"config",
"is",
"the",
"zero",
"value",
"."
] | [
"func",
"(",
"c",
"*",
"GlobalConfig",
")",
"isZero",
"(",
")",
"bool",
"{",
"<mask>",
"c",
".",
"ExternalLabels",
"==",
"nil",
"&&",
"c",
".",
"ScrapeInterval",
"==",
"0",
"&&",
"c",
".",
"ScrapeTimeout",
"==",
"0",
"&&",
"c",
".",
"EvaluationInterval",
"==",
"0",
"\n",
"}"
] |
4,294 | all-4295 | [
"GetLayoutOk",
"returns",
"a",
"tuple",
"with",
"the",
"Layout",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"b",
"*",
"BoardWidget",
")",
"GetLayoutOk",
"(",
")",
"(",
"WidgetLayout",
",",
"bool",
")",
"{",
"if",
"b",
"==",
"nil",
"||",
"b",
".",
"Layout",
"==",
"nil",
"{",
"return",
"WidgetLayout",
"{",
"}",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"b",
".",
"Layout",
",",
"<mask>",
"\n",
"}"
] |
4,295 | all-4296 | [
"New",
"returns",
"a",
"MockTracer",
"opentracing",
".",
"Tracer",
"implementation",
"that",
"s",
"intended",
"to",
"facilitate",
"tests",
"of",
"OpenTracing",
"instrumentation",
"."
] | [
"func",
"New",
"(",
")",
"*",
"MockTracer",
"{",
"t",
":=",
"&",
"MockTracer",
"{",
"finishedSpans",
":",
"[",
"]",
"*",
"MockSpan",
"{",
"}",
",",
"injectors",
":",
"make",
"(",
"map",
"[",
"interface",
"{",
"}",
"]",
"Injector",
")",
",",
"extractors",
":",
"<mask>",
"(",
"map",
"[",
"interface",
"{",
"}",
"]",
"Extractor",
")",
",",
"}",
"\n\n",
"// register default injectors/extractors",
"textPropagator",
":=",
"new",
"(",
"TextMapPropagator",
")",
"\n",
"t",
".",
"RegisterInjector",
"(",
"opentracing",
".",
"TextMap",
",",
"textPropagator",
")",
"\n",
"t",
".",
"RegisterExtractor",
"(",
"opentracing",
".",
"TextMap",
",",
"textPropagator",
")",
"\n\n",
"httpPropagator",
":=",
"&",
"TextMapPropagator",
"{",
"HTTPHeaders",
":",
"true",
"}",
"\n",
"t",
".",
"RegisterInjector",
"(",
"opentracing",
".",
"HTTPHeaders",
",",
"httpPropagator",
")",
"\n",
"t",
".",
"RegisterExtractor",
"(",
"opentracing",
".",
"HTTPHeaders",
",",
"httpPropagator",
")",
"\n\n",
"return",
"t",
"\n",
"}"
] |
4,296 | all-4297 | [
"DeleteBoard",
"deletes",
"a",
"dashboard",
"by",
"the",
"identifier",
"."
] | [
"func",
"(",
"client",
"*",
"Client",
")",
"DeleteBoard",
"(",
"id",
"string",
")",
"error",
"{",
"return",
"client",
".",
"doJsonRequest",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"<mask>",
")",
",",
"nil",
",",
"nil",
")",
"\n",
"}"
] |
4,297 | all-4298 | [
"GetStoragePool",
"returns",
"a",
"StoragePool",
"entry",
"for",
"the",
"provided",
"pool",
"name"
] | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"GetStoragePool",
"(",
"name",
"string",
")",
"(",
"*",
"api",
".",
"StoragePool",
",",
"string",
",",
"error",
")",
"{",
"if",
"!",
"r",
".",
"HasExtension",
"(",
"\"",
"\"",
")",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"pool",
":=",
"api",
".",
"StoragePool",
"{",
"}",
"\n\n",
"// Fetch the raw value",
"etag",
",",
"err",
":=",
"r",
".",
"queryStruct",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"<mask>",
".",
"QueryEscape",
"(",
"name",
")",
")",
",",
"nil",
",",
"\"",
"\"",
",",
"&",
"pool",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"pool",
",",
"etag",
",",
"nil",
"\n",
"}"
] |
4,298 | all-4299 | [
"Send",
"sends",
"the",
"request",
"and",
"return",
"the",
"response",
"."
] | [
"func",
"(",
"r",
"*",
"RequestBuilder",
")",
"Send",
"(",
"ctx",
"<mask>",
".",
"Context",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"req",
":=",
"NewRequest",
"(",
"ctx",
",",
"r",
".",
"shell",
".",
"url",
",",
"r",
".",
"command",
",",
"r",
".",
"args",
"...",
")",
"\n",
"req",
".",
"Opts",
"=",
"r",
".",
"opts",
"\n",
"req",
".",
"Headers",
"=",
"r",
".",
"headers",
"\n",
"req",
".",
"Body",
"=",
"r",
".",
"body",
"\n",
"return",
"req",
".",
"Send",
"(",
"&",
"r",
".",
"shell",
".",
"httpcli",
")",
"\n",
"}"
] |
4,299 | all-4300 | [
"GetURL",
"returns",
"a",
"URL",
"that",
"can",
"be",
"retrieved",
"to",
"download",
"the",
"given",
"image",
"."
] | [
"func",
"(",
"m",
"*",
"MediaService",
")",
"GetURL",
"(",
"ctx",
"context",
".",
"Context",
",",
"messageSid",
"string",
",",
"sid",
"string",
")",
"(",
"*",
"url",
".",
"URL",
",",
"error",
")",
"{",
"uriEnd",
":=",
"strings",
".",
"Join",
"(",
"[",
"]",
"string",
"{",
"mediaPathPart",
"(",
"messageSid",
")",
",",
"sid",
"}",
",",
"\"",
"\"",
")",
"\n",
"path",
":=",
"m",
".",
"client",
".",
"FullPath",
"(",
"uriEnd",
")",
"\n",
"// We want the media, not the .json representation",
"if",
"strings",
".",
"HasSuffix",
"(",
"path",
",",
"\"",
"\"",
")",
"{",
"path",
"=",
"path",
"[",
":",
"len",
"(",
"path",
")",
"-",
"len",
"(",
"\"",
"\"",
")",
"]",
"\n",
"}",
"\n",
"urlStr",
":=",
"m",
".",
"client",
".",
"Client",
".",
"Base",
"+",
"path",
"\n",
"count",
":=",
"0",
"\n",
"for",
"{",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"urlStr",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"req",
"=",
"withContext",
"(",
"req",
",",
"ctx",
")",
"\n",
"req",
".",
"SetBasicAuth",
"(",
"m",
".",
"client",
".",
"AccountSid",
",",
"m",
".",
"client",
".",
"AuthToken",
")",
"\n",
"req",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"userAgent",
")",
"\n",
"if",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"==",
"\"",
"\"",
"||",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"==",
"\"",
"\"",
"{",
"b",
":=",
"<mask>",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"bits",
",",
"_",
":=",
"httputil",
".",
"DumpRequestOut",
"(",
"req",
",",
"true",
")",
"\n",
"if",
"len",
"(",
"bits",
")",
">",
"0",
"&&",
"bits",
"[",
"len",
"(",
"bits",
")",
"-",
"1",
"]",
"!=",
"'\\n'",
"{",
"bits",
"=",
"append",
"(",
"bits",
",",
"'\\n'",
")",
"\n",
"}",
"\n",
"b",
".",
"Write",
"(",
"bits",
")",
"\n",
"io",
".",
"Copy",
"(",
"os",
".",
"Stderr",
",",
"b",
")",
"\n",
"}",
"\n",
"resp",
",",
"err",
":=",
"MediaClient",
".",
"Do",
"(",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"==",
"\"",
"\"",
"||",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"==",
"\"",
"\"",
"{",
"b",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"bits",
",",
"_",
":=",
"httputil",
".",
"DumpResponse",
"(",
"resp",
",",
"true",
")",
"\n",
"if",
"len",
"(",
"bits",
")",
">",
"0",
"&&",
"bits",
"[",
"len",
"(",
"bits",
")",
"-",
"1",
"]",
"!=",
"'\\n'",
"{",
"bits",
"=",
"append",
"(",
"bits",
",",
"'\\n'",
")",
"\n",
"}",
"\n",
"b",
".",
"Write",
"(",
"bits",
")",
"\n",
"io",
".",
"Copy",
"(",
"os",
".",
"Stderr",
",",
"b",
")",
"\n",
"}",
"else",
"{",
"io",
".",
"Copy",
"(",
"ioutil",
".",
"Discard",
",",
"resp",
".",
"Body",
")",
"\n",
"}",
"\n\n",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"// This is brittle because we need to detect/rewrite the S3 URL.",
"// I don't want to hard code a S3 URL but we have to do some",
"// substitution.",
"location",
":=",
"resp",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"location",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"location",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"strings",
".",
"Contains",
"(",
"u",
".",
"Host",
",",
"\"",
"\"",
")",
"&&",
"strings",
".",
"Count",
"(",
"u",
".",
"Host",
",",
"\"",
"\"",
")",
"==",
"2",
"&&",
"u",
".",
"Scheme",
"==",
"\"",
"\"",
"{",
"return",
"u",
",",
"nil",
"\n",
"}",
"\n",
"if",
"strings",
".",
"Contains",
"(",
"u",
".",
"Host",
",",
"\"",
"\"",
")",
"&&",
"strings",
".",
"Contains",
"(",
"u",
".",
"Host",
",",
"\"",
"\"",
")",
"{",
"// This is the URL we can use to download the content. The URL that",
"// Twilio gives us back is insecure and uses HTTP. Rewrite it to",
"// use the HTTPS path-based URL scheme.",
"//",
"// https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html",
"if",
"u",
".",
"Scheme",
"==",
"\"",
"\"",
"{",
"u",
".",
"Host",
"=",
"strings",
".",
"Replace",
"(",
"u",
".",
"Host",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"1",
")",
"\n",
"u",
".",
"Path",
"=",
"\"",
"\"",
"+",
"u",
".",
"Path",
"\n",
"u",
".",
"Scheme",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"u",
",",
"nil",
"\n",
"}",
"\n",
"count",
"++",
"\n",
"if",
"count",
">",
"5",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"urlStr",
"=",
"location",
"\n",
"}",
"\n",
"}"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.