id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
listlengths 1
418
| pl_tokens
listlengths 22
4.98k
|
---|---|---|---|
21,000 | all-21001 | [
"NodeIsOutdated",
"returns",
"true",
"if",
"there",
"s",
"some",
"cluster",
"node",
"having",
"an",
"API",
"or",
"schema",
"version",
"greater",
"than",
"the",
"node",
"this",
"method",
"is",
"invoked",
"on",
"."
] | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"NodeIsOutdated",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"nodes",
",",
"err",
":=",
"c",
".",
"nodes",
"(",
"false",
"/* not pending */",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Figure our own version.",
"version",
":=",
"[",
"2",
"]",
"int",
"{",
"}",
"\n",
"for",
"_",
",",
"node",
":=",
"range",
"nodes",
"{",
"if",
"node",
".",
"ID",
"==",
"c",
".",
"nodeID",
"{",
"version",
"=",
"node",
".",
"Version",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"version",
"[",
"0",
"]",
"==",
"0",
"||",
"<mask>",
"[",
"1",
"]",
"==",
"0",
"{",
"return",
"false",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Check if any of the other nodes is greater than us.",
"for",
"_",
",",
"node",
":=",
"range",
"nodes",
"{",
"if",
"node",
".",
"ID",
"==",
"c",
".",
"nodeID",
"{",
"continue",
"\n",
"}",
"\n",
"n",
",",
"err",
":=",
"util",
".",
"CompareVersions",
"(",
"node",
".",
"Version",
"(",
")",
",",
"version",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"node",
".",
"Name",
")",
"\n",
"}",
"\n\n",
"if",
"n",
"==",
"1",
"{",
"// The other node's version is greater than ours.",
"return",
"true",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"false",
",",
"nil",
"\n",
"}"
] |
21,001 | all-21002 | [
"Send",
"sends",
"a",
"message",
".",
"If",
"any",
"failures",
"occur",
"with",
"specific",
"recipients",
"the",
"error",
"will",
"be",
"an",
"appengine",
".",
"MultiError",
"."
] | [
"func",
"(",
"m",
"*",
"Message",
")",
"Send",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"req",
":=",
"&",
"pb",
".",
"XmppMessageRequest",
"{",
"Jid",
":",
"m",
".",
"To",
",",
"Body",
":",
"&",
"m",
".",
"Body",
",",
"RawXml",
":",
"&",
"m",
".",
"RawXML",
",",
"}",
"\n",
"if",
"m",
".",
"Type",
"!=",
"\"",
"\"",
"&&",
"m",
".",
"Type",
"!=",
"\"",
"\"",
"{",
"req",
".",
"Type",
"=",
"&",
"m",
".",
"Type",
"\n",
"}",
"\n",
"if",
"m",
".",
"Sender",
"!=",
"\"",
"\"",
"{",
"req",
".",
"FromJid",
"=",
"&",
"m",
".",
"Sender",
"\n",
"}",
"\n",
"res",
":=",
"&",
"pb",
".",
"XmppMessageResponse",
"{",
"}",
"\n",
"if",
"err",
":=",
"internal",
".",
"Call",
"(",
"c",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"req",
",",
"res",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
".",
"Status",
")",
"!=",
"len",
"(",
"req",
".",
"Jid",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"len",
"(",
"req",
".",
"Jid",
")",
",",
"len",
"(",
"res",
".",
"Status",
")",
")",
"\n",
"}",
"\n",
"me",
",",
"any",
":=",
"make",
"(",
"appengine",
".",
"MultiError",
",",
"len",
"(",
"req",
".",
"Jid",
")",
")",
",",
"false",
"\n",
"for",
"i",
",",
"st",
":=",
"range",
"res",
".",
"Status",
"{",
"if",
"st",
"!=",
"pb",
".",
"XmppMessageResponse_NO_ERROR",
"{",
"me",
"[",
"i",
"]",
"=",
"<mask>",
".",
"New",
"(",
"st",
".",
"String",
"(",
")",
")",
"\n",
"any",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"any",
"{",
"return",
"me",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
21,002 | all-21003 | [
"Equal",
"checks",
"equality",
"of",
"two",
"values",
"."
] | [
"func",
"Equal",
"(",
"tb",
"testing",
".",
"TB",
",",
"expected",
"interface",
"{",
"}",
",",
"actual",
"interface",
"{",
"}",
",",
"msgAndArgs",
"...",
"interface",
"{",
"}",
")",
"{",
"tb",
".",
"Helper",
"(",
")",
"\n",
"eV",
",",
"aV",
":=",
"reflect",
".",
"ValueOf",
"(",
"expected",
")",
",",
"reflect",
".",
"ValueOf",
"(",
"actual",
")",
"\n",
"if",
"eV",
".",
"Type",
"(",
")",
"!=",
"aV",
".",
"Type",
"(",
")",
"{",
"fatal",
"(",
"tb",
",",
"msgAndArgs",
",",
"\"",
"\\n",
"\"",
"+",
"\"",
"\"",
",",
"expected",
",",
"expected",
",",
"<mask>",
",",
"actual",
")",
"\n",
"}",
"\n",
"if",
"!",
"reflect",
".",
"DeepEqual",
"(",
"expected",
",",
"actual",
")",
"{",
"fatal",
"(",
"tb",
",",
"msgAndArgs",
",",
"\"",
"\\n",
"\"",
"+",
"\"",
"\"",
",",
"expected",
",",
"actual",
")",
"\n",
"}",
"\n",
"}"
] |
21,003 | all-21004 | [
"Delete",
"implements",
"gRPC",
"KVServer",
".",
"Delete",
"deletes",
"the",
"given",
"range",
"from",
"the",
"store",
".",
"A",
"delete",
"request",
"increase",
"the",
"revision",
"of",
"the",
"store",
"and",
"generates",
"one",
"event",
"in",
"the",
"event",
"history",
"."
] | [
"func",
"(",
"s",
"*",
"etcdStore",
")",
"DeleteRange",
"(",
"ctx",
"context",
".",
"<mask>",
",",
"req",
"*",
"etcdserverpb",
".",
"DeleteRangeRequest",
")",
"(",
"*",
"etcdserverpb",
".",
"DeleteRangeResponse",
",",
"error",
")",
"{",
"ireq",
":=",
"etcdserverpb",
".",
"InternalRaftRequest",
"{",
"ID",
":",
"<-",
"s",
".",
"idgen",
",",
"DeleteRange",
":",
"req",
"}",
"\n",
"msgc",
",",
"errc",
",",
"err",
":=",
"s",
".",
"proposeInternalRaftRequest",
"(",
"ireq",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"s",
".",
"cancelInternalRaftRequest",
"(",
"ireq",
")",
"\n",
"return",
"nil",
",",
"ctx",
".",
"Err",
"(",
")",
"\n",
"case",
"msg",
":=",
"<-",
"msgc",
":",
"return",
"msg",
".",
"(",
"*",
"etcdserverpb",
".",
"DeleteRangeResponse",
")",
",",
"nil",
"\n",
"case",
"err",
":=",
"<-",
"errc",
":",
"return",
"nil",
",",
"err",
"\n",
"case",
"<-",
"s",
".",
"quitc",
":",
"return",
"nil",
",",
"errStopped",
"\n",
"}",
"\n",
"}"
] |
21,004 | all-21005 | [
"UnescapeHTML",
"is",
"an",
"alias",
"for",
"html",
".",
"UnescapeString",
"."
] | [
"func",
"UnescapeHTML",
"(",
"s",
"string",
")",
"string",
"{",
"if",
"Verbose",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"<mask>",
".",
"UnescapeString",
"(",
"s",
")",
"\n",
"}"
] |
21,005 | all-21006 | [
"GetUserSpecialDir",
"is",
"a",
"wrapper",
"around",
"g_get_user_special_dir",
"()",
".",
"A",
"non",
"-",
"nil",
"error",
"is",
"returned",
"in",
"the",
"case",
"that",
"g_get_user_special_dir",
"()",
"returns",
"NULL",
"to",
"differentiate",
"between",
"NULL",
"and",
"an",
"empty",
"string",
"."
] | [
"func",
"GetUserSpecialDir",
"(",
"<mask>",
"UserDirectory",
")",
"(",
"string",
",",
"error",
")",
"{",
"c",
":=",
"C",
".",
"g_get_user_special_dir",
"(",
"C",
".",
"GUserDirectory",
"(",
"directory",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"errNilPtr",
"\n",
"}",
"\n",
"return",
"C",
".",
"GoString",
"(",
"(",
"*",
"C",
".",
"char",
")",
"(",
"c",
")",
")",
",",
"nil",
"\n",
"}"
] |
21,006 | all-21007 | [
"InspectFile",
"returns",
"info",
"about",
"a",
"specific",
"file",
"."
] | [
"func",
"(",
"c",
"APIClient",
")",
"InspectFile",
"(",
"repoName",
"string",
",",
"commitID",
"string",
",",
"<mask>",
"string",
")",
"(",
"*",
"pfs",
".",
"FileInfo",
",",
"error",
")",
"{",
"return",
"c",
".",
"inspectFile",
"(",
"repoName",
",",
"commitID",
",",
"path",
")",
"\n",
"}"
] |
21,007 | all-21008 | [
"database",
"connection"
] | [
"func",
"(",
"c",
"*",
"conn",
")",
"PrepareContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"string",
")",
"(",
"stmt",
"driver",
".",
"Stmt",
",",
"err",
"error",
")",
"{",
"if",
"c",
".",
"session",
".",
"IsBad",
"(",
")",
"{",
"return",
"nil",
",",
"driver",
".",
"ErrBadConn",
"\n",
"}",
"\n\n",
"done",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"prepareQuery",
",",
"bulkInsert",
":=",
"checkBulkInsert",
"(",
"<mask>",
")",
"\n",
"var",
"(",
"qt",
"p",
".",
"QueryType",
"\n",
"id",
"uint64",
"\n",
"prmFieldSet",
"*",
"p",
".",
"ParameterFieldSet",
"\n",
"resultFieldSet",
"*",
"p",
".",
"ResultFieldSet",
"\n",
")",
"\n",
"qt",
",",
"id",
",",
"prmFieldSet",
",",
"resultFieldSet",
",",
"err",
"=",
"c",
".",
"session",
".",
"Prepare",
"(",
"prepareQuery",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"goto",
"done",
"\n",
"}",
"\n",
"select",
"{",
"default",
":",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"\n",
"}",
"\n",
"if",
"bulkInsert",
"{",
"stmt",
",",
"err",
"=",
"newBulkInsertStmt",
"(",
"c",
".",
"session",
",",
"prepareQuery",
",",
"id",
",",
"prmFieldSet",
")",
"\n",
"}",
"else",
"{",
"stmt",
",",
"err",
"=",
"newStmt",
"(",
"qt",
",",
"c",
".",
"session",
",",
"prepareQuery",
",",
"id",
",",
"prmFieldSet",
",",
"resultFieldSet",
")",
"\n",
"}",
"\n",
"done",
":",
"close",
"(",
"done",
")",
"\n",
"}",
"(",
")",
"\n\n",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"nil",
",",
"ctx",
".",
"Err",
"(",
")",
"\n",
"case",
"<-",
"done",
":",
"return",
"stmt",
",",
"err",
"\n",
"}",
"\n",
"}"
] |
21,008 | all-21009 | [
"SetChildPacking",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_box_set_child_packing",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Box",
")",
"SetChildPacking",
"(",
"child",
"IWidget",
",",
"expand",
",",
"fill",
"bool",
",",
"padding",
"uint",
",",
"packType",
"PackType",
")",
"{",
"C",
".",
"gtk_box_set_child_packing",
"(",
"v",
".",
"native",
"(",
")",
",",
"child",
".",
"toWidget",
"(",
")",
",",
"gbool",
"(",
"expand",
")",
",",
"gbool",
"(",
"<mask>",
")",
",",
"C",
".",
"guint",
"(",
"padding",
")",
",",
"C",
".",
"GtkPackType",
"(",
"packType",
")",
")",
"\n",
"}"
] |
21,009 | all-21010 | [
"ImageExists",
"returns",
"whether",
"an",
"image",
"with",
"the",
"given",
"fingerprint",
"exists",
"."
] | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ImageExists",
"(",
"project",
"string",
",",
"fingerprint",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"err",
":=",
"c",
".",
"Transaction",
"(",
"func",
"(",
"tx",
"*",
"ClusterTx",
")",
"error",
"{",
"enabled",
",",
"err",
":=",
"<mask>",
".",
"ProjectHasImages",
"(",
"project",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"!",
"enabled",
"{",
"project",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"exists",
"bool",
"\n",
"query",
":=",
"`\nSELECT COUNT(*) > 0\n FROM images\n JOIN projects ON projects.id = images.project_id\n WHERE projects.name = ? AND fingerprint=?\n`",
"\n",
"inargs",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"project",
",",
"fingerprint",
"}",
"\n",
"outargs",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"&",
"exists",
"}",
"\n",
"err",
"=",
"dbQueryRowScan",
"(",
"c",
".",
"db",
",",
"query",
",",
"inargs",
",",
"outargs",
")",
"\n",
"if",
"err",
"==",
"sql",
".",
"ErrNoRows",
"{",
"return",
"exists",
",",
"ErrNoSuchObject",
"\n",
"}",
"\n\n",
"return",
"exists",
",",
"err",
"\n",
"}"
] |
21,010 | all-21011 | [
"Transform",
"is",
"a",
"wrapper",
"around",
"cairo_transform",
"."
] | [
"func",
"(",
"v",
"*",
"<mask>",
")",
"Transform",
"(",
"matrix",
"*",
"Matrix",
")",
"{",
"C",
".",
"cairo_transform",
"(",
"v",
".",
"native",
"(",
")",
",",
"matrix",
".",
"native",
"(",
")",
")",
"\n",
"}"
] |
21,011 | all-21012 | [
"toPB",
"converts",
"an",
"internal",
"watch",
"request",
"structure",
"to",
"its",
"protobuf",
"WatchRequest",
"structure",
"."
] | [
"func",
"(",
"wr",
"*",
"watchRequest",
")",
"toPB",
"(",
")",
"*",
"pb",
".",
"WatchRequest",
"{",
"req",
":=",
"&",
"pb",
".",
"WatchCreateRequest",
"{",
"StartRevision",
":",
"wr",
".",
"rev",
",",
"<mask>",
":",
"[",
"]",
"byte",
"(",
"wr",
".",
"key",
")",
",",
"RangeEnd",
":",
"[",
"]",
"byte",
"(",
"wr",
".",
"end",
")",
",",
"ProgressNotify",
":",
"wr",
".",
"progressNotify",
",",
"Filters",
":",
"wr",
".",
"filters",
",",
"PrevKv",
":",
"wr",
".",
"prevKV",
",",
"Fragment",
":",
"wr",
".",
"fragment",
",",
"}",
"\n",
"cr",
":=",
"&",
"pb",
".",
"WatchRequest_CreateRequest",
"{",
"CreateRequest",
":",
"req",
"}",
"\n",
"return",
"&",
"pb",
".",
"WatchRequest",
"{",
"RequestUnion",
":",
"cr",
"}",
"\n",
"}"
] |
21,012 | all-21013 | [
"IsDeadKey",
"returns",
"true",
"if",
"the",
"pressed",
"key",
"is",
"the",
"first",
"key",
"in",
"the",
"key",
"sequence",
"understood",
"by",
"composer",
".",
"Dead",
"key",
"is",
"never",
"sent",
"to",
"any",
"control"
] | [
"func",
"IsDeadKey",
"(",
"key",
"term",
".",
"Key",
")",
"bool",
"{",
"if",
"key",
"==",
"term",
".",
"KeyCtrlS",
"||",
"key",
"==",
"term",
".",
"KeyCtrlP",
"||",
"key",
"==",
"term",
".",
"KeyCtrlW",
"||",
"key",
"==",
"term",
".",
"KeyCtrlQ",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
21,013 | all-21014 | [
"NextBackOff",
"..."
] | [
"func",
"(",
"b",
"*",
"ConstantBackOff",
")",
"NextBackOff",
"(",
")",
"<mask>",
".",
"Duration",
"{",
"if",
"b",
".",
"MaxElapsedTime",
"!=",
"0",
"&&",
"b",
".",
"GetElapsedTime",
"(",
")",
">",
"b",
".",
"MaxElapsedTime",
"{",
"return",
"Stop",
"\n",
"}",
"\n",
"return",
"b",
".",
"Interval",
"\n",
"}"
] |
21,014 | all-21015 | [
"HasClientX509CertURL",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"i",
"*",
"IntegrationGCPCreateRequest",
")",
"HasClientX509CertURL",
"(",
")",
"bool",
"{",
"if",
"i",
"!=",
"nil",
"&&",
"i",
".",
"ClientX509CertURL",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
21,015 | all-21016 | [
"ContainerListExpanded",
"loads",
"all",
"containers",
"across",
"all",
"projects",
"and",
"expands",
"their",
"config",
"and",
"devices",
"using",
"the",
"profiles",
"they",
"are",
"associated",
"to",
"."
] | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"ContainerListExpanded",
"(",
")",
"(",
"[",
"]",
"Container",
",",
"error",
")",
"{",
"containers",
",",
"err",
":=",
"c",
".",
"ContainerList",
"(",
"ContainerFilter",
"{",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"profiles",
",",
"err",
":=",
"c",
".",
"ProfileList",
"(",
"ProfileFilter",
"{",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Index of all profiles by project and name.",
"profilesByProjectAndName",
":=",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]",
"Profile",
"{",
"}",
"\n",
"for",
"_",
",",
"profile",
":=",
"range",
"profiles",
"{",
"profilesByName",
",",
"ok",
":=",
"profilesByProjectAndName",
"[",
"profile",
".",
"Project",
"]",
"\n",
"if",
"!",
"ok",
"{",
"profilesByName",
"=",
"map",
"[",
"string",
"]",
"Profile",
"{",
"}",
"\n",
"profilesByProjectAndName",
"[",
"profile",
".",
"Project",
"]",
"=",
"profilesByName",
"\n",
"}",
"\n",
"profilesByName",
"[",
"profile",
".",
"Name",
"]",
"=",
"profile",
"\n",
"}",
"\n\n",
"for",
"i",
",",
"container",
":=",
"range",
"containers",
"{",
"profiles",
":=",
"make",
"(",
"[",
"]",
"api",
".",
"Profile",
",",
"len",
"(",
"container",
".",
"Profiles",
")",
")",
"\n",
"for",
"j",
",",
"name",
":=",
"<mask>",
"container",
".",
"Profiles",
"{",
"profile",
":=",
"profilesByProjectAndName",
"[",
"container",
".",
"Project",
"]",
"[",
"name",
"]",
"\n",
"profiles",
"[",
"j",
"]",
"=",
"*",
"ProfileToAPI",
"(",
"&",
"profile",
")",
"\n",
"}",
"\n\n",
"containers",
"[",
"i",
"]",
".",
"Config",
"=",
"ProfilesExpandConfig",
"(",
"container",
".",
"Config",
",",
"profiles",
")",
"\n",
"containers",
"[",
"i",
"]",
".",
"Devices",
"=",
"ProfilesExpandDevices",
"(",
"container",
".",
"Devices",
",",
"profiles",
")",
"\n",
"}",
"\n\n",
"return",
"containers",
",",
"nil",
"\n",
"}"
] |
21,016 | all-21017 | [
"FindApproverOwnersForFile",
"returns",
"the",
"OWNERS",
"file",
"path",
"furthest",
"down",
"the",
"tree",
"for",
"a",
"specified",
"file",
"that",
"contains",
"an",
"approvers",
"section"
] | [
"func",
"(",
"o",
"*",
"RepoOwners",
")",
"FindApproverOwnersForFile",
"(",
"path",
"string",
")",
"string",
"{",
"return",
"findOwnersForFile",
"(",
"o",
".",
"log",
",",
"<mask>",
",",
"o",
".",
"approvers",
")",
"\n",
"}"
] |
21,017 | all-21018 | [
"HeaderBarNew",
"is",
"a",
"wrapper",
"around",
"gtk_header_bar_new",
"()",
"."
] | [
"func",
"HeaderBarNew",
"(",
")",
"(",
"*",
"HeaderBar",
",",
"error",
")",
"{",
"c",
":=",
"C",
".",
"gtk_header_bar_new",
"(",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"<mask>",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"return",
"wrapHeaderBar",
"(",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
")",
",",
"nil",
"\n",
"}"
] |
21,018 | all-21019 | [
"Pop",
"removes",
"the",
"topmost",
"item",
"from",
"the",
"stack",
"and",
"return",
"its",
"value",
".",
"If",
"the",
"stack",
"is",
"empty",
"Pop",
"returns",
"nil",
"."
] | [
"func",
"(",
"s",
"*",
"VecStack",
")",
"Pop",
"(",
")",
"(",
"value",
"*",
"Vec",
")",
"{",
"if",
"s",
".",
"size",
">",
"0",
"{",
"value",
",",
"s",
".",
"<mask>",
"=",
"s",
".",
"top",
".",
"value",
",",
"s",
".",
"top",
".",
"next",
"\n",
"s",
".",
"size",
"--",
"\n",
"return",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
21,019 | all-21020 | [
"PeriodicToJobSpec",
"generates",
"a",
"downwardapi",
".",
"JobSpec",
"out",
"of",
"a",
"Periodic",
".",
"Useful",
"for",
"figuring",
"out",
"GCS",
"paths",
"when",
"parsing",
"jobs",
"out",
"of",
"a",
"prow",
"config",
"."
] | [
"func",
"PeriodicToJobSpec",
"(",
"periodic",
"config",
".",
"Periodic",
")",
"*",
"downwardapi",
".",
"JobSpec",
"{",
"return",
"&",
"downwardapi",
".",
"JobSpec",
"{",
"Type",
":",
"prowapi",
".",
"PeriodicJob",
",",
"Job",
":",
"periodic",
".",
"<mask>",
",",
"}",
"\n",
"}"
] |
21,020 | all-21021 | [
"DeepCopyObject",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"runtime",
".",
"Object",
"."
] | [
"func",
"(",
"in",
"*",
"App",
")",
"DeepCopyObject",
"(",
")",
"runtime",
".",
"Object",
"{",
"if",
"c",
":=",
"<mask>",
".",
"DeepCopy",
"(",
")",
";",
"c",
"!=",
"nil",
"{",
"return",
"c",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
21,021 | all-21022 | [
"initHeap",
"checks",
"all",
"iterators",
"and",
"initializes",
"our",
"heap",
"and",
"array",
"of",
"keys",
".",
"Whenever",
"we",
"reverse",
"direction",
"we",
"need",
"to",
"run",
"this",
"."
] | [
"func",
"(",
"s",
"*",
"MergeIterator",
")",
"initHeap",
"(",
")",
"{",
"s",
".",
"h",
"=",
"s",
".",
"h",
"[",
":",
"0",
"]",
"\n",
"for",
"idx",
",",
"itr",
":=",
"range",
"s",
".",
"all",
"{",
"if",
"!",
"itr",
".",
"Valid",
"(",
")",
"{",
"continue",
"\n",
"}",
"\n",
"e",
":=",
"&",
"elem",
"{",
"itr",
":",
"itr",
",",
"nice",
":",
"idx",
",",
"reversed",
":",
"s",
".",
"reversed",
"}",
"\n",
"s",
".",
"h",
"=",
"append",
"(",
"s",
".",
"h",
",",
"e",
")",
"\n",
"}",
"\n",
"heap",
".",
"Init",
"(",
"&",
"s",
".",
"h",
")",
"\n",
"for",
"len",
"(",
"s",
".",
"h",
")",
">",
"0",
"{",
"it",
":=",
"s",
".",
"h",
"[",
"0",
"]",
".",
"itr",
"\n",
"if",
"it",
"==",
"nil",
"||",
"!",
"it",
".",
"Valid",
"(",
")",
"{",
"heap",
".",
"Pop",
"(",
"&",
"s",
".",
"h",
")",
"\n",
"<mask>",
"\n",
"}",
"\n",
"s",
".",
"storeKey",
"(",
"s",
".",
"h",
"[",
"0",
"]",
".",
"itr",
")",
"\n",
"break",
"\n",
"}",
"\n",
"}"
] |
21,022 | all-21023 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"CloseTargetParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"<mask>",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoTarget27",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
21,023 | all-21024 | [
"Error",
"returns",
"the",
"error",
"as",
"a",
"string"
] | [
"func",
"(",
"err",
"*",
"ResourceInitError",
")",
"<mask>",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"err",
".",
"taskARN",
",",
"err",
".",
"origErr",
")",
"\n",
"}"
] |
21,024 | all-21025 | [
"TODO",
":",
"use",
"syscalls",
":",
"http",
":",
"//",
"pastebin",
".",
"com",
"/",
"9exZG4rh"
] | [
"func",
"getNaiveExternalAddress",
"(",
"port",
"int",
")",
"*",
"NetAddress",
"{",
"addrs",
",",
"err",
":=",
"net",
".",
"InterfaceAddrs",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"PanicCrisis",
"(",
"Fmt",
"(",
"\"",
"\"",
",",
"err",
")",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"a",
":=",
"range",
"addrs",
"{",
"ipnet",
",",
"ok",
":=",
"a",
".",
"(",
"*",
"<mask>",
".",
"IPNet",
")",
"\n",
"if",
"!",
"ok",
"{",
"continue",
"\n",
"}",
"\n",
"v4",
":=",
"ipnet",
".",
"IP",
".",
"To4",
"(",
")",
"\n",
"if",
"v4",
"==",
"nil",
"||",
"v4",
"[",
"0",
"]",
"==",
"127",
"{",
"continue",
"\n",
"}",
"// loopback",
"\n",
"return",
"NewNetAddressIPPort",
"(",
"ipnet",
".",
"IP",
",",
"uint16",
"(",
"port",
")",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
21,025 | all-21026 | [
"GetCriticalRecoveryOk",
"returns",
"a",
"tuple",
"with",
"the",
"CriticalRecovery",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"t",
"*",
"ThresholdCount",
")",
"GetCriticalRecoveryOk",
"(",
")",
"(",
"json",
".",
"Number",
",",
"bool",
")",
"{",
"if",
"t",
"==",
"nil",
"||",
"t",
".",
"CriticalRecovery",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"t",
".",
"CriticalRecovery",
",",
"true",
"\n",
"}"
] |
21,026 | all-21027 | [
"CreateContactGroup",
"creates",
"a",
"new",
"contact",
"group",
"."
] | [
"func",
"(",
"a",
"*",
"API",
")",
"CreateContactGroup",
"(",
"cfg",
"*",
"ContactGroup",
")",
"(",
"*",
"ContactGroup",
",",
"error",
")",
"{",
"if",
"cfg",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"jsonCfg",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"cfg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"a",
".",
"Debug",
"{",
"a",
".",
"Log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"string",
"(",
"jsonCfg",
")",
")",
"\n",
"}",
"\n\n",
"result",
",",
"err",
":=",
"a",
".",
"Post",
"(",
"config",
".",
"ContactGroupPrefix",
",",
"jsonCfg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"group",
":=",
"&",
"ContactGroup",
"{",
"}",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"result",
",",
"<mask>",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"group",
",",
"nil",
"\n",
"}"
] |
21,027 | all-21028 | [
"NewAttrsFromAttrs",
"is",
"a",
"convenience",
"function",
"that",
"will",
"accept",
"zero",
"or",
"more",
"existing",
"Attrs",
"create",
"a",
"new",
"Attrs",
"and",
"then",
"merge",
"all",
"the",
"supplied",
"Attrs",
"values",
"into",
"the",
"new",
"Attrs",
"instance",
"."
] | [
"func",
"NewAttrsFromAttrs",
"(",
"attrs",
"...",
"*",
"Attrs",
")",
"*",
"Attrs",
"{",
"newAttrs",
":=",
"NewAttrs",
"(",
")",
"\n",
"for",
"_",
",",
"attr",
":=",
"<mask>",
"attrs",
"{",
"newAttrs",
".",
"MergeAttrs",
"(",
"attr",
")",
"\n",
"}",
"\n",
"return",
"newAttrs",
"\n",
"}"
] |
21,028 | all-21029 | [
"AllByName",
"finds",
"zero",
"or",
"more",
"elements",
"with",
"the",
"provided",
"name",
"attribute",
"."
] | [
"func",
"(",
"s",
"*",
"selectable",
")",
"AllByName",
"(",
"<mask>",
"string",
")",
"*",
"MultiSelection",
"{",
"return",
"newMultiSelection",
"(",
"s",
".",
"session",
",",
"s",
".",
"selectors",
".",
"Append",
"(",
"target",
".",
"Name",
",",
"name",
")",
")",
"\n",
"}"
] |
21,029 | all-21030 | [
"CheckAlreadyRunning",
"checks",
"if",
"the",
"socket",
"at",
"the",
"given",
"path",
"is",
"already",
"bound",
"to",
"a",
"running",
"LXD",
"process",
"and",
"return",
"an",
"error",
"if",
"so",
".",
"FIXME",
":",
"We",
"should",
"probably",
"rather",
"just",
"try",
"a",
"regular",
"unix",
"socket",
"connection",
"without",
"using",
"the",
"client",
".",
"However",
"this",
"is",
"the",
"way",
"this",
"logic",
"has",
"historically",
"behaved",
"so",
"let",
"s",
"keep",
"it",
"like",
"it",
"was",
"."
] | [
"func",
"CheckAlreadyRunning",
"(",
"<mask>",
"string",
")",
"error",
"{",
"// If socket activated, nothing to do",
"pid",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"if",
"pid",
"==",
"os",
".",
"Getpid",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"// If there's no socket file at all, there's nothing to do.",
"if",
"!",
"shared",
".",
"PathExists",
"(",
"path",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"_",
",",
"err",
"=",
"lxd",
".",
"ConnectLXDUnix",
"(",
"path",
",",
"nil",
")",
"\n\n",
"// If the connection succeeded it means there's another LXD running.",
"if",
"err",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
21,030 | all-21031 | [
"ValidateWebhook",
"ensures",
"that",
"the",
"provided",
"request",
"conforms",
"to",
"the",
"format",
"of",
"a",
"GitHub",
"webhook",
"and",
"the",
"payload",
"can",
"be",
"validated",
"with",
"the",
"provided",
"hmac",
"secret",
".",
"It",
"returns",
"the",
"event",
"type",
"the",
"event",
"guid",
"the",
"payload",
"of",
"the",
"request",
"whether",
"the",
"webhook",
"is",
"valid",
"or",
"not",
"and",
"finally",
"the",
"resultant",
"HTTP",
"status",
"code"
] | [
"func",
"ValidateWebhook",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"hmacSecret",
"[",
"]",
"byte",
")",
"(",
"string",
",",
"string",
",",
"[",
"]",
"byte",
",",
"bool",
",",
"int",
")",
"{",
"defer",
"r",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"// Our health check uses GET, so just kick back a 200.",
"if",
"r",
".",
"Method",
"==",
"http",
".",
"MethodGet",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"false",
",",
"http",
".",
"StatusOK",
"\n",
"}",
"\n\n",
"// Header checks: It must be a POST with an event type and a signature.",
"if",
"r",
".",
"Method",
"!=",
"http",
".",
"MethodPost",
"{",
"responseHTTPError",
"(",
"w",
",",
"http",
".",
"StatusMethodNotAllowed",
",",
"\"",
"\"",
")",
"\n",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"false",
",",
"http",
".",
"StatusMethodNotAllowed",
"\n",
"}",
"\n",
"eventType",
":=",
"r",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"eventType",
"==",
"\"",
"\"",
"{",
"responseHTTPError",
"(",
"w",
",",
"http",
".",
"StatusBadRequest",
",",
"\"",
"\"",
")",
"\n",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"false",
",",
"http",
".",
"StatusBadRequest",
"\n",
"}",
"\n",
"eventGUID",
":=",
"r",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"eventGUID",
"==",
"\"",
"\"",
"{",
"responseHTTPError",
"(",
"w",
",",
"http",
".",
"StatusBadRequest",
",",
"\"",
"\"",
")",
"\n",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"<mask>",
",",
"http",
".",
"StatusBadRequest",
"\n",
"}",
"\n",
"sig",
":=",
"r",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"sig",
"==",
"\"",
"\"",
"{",
"responseHTTPError",
"(",
"w",
",",
"http",
".",
"StatusForbidden",
",",
"\"",
"\"",
")",
"\n",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"false",
",",
"http",
".",
"StatusForbidden",
"\n",
"}",
"\n",
"contentType",
":=",
"r",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"contentType",
"!=",
"\"",
"\"",
"{",
"responseHTTPError",
"(",
"w",
",",
"http",
".",
"StatusBadRequest",
",",
"\"",
"\"",
")",
"\n",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"false",
",",
"http",
".",
"StatusBadRequest",
"\n",
"}",
"\n",
"payload",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"r",
".",
"Body",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"responseHTTPError",
"(",
"w",
",",
"http",
".",
"StatusInternalServerError",
",",
"\"",
"\"",
")",
"\n",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"false",
",",
"http",
".",
"StatusInternalServerError",
"\n",
"}",
"\n",
"// Validate the payload with our HMAC secret.",
"if",
"!",
"ValidatePayload",
"(",
"payload",
",",
"sig",
",",
"hmacSecret",
")",
"{",
"responseHTTPError",
"(",
"w",
",",
"http",
".",
"StatusForbidden",
",",
"\"",
"\"",
")",
"\n",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"false",
",",
"http",
".",
"StatusForbidden",
"\n",
"}",
"\n\n",
"return",
"eventType",
",",
"eventGUID",
",",
"payload",
",",
"true",
",",
"http",
".",
"StatusOK",
"\n",
"}"
] |
21,031 | all-21032 | [
"Handle",
"satisfies",
"hookHandler",
"."
] | [
"func",
"(",
"g",
"GithubHook",
")",
"Handle",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"repo",
"*",
"Repo",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"r",
".",
"Method",
"!=",
"\"",
"\"",
"{",
"return",
"http",
".",
"StatusMethodNotAllowed",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// read full body - required for signature",
"body",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"r",
".",
"Body",
")",
"\n\n",
"err",
"=",
"g",
".",
"handleSignature",
"(",
"r",
",",
"body",
",",
"repo",
".",
"Hook",
".",
"Secret",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"http",
".",
"StatusBadRequest",
",",
"err",
"\n",
"}",
"\n\n",
"event",
":=",
"r",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"event",
"==",
"\"",
"\"",
"{",
"return",
"http",
".",
"StatusBadRequest",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"switch",
"event",
"{",
"case",
"\"",
"\"",
":",
"w",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
")",
"\n",
"case",
"\"",
"\"",
":",
"err",
"=",
"g",
".",
"handlePush",
"(",
"body",
",",
"repo",
")",
"\n",
"if",
"!",
"hookIgnored",
"(",
"err",
")",
"&&",
"err",
"!=",
"nil",
"{",
"return",
"http",
".",
"StatusBadRequest",
",",
"err",
"\n",
"}",
"\n",
"case",
"\"",
"\"",
":",
"err",
"=",
"g",
".",
"handleRelease",
"(",
"<mask>",
",",
"repo",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"http",
".",
"StatusBadRequest",
",",
"err",
"\n",
"}",
"\n\n",
"// return 400 if we do not handle the event type.",
"// This is to visually show the user a configuration error in the GH ui.",
"default",
":",
"return",
"http",
".",
"StatusBadRequest",
",",
"nil",
"\n",
"}",
"\n\n",
"return",
"http",
".",
"StatusOK",
",",
"err",
"\n",
"}"
] |
21,032 | all-21033 | [
"BytesPer",
"tells",
"the",
"rate",
"per",
"period",
"at",
"which",
"bytes",
"were",
"read",
"since",
"last",
"measurement",
"."
] | [
"func",
"(",
"m",
"*",
"MeasuredReader",
")",
"BytesPer",
"(",
"perPeriod",
"<mask>",
".",
"Duration",
")",
"uint64",
"{",
"return",
"uint64",
"(",
"m",
".",
"rate",
".",
"Rate",
"(",
"perPeriod",
")",
")",
"\n",
"}"
] |
21,033 | all-21034 | [
"NewWithAlphabet",
"returns",
"a",
"new",
"UUIDv4",
"encoded",
"with",
"base57",
"using",
"the",
"alternative",
"alphabet",
"abc",
"."
] | [
"func",
"NewWithAlphabet",
"(",
"abc",
"<mask>",
")",
"string",
"{",
"enc",
":=",
"base57",
"{",
"newAlphabet",
"(",
"abc",
")",
"}",
"\n",
"return",
"enc",
".",
"Encode",
"(",
"uuid",
".",
"New",
"(",
")",
")",
"\n",
"}"
] |
21,034 | all-21035 | [
"equal",
"returns",
"true",
"only",
"if",
"both",
"signatures",
"are",
"exactly",
"equal",
"."
] | [
"func",
"(",
"s",
"*",
"Signature",
")",
"<mask>",
"(",
"r",
"*",
"Signature",
")",
"bool",
"{",
"if",
"s",
".",
"State",
"!=",
"r",
".",
"State",
"||",
"!",
"s",
".",
"CreatedBy",
".",
"equal",
"(",
"&",
"r",
".",
"CreatedBy",
")",
"||",
"s",
".",
"Locked",
"!=",
"r",
".",
"Locked",
"||",
"s",
".",
"SleepMin",
"!=",
"r",
".",
"SleepMin",
"||",
"s",
".",
"SleepMax",
"!=",
"r",
".",
"SleepMax",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"s",
".",
"Stack",
".",
"equal",
"(",
"&",
"r",
".",
"Stack",
")",
"\n",
"}"
] |
21,035 | all-21036 | [
"ParseInt",
"parses",
"a",
"decimanl",
"representation",
"of",
"an",
"int64",
"from",
"b",
".",
"The",
"function",
"is",
"equivalent",
"to",
"calling",
"strconv",
".",
"ParseInt",
"(",
"string",
"(",
"b",
")",
"10",
"64",
")",
"but",
"it",
"prevents",
"Go",
"from",
"making",
"a",
"memory",
"allocation",
"for",
"converting",
"a",
"byte",
"slice",
"to",
"a",
"string",
"(",
"escape",
"analysis",
"fails",
"due",
"to",
"the",
"error",
"returned",
"by",
"strconv",
".",
"ParseInt",
")",
".",
"Because",
"it",
"only",
"works",
"with",
"base",
"10",
"the",
"function",
"is",
"also",
"significantly",
"faster",
"than",
"strconv",
".",
"ParseInt",
"."
] | [
"func",
"ParseInt",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"int64",
",",
"error",
")",
"{",
"var",
"val",
"int64",
"\n\n",
"if",
"len",
"(",
"b",
")",
"==",
"0",
"{",
"return",
"0",
",",
"errorInvalidUint64",
"(",
"b",
")",
"\n",
"}",
"\n\n",
"if",
"b",
"[",
"0",
"]",
"==",
"'-'",
"{",
"const",
"<mask>",
"=",
"Int64Min",
"\n",
"const",
"lim",
"=",
"max",
"/",
"10",
"\n\n",
"if",
"b",
"=",
"b",
"[",
"1",
":",
"]",
";",
"len",
"(",
"b",
")",
"==",
"0",
"{",
"return",
"0",
",",
"errorInvalidUint64",
"(",
"b",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"d",
":=",
"range",
"b",
"{",
"if",
"!",
"(",
"d",
">=",
"'0'",
"&&",
"d",
"<=",
"'9'",
")",
"{",
"return",
"0",
",",
"errorInvalidInt64",
"(",
"b",
")",
"\n",
"}",
"\n\n",
"if",
"val",
"<",
"lim",
"{",
"return",
"0",
",",
"errorOverflowInt64",
"(",
"b",
")",
"\n",
"}",
"\n\n",
"val",
"*=",
"10",
"\n",
"x",
":=",
"int64",
"(",
"d",
"-",
"'0'",
")",
"\n\n",
"if",
"val",
"<",
"(",
"max",
"+",
"x",
")",
"{",
"return",
"0",
",",
"errorOverflowInt64",
"(",
"b",
")",
"\n",
"}",
"\n\n",
"val",
"-=",
"x",
"\n",
"}",
"\n",
"}",
"else",
"{",
"const",
"max",
"=",
"Int64Max",
"\n",
"const",
"lim",
"=",
"max",
"/",
"10",
"\n\n",
"for",
"_",
",",
"d",
":=",
"range",
"b",
"{",
"if",
"!",
"(",
"d",
">=",
"'0'",
"&&",
"d",
"<=",
"'9'",
")",
"{",
"return",
"0",
",",
"errorInvalidInt64",
"(",
"b",
")",
"\n",
"}",
"\n",
"x",
":=",
"int64",
"(",
"d",
"-",
"'0'",
")",
"\n\n",
"if",
"val",
">",
"lim",
"{",
"return",
"0",
",",
"errorOverflowInt64",
"(",
"b",
")",
"\n",
"}",
"\n\n",
"if",
"val",
"*=",
"10",
";",
"val",
">",
"(",
"max",
"-",
"x",
")",
"{",
"return",
"0",
",",
"errorOverflowInt64",
"(",
"b",
")",
"\n",
"}",
"\n\n",
"val",
"+=",
"x",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"val",
",",
"nil",
"\n",
"}"
] |
21,036 | all-21037 | [
"Create",
"implements",
"ClientInterface"
] | [
"func",
"(",
"c",
"*",
"dummyClient",
")",
"Create",
"(",
"obj",
"<mask>",
")",
"(",
"Object",
",",
"error",
")",
"{",
"c",
".",
"objects",
"[",
"obj",
".",
"GetName",
"(",
")",
"]",
"=",
"obj",
"\n",
"return",
"obj",
",",
"nil",
"\n",
"}"
] |
21,037 | all-21038 | [
"waitForGlobalOp",
"waits",
"for",
"the",
"global",
"operation",
"to",
"finish",
"."
] | [
"func",
"(",
"c",
"*",
"ComputeUtil",
")",
"waitForGlobalOp",
"(",
"<mask>",
"string",
")",
"error",
"{",
"return",
"c",
".",
"waitForOp",
"(",
"func",
"(",
")",
"(",
"*",
"raw",
".",
"Operation",
",",
"error",
")",
"{",
"return",
"c",
".",
"service",
".",
"GlobalOperations",
".",
"Get",
"(",
"c",
".",
"project",
",",
"name",
")",
".",
"Do",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] |
21,038 | all-21039 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"SetSinkToUseParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"<mask>",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoCast2",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
21,039 | all-21040 | [
"Closing",
"returns",
"whether",
"the",
"child",
"is",
"closing"
] | [
"func",
"(",
"pl",
"*",
"processLink",
")",
"ChildClosing",
"(",
")",
"<-",
"chan",
"struct",
"{",
"}",
"{",
"// grab a hold of it, and unlock, as .Closing may block.",
"pl",
".",
"Lock",
"(",
")",
"\n",
"child",
":=",
"pl",
".",
"child",
"\n",
"pl",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"child",
"==",
"nil",
"{",
"// already closed? memory optimization.",
"return",
"closedCh",
"\n",
"}",
"\n",
"return",
"<mask>",
".",
"Closing",
"(",
")",
"\n",
"}"
] |
21,040 | all-21041 | [
"resourceVSphereComputeClusterVMHostRuleObjects",
"handles",
"the",
"fetching",
"of",
"the",
"cluster",
"and",
"rule",
"key",
"depending",
"on",
"what",
"attributes",
"are",
"available",
":",
"*",
"If",
"the",
"resource",
"ID",
"is",
"available",
"the",
"data",
"is",
"derived",
"from",
"the",
"ID",
".",
"*",
"If",
"not",
"only",
"the",
"cluster",
"is",
"retrieved",
"from",
"compute_cluster_id",
".",
"-",
"1",
"is",
"returned",
"for",
"the",
"key",
"."
] | [
"func",
"resourceVSphereComputeClusterVMHostRuleObjects",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
",",
"meta",
"interface",
"{",
"}",
",",
")",
"(",
"*",
"<mask>",
".",
"ClusterComputeResource",
",",
"int32",
",",
"error",
")",
"{",
"if",
"d",
".",
"Id",
"(",
")",
"!=",
"\"",
"\"",
"{",
"return",
"resourceVSphereComputeClusterVMHostRuleObjectsFromID",
"(",
"d",
",",
"meta",
")",
"\n",
"}",
"\n",
"return",
"resourceVSphereComputeClusterVMHostRuleObjectsFromAttributes",
"(",
"d",
",",
"meta",
")",
"\n",
"}"
] |
21,041 | all-21042 | [
"newDigestingReader",
"returns",
"an",
"io",
".",
"Reader",
"implementation",
"with",
"contents",
"of",
"source",
"which",
"will",
"eventually",
"return",
"a",
"non",
"-",
"EOF",
"error",
"or",
"set",
"validationSucceeded",
"/",
"validationFailed",
"to",
"true",
"if",
"the",
"source",
"stream",
"does",
"/",
"does",
"not",
"match",
"expectedDigest",
".",
"(",
"neither",
"is",
"set",
"if",
"EOF",
"is",
"never",
"reached",
")",
"."
] | [
"func",
"newDigestingReader",
"(",
"source",
"io",
".",
"Reader",
",",
"expectedDigest",
"digest",
".",
"Digest",
")",
"(",
"*",
"digestingReader",
",",
"error",
")",
"{",
"if",
"err",
":=",
"expectedDigest",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"<mask>",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"expectedDigest",
")",
"\n",
"}",
"\n",
"digestAlgorithm",
":=",
"expectedDigest",
".",
"Algorithm",
"(",
")",
"\n",
"if",
"!",
"digestAlgorithm",
".",
"Available",
"(",
")",
"{",
"return",
"nil",
",",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"expectedDigest",
",",
"digestAlgorithm",
")",
"\n",
"}",
"\n",
"return",
"&",
"digestingReader",
"{",
"source",
":",
"source",
",",
"digester",
":",
"digestAlgorithm",
".",
"Digester",
"(",
")",
",",
"expectedDigest",
":",
"expectedDigest",
",",
"validationFailed",
":",
"false",
",",
"}",
",",
"nil",
"\n",
"}"
] |
21,042 | all-21043 | [
"GetGroupingOk",
"returns",
"a",
"tuple",
"with",
"the",
"Grouping",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"c",
"*",
"CheckStatusDefinition",
")",
"GetGroupingOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"c",
"==",
"nil",
"||",
"c",
".",
"Grouping",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"c",
".",
"Grouping",
",",
"<mask>",
"\n",
"}"
] |
21,043 | all-21044 | [
"/",
"*",
"SetLocale",
"sets",
"the",
"locale",
"of",
"the",
"connector",
"."
] | [
"func",
"(",
"c",
"*",
"Connector",
")",
"SetLocale",
"(",
"locale",
"<mask>",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"c",
".",
"locale",
"=",
"locale",
"\n",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"}"
] |
21,044 | all-21045 | [
"currentMonitor",
"returns",
"the",
"monitor",
"most",
"suitable",
"with",
"the",
"current",
"window",
".",
"currentMonitor",
"must",
"be",
"called",
"on",
"the",
"main",
"thread",
"."
] | [
"func",
"(",
"u",
"*",
"UserInterface",
")",
"currentMonitor",
"(",
")",
"*",
"glfw",
".",
"Monitor",
"{",
"w",
":=",
"u",
".",
"<mask>",
"\n",
"if",
"m",
":=",
"w",
".",
"GetMonitor",
"(",
")",
";",
"m",
"!=",
"nil",
"{",
"return",
"m",
"\n",
"}",
"\n",
"// Get the monitor which the current window belongs to. This requires OS API.",
"return",
"u",
".",
"currentMonitorFromPosition",
"(",
")",
"\n",
"}"
] |
21,045 | all-21046 | [
"LogoutURL",
"returns",
"a",
"URL",
"that",
"when",
"visited",
"signs",
"the",
"user",
"out",
"then",
"redirects",
"the",
"user",
"to",
"the",
"URL",
"specified",
"by",
"dest",
"."
] | [
"func",
"LogoutURL",
"(",
"c",
"context",
".",
"Context",
",",
"dest",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"req",
":=",
"&",
"<mask>",
".",
"CreateLogoutURLRequest",
"{",
"DestinationUrl",
":",
"proto",
".",
"String",
"(",
"dest",
")",
",",
"}",
"\n",
"res",
":=",
"&",
"pb",
".",
"CreateLogoutURLResponse",
"{",
"}",
"\n",
"if",
"err",
":=",
"internal",
".",
"Call",
"(",
"c",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"req",
",",
"res",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"*",
"res",
".",
"LogoutUrl",
",",
"nil",
"\n",
"}"
] |
21,046 | all-21047 | [
"NewCatalogNodesQuery",
"parses",
"the",
"given",
"string",
"into",
"a",
"dependency",
".",
"If",
"the",
"name",
"is",
"empty",
"then",
"the",
"name",
"of",
"the",
"local",
"agent",
"is",
"used",
"."
] | [
"func",
"NewCatalogNodesQuery",
"(",
"s",
"string",
")",
"(",
"*",
"CatalogNodesQuery",
",",
"error",
")",
"{",
"if",
"!",
"CatalogNodesQueryRe",
".",
"MatchString",
"(",
"s",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"s",
")",
"\n",
"}",
"\n\n",
"m",
":=",
"regexpMatch",
"(",
"CatalogNodesQueryRe",
",",
"s",
")",
"\n",
"return",
"&",
"CatalogNodesQuery",
"{",
"dc",
":",
"m",
"[",
"\"",
"\"",
"]",
",",
"near",
":",
"m",
"[",
"\"",
"\"",
"]",
",",
"stopCh",
":",
"<mask>",
"(",
"chan",
"struct",
"{",
"}",
",",
"1",
")",
",",
"}",
",",
"nil",
"\n",
"}"
] |
21,047 | all-21048 | [
"NewPod",
"creates",
"a",
"new",
"pod",
"discovery",
"."
] | [
"func",
"NewPod",
"(",
"l",
"log",
".",
"Logger",
",",
"pods",
"cache",
".",
"SharedInformer",
")",
"*",
"Pod",
"{",
"if",
"l",
"==",
"nil",
"{",
"l",
"=",
"log",
".",
"NewNopLogger",
"(",
")",
"\n",
"}",
"\n",
"p",
":=",
"&",
"Pod",
"{",
"informer",
":",
"pods",
",",
"store",
":",
"pods",
".",
"GetStore",
"(",
")",
",",
"logger",
":",
"l",
",",
"queue",
":",
"workqueue",
".",
"NewNamed",
"(",
"\"",
"\"",
")",
",",
"}",
"\n",
"p",
".",
"informer",
".",
"AddEventHandler",
"(",
"cache",
".",
"ResourceEventHandlerFuncs",
"{",
"AddFunc",
":",
"func",
"(",
"o",
"interface",
"{",
"}",
")",
"{",
"eventCount",
".",
"WithLabelValues",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
".",
"Inc",
"(",
")",
"\n",
"p",
".",
"enqueue",
"(",
"o",
")",
"\n",
"}",
",",
"DeleteFunc",
":",
"func",
"(",
"o",
"<mask>",
"{",
"}",
")",
"{",
"eventCount",
".",
"WithLabelValues",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
".",
"Inc",
"(",
")",
"\n",
"p",
".",
"enqueue",
"(",
"o",
")",
"\n",
"}",
",",
"UpdateFunc",
":",
"func",
"(",
"_",
",",
"o",
"interface",
"{",
"}",
")",
"{",
"eventCount",
".",
"WithLabelValues",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
".",
"Inc",
"(",
")",
"\n",
"p",
".",
"enqueue",
"(",
"o",
")",
"\n",
"}",
",",
"}",
")",
"\n",
"return",
"p",
"\n",
"}"
] |
21,048 | all-21049 | [
"--------------------------------------------------------------------"
] | [
"func",
"(",
"c",
"*",
"<mask>",
")",
"createConsumer",
"(",
"tomb",
"*",
"loopTomb",
",",
"topic",
"string",
",",
"partition",
"int32",
",",
"info",
"offsetInfo",
")",
"error",
"{",
"memberID",
",",
"_",
":=",
"c",
".",
"membership",
"(",
")",
"\n",
"sarama",
".",
"Logger",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"memberID",
",",
"topic",
",",
"partition",
",",
"info",
".",
"NextOffset",
"(",
"c",
".",
"client",
".",
"config",
".",
"Consumer",
".",
"Offsets",
".",
"Initial",
")",
")",
"\n\n",
"// Create partitionConsumer",
"pc",
",",
"err",
":=",
"newPartitionConsumer",
"(",
"c",
".",
"consumer",
",",
"topic",
",",
"partition",
",",
"info",
",",
"c",
".",
"client",
".",
"config",
".",
"Consumer",
".",
"Offsets",
".",
"Initial",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Store in subscriptions",
"c",
".",
"subs",
".",
"Store",
"(",
"topic",
",",
"partition",
",",
"pc",
")",
"\n\n",
"// Start partition consumer goroutine",
"tomb",
".",
"Go",
"(",
"func",
"(",
"stopper",
"<-",
"chan",
"none",
")",
"{",
"if",
"c",
".",
"client",
".",
"config",
".",
"Group",
".",
"Mode",
"==",
"ConsumerModePartitions",
"{",
"pc",
".",
"waitFor",
"(",
"stopper",
")",
"\n",
"}",
"else",
"{",
"pc",
".",
"multiplex",
"(",
"stopper",
",",
"c",
".",
"messages",
",",
"c",
".",
"errors",
")",
"\n",
"}",
"\n",
"}",
")",
"\n\n",
"if",
"c",
".",
"client",
".",
"config",
".",
"Group",
".",
"Mode",
"==",
"ConsumerModePartitions",
"{",
"select",
"{",
"case",
"c",
".",
"partitions",
"<-",
"pc",
":",
"case",
"<-",
"c",
".",
"dying",
":",
"pc",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
21,049 | all-21050 | [
"Warnf",
"is",
"used",
"to",
"generate",
"warnings",
"during",
"virtual",
"machine",
"execution"
] | [
"func",
"(",
"st",
"*",
"State",
")",
"Warnf",
"(",
"format",
"string",
",",
"args",
"...",
"<mask>",
"{",
"}",
")",
"{",
"st",
".",
"warn",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
")",
")",
"\n",
"}"
] |
21,050 | all-21051 | [
"toJSON",
"converts",
"the",
"given",
"structure",
"into",
"a",
"deeply",
"nested",
"JSON",
"string",
"."
] | [
"func",
"toJSON",
"(",
"i",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"result",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"i",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"string",
"(",
"<mask>",
".",
"TrimSpace",
"(",
"result",
")",
")",
",",
"err",
"\n",
"}"
] |
21,051 | all-21052 | [
"Filter",
"demangles",
"a",
"C",
"++",
"symbol",
"name",
"returning",
"the",
"human",
"-",
"readable",
"C",
"++",
"name",
".",
"If",
"any",
"error",
"occurs",
"during",
"demangling",
"the",
"input",
"string",
"is",
"returned",
"."
] | [
"func",
"Filter",
"(",
"name",
"string",
",",
"options",
"...",
"Option",
")",
"string",
"{",
"ret",
",",
"err",
":=",
"ToString",
"(",
"name",
",",
"<mask>",
"...",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"name",
"\n",
"}",
"\n",
"return",
"ret",
"\n",
"}"
] |
21,052 | all-21053 | [
"getSuitableAlgFromCurve",
"inspects",
"the",
"key",
"length",
"in",
"curve",
"and",
"determines",
"the",
"corresponding",
"jwt",
".",
"Algorithm",
"."
] | [
"func",
"getSuitableAlgFromCurve",
"(",
"curve",
"elliptic",
".",
"Curve",
")",
"(",
"jwt",
".",
"Algorithm",
",",
"error",
")",
"{",
"curveBitSize",
":=",
"curve",
".",
"Params",
"(",
")",
".",
"BitSize",
"\n\n",
"// compute curve key len",
"keyLen",
":=",
"curveBitSize",
"/",
"8",
"\n",
"if",
"curveBitSize",
"%",
"8",
">",
"0",
"{",
"keyLen",
"++",
"\n",
"}",
"\n\n",
"// determine alg",
"var",
"alg",
"jwt",
".",
"Algorithm",
"\n",
"switch",
"2",
"*",
"keyLen",
"{",
"case",
"64",
":",
"alg",
"=",
"jwt",
".",
"ES256",
"\n",
"case",
"96",
":",
"alg",
"=",
"jwt",
".",
"ES384",
"\n",
"case",
"132",
":",
"alg",
"=",
"jwt",
".",
"ES512",
"\n\n",
"<mask>",
":",
"return",
"jwt",
".",
"NONE",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"keyLen",
")",
"\n",
"}",
"\n\n",
"return",
"alg",
",",
"nil",
"\n",
"}"
] |
21,053 | all-21054 | [
"LocalStorage",
"creates",
"a",
"local",
"chunk",
"storage",
"instance",
".",
"Useful",
"for",
"storage",
"layer",
"tests",
"."
] | [
"func",
"LocalStorage",
"(",
"tb",
"testing",
".",
"TB",
")",
"(",
"obj",
".",
"Client",
",",
"*",
"Storage",
")",
"{",
"wd",
",",
"err",
":=",
"os",
".",
"Getwd",
"(",
")",
"\n",
"<mask>",
".",
"NoError",
"(",
"tb",
",",
"err",
")",
"\n",
"objC",
",",
"err",
":=",
"obj",
".",
"NewLocalClient",
"(",
"wd",
")",
"\n",
"require",
".",
"NoError",
"(",
"tb",
",",
"err",
")",
"\n",
"return",
"objC",
",",
"NewStorage",
"(",
"objC",
",",
"Prefix",
")",
"\n",
"}"
] |
21,054 | all-21055 | [
"DiskMigrateRelocateOperation",
"assembles",
"the",
"VirtualMachineRelocateSpecDiskLocator",
"slice",
"for",
"a",
"virtual",
"machine",
"migration",
"operation",
"otherwise",
"known",
"as",
"storage",
"vMotion",
"."
] | [
"func",
"DiskMigrateRelocateOperation",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
",",
"c",
"*",
"govmomi",
".",
"Client",
",",
"l",
"object",
".",
"VirtualDeviceList",
")",
"(",
"[",
"]",
"types",
".",
"VirtualMachineRelocateSpecDiskLocator",
",",
"bool",
",",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"ods",
",",
"nds",
":=",
"d",
".",
"GetChange",
"(",
"subresourceTypeDisk",
")",
"\n\n",
"var",
"relocators",
"[",
"]",
"types",
".",
"VirtualMachineRelocateSpecDiskLocator",
"\n",
"var",
"relocateOK",
"bool",
"\n\n",
"// We are only concerned with resources that would normally be updated, as",
"// incoming or outgoing disks obviously won't need migrating. Hence, this is",
"// a simplified subset of the normal apply logic.",
"for",
"ni",
",",
"ne",
":=",
"range",
"nds",
".",
"(",
"[",
"]",
"interface",
"{",
"}",
")",
"{",
"nm",
":=",
"ne",
".",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"var",
"name",
"string",
"\n",
"var",
"err",
"error",
"\n",
"if",
"name",
",",
"err",
"=",
"diskLabelOrName",
"(",
"<mask>",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"false",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ni",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"name",
"==",
"diskDeletedName",
"||",
"name",
"==",
"diskDetachedName",
"{",
"continue",
"\n",
"}",
"\n",
"for",
"_",
",",
"oe",
":=",
"range",
"ods",
".",
"(",
"[",
"]",
"interface",
"{",
"}",
")",
"{",
"om",
":=",
"oe",
".",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"if",
"nm",
"[",
"\"",
"\"",
"]",
"==",
"om",
"[",
"\"",
"\"",
"]",
"{",
"// No change in datastore is a no-op, unless we are changing default datastores",
"if",
"nm",
"[",
"\"",
"\"",
"]",
"==",
"om",
"[",
"\"",
"\"",
"]",
"&&",
"!",
"d",
".",
"HasChange",
"(",
"\"",
"\"",
")",
"{",
"break",
"\n",
"}",
"\n",
"// If we got this far, some sort of datastore migration will be",
"// necessary. Flag this now.",
"relocateOK",
"=",
"true",
"\n\n",
"// A disk locator is only useful if a target datastore is available. If we",
"// don't have a datastore specified (ie: when Storage DRS is in use), then",
"// we just need to skip this disk. The disk will be migrated properly",
"// through the SDRS API.",
"if",
"nm",
"[",
"\"",
"\"",
"]",
"==",
"\"",
"\"",
"||",
"nm",
"[",
"\"",
"\"",
"]",
"==",
"diskDatastoreComputedName",
"{",
"break",
"\n",
"}",
"\n",
"r",
":=",
"NewDiskSubresource",
"(",
"c",
",",
"d",
",",
"nm",
",",
"om",
",",
"ni",
")",
"\n",
"relocator",
",",
"err",
":=",
"r",
".",
"Relocate",
"(",
"l",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"false",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"r",
".",
"Addr",
"(",
")",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"d",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"(",
"string",
")",
"==",
"relocator",
".",
"Datastore",
".",
"Value",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"r",
".",
"Addr",
"(",
")",
")",
"\n",
"break",
"\n",
"}",
"\n",
"relocators",
"=",
"append",
"(",
"relocators",
",",
"relocator",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"!",
"relocateOK",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
",",
"false",
",",
"nil",
"\n",
"}",
"\n\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"diskRelocateListString",
"(",
"relocators",
")",
")",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"relocators",
",",
"true",
",",
"nil",
"\n",
"}"
] |
21,055 | all-21056 | [
"ChangeSvcCheckTimeperiod",
"creates",
"a",
"new",
"CHANGE_SVC_CHECK_TIMEPERIOD",
"Nagios",
"command",
".",
"Changes",
"the",
"check",
"timeperiod",
"for",
"a",
"particular",
"service",
"to",
"what",
"is",
"specified",
"by",
"the",
"check_timeperiod",
"option",
".",
"The",
"check_timeperiod",
"option",
"should",
"be",
"the",
"short",
"name",
"of",
"the",
"timeperod",
"that",
"is",
"to",
"be",
"used",
"as",
"the",
"service",
"check",
"timeperiod",
".",
"The",
"timeperiod",
"must",
"have",
"been",
"configured",
"in",
"Nagios",
"before",
"it",
"was",
"last",
"(",
"re",
")",
"started",
"."
] | [
"func",
"ChangeSvcCheckTimeperiod",
"(",
"host_name",
"string",
",",
"service_description",
"string",
",",
"check_timeperiod",
"string",
",",
")",
"*",
"livestatus",
".",
"Command",
"{",
"<mask>",
"livestatus",
".",
"NewCommand",
"(",
"\"",
"\"",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"host_name",
")",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"service_description",
")",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"check_timeperiod",
")",
",",
")",
"\n",
"}"
] |
21,056 | all-21057 | [
"MiddlewareFunc",
"makes",
"RecorderMiddleware",
"implement",
"the",
"Middleware",
"interface",
"."
] | [
"func",
"(",
"mw",
"*",
"RecorderMiddleware",
")",
"MiddlewareFunc",
"(",
"h",
"HandlerFunc",
")",
"HandlerFunc",
"{",
"return",
"func",
"(",
"w",
"ResponseWriter",
",",
"r",
"*",
"Request",
")",
"{",
"<mask>",
":=",
"&",
"recorderResponseWriter",
"{",
"w",
",",
"0",
",",
"false",
",",
"0",
"}",
"\n\n",
"// call the handler",
"h",
"(",
"writer",
",",
"r",
")",
"\n\n",
"r",
".",
"Env",
"[",
"\"",
"\"",
"]",
"=",
"writer",
".",
"statusCode",
"\n",
"r",
".",
"Env",
"[",
"\"",
"\"",
"]",
"=",
"writer",
".",
"bytesWritten",
"\n",
"}",
"\n",
"}"
] |
21,057 | all-21058 | [
"Do",
"executes",
"Overlay",
".",
"setShowFPSCounter",
"against",
"the",
"provided",
"context",
"."
] | [
"func",
"(",
"p",
"*",
"SetShowFPSCounterParams",
")",
"Do",
"(",
"ctx",
"<mask>",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"return",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandSetShowFPSCounter",
",",
"p",
",",
"nil",
")",
"\n",
"}"
] |
21,058 | all-21059 | [
"Panicf",
"is",
"equivalent",
"to",
"l",
".",
"Critical",
"followed",
"by",
"a",
"call",
"to",
"panic",
"()",
"."
] | [
"func",
"(",
"l",
"*",
"Logger",
")",
"Panicf",
"(",
"format",
"string",
",",
"args",
"...",
"<mask>",
"{",
"}",
")",
"{",
"l",
".",
"log",
"(",
"CRITICAL",
",",
"&",
"format",
",",
"args",
"...",
")",
"\n",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
")",
"\n",
"}"
] |
21,059 | all-21060 | [
"Last",
"returns",
"the",
"last",
"error",
"in",
"the",
"list",
"or",
"nil",
".",
"Can",
"be",
"called",
"for",
"a",
"nil",
"ErrorList",
"."
] | [
"func",
"(",
"list",
"ErrorList",
")",
"Last",
"(",
")",
"error",
"{",
"if",
"len",
"(",
"list",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"list",
"[",
"len",
"(",
"<mask>",
")",
"-",
"1",
"]",
"\n",
"}"
] |
21,060 | all-21061 | [
"Sign",
"produces",
"signed",
"JWT",
"token",
"given",
"arbitrary",
"string",
"payload",
"signature",
"algorithm",
"to",
"use",
"(",
"see",
"constants",
"for",
"list",
"of",
"supported",
"algs",
")",
"signing",
"key",
"and",
"extra",
"options",
"(",
"see",
"option",
"functions",
")",
"Signing",
"key",
"is",
"of",
"different",
"type",
"for",
"different",
"signing",
"alg",
"see",
"specific",
"signing",
"alg",
"implementation",
"documentation",
".",
"It",
"returns",
"3",
"parts",
"signed",
"JWT",
"token",
"as",
"string",
"and",
"not",
"nil",
"error",
"if",
"something",
"went",
"wrong",
"."
] | [
"func",
"Sign",
"(",
"payload",
"string",
",",
"signingAlg",
"string",
",",
"key",
"interface",
"{",
"}",
",",
"<mask>",
"...",
"func",
"(",
"*",
"JoseConfig",
")",
")",
"(",
"token",
"string",
",",
"err",
"error",
")",
"{",
"return",
"SignBytes",
"(",
"[",
"]",
"byte",
"(",
"payload",
")",
",",
"signingAlg",
",",
"key",
",",
"options",
"...",
")",
"\n",
"}"
] |
21,061 | all-21062 | [
"Copy",
"an",
"LVM",
"custom",
"volume",
"."
] | [
"func",
"(",
"s",
"*",
"storageLvm",
")",
"copyVolume",
"(",
"sourcePool",
"string",
",",
"source",
"string",
")",
"error",
"{",
"targetMntPoint",
":=",
"getStoragePoolVolumeMountPoint",
"(",
"s",
".",
"pool",
".",
"<mask>",
",",
"s",
".",
"volume",
".",
"Name",
")",
"\n\n",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"targetMntPoint",
",",
"0711",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"s",
".",
"useThinpool",
"&&",
"sourcePool",
"==",
"s",
".",
"pool",
".",
"Name",
"{",
"err",
"=",
"s",
".",
"copyVolumeThinpool",
"(",
"source",
",",
"s",
".",
"volume",
".",
"Name",
",",
"false",
")",
"\n",
"}",
"else",
"{",
"err",
"=",
"s",
".",
"copyVolumeLv",
"(",
"sourcePool",
",",
"source",
",",
"s",
".",
"volume",
".",
"Name",
",",
"false",
")",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
21,062 | all-21063 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"FontFamilies",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"<mask>",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage49",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
21,063 | all-21064 | [
"WithApp",
"adds",
"the",
"app",
"to",
"the",
"delete",
"apps",
"app",
"params"
] | [
"func",
"(",
"o",
"*",
"DeleteAppsAppParams",
")",
"WithApp",
"(",
"app",
"<mask>",
")",
"*",
"DeleteAppsAppParams",
"{",
"o",
".",
"SetApp",
"(",
"app",
")",
"\n",
"return",
"o",
"\n",
"}"
] |
21,064 | all-21065 | [
"NewLogFilter",
"returns",
"a",
"LevelFilter",
"that",
"is",
"configured",
"with",
"the",
"log",
"levels",
"that",
"we",
"use",
"."
] | [
"func",
"NewLogFilter",
"(",
")",
"*",
"logutils",
".",
"LevelFilter",
"{",
"return",
"&",
"logutils",
".",
"LevelFilter",
"{",
"Levels",
":",
"Levels",
",",
"MinLevel",
":",
"\"",
"\"",
",",
"<mask>",
":",
"ioutil",
".",
"Discard",
",",
"}",
"\n",
"}"
] |
21,065 | all-21066 | [
"ConsoleContainer",
"requests",
"that",
"LXD",
"attaches",
"to",
"the",
"console",
"device",
"of",
"a",
"container",
"."
] | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"ConsoleContainer",
"(",
"containerName",
"string",
",",
"console",
"api",
".",
"ContainerConsolePost",
",",
"args",
"*",
"ContainerConsoleArgs",
")",
"(",
"Operation",
",",
"error",
")",
"{",
"if",
"!",
"r",
".",
"HasExtension",
"(",
"\"",
"\"",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Send the request",
"op",
",",
"_",
",",
"err",
":=",
"r",
".",
"queryOperation",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"url",
".",
"QueryEscape",
"(",
"containerName",
")",
")",
",",
"console",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"opAPI",
":=",
"op",
".",
"Get",
"(",
")",
"\n\n",
"if",
"args",
"==",
"nil",
"||",
"args",
".",
"Terminal",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"args",
".",
"Control",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Parse the fds",
"fds",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n\n",
"value",
",",
"ok",
":=",
"opAPI",
".",
"Metadata",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"ok",
"{",
"values",
":=",
"value",
".",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"<mask>",
"{",
"fds",
"[",
"k",
"]",
"=",
"v",
".",
"(",
"string",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"var",
"controlConn",
"*",
"websocket",
".",
"Conn",
"\n",
"// Call the control handler with a connection to the control socket",
"if",
"fds",
"[",
"\"",
"\"",
"]",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"controlConn",
",",
"err",
"=",
"r",
".",
"GetOperationWebsocket",
"(",
"opAPI",
".",
"ID",
",",
"fds",
"[",
"\"",
"\"",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"go",
"args",
".",
"Control",
"(",
"controlConn",
")",
"\n\n",
"// Connect to the websocket",
"conn",
",",
"err",
":=",
"r",
".",
"GetOperationWebsocket",
"(",
"opAPI",
".",
"ID",
",",
"fds",
"[",
"\"",
"\"",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Detach from console.",
"go",
"func",
"(",
"consoleDisconnect",
"<-",
"chan",
"bool",
")",
"{",
"<-",
"consoleDisconnect",
"\n",
"msg",
":=",
"websocket",
".",
"FormatCloseMessage",
"(",
"websocket",
".",
"CloseNormalClosure",
",",
"\"",
"\"",
")",
"\n",
"// We don't care if this fails. This is just for convenience.",
"controlConn",
".",
"WriteMessage",
"(",
"websocket",
".",
"CloseMessage",
",",
"msg",
")",
"\n",
"controlConn",
".",
"Close",
"(",
")",
"\n",
"}",
"(",
"args",
".",
"ConsoleDisconnect",
")",
"\n\n",
"// And attach stdin and stdout to it",
"go",
"func",
"(",
")",
"{",
"shared",
".",
"WebsocketSendStream",
"(",
"conn",
",",
"args",
".",
"Terminal",
",",
"-",
"1",
")",
"\n",
"<-",
"shared",
".",
"WebsocketRecvStream",
"(",
"args",
".",
"Terminal",
",",
"conn",
")",
"\n",
"conn",
".",
"Close",
"(",
")",
"\n",
"}",
"(",
")",
"\n\n",
"return",
"op",
",",
"nil",
"\n",
"}"
] |
21,066 | all-21067 | [
"ChangeMaxSvcCheckAttempts",
"creates",
"a",
"new",
"CHANGE_MAX_SVC_CHECK_ATTEMPTS",
"Nagios",
"command",
".",
"Changes",
"the",
"maximum",
"number",
"of",
"check",
"attempts",
"(",
"retries",
")",
"for",
"a",
"particular",
"service",
"."
] | [
"func",
"ChangeMaxSvcCheckAttempts",
"(",
"host_name",
"string",
",",
"service_description",
"string",
",",
"check_attempts",
"int",
",",
")",
"*",
"livestatus",
".",
"Command",
"{",
"<mask>",
"livestatus",
".",
"NewCommand",
"(",
"\"",
"\"",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"host_name",
")",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"service_description",
")",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"check_attempts",
")",
",",
")",
"\n",
"}"
] |
21,067 | all-21068 | [
"passive",
"to",
"close",
"fileLogger"
] | [
"func",
"(",
"f",
"*",
"FileLogger",
")",
"Close",
"(",
")",
"error",
"{",
"<mask>",
"(",
"f",
".",
"logChan",
")",
"\n",
"f",
".",
"lg",
"=",
"nil",
"\n\n",
"return",
"f",
".",
"logFile",
".",
"Close",
"(",
")",
"\n",
"}"
] |
21,068 | all-21069 | [
"GetCredentialsID",
"gets",
"the",
"credentials",
"ID",
"for",
"the",
"task"
] | [
"func",
"(",
"task",
"*",
"Task",
")",
"GetCredentialsID",
"(",
")",
"string",
"{",
"<mask>",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"task",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"task",
".",
"credentialsID",
"\n",
"}"
] |
21,069 | all-21070 | [
"Unix",
"devices",
"handling"
] | [
"func",
"(",
"c",
"*",
"containerLXC",
")",
"createUnixDevice",
"(",
"prefix",
"string",
",",
"m",
"types",
".",
"Device",
",",
"defaultMode",
"bool",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"major",
",",
"minor",
"int",
"\n\n",
"// Extra checks for nesting",
"if",
"c",
".",
"state",
".",
"OS",
".",
"RunningInUserNS",
"{",
"for",
"key",
",",
"value",
":=",
"range",
"m",
"{",
"if",
"shared",
".",
"StringInSlice",
"(",
"key",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
")",
"&&",
"value",
"!=",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"key",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"srcPath",
":=",
"m",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"srcPath",
"==",
"\"",
"\"",
"{",
"srcPath",
"=",
"m",
"[",
"\"",
"\"",
"]",
"\n",
"}",
"\n",
"srcPath",
"=",
"shared",
".",
"HostPath",
"(",
"srcPath",
")",
"\n\n",
"// Get the major/minor of the device we want to create",
"if",
"m",
"[",
"\"",
"\"",
"]",
"==",
"\"",
"\"",
"&&",
"m",
"[",
"\"",
"\"",
"]",
"==",
"\"",
"\"",
"{",
"// If no major and minor are set, use those from the device on the host",
"_",
",",
"major",
",",
"minor",
",",
"err",
"=",
"deviceGetAttributes",
"(",
"srcPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"m",
"[",
"\"",
"\"",
"]",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"else",
"if",
"m",
"[",
"\"",
"\"",
"]",
"==",
"\"",
"\"",
"||",
"m",
"[",
"\"",
"\"",
"]",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"m",
"[",
"\"",
"\"",
"]",
")",
"\n",
"}",
"else",
"{",
"major",
",",
"err",
"=",
"strconv",
".",
"Atoi",
"(",
"m",
"[",
"\"",
"\"",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"m",
"[",
"\"",
"\"",
"]",
",",
"m",
"[",
"\"",
"\"",
"]",
")",
"\n",
"}",
"\n\n",
"minor",
",",
"err",
"=",
"strconv",
".",
"Atoi",
"(",
"m",
"[",
"\"",
"\"",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"m",
"[",
"\"",
"\"",
"]",
",",
"m",
"[",
"\"",
"\"",
"]",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Get the device mode",
"mode",
":=",
"os",
".",
"FileMode",
"(",
"0660",
")",
"\n",
"if",
"m",
"[",
"\"",
"\"",
"]",
"!=",
"\"",
"\"",
"{",
"tmp",
",",
"err",
":=",
"deviceModeOct",
"(",
"m",
"[",
"\"",
"\"",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"m",
"[",
"\"",
"\"",
"]",
",",
"m",
"[",
"\"",
"\"",
"]",
")",
"\n",
"}",
"\n",
"<mask>",
"=",
"os",
".",
"FileMode",
"(",
"tmp",
")",
"\n",
"}",
"else",
"if",
"!",
"defaultMode",
"{",
"mode",
",",
"err",
"=",
"shared",
".",
"GetPathMode",
"(",
"srcPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"errno",
",",
"isErrno",
":=",
"shared",
".",
"GetErrno",
"(",
"err",
")",
"\n",
"if",
"!",
"isErrno",
"||",
"errno",
"!=",
"syscall",
".",
"ENOENT",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"m",
"[",
"\"",
"\"",
"]",
",",
"err",
")",
"\n",
"}",
"\n",
"mode",
"=",
"os",
".",
"FileMode",
"(",
"0660",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"m",
"[",
"\"",
"\"",
"]",
"==",
"\"",
"\"",
"{",
"mode",
"|=",
"syscall",
".",
"S_IFBLK",
"\n",
"}",
"else",
"{",
"mode",
"|=",
"syscall",
".",
"S_IFCHR",
"\n",
"}",
"\n\n",
"// Get the device owner",
"uid",
":=",
"0",
"\n",
"gid",
":=",
"0",
"\n\n",
"if",
"m",
"[",
"\"",
"\"",
"]",
"!=",
"\"",
"\"",
"{",
"uid",
",",
"err",
"=",
"strconv",
".",
"Atoi",
"(",
"m",
"[",
"\"",
"\"",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"m",
"[",
"\"",
"\"",
"]",
",",
"m",
"[",
"\"",
"\"",
"]",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"m",
"[",
"\"",
"\"",
"]",
"!=",
"\"",
"\"",
"{",
"gid",
",",
"err",
"=",
"strconv",
".",
"Atoi",
"(",
"m",
"[",
"\"",
"\"",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"m",
"[",
"\"",
"\"",
"]",
",",
"m",
"[",
"\"",
"\"",
"]",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Create the devices directory if missing",
"if",
"!",
"shared",
".",
"PathExists",
"(",
"c",
".",
"DevicesPath",
"(",
")",
")",
"{",
"os",
".",
"Mkdir",
"(",
"c",
".",
"DevicesPath",
"(",
")",
",",
"0711",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"destPath",
":=",
"m",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"destPath",
"==",
"\"",
"\"",
"{",
"destPath",
"=",
"m",
"[",
"\"",
"\"",
"]",
"\n",
"}",
"\n",
"relativeDestPath",
":=",
"strings",
".",
"TrimPrefix",
"(",
"destPath",
",",
"\"",
"\"",
")",
"\n",
"devName",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"strings",
".",
"Replace",
"(",
"prefix",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
",",
"strings",
".",
"Replace",
"(",
"relativeDestPath",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
")",
"\n",
"devPath",
":=",
"filepath",
".",
"Join",
"(",
"c",
".",
"DevicesPath",
"(",
")",
",",
"devName",
")",
"\n\n",
"// Create the new entry",
"if",
"!",
"c",
".",
"state",
".",
"OS",
".",
"RunningInUserNS",
"{",
"encoded_device_number",
":=",
"(",
"minor",
"&",
"0xff",
")",
"|",
"(",
"major",
"<<",
"8",
")",
"|",
"(",
"(",
"minor",
"&",
"^",
"0xff",
")",
"<<",
"12",
")",
"\n",
"if",
"err",
":=",
"syscall",
".",
"Mknod",
"(",
"devPath",
",",
"uint32",
"(",
"mode",
")",
",",
"encoded_device_number",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"devPath",
",",
"m",
"[",
"\"",
"\"",
"]",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"os",
".",
"Chown",
"(",
"devPath",
",",
"uid",
",",
"gid",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"devPath",
",",
"err",
")",
"\n",
"}",
"\n\n",
"// Needed as mknod respects the umask",
"if",
"err",
":=",
"os",
".",
"Chmod",
"(",
"devPath",
",",
"mode",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"devPath",
",",
"err",
")",
"\n",
"}",
"\n\n",
"idmapset",
",",
"err",
":=",
"c",
".",
"CurrentIdmap",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"idmapset",
"!=",
"nil",
"{",
"if",
"err",
":=",
"idmapset",
".",
"ShiftFile",
"(",
"devPath",
")",
";",
"err",
"!=",
"nil",
"{",
"// uidshift failing is weird, but not a big problem. Log and proceed",
"logger",
".",
"Debugf",
"(",
"\"",
"\\n",
"\"",
",",
"m",
"[",
"\"",
"\"",
"]",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"else",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"devPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"f",
".",
"Close",
"(",
")",
"\n\n",
"err",
"=",
"deviceMountDisk",
"(",
"srcPath",
",",
"devPath",
",",
"false",
",",
"false",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"[",
"]",
"string",
"{",
"devPath",
",",
"relativeDestPath",
"}",
",",
"nil",
"\n",
"}"
] |
21,070 | all-21071 | [
"Check",
"returns",
"true",
"if",
"given",
"string",
"matches",
"stored",
"."
] | [
"func",
"(",
"t",
"*",
"SimpleToken",
")",
"Check",
"(",
"s",
"string",
")",
"bool",
"{",
"t",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"t",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"s",
"==",
"t",
".",
"<mask>",
"\n",
"}"
] |
21,071 | all-21072 | [
"patNextSegment",
"returns",
"the",
"next",
"segment",
"details",
"from",
"a",
"pattern",
":",
"node",
"type",
"param",
"key",
"regexp",
"string",
"param",
"tail",
"byte",
"param",
"starting",
"index",
"param",
"ending",
"index"
] | [
"func",
"patNextSegment",
"(",
"pattern",
"string",
")",
"(",
"nodeTyp",
",",
"string",
",",
"string",
",",
"byte",
",",
"int",
",",
"int",
")",
"{",
"ps",
":=",
"strings",
".",
"Index",
"(",
"pattern",
",",
"\"",
"\"",
")",
"\n",
"ws",
":=",
"strings",
".",
"Index",
"(",
"pattern",
",",
"\"",
"\"",
")",
"\n\n",
"if",
"ps",
"<",
"0",
"&&",
"ws",
"<",
"0",
"{",
"return",
"ntStatic",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"0",
",",
"0",
",",
"len",
"(",
"pattern",
")",
"// we return the entire thing",
"\n",
"}",
"\n\n",
"// Sanity check",
"if",
"ps",
">=",
"0",
"&&",
"ws",
">=",
"0",
"&&",
"ws",
"<",
"ps",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"var",
"tail",
"byte",
"=",
"'/'",
"// Default endpoint tail to / byte",
"\n\n",
"if",
"ps",
">=",
"0",
"{",
"// Param/Regexp pattern is next",
"nt",
":=",
"ntParam",
"\n\n",
"// Read to closing } taking into account opens and closes in curl count (cc)",
"cc",
":=",
"0",
"\n",
"pe",
":=",
"ps",
"\n",
"for",
"i",
",",
"c",
":=",
"range",
"pattern",
"[",
"ps",
":",
"]",
"{",
"if",
"c",
"==",
"'{'",
"{",
"cc",
"++",
"\n",
"}",
"else",
"if",
"c",
"==",
"'}'",
"{",
"cc",
"--",
"\n",
"if",
"cc",
"==",
"0",
"{",
"pe",
"=",
"ps",
"+",
"i",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"pe",
"==",
"ps",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"key",
":=",
"pattern",
"[",
"ps",
"+",
"1",
":",
"pe",
"]",
"\n",
"pe",
"++",
"// set end to next position",
"\n\n",
"if",
"pe",
"<",
"len",
"(",
"pattern",
")",
"{",
"tail",
"=",
"pattern",
"[",
"pe",
"]",
"\n",
"}",
"\n\n",
"<mask>",
"rexpat",
"string",
"\n",
"if",
"idx",
":=",
"strings",
".",
"Index",
"(",
"key",
",",
"\"",
"\"",
")",
";",
"idx",
">=",
"0",
"{",
"nt",
"=",
"ntRegexp",
"\n",
"rexpat",
"=",
"key",
"[",
"idx",
"+",
"1",
":",
"]",
"\n",
"key",
"=",
"key",
"[",
":",
"idx",
"]",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"rexpat",
")",
">",
"0",
"{",
"if",
"rexpat",
"[",
"0",
"]",
"!=",
"'^'",
"{",
"rexpat",
"=",
"\"",
"\"",
"+",
"rexpat",
"\n",
"}",
"\n",
"if",
"rexpat",
"[",
"len",
"(",
"rexpat",
")",
"-",
"1",
"]",
"!=",
"'$'",
"{",
"rexpat",
"=",
"rexpat",
"+",
"\"",
"\"",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nt",
",",
"key",
",",
"rexpat",
",",
"tail",
",",
"ps",
",",
"pe",
"\n",
"}",
"\n\n",
"// Wildcard pattern as finale",
"if",
"ws",
"<",
"len",
"(",
"pattern",
")",
"-",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"ntCatchAll",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"0",
",",
"ws",
",",
"len",
"(",
"pattern",
")",
"\n",
"}"
] |
21,072 | all-21073 | [
"copyLayer",
"copies",
"a",
"layer",
"with",
"srcInfo",
"(",
"with",
"known",
"Digest",
"and",
"possibly",
"known",
"Size",
")",
"in",
"src",
"to",
"dest",
"perhaps",
"compressing",
"it",
"if",
"canCompress",
"and",
"returns",
"a",
"complete",
"blobInfo",
"of",
"the",
"copied",
"layer",
"and",
"a",
"value",
"for",
"LayerDiffIDs",
"if",
"diffIDIsNeeded"
] | [
"func",
"(",
"ic",
"*",
"imageCopier",
")",
"copyLayer",
"(",
"ctx",
"context",
".",
"Context",
",",
"srcInfo",
"types",
".",
"BlobInfo",
",",
"pool",
"*",
"mpb",
".",
"Progress",
")",
"(",
"types",
".",
"BlobInfo",
",",
"digest",
".",
"Digest",
",",
"error",
")",
"{",
"cachedDiffID",
":=",
"ic",
".",
"c",
".",
"blobInfoCache",
".",
"UncompressedDigest",
"(",
"srcInfo",
".",
"Digest",
")",
"// May be \"\"",
"\n",
"diffIDIsNeeded",
":=",
"<mask>",
".",
"diffIDsAreNeeded",
"&&",
"cachedDiffID",
"==",
"\"",
"\"",
"\n\n",
"// If we already have the blob, and we don't need to compute the diffID, then we don't need to read it from the source.",
"if",
"!",
"diffIDIsNeeded",
"{",
"reused",
",",
"blobInfo",
",",
"err",
":=",
"ic",
".",
"c",
".",
"dest",
".",
"TryReusingBlob",
"(",
"ctx",
",",
"srcInfo",
",",
"ic",
".",
"c",
".",
"blobInfoCache",
",",
"ic",
".",
"canSubstituteBlobs",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"types",
".",
"BlobInfo",
"{",
"}",
",",
"\"",
"\"",
",",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"srcInfo",
".",
"Digest",
")",
"\n",
"}",
"\n",
"if",
"reused",
"{",
"logrus",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"srcInfo",
".",
"Digest",
")",
"\n",
"bar",
":=",
"ic",
".",
"c",
".",
"createProgressBar",
"(",
"pool",
",",
"srcInfo",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"bar",
".",
"SetTotal",
"(",
"0",
",",
"true",
")",
"\n",
"return",
"blobInfo",
",",
"cachedDiffID",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Fallback: copy the layer, computing the diffID if we need to do so",
"srcStream",
",",
"srcBlobSize",
",",
"err",
":=",
"ic",
".",
"c",
".",
"rawSource",
".",
"GetBlob",
"(",
"ctx",
",",
"srcInfo",
",",
"ic",
".",
"c",
".",
"blobInfoCache",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"types",
".",
"BlobInfo",
"{",
"}",
",",
"\"",
"\"",
",",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"srcInfo",
".",
"Digest",
")",
"\n",
"}",
"\n",
"defer",
"srcStream",
".",
"Close",
"(",
")",
"\n\n",
"bar",
":=",
"ic",
".",
"c",
".",
"createProgressBar",
"(",
"pool",
",",
"srcInfo",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"blobInfo",
",",
"diffIDChan",
",",
"err",
":=",
"ic",
".",
"copyLayerFromStream",
"(",
"ctx",
",",
"srcStream",
",",
"types",
".",
"BlobInfo",
"{",
"Digest",
":",
"srcInfo",
".",
"Digest",
",",
"Size",
":",
"srcBlobSize",
"}",
",",
"diffIDIsNeeded",
",",
"bar",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"types",
".",
"BlobInfo",
"{",
"}",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"diffID",
":=",
"cachedDiffID",
"\n",
"if",
"diffIDIsNeeded",
"{",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"types",
".",
"BlobInfo",
"{",
"}",
",",
"\"",
"\"",
",",
"ctx",
".",
"Err",
"(",
")",
"\n",
"case",
"diffIDResult",
":=",
"<-",
"diffIDChan",
":",
"if",
"diffIDResult",
".",
"err",
"!=",
"nil",
"{",
"return",
"types",
".",
"BlobInfo",
"{",
"}",
",",
"\"",
"\"",
",",
"errors",
".",
"Wrap",
"(",
"diffIDResult",
".",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"logrus",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"diffIDResult",
".",
"digest",
",",
"srcInfo",
".",
"Digest",
")",
"\n",
"// This is safe because we have just computed diffIDResult.Digest ourselves, and in the process",
"// we have read all of the input blob, so srcInfo.Digest must have been validated by digestingReader.",
"ic",
".",
"c",
".",
"blobInfoCache",
".",
"RecordDigestUncompressedPair",
"(",
"srcInfo",
".",
"Digest",
",",
"diffIDResult",
".",
"digest",
")",
"\n",
"diffID",
"=",
"diffIDResult",
".",
"digest",
"\n",
"}",
"\n",
"}",
"\n\n",
"bar",
".",
"SetTotal",
"(",
"srcInfo",
".",
"Size",
",",
"true",
")",
"\n",
"return",
"blobInfo",
",",
"diffID",
",",
"nil",
"\n",
"}"
] |
21,073 | all-21074 | [
"NewAuthenticator",
"constructs",
"a",
"new",
"Authenticator",
"from",
"a",
"store",
"and",
"policy",
"."
] | [
"func",
"NewAuthenticator",
"(",
"store",
"*",
"coal",
".",
"Store",
",",
"policy",
"*",
"Policy",
")",
"*",
"Authenticator",
"{",
"// initialize token",
"coal",
".",
"Init",
"(",
"policy",
".",
"Token",
")",
"\n\n",
"// initialize clients",
"for",
"_",
",",
"model",
":=",
"range",
"policy",
".",
"Clients",
"{",
"coal",
".",
"Init",
"(",
"model",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"Authenticator",
"{",
"store",
":",
"store",
",",
"policy",
":",
"<mask>",
",",
"}",
"\n",
"}"
] |
21,074 | all-21075 | [
"ParseIPv4",
"parses",
"ip",
"address",
"from",
"ipStr",
"into",
"dst",
"and",
"returns",
"the",
"extended",
"dst",
"."
] | [
"func",
"ParseIPv4",
"(",
"dst",
"net",
".",
"IP",
",",
"ipStr",
"[",
"]",
"byte",
")",
"(",
"net",
".",
"IP",
",",
"error",
")",
"{",
"if",
"len",
"(",
"ipStr",
")",
"==",
"0",
"{",
"return",
"dst",
",",
"errEmptyIPStr",
"\n",
"}",
"\n",
"if",
"len",
"(",
"dst",
")",
"<",
"<mask>",
".",
"IPv4len",
"{",
"dst",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"net",
".",
"IPv4len",
")",
"\n",
"}",
"\n",
"copy",
"(",
"dst",
",",
"net",
".",
"IPv4zero",
")",
"\n",
"dst",
"=",
"dst",
".",
"To4",
"(",
")",
"\n",
"if",
"dst",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"b",
":=",
"ipStr",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
"{",
"n",
":=",
"bytes",
".",
"IndexByte",
"(",
"b",
",",
"'.'",
")",
"\n",
"if",
"n",
"<",
"0",
"{",
"return",
"dst",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ipStr",
")",
"\n",
"}",
"\n",
"v",
",",
"err",
":=",
"ParseUint",
"(",
"b",
"[",
":",
"n",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"dst",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ipStr",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"v",
">",
"255",
"{",
"return",
"dst",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ipStr",
",",
"v",
")",
"\n",
"}",
"\n",
"dst",
"[",
"i",
"]",
"=",
"byte",
"(",
"v",
")",
"\n",
"b",
"=",
"b",
"[",
"n",
"+",
"1",
":",
"]",
"\n",
"}",
"\n",
"v",
",",
"err",
":=",
"ParseUint",
"(",
"b",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"dst",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ipStr",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"v",
">",
"255",
"{",
"return",
"dst",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ipStr",
",",
"v",
")",
"\n",
"}",
"\n",
"dst",
"[",
"3",
"]",
"=",
"byte",
"(",
"v",
")",
"\n\n",
"return",
"dst",
",",
"nil",
"\n",
"}"
] |
21,075 | all-21076 | [
"multiply",
"the",
"current",
"matrix",
"with",
"an",
"orthographic",
"matrix"
] | [
"func",
"Ortho",
"(",
"left",
"float64",
",",
"right",
"float64",
",",
"bottom",
"float64",
",",
"<mask>",
"float64",
",",
"zNear",
"float64",
",",
"zFar",
"float64",
")",
"{",
"syscall",
".",
"Syscall6",
"(",
"gpOrtho",
",",
"6",
",",
"uintptr",
"(",
"math",
".",
"Float64bits",
"(",
"left",
")",
")",
",",
"uintptr",
"(",
"math",
".",
"Float64bits",
"(",
"right",
")",
")",
",",
"uintptr",
"(",
"math",
".",
"Float64bits",
"(",
"bottom",
")",
")",
",",
"uintptr",
"(",
"math",
".",
"Float64bits",
"(",
"top",
")",
")",
",",
"uintptr",
"(",
"math",
".",
"Float64bits",
"(",
"zNear",
")",
")",
",",
"uintptr",
"(",
"math",
".",
"Float64bits",
"(",
"zFar",
")",
")",
")",
"\n",
"}"
] |
21,076 | all-21077 | [
"StoragePoolConfigAdd",
"adds",
"a",
"new",
"entry",
"in",
"the",
"storage_pools_config",
"table"
] | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"StoragePoolConfigAdd",
"(",
"poolID",
",",
"nodeID",
"int64",
",",
"config",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"return",
"storagePoolConfigAdd",
"(",
"c",
".",
"<mask>",
",",
"poolID",
",",
"nodeID",
",",
"config",
")",
"\n",
"}"
] |
21,077 | all-21078 | [
"addToStatsContainerMapUnsafe",
"adds",
"the",
"statscontainer",
"into",
"stats",
"for",
"tracking",
"and",
"returns",
"a",
"boolean",
"indicates",
"whether",
"this",
"container",
"should",
"be",
"tracked",
"for",
"collecting",
"metrics"
] | [
"func",
"(",
"engine",
"*",
"DockerStatsEngine",
")",
"addToStatsContainerMapUnsafe",
"(",
"taskARN",
",",
"containerID",
"string",
",",
"statsContainer",
"*",
"StatsContainer",
",",
"statsMapToUpdate",
"func",
"(",
")",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]",
"*",
"StatsContainer",
")",
"bool",
"{",
"taskToContainerMap",
":=",
"statsMapToUpdate",
"(",
")",
"\n\n",
"// Check if this container is already being watched.",
"_",
",",
"taskExists",
":=",
"taskToContainerMap",
"[",
"taskARN",
"]",
"\n",
"if",
"taskExists",
"{",
"// task arn exists in map.",
"_",
",",
"containerExists",
":=",
"taskToContainerMap",
"[",
"taskARN",
"]",
"[",
"containerID",
"]",
"\n",
"if",
"containerExists",
"{",
"// container arn exists in map.",
"seelog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"containerID",
")",
"\n",
"return",
"false",
"\n",
"}",
"\n",
"}",
"else",
"{",
"// Create a map for the task arn if it doesn't exist yet.",
"taskToContainerMap",
"[",
"taskARN",
"]",
"=",
"<mask>",
"(",
"map",
"[",
"string",
"]",
"*",
"StatsContainer",
")",
"\n",
"}",
"\n",
"taskToContainerMap",
"[",
"taskARN",
"]",
"[",
"containerID",
"]",
"=",
"statsContainer",
"\n\n",
"return",
"true",
"\n",
"}"
] |
21,078 | all-21079 | [
"NewStreamAt",
"creates",
"a",
"new",
"Stream",
"at",
"a",
"particular",
"timestamp",
".",
"Should",
"only",
"be",
"used",
"with",
"managed",
"DB",
"."
] | [
"func",
"(",
"db",
"*",
"DB",
")",
"NewStreamAt",
"(",
"readTs",
"uint64",
")",
"*",
"Stream",
"{",
"if",
"!",
"db",
".",
"opt",
".",
"managedTxns",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"stream",
":=",
"db",
".",
"newStream",
"(",
")",
"\n",
"stream",
".",
"readTs",
"=",
"readTs",
"\n",
"return",
"<mask>",
"\n",
"}"
] |
21,079 | all-21080 | [
"APIURL",
"-",
"Establishes",
"the",
"ApiURL",
"given",
"a",
"whether",
"the",
"Label",
"is",
"a",
"Person",
"Organisation",
"or",
"Company",
"(",
"Public",
"or",
"Private",
")"
] | [
"func",
"APIURL",
"(",
"uuid",
"string",
",",
"labels",
"[",
"]",
"string",
",",
"env",
"string",
")",
"string",
"{",
"base",
":=",
"\"",
"\"",
"\n",
"if",
"env",
"==",
"\"",
"\"",
"{",
"base",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"path",
":=",
"\"",
"\"",
"\n",
"mostSpecific",
",",
"err",
":=",
"MostSpecificType",
"(",
"labels",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"for",
"t",
":=",
"mostSpecific",
";",
"t",
"!=",
"\"",
"\"",
"&&",
"<mask>",
"==",
"\"",
"\"",
";",
"t",
"=",
"ParentType",
"(",
"t",
")",
"{",
"path",
"=",
"apiPaths",
"[",
"t",
"]",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"path",
"==",
"\"",
"\"",
"{",
"// TODO: I don't thing we should default to this, but I kept it",
"// for compatability and because this function can't return an error",
"path",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"base",
"+",
"path",
"+",
"\"",
"\"",
"+",
"uuid",
"\n",
"}"
] |
21,080 | all-21081 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"TakeTypeProfileParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoProfiler3",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"<mask>",
"(",
")",
"\n",
"}"
] |
21,081 | all-21082 | [
"Update",
"returns",
"the",
"difference",
"between",
"two",
"sets"
] | [
"func",
"(",
"list",
"Devices",
")",
"Update",
"(",
"newlist",
"Devices",
")",
"(",
"map",
"[",
"string",
"]",
"Device",
",",
"map",
"[",
"string",
"]",
"Device",
",",
"map",
"[",
"string",
"]",
"Device",
",",
"[",
"]",
"string",
")",
"{",
"rmlist",
":=",
"map",
"[",
"string",
"]",
"Device",
"{",
"}",
"\n",
"addlist",
":=",
"map",
"[",
"string",
"]",
"Device",
"{",
"}",
"\n",
"updatelist",
":=",
"map",
"[",
"string",
"]",
"Device",
"{",
"}",
"\n\n",
"for",
"key",
",",
"d",
":=",
"<mask>",
"list",
"{",
"if",
"!",
"newlist",
".",
"Contains",
"(",
"key",
",",
"d",
")",
"{",
"rmlist",
"[",
"key",
"]",
"=",
"d",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"key",
",",
"d",
":=",
"range",
"newlist",
"{",
"if",
"!",
"list",
".",
"Contains",
"(",
"key",
",",
"d",
")",
"{",
"addlist",
"[",
"key",
"]",
"=",
"d",
"\n",
"}",
"\n",
"}",
"\n\n",
"updateDiff",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"key",
",",
"d",
":=",
"range",
"addlist",
"{",
"srcOldDevice",
":=",
"rmlist",
"[",
"key",
"]",
"\n",
"var",
"oldDevice",
"Device",
"\n",
"err",
":=",
"shared",
".",
"DeepCopy",
"(",
"&",
"srcOldDevice",
",",
"&",
"oldDevice",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"continue",
"\n",
"}",
"\n\n",
"srcNewDevice",
":=",
"newlist",
"[",
"key",
"]",
"\n",
"var",
"newDevice",
"Device",
"\n",
"err",
"=",
"shared",
".",
"DeepCopy",
"(",
"&",
"srcNewDevice",
",",
"&",
"newDevice",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"continue",
"\n",
"}",
"\n\n",
"updateDiff",
"=",
"deviceEqualsDiffKeys",
"(",
"oldDevice",
",",
"newDevice",
")",
"\n\n",
"for",
"_",
",",
"k",
":=",
"range",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"{",
"delete",
"(",
"oldDevice",
",",
"k",
")",
"\n",
"delete",
"(",
"newDevice",
",",
"k",
")",
"\n",
"}",
"\n\n",
"if",
"deviceEquals",
"(",
"oldDevice",
",",
"newDevice",
")",
"{",
"delete",
"(",
"rmlist",
",",
"key",
")",
"\n",
"delete",
"(",
"addlist",
",",
"key",
")",
"\n",
"updatelist",
"[",
"key",
"]",
"=",
"d",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"rmlist",
",",
"addlist",
",",
"updatelist",
",",
"updateDiff",
"\n",
"}"
] |
21,082 | all-21083 | [
"ConfigureNetworks",
"updates",
"the",
"agent",
"settings",
"with",
"the",
"networks",
"settings",
"."
] | [
"func",
"(",
"<mask>",
"AgentSettings",
")",
"ConfigureNetworks",
"(",
"networksSettings",
"NetworksSettings",
")",
"AgentSettings",
"{",
"as",
".",
"Networks",
"=",
"networksSettings",
"\n\n",
"return",
"as",
"\n",
"}"
] |
21,083 | all-21084 | [
"returns",
"ipfs",
"version",
"and",
"commit",
"sha"
] | [
"func",
"(",
"s",
"*",
"Shell",
")",
"Version",
"(",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"ver",
":=",
"struct",
"{",
"Version",
"string",
"\n",
"Commit",
"string",
"\n",
"}",
"{",
"}",
"\n\n",
"if",
"err",
":=",
"s",
".",
"<mask>",
"(",
"\"",
"\"",
")",
".",
"Exec",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"ver",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"ver",
".",
"Version",
",",
"ver",
".",
"Commit",
",",
"nil",
"\n",
"}"
] |
21,084 | all-21085 | [
"MutateSetOptions",
"for",
"Thresholds",
"sets",
"the",
"SetOptionsOp",
"s",
"thresholds",
"fields"
] | [
"func",
"(",
"m",
"Thresholds",
")",
"MutateSetOptions",
"(",
"o",
"*",
"xdr",
".",
"SetOptionsOp",
")",
"(",
"err",
"<mask>",
")",
"{",
"if",
"m",
".",
"Low",
"!=",
"nil",
"{",
"val",
":=",
"xdr",
".",
"Uint32",
"(",
"*",
"m",
".",
"Low",
")",
"\n",
"o",
".",
"LowThreshold",
"=",
"&",
"val",
"\n",
"}",
"\n\n",
"if",
"m",
".",
"Medium",
"!=",
"nil",
"{",
"val",
":=",
"xdr",
".",
"Uint32",
"(",
"*",
"m",
".",
"Medium",
")",
"\n",
"o",
".",
"MedThreshold",
"=",
"&",
"val",
"\n",
"}",
"\n\n",
"if",
"m",
".",
"High",
"!=",
"nil",
"{",
"val",
":=",
"xdr",
".",
"Uint32",
"(",
"*",
"m",
".",
"High",
")",
"\n",
"o",
".",
"HighThreshold",
"=",
"&",
"val",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] |
21,085 | all-21086 | [
"Uint64Var",
"defines",
"a",
"uint64",
"flag",
"with",
"specified",
"name",
"default",
"value",
"and",
"usage",
"string",
".",
"The",
"argument",
"p",
"points",
"to",
"a",
"uint64",
"variable",
"in",
"which",
"to",
"store",
"the",
"value",
"of",
"the",
"flag",
"."
] | [
"func",
"Uint64Var",
"(",
"p",
"*",
"uint64",
",",
"name",
"string",
",",
"value",
"uint64",
",",
"usage",
"string",
")",
"{",
"EnvironmentFlags",
".",
"Uint64Var",
"(",
"p",
",",
"name",
",",
"<mask>",
",",
"usage",
")",
"\n",
"}"
] |
21,086 | all-21087 | [
"title",
":",
"delete",
"autoscale",
"rule",
"path",
":",
"/",
"autoscale",
"/",
"rules",
"/",
"{",
"id",
"}",
"method",
":",
"DELETE",
"responses",
":",
"200",
":",
"Ok",
"401",
":",
"Unauthorized",
"404",
":",
"Not",
"found"
] | [
"func",
"autoScaleDeleteRule",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"t",
"auth",
".",
"Token",
")",
"(",
"err",
"error",
")",
"{",
"allowedDeleteRule",
":=",
"permission",
".",
"Check",
"(",
"t",
",",
"permission",
".",
"PermNodeAutoscale",
")",
"\n",
"if",
"!",
"allowedDeleteRule",
"{",
"return",
"permission",
".",
"ErrUnauthorized",
"\n",
"}",
"\n",
"rulePool",
":=",
"r",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"var",
"ctxs",
"[",
"]",
"permTypes",
".",
"PermissionContext",
"\n",
"if",
"rulePool",
"!=",
"\"",
"\"",
"{",
"ctxs",
"=",
"append",
"(",
"ctxs",
",",
"permission",
".",
"Context",
"(",
"permTypes",
".",
"CtxPool",
",",
"rulePool",
")",
")",
"\n",
"}",
"\n",
"evt",
",",
"err",
":=",
"event",
".",
"New",
"(",
"&",
"event",
".",
"Opts",
"{",
"Target",
":",
"event",
".",
"Target",
"{",
"Type",
":",
"event",
".",
"TargetTypePool",
",",
"Value",
":",
"rulePool",
"}",
",",
"Kind",
":",
"permission",
".",
"PermNodeAutoscaleDelete",
",",
"Owner",
":",
"t",
",",
"CustomData",
":",
"<mask>",
".",
"FormToCustomData",
"(",
"InputFields",
"(",
"r",
")",
")",
",",
"Allowed",
":",
"event",
".",
"Allowed",
"(",
"permission",
".",
"PermPoolReadEvents",
",",
"ctxs",
"...",
")",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"evt",
".",
"Done",
"(",
"err",
")",
"}",
"(",
")",
"\n",
"err",
"=",
"autoscale",
".",
"DeleteRule",
"(",
"rulePool",
")",
"\n",
"if",
"err",
"==",
"mgo",
".",
"ErrNotFound",
"{",
"return",
"&",
"tsuruErrors",
".",
"HTTP",
"{",
"Code",
":",
"http",
".",
"StatusNotFound",
",",
"Message",
":",
"\"",
"\"",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
21,087 | all-21088 | [
"Start",
"starts",
"the",
"existing",
"VM",
"instance",
"."
] | [
"func",
"(",
"d",
"*",
"Driver",
")",
"Start",
"(",
")",
"error",
"{",
"<mask>",
":=",
"d",
".",
"client",
"(",
")",
"\n",
"_",
",",
"err",
":=",
"cs",
".",
"RequestWithContext",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"&",
"egoscale",
".",
"StartVirtualMachine",
"{",
"ID",
":",
"d",
".",
"ID",
",",
"}",
")",
"\n\n",
"return",
"err",
"\n",
"}"
] |
21,088 | all-21089 | [
"GetApplicationID",
"is",
"a",
"wrapper",
"around",
"g_application_get_application_id",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Application",
")",
"GetApplicationID",
"(",
")",
"string",
"{",
"c",
":=",
"C",
".",
"g_application_get_application_id",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n\n",
"return",
"C",
".",
"GoString",
"(",
"(",
"*",
"C",
".",
"<mask>",
")",
"(",
"c",
")",
")",
"\n",
"}"
] |
21,089 | all-21090 | [
"flattenClusterDrsVmConfigInfo",
"saves",
"a",
"ClusterDrsVmConfigInfo",
"into",
"the",
"supplied",
"ResourceData",
"."
] | [
"func",
"flattenClusterDrsVMConfigInfo",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
",",
"obj",
"*",
"<mask>",
".",
"ClusterDrsVmConfigInfo",
")",
"error",
"{",
"return",
"structure",
".",
"SetBatch",
"(",
"d",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"obj",
".",
"Behavior",
",",
"\"",
"\"",
":",
"obj",
".",
"Enabled",
",",
"}",
")",
"\n",
"}"
] |
21,090 | all-21091 | [
"ContentType",
"returns",
"a",
"valid",
"content",
"type"
] | [
"func",
"(",
"r",
"*",
"<mask>",
")",
"ContentType",
"(",
")",
"string",
"{",
"if",
"r",
".",
"contentType",
"==",
"\"",
"\"",
"{",
"r",
".",
"contentType",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"r",
".",
"contentType",
"\n",
"}"
] |
21,091 | all-21092 | [
"get",
"returns",
"the",
"value",
"in",
"memtable",
"or",
"disk",
"for",
"given",
"key",
".",
"Note",
"that",
"value",
"will",
"include",
"meta",
"byte",
".",
"IMPORTANT",
":",
"We",
"should",
"never",
"write",
"an",
"entry",
"with",
"an",
"older",
"timestamp",
"for",
"the",
"same",
"key",
"We",
"need",
"to",
"maintain",
"this",
"invariant",
"to",
"search",
"for",
"the",
"latest",
"value",
"of",
"a",
"key",
"or",
"else",
"we",
"need",
"to",
"search",
"in",
"all",
"tables",
"and",
"find",
"the",
"max",
"version",
"among",
"them",
".",
"To",
"maintain",
"this",
"invariant",
"we",
"also",
"need",
"to",
"ensure",
"that",
"all",
"versions",
"of",
"a",
"key",
"are",
"always",
"present",
"in",
"the",
"same",
"table",
"from",
"level",
"1",
"because",
"compaction",
"can",
"push",
"any",
"table",
"down",
".",
"Update",
"(",
"Sep",
"22",
"2018",
")",
":",
"To",
"maintain",
"the",
"above",
"invariant",
"and",
"to",
"allow",
"keys",
"to",
"be",
"moved",
"from",
"one",
"value",
"log",
"to",
"another",
"(",
"while",
"reclaiming",
"space",
"during",
"value",
"log",
"GC",
")",
"we",
"have",
"logically",
"moved",
"this",
"need",
"to",
"write",
"old",
"versions",
"after",
"new",
"versions",
"to",
"the",
"badgerMove",
"keyspace",
".",
"Thus",
"for",
"normal",
"gets",
"we",
"can",
"stop",
"going",
"down",
"the",
"LSM",
"tree",
"once",
"we",
"find",
"any",
"version",
"of",
"the",
"key",
"(",
"note",
"however",
"that",
"we",
"will",
"ALWAYS",
"skip",
"versions",
"with",
"ts",
"greater",
"than",
"the",
"key",
"version",
")",
".",
"However",
"if",
"that",
"key",
"has",
"been",
"moved",
"then",
"for",
"the",
"corresponding",
"movekey",
"we",
"ll",
"look",
"through",
"all",
"the",
"levels",
"of",
"the",
"tree",
"to",
"ensure",
"that",
"we",
"pick",
"the",
"highest",
"version",
"of",
"the",
"movekey",
"present",
"."
] | [
"func",
"(",
"<mask>",
"*",
"DB",
")",
"get",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"y",
".",
"ValueStruct",
",",
"error",
")",
"{",
"tables",
",",
"decr",
":=",
"db",
".",
"getMemTables",
"(",
")",
"// Lock should be released.",
"\n",
"defer",
"decr",
"(",
")",
"\n\n",
"var",
"maxVs",
"*",
"y",
".",
"ValueStruct",
"\n",
"var",
"version",
"uint64",
"\n",
"if",
"bytes",
".",
"HasPrefix",
"(",
"key",
",",
"badgerMove",
")",
"{",
"// If we are checking badgerMove key, we should look into all the",
"// levels, so we can pick up the newer versions, which might have been",
"// compacted down the tree.",
"maxVs",
"=",
"&",
"y",
".",
"ValueStruct",
"{",
"}",
"\n",
"version",
"=",
"y",
".",
"ParseTs",
"(",
"key",
")",
"\n",
"}",
"\n\n",
"y",
".",
"NumGets",
".",
"Add",
"(",
"1",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"tables",
")",
";",
"i",
"++",
"{",
"vs",
":=",
"tables",
"[",
"i",
"]",
".",
"Get",
"(",
"key",
")",
"\n",
"y",
".",
"NumMemtableGets",
".",
"Add",
"(",
"1",
")",
"\n",
"if",
"vs",
".",
"Meta",
"==",
"0",
"&&",
"vs",
".",
"Value",
"==",
"nil",
"{",
"continue",
"\n",
"}",
"\n",
"// Found a version of the key. For user keyspace, return immediately. For move keyspace,",
"// continue iterating, unless we found a version == given key version.",
"if",
"maxVs",
"==",
"nil",
"||",
"vs",
".",
"Version",
"==",
"version",
"{",
"return",
"vs",
",",
"nil",
"\n",
"}",
"\n",
"if",
"maxVs",
".",
"Version",
"<",
"vs",
".",
"Version",
"{",
"*",
"maxVs",
"=",
"vs",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"db",
".",
"lc",
".",
"get",
"(",
"key",
",",
"maxVs",
")",
"\n",
"}"
] |
21,092 | all-21093 | [
"Calculates",
"the",
"per",
"-",
"element",
"bit",
"-",
"wise",
"“exclusive",
"or”",
"operation",
"on",
"two",
"arrays",
"with",
"a",
"mask",
"."
] | [
"func",
"XorWithMask",
"(",
"src1",
",",
"src2",
",",
"dst",
",",
"<mask>",
"*",
"IplImage",
")",
"{",
"C",
".",
"cvXor",
"(",
"unsafe",
".",
"Pointer",
"(",
"src1",
")",
",",
"unsafe",
".",
"Pointer",
"(",
"src2",
")",
",",
"unsafe",
".",
"Pointer",
"(",
"dst",
")",
",",
"unsafe",
".",
"Pointer",
"(",
"mask",
")",
",",
")",
"\n",
"}"
] |
21,093 | all-21094 | [
"Publish",
"message",
"to",
"given",
"channels",
"."
] | [
"func",
"Publish",
"(",
"channels",
"[",
"]",
"string",
",",
"<mask>",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"hubInstance",
"==",
"nil",
"{",
"return",
"errorNohub",
"\n",
"}",
"\n",
"log",
".",
"Debug",
"(",
"\"",
"\"",
",",
"channels",
")",
"\n",
"hubInstance",
".",
"Publish",
"(",
"channels",
",",
"msg",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
21,094 | all-21095 | [
"RemoveImage",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockDockerClient",
")",
"RemoveImage",
"(",
"arg0",
"<mask>",
".",
"Context",
",",
"arg1",
"string",
",",
"arg2",
"time",
".",
"Duration",
")",
"error",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
",",
"arg1",
",",
"arg2",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"error",
")",
"\n",
"return",
"ret0",
"\n",
"}"
] |
21,095 | all-21096 | [
"HasPalette",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"c",
"*",
"ConditionalFormat",
")",
"HasPalette",
"(",
")",
"bool",
"{",
"if",
"c",
"!=",
"nil",
"&&",
"c",
".",
"Palette",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
21,096 | all-21097 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"GetPossibleBreakpointsParams",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoDebugger36",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
21,097 | all-21098 | [
"finishesCall",
"checks",
"whether",
"this",
"frame",
"is",
"the",
"last",
"one",
"we",
"should",
"expect",
"for",
"this",
"RPC",
"req",
"-",
"res",
"."
] | [
"func",
"finishesCall",
"(",
"f",
"*",
"Frame",
")",
"bool",
"{",
"switch",
"f",
".",
"messageType",
"(",
")",
"{",
"case",
"messageTypeError",
":",
"return",
"true",
"\n",
"<mask>",
"messageTypeCallRes",
",",
"messageTypeCallResContinue",
":",
"flags",
":=",
"f",
".",
"Payload",
"[",
"_flagsIndex",
"]",
"\n",
"return",
"flags",
"&",
"hasMoreFragmentsFlag",
"==",
"0",
"\n",
"default",
":",
"return",
"false",
"\n",
"}",
"\n",
"}"
] |
21,098 | all-21099 | [
"SetText",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_progress_bar_set_text",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"ProgressBar",
")",
"SetText",
"(",
"text",
"string",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"text",
")",
"\n",
"defer",
"C",
".",
"<mask>",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"C",
".",
"gtk_progress_bar_set_text",
"(",
"v",
".",
"native",
"(",
")",
",",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
")",
"\n",
"}"
] |
21,099 | all-21100 | [
"Draw",
"a",
"line",
"with",
"an",
"angle",
"with",
"specified",
"line",
"cap",
"and",
"join"
] | [
"func",
"Draw",
"(",
"gc",
"draw2d",
".",
"GraphicContext",
",",
"cap",
"draw2d",
".",
"LineCap",
",",
"join",
"draw2d",
".",
"LineJoin",
",",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
",",
"offset",
"float64",
")",
"{",
"gc",
".",
"SetLineCap",
"(",
"cap",
")",
"\n",
"gc",
".",
"SetLineJoin",
"(",
"join",
")",
"\n\n",
"// Draw thick line",
"gc",
".",
"SetStrokeColor",
"(",
"color",
".",
"NRGBA",
"{",
"0x33",
",",
"0x33",
",",
"0x33",
",",
"0xFF",
"}",
")",
"\n",
"gc",
".",
"SetLineWidth",
"(",
"30.0",
")",
"\n",
"gc",
".",
"MoveTo",
"(",
"x0",
",",
"y0",
")",
"\n",
"gc",
".",
"LineTo",
"(",
"(",
"x0",
"+",
"x1",
")",
"/",
"2",
"+",
"<mask>",
",",
"(",
"y0",
"+",
"y1",
")",
"/",
"2",
")",
"\n",
"gc",
".",
"LineTo",
"(",
"x1",
",",
"y1",
")",
"\n",
"gc",
".",
"Stroke",
"(",
")",
"\n\n",
"// Draw thin helping line",
"gc",
".",
"SetStrokeColor",
"(",
"color",
".",
"NRGBA",
"{",
"0xFF",
",",
"0x33",
",",
"0x33",
",",
"0xFF",
"}",
")",
"\n",
"gc",
".",
"SetLineWidth",
"(",
"2.56",
")",
"\n",
"gc",
".",
"MoveTo",
"(",
"x0",
",",
"y0",
")",
"\n",
"gc",
".",
"LineTo",
"(",
"(",
"x0",
"+",
"x1",
")",
"/",
"2",
"+",
"offset",
",",
"(",
"y0",
"+",
"y1",
")",
"/",
"2",
")",
"\n",
"gc",
".",
"LineTo",
"(",
"x1",
",",
"y1",
")",
"\n",
"gc",
".",
"Stroke",
"(",
")",
"\n",
"}"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.