anchor dict | positive dict | negative dict |
|---|---|---|
{
"audio": "",
"image": "",
"text": "func (db *database) Lookup(hash hashPrefix) (h hashPrefix, tds []ThreatDescriptor) {\n\tif !hash.IsFull() {\n\t\tpanic(\"hash is not full\")\n\t}\n\n\tdb.ml.RLock()\n\tfor td, hs := range db.tfl {\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tif n := hs.Lookup(hash); n > 0 {\n\t\t\th = hash[:n]\n\t\t\ttds = append(tds, td)\n\t\t}\n\t}\n\tdb.ml.RUnlock()\n\treturn h, tds\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " db.ml.Unlock()\n\n\tif db.err != nil {\n\t\tclose(db.readyCh)\n\t}\n\tdb.err = nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (db *database) setError(err error) {\n\tdb.tfu = nil\n\n\tdb.ml.Lock()\n\tif db.err == nil {\n\t\tdb.readyCh = make(chan struct{})",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t}\n\tdb.tfl, db.err, db.last = nil, err, time.Time{}\n\tdb.ml.Unlock()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " db.ml.Unlock()\n\n\tif db.err != nil {\n\t\tclose(db.readyCh)\n\t}\n\tdb.err = nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (db *database) isStale(lastUpdate time.Time) bool {\n\tif db.config.now().Sub(lastUpdate)",
"video": ""
} | {
"audio": "",
"image": "",
"text": " > 2*(db.config.UpdatePeriod+jitter) {\n\t\treturn true\n\t}\n\treturn false\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tswitch d {\n\t\t\t\tcase time.Millisecond:\n\t\t\t\t\tts = time.Unix(int64(i/1000), 1000000*int64(i%1000))\n\t\t\t\tcase time.Second:\n\t\t\t\t\tts = time.Unix(int64(i), 0)\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(\"invalid time unit (d). Fixme!\")\n\t\t\t\t}\n\t\t\t\tnow := m.now... |
{
"audio": "",
"image": "",
"text": "func (db *database) setStale() {\n\tif db.err ==",
"video": ""
} | {
"audio": "",
"image": "",
"text": " nil {\n\t\tdb.readyCh = make(chan struct{})\n\t}\n\tdb.err = errStale\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " db.ml.Unlock()\n\n\tif db.err != nil {\n\t\tclose(db.readyCh)\n\t}\n\tdb.err = nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (db *database) clearError() {\n\tdb.ml.Lock()\n\tdefer",
"video": ""
} | {
"audio": "",
"image": "",
"text": " db.ml.Unlock()\n\n\tif db.err != nil {\n\t\tclose(db.readyCh)\n\t}\n\tdb.err = nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tdefer db.mtx.Unlock()\n\n\treturn db.lastSync\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (db *database) generateThreatsForUpdate() {\n\tif db.tfu == nil {\n\t\tdb.tfu = make(threatsForUpdate)\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t}\n\n\tdb.ml.RLock()\n\tfor td, hs := range db.tfl {\n\t\tphs := db.tfu[td]\n\t\tphs.Hashes = hs.Export()\n\t\tdb.tfu[td] = phs\n\t}\n\tdb.ml.RUnlock()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " db.ml.Unlock()\n\n\tif db.err != nil {\n\t\tclose(db.readyCh)\n\t}\n\tdb.err = nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (db *database) generateThreatsForLookups(last time.Time) {\n\ttfl := make(threatsForLookup)\n\tfor td, phs := range db.tfu {\n\t\tvar hs hashSet\n\t\ths.Import(phs.Hashes)\n\t\ttfl[td] = hs",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\n\t\tphs.Hashes = nil // Clear hashes to keep memory usage low\n\t\tdb.tfu[td] = phs\n\t}\n\n\tdb.ml.Lock()\n\twasBad := db.err != nil\n\tdb.tfl, db.last = tfl, last\n\tdb.ml.Unlock()\n\n\tif wasBad {\n\t\tdb.clearError()\n\t\tdb.log.Printf(\"database is now healthy\")\n\t}... | {
"audio": "",
"image": "",
"text": " newHookWeightSorter(hooks)\n\tsort.Sort(hs)\n\treturn hs.hooks\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func saveDatabase(path string, db databaseFormat) (err error) {\n\tvar file *os.File\n\tfile, err = os.Create(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\tif cerr := file.Close(); err == nil {\n\t\t\terr = cerr\n\t\t}\n\t}()\n\n\tgz, err := gzip.NewWrit... | {
"audio": "",
"image": "",
"text": "\tif zerr := gz.Close(); err == nil {\n\t\t\terr = zerr\n\t\t}\n\t}()\n\n\tencoder := gob.NewEncoder(gz)\n\tif err = encoder.Encode(db); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " nil {\n\t\treturn error\n\t}\n\tfile, error := os.Create(filename)\n\tif error != nil {\n\t\treturn error\n\t}\n\t_, err := file.WriteString(content)\n\treturn err\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func loadDatabase(path string) (db databaseFormat, err error) {\n\tvar file *os.File\n\tfile, err = os.Open(path)\n\tif err != nil {\n\t\treturn db, err\n\t}\n\tdefer func() {\n\t\tif cerr := file.Close(); err == nil {\n\t\t\terr = cerr\n\t\t}\n\t}()\n\n\tgz, err := gzip.NewRe... | {
"audio": "",
"image": "",
"text": "\n\t}()\n\n\tdecoder := gob.NewDecoder(gz)\n\tif err = decoder.Decode(&db); err != nil {\n\t\treturn db, err\n\t}\n\tfor _, dv := range db.Table {\n\t\tif !bytes.Equal(dv.SHA256, dv.Hashes.SHA256()) {\n\t\t\treturn db, errors.New(\"safebrowsing: threat list SHA256 mismatch\")\... | {
"audio": "",
"image": "",
"text": "\t}\n\t\t\t// If it is not running, make sure the backup is legit\n\t\t\tif !bf.InProgress {\n\t\t\t\tisbackup := func(filename string) bool {\n\t\t\t\t\tfh, err := os.Open(fullpath)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t\tdefer fh.Close()\... |
{
"audio": "",
"image": "",
"text": "func (tfu threatsForUpdate) update(resp *pb.FetchThreatListUpdatesResponse) error {\n\t// For each update response do the removes and adds\n\tfor _, m := range resp.GetListUpdateResponses() {\n\t\ttd := ThreatDescriptor{\n\t\t\tPlatformType: PlatformType(m.PlatformType),\n\... | {
"audio": "",
"image": "",
"text": " phs.Hashes {\n\t\t\t\tif h != \"\" {\n\t\t\t\t\tcompactHashes = append(compactHashes, h)\n\t\t\t\t}\n\t\t\t}\n\t\t\tphs.Hashes = compactHashes\n\t\t}\n\n\t\tfor _, addition := range m.Additions {\n\t\t\thashes, err := decodeHashes(addition)\n\t\t\tif err != nil {\n\t\t\t\tret... | {
"audio": "",
"image": "",
"text": "\t// Keep records of ones we've already seen.\n\tpaths := stringset.New(len(m.Paths))\n\tfor _, path := range m.Paths {\n\t\tif !paths.Add(path) {\n\t\t\treturn status.Errorf(codes.InvalidArgument, \"duplicate update mask path %q\", path)\n\t\t}\n\t}\n\treturn nil\n}",
"vide... |
{
"audio": "",
"image": "",
"text": "func unmarshal(req *http.Request, pbReq proto.Message) (string, error) {\n\tvar mime string\n\talt := req.URL.Query().Get(\"alt\")\n\tif alt == \"\" {\n\t\talt = req.Header.Get(\"Content-Type\")\n\t}\n\tswitch alt {\n\tcase \"json\", mimeJSON:\n\t\tmime = mimeJSON\n\tcase \"pr... | {
"audio": "",
"image": "",
"text": "\n\t\treturn mime, errors.New(\"invalid interchange format\")\n\t}\n\n\tswitch req.Header.Get(\"Content-Type\") {\n\tcase mimeJSON:\n\t\tif err := jsonpb.Unmarshal(req.Body, pbReq); err != nil {\n\t\t\treturn mime, err\n\t\t}\n\tcase mimeProto:\n\t\tbody, err := ioutil.ReadAll... | {
"audio": "",
"image": "",
"text": "\t}\n\n\treq.WrapInfo = &logical.RequestWrapInfo{\n\t\tTTL: dur,\n\t}\n\n\twrapFormat := r.Header.Get(WrapFormatHeaderName)\n\tswitch wrapFormat {\n\tcase \"jwt\":\n\t\treq.WrapInfo.Format = \"jwt\"\n\t}\n\n\treturn req, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func marshal(resp http.ResponseWriter, pbResp proto.Message, mime string) error {\n\tresp.Header().Set(\"Content-Type\", mime)\n\tswitch mime {\n\tcase mimeProto:\n\t\tbody, err := proto.Marshal(pbResp)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif _, err := resp.Write... | {
"audio": "",
"image": "",
"text": " := m.Marshal(&b, pbResp); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif _, err := resp.Write(b.Bytes()); err != nil {\n\t\t\treturn err\n\t\t}\n\tdefault:\n\t\treturn errors.New(\"invalid interchange format\")\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " proto.Uint64(resp.Term),\n\t\tVoteGranted: proto.Bool(resp.VoteGranted),\n\t}\n\n\tp, err := proto.Marshal(pb)\n\tif err != nil {\n\t\treturn -1, err\n\t}\n\n\treturn w.Write(p)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func serveStatus(resp http.ResponseWriter, req *http.Request, sb *safebrowsing.SafeBrowser) {\n\tstats, sbErr := sb.Status()\n\terrStr := \"\"\n\tif sbErr != nil {\n\t\terrStr = sbErr.Error()\n\t}\n\tbuf, err := json.Marshal(struct {\n\t\tStats safebrowsing.Stats\n\t\tError st... | {
"audio": "",
"image": "",
"text": " errStr})\n\tif err != nil {\n\t\thttp.Error(resp, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tresp.Header().Set(\"Content-Type\", mimeJSON)\n\tresp.Write(buf)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(responseWriter http.ResponseWriter, request *http.Request) {\n\t\thttp.ServeFile(responseWriter, request, filePath)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func serveRedirector(resp http.ResponseWriter, req *http.Request, sb *safebrowsing.SafeBrowser, fs http.FileSystem) {\n\trawURL := req.URL.Query().Get(\"url\")\n\tif rawURL == \"\" || req.URL.Path != \"/r\" {\n\t\thttp.NotFound(resp, req)\n\t\treturn\n\t}\n\tparsedURL, err := ... | {
"audio": "",
"image": "",
"text": " threats[0] {\n\t\tif tmpl, ok := threatTemplate[threat.ThreatType]; ok {\n\t\t\tt, err = parseTemplates(fs, t, tmpl, \"/interstitial.html\")\n\t\t\tif err != nil {\n\t\t\t\thttp.Error(resp, err.Error(), http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\t\t\terr = t.E... | {
"audio": "",
"image": "",
"text": "\tif t == nil {\n\t\tt = http.DefaultTransport\n\t}\n\tresp, err := t.RoundTrip(req)\n\tif err != nil {\n\t\treturn nil, &RemoteError{req.URL.Host, err}\n\t}\n\treturn resp, err\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func generateHashes(url string) (map[hashPrefix]string, error) {\n\tpatterns, err := generatePatterns(url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\thashes := make(map[hashPrefix]string)\n\tfor",
"video": ""
} | {
"audio": "",
"image": "",
"text": " _, p := range patterns {\n\t\thashes[hashFromPattern(p)] = p\n\t}\n\treturn hashes, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := req.Send(); err != nil {\n\t\treturn nil, err\n\t}\n\n\turl := req.HTTPRequest.URL.String()\n\treturn &UploadOutput{\n\t\tLocation: url,\n\t\tVersionID: out.VersionId,\n\t}, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func generatePatterns(url string) ([]string, error) {\n\thosts, err := generateLookupHosts(url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tpaths, err := generateLookupPaths(url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar patterns",
"video": ""
} | {
"audio": "",
"image": "",
"text": " []string\n\tfor _, h := range hosts {\n\t\tfor _, p := range paths {\n\t\t\tpatterns = append(patterns, h+p)\n\t\t}\n\t}\n\treturn patterns, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := req.Send(); err != nil {\n\t\treturn nil, err\n\t}\n\n\turl := req.HTTPRequest.URL.String()\n\treturn &UploadOutput{\n\t\tLocation: url,\n\t\tVersionID: out.VersionId,\n\t}, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func isHex(c byte) bool {\n\tswitch {\n\tcase '0' <= c && c <= '9':\n\t\treturn true",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tcase 'a' <= c && c <= 'f':\n\t\treturn true\n\tcase 'A' <= c && c <= 'F':\n\t\treturn true\n\t}\n\treturn false\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " 'A' && c <= 'Z':\n\t\tcase i > 0 && c >= '0' && c <= '9':\n\t\tdefault:\n\t\t\t// Replace!\n\t\t\tb[i] = r\n\t\t}\n\t}\n\treturn string(b)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func isUnicode(s string) bool {\n\tfor _, c := range []byte(s) {\n\t\t// For legacy",
"video": ""
} | {
"audio": "",
"image": "",
"text": " reasons, 0x80 is not considered a Unicode character.\n\t\tif c > 0x80 {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string {\n\tfor _, fn := range funcs {\n\t\ts = fn(s)\n\t}\n\treturn s\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func escape(s string) string {\n\tvar b bytes.Buffer\n\tfor _, c := range []byte(s) {\n\t\tif c < 0x20 || c >= 0x7f || c == ' ' || c == '#' || c == '%' {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\tb.WriteString(fmt.Sprintf(\"%%%02x\", c))\n\t\t} else {\n\t\t\tb.WriteByte(c)\n\t\t}\n\t}\n\treturn b.String()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tparser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == '@' ||\n\t\tparser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '=' ||\n\t\tparser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '$' ||\n\t\t... |
{
"audio": "",
"image": "",
"text": "func unescape(s string) string {\n\tvar b bytes.Buffer\n\tfor len(s) > 0 {\n\t\tif len(s) >= 3 && s[0] == '%' && isHex(s[1]) && isHex(s[2]) {\n\t\t\tb.WriteByte(unhex(s[1])<<4 | unhex(s[2]))",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\t\ts = s[3:]\n\t\t} else {\n\t\t\tb.WriteByte(s[0])\n\t\t\ts = s[1:]\n\t\t}\n\t}\n\treturn b.String()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " of rows before:%d\\n\", dt.numberOfRecords)\n\tdt.numberOfRecords++\n\ts := uint32ToBytes(dt.numberOfRecords)\n\tdt.dataStore[4] = s[0]\n\tdt.dataStore[5] = s[1]\n\tdt.dataStore[6] = s[2]\n\tdt.dataStore[7] = s[3]\n\t//fmt.Printf(\"Number of rows after:%d\\n\", dt.numberOfRec... |
{
"audio": "",
"image": "",
"text": "func recursiveUnescape(s string) (string, error) {\n\tconst maxDepth = 1024\n\tfor i := 0; i < maxDepth; i++ {\n\t\tt := unescape(s)\n\t\tif t == s {\n\t\t\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " s, nil\n\t\t}\n\t\ts = t\n\t}\n\treturn \"\", errors.New(\"safebrowsing: unescaping is too recursive\")\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tfor i := 0; i < cap(s); i++ {\n\t\ts.Lock()\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func normalizeEscape(s string) (string, error) {\n\tu, err := recursiveUnescape(s)\n\tif err != nil {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\treturn \"\", err\n\t}\n\treturn escape(u), nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string, err error) {\n\treturn s.SendRequest(connID, method, params, resHandler)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func parseHost(hostish string) (host string, err error) {\n\ti := strings.LastIndex(hostish, \"@\")\n\tif i < 0 {\n\t\thost = hostish\n\t} else {\n\t\thost = hostish[i+1:]\n\t}\n\tif strings.HasPrefix(host, \"[\") {\n\t\t// Parse an IP-Literal per RFC 3986 and RFC 6874.\n\t\t/... | {
"audio": "",
"image": "",
"text": "\n\t\t}\n\t}\n\t// Remove the port if it is there.\n\thost = portRegexp.ReplaceAllString(host, \"\")\n\n\t// Convert internationalized hostnames to IDNA.\n\tu := unescape(host)\n\tif isUnicode(u) {\n\t\thost, err = idna.ToASCII(u)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n... | {
"audio": "",
"image": "",
"text": "\n\tif i := strings.LastIndex(name, \".\"); i >= 0 {\n\t\tname = name[0:i]\n\t}\n\treturn name\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func parseURL(urlStr string) (parsedURL *url.URL, err error) {\n\t// For legacy reasons, this is a simplified version of the net/url logic.\n\t//\n\t// Few cases where net/url was not helpful:\n\t// 1. URLs are are expected to have no escaped encoding in the host but to\n\t// ... | {
"audio": "",
"image": "",
"text": "\t}\n\tparsedURL.Scheme, rest = getScheme(rest)\n\trest, parsedURL.RawQuery = split(rest, \"?\", true)\n\n\t// Add HTTP as scheme if none.\n\tvar hostish string\n\tif !strings.HasPrefix(rest, \"//\") && parsedURL.Scheme != \"\" {\n\t\treturn nil, errors.New(\"safebrowsing: inv... | {
"audio": "",
"image": "",
"text": " ok\n\t\t}\n\t}\n\n\t// If no match has been found, we assume that the '**' token matches the\n\t// empty string, and defer pattern matching to the rest of the path.\n\treturn d.Until.Consume(path, isDir)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func generateLookupHosts(urlStr string) ([]string, error) {\n\t// Safe Browsing policy asks to generate lookup hosts for the URL.\n\t// Those are formed by the domain and also up to 4 hostnames suffixes.\n\t// The last component or sometimes the pair isn't examined alone,\n\t/... | {
"audio": "",
"image": "",
"text": " significantly\n\t// slower on the server side to check some extra hashes. Also the client\n\t// does not need to keep a database of TLDs.\n\tconst maxHostComponents = 7\n\n\thost, err := canonicalHost(urlStr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// handle IPv4 and ... | {
"audio": "",
"image": "",
"text": " here since we are\n\t// closing the conns which is the only externally visible sideeffect of that\n\t// goroutine running and there should be no way for it to hang or leak once\n\t// the conns are closed so we can save the extra coordination.\n\tatomic.StoreInt32(&c.stopping,... |
{
"audio": "",
"image": "",
"text": "func generateLookupPaths(urlStr string) ([]string, error) {\n\tconst maxPathComponents = 4\n\n\tparsedURL, err := parseURL(urlStr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tpath := parsedURL.Path\n\n\tpaths := []string{\"/\"}\n\tvar pathComponents []string\n\tfor _, p :=... | {
"audio": "",
"image": "",
"text": " 1; i < numComponents; i++ {\n\t\tpaths = append(paths, \"/\"+strings.Join(pathComponents[:i], \"/\")+\"/\")\n\t}\n\tif path != \"/\" {\n\t\tpaths = append(paths, path)\n\t}\n\tif len(parsedURL.RawQuery) > 0 {\n\t\tpaths = append(paths, path+\"?\"+parsedURL.RawQuery)\n\t}\n\tr... | {
"audio": "",
"image": "",
"text": " []string\n\tfor _, h := range hosts {\n\t\tfor _, p := range paths {\n\t\t\tpatterns = append(patterns, h+p)\n\t\t}\n\t}\n\treturn patterns, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func hashFromPattern(pattern string) hashPrefix {\n\thash",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := sha256.New()\n\thash.Write([]byte(pattern))\n\treturn hashPrefix(hash.Sum(nil))\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " *SortCommand {\n\ts.by = pattern\n\treturn s\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (h hashPrefix) HasPrefix(other hashPrefix) bool {\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " strings.HasPrefix(string(h), string(other))\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " nil\n\t}\n\n\treturn filter(rawResolved, func(a, b ast.Ref) bool {\n\t\treturn b.HasPrefix(a)\n\t}), nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (h hashPrefix) IsValid() bool {\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " len(h) >= minHashPrefixLength && len(h) <= maxHashPrefixLength\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " bool {\n\treturn func(err error) bool {\n\t\treturn Cause(err) == cause\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func decodeHashes(input *pb.ThreatEntrySet) ([]hashPrefix, error) {\n\tswitch input.CompressionType {\n\tcase pb.CompressionType_RAW:\n\t\traw := input.GetRawHashes()\n\t\tif raw == nil {\n\t\t\treturn nil, errors.New(\"safebrowsing: nil raw hashes\")\n\t\t}\n\t\tif raw.Prefix... | {
"audio": "",
"image": "",
"text": "\t\treturn hashes, nil\n\tcase pb.CompressionType_RICE:\n\t\tvalues, err := decodeRiceIntegers(input.GetRiceHashes())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\thashes := make([]hashPrefix, 0, len(values))\n\t\tvar buf [4]byte\n\t\tfor _, h := range values {\n\t\t... | {
"audio": "",
"image": "",
"text": "\n\t\treturn err\n\t}\n\n\tif raw.Duration > 0 {\n\t\tnsec := int64(raw.Duration * float64(time.Second))\n\t\traw.EmbeddedJSONAttachment.Duration = time.Duration(nsec)\n\t}\n\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func decodeIndices(input *pb.ThreatEntrySet) ([]int32, error) {\n\tswitch input.CompressionType {\n\tcase pb.CompressionType_RAW:\n\t\traw := input.GetRawIndices()\n\t\tif raw == nil {\n\t\t\treturn nil, errors.New(\"safebrowsing: invalid raw indices\")\n\t\t}\n\t\treturn raw.... | {
"audio": "",
"image": "",
"text": "\n\tcase pb.CompressionType_RICE:\n\t\tvalues, err := decodeRiceIntegers(input.GetRiceIndices())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tindices := make([]int32, 0, len(values))\n\t\tfor _, v := range values {\n\t\t\tindices = append(indices, int32(v))\n\t\t}\n... | {
"audio": "",
"image": "",
"text": "\n\t\treturn err\n\t}\n\n\tif raw.Duration > 0 {\n\t\tnsec := int64(raw.Duration * float64(time.Second))\n\t\traw.EmbeddedJSONAttachment.Duration = time.Duration(nsec)\n\t}\n\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func decodeRiceIntegers(rice *pb.RiceDeltaEncoding) ([]uint32, error) {\n\tif rice == nil {\n\t\treturn nil, errors.New(\"safebrowsing: missing rice encoded data\")\n\t}\n\tif rice.RiceParameter < 0 || rice.RiceParameter > 32 {\n\t\treturn nil, errors.New(\"safebrowsing: inval... | {
"audio": "",
"image": "",
"text": " < int(rice.NumEntries); i++ {\n\t\tdelta, err := rd.ReadValue()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tvalues = append(values, values[i]+delta)\n\t}\n\n\tif br.BitsRemaining() >= 8 {\n\t\treturn nil, errors.New(\"safebrowsing: unconsumed rice encoded data\")\... | {
"audio": "",
"image": "",
"text": " - 1)\n\tfor i := 0; i < end; i++ {\n\t\tif src[i] > max {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (br *bitReader) BitsRemaining() int {\n\tn := 8 * len(br.buf)\n\tfor m := br.mask | 1;",
"video": ""
} | {
"audio": "",
"image": "",
"text": " m != 1; m >>= 1 {\n\t\tn--\n\t}\n\treturn n\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err := br.readBits(2)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tbytes++\n\n\tvar data int\n\tfor i := 0; i < bytes; i++ {\n\t\tn, err := br.readBits(8)\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\tdata |= n << (uint(i) * 8)\n\t}\n\treturn data, nil\n}",
"video"... |
{
"audio": "",
"image": "",
"text": "func (c *Config) setDefaults() bool {\n\tif c.ServerURL == \"\" {\n\t\tc.ServerURL = DefaultServerURL\n\t}\n\tif len(c.ThreatLists) == 0 {\n\t\tc.ThreatLists = DefaultThreatLists\n\t}\n\tif c.UpdatePeriod <= 0 {\n\t\tc.UpdatePeriod = DefaultUpdatePeriod\n\t}\n\tif c.RequestTim... | {
"audio": "",
"image": "",
"text": "\tc.RequestTimeout = DefaultRequestTimeout\n\t}\n\tif c.compressionTypes == nil {\n\t\tc.compressionTypes = []pb.CompressionType{pb.CompressionType_RAW, pb.CompressionType_RICE}\n\t}\n\treturn true\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tif resp != nil {\n\t\tresp.Request = r\n\t}\n\n\tif c.emitErrorAfter > 0 {\n\t\tc.emitErrorAfter--\n\t} else if c.err != nil {\n\t\terr = c.err\n\t\tc.repeatError--\n\t\tif c.repeatError == 0 {\n\t\t\tc.err = nil\n\t\t}\n\t}\n\n\treturn\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewSafeBrowser(conf Config) (*SafeBrowser, error) {\n\tconf = conf.copy()\n\tif !conf.setDefaults() {\n\t\treturn nil, errors.New(\"safebrowsing: invalid configuration\")\n\t}\n\n\t// Create the SafeBrowsing object.\n\tif conf.api == nil {\n\t\tvar err error\n\t\tconf.api... | {
"audio": "",
"image": "",
"text": "\n\t// If database file is provided, use that to initialize.\n\tif !sb.db.Init(&sb.config, sb.log) {\n\t\tctx, cancel := context.WithTimeout(context.Background(), sb.config.RequestTimeout)\n\t\tdelay, _ = sb.db.Update(ctx, sb.api)\n\t\tcancel()\n\t} else {\n\t\tif age := sb.db... | {
"audio": "",
"image": "",
"text": " = append(cmds, renderer.RedirectOutput(filename)...)\n\t\tcmds = append(cmds, renderer.RedirectFD(\"out\", \"err\")...)\n\t\tcmds = append(cmds,\n\t\t\t\"\",\n\t\t\t\"# Run the script.\",\n\t\t)\n\t\t// We leave conf.Logfile alone (it will be ignored during validation).\n\t}\... |
{
"audio": "",
"image": "",
"text": "func (sb *SafeBrowser) Status() (Stats, error) {\n\tstats := Stats{\n\t\tQueriesByDatabase: atomic.LoadInt64(&sb.stats.QueriesByDatabase),\n\t\tQueriesByCache: atomic.LoadInt64(&sb.stats.QueriesByCache),\n\t\tQueriesByAPI: atomic.LoadInt64(&sb.stats.QueriesByAPI),",
... | {
"audio": "",
"image": "",
"text": "\n\t\tQueriesFail: atomic.LoadInt64(&sb.stats.QueriesFail),\n\t\tDatabaseUpdateLag: sb.db.UpdateLag(),\n\t}\n\treturn stats, sb.db.Status()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tBytes: atomic.LoadInt64(&c.outBytes),\n\t\t\t}\n\t\t\tc.mu.Unlock()\n\t\t\t// Gather matching inbound connections\n\t\t\tgs.Received = DataStats{}\n\t\t\tfor _, c := range gw.in {\n\t\t\t\tc.mu.Lock()\n\t\t\t\tif c.gw.name == name {\n\t\t\t\t\tgs.Received.Msgs += atomic.Lo... |
{
"audio": "",
"image": "",
"text": "func (sb *SafeBrowser) WaitUntilReady(ctx context.Context) error {\n\tif atomic.LoadUint32(&sb.closed) == 1 {\n\t\treturn errClosed\n\t}\n\tselect {\n\tcase <-sb.db.Ready():\n\t\treturn nil",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tcase <-sb.done:\n\t\treturn errClosed\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(ctx context.Context) error {\n\t\treturn UpdateTenant(ctx, config)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (sb *SafeBrowser) Close() error {\n\tif atomic.LoadUint32(&sb.closed) == 0 {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tatomic.StoreUint32(&sb.closed, 1)\n\t\tclose(sb.done)\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn func(sb *sandbox) {\n\t\tsb.config.originResolvConfPath = path\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (a *netAPI) doRequest(ctx context.Context, requestPath string, req proto.Message, resp proto.Message) error {\n\tp, err := proto.Marshal(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tu := *a.url // Make a copy of URL\n\tu.Path = requestPath\n\thttpReq, err := http.New... | {
"audio": "",
"image": "",
"text": "\n\t\treturn err\n\t}\n\tdefer httpResp.Body.Close()\n\tif httpResp.StatusCode != 200 {\n\t\treturn fmt.Errorf(\"safebrowsing: unexpected server response code: %d\", httpResp.StatusCode)\n\t}\n\tbody, err := ioutil.ReadAll(httpResp.Body)\n\tif err != nil {\n\t\treturn err\n\t}... | {
"audio": "",
"image": "",
"text": " proto.Uint64(resp.Term),\n\t\tVoteGranted: proto.Bool(resp.VoteGranted),\n\t}\n\n\tp, err := proto.Marshal(pb)\n\tif err != nil {\n\t\treturn -1, err\n\t}\n\n\treturn w.Write(p)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (a *netAPI) ListUpdate(ctx context.Context, req *pb.FetchThreatListUpdatesRequest) (*pb.FetchThreatListUpdatesResponse, error) {\n\tresp",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := new(pb.FetchThreatListUpdatesResponse)\n\treturn resp, a.doRequest(ctx, fetchUpdatePath, req, resp)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " (resp *pb.StopPodSandboxResponse, err error) {\n\t// platform dependent call\n\treturn s.stopPodSandbox(ctx, req)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (a *netAPI) HashLookup(ctx context.Context, req *pb.FindFullHashesRequest) (*pb.FindFullHashesResponse, error) {\n\tresp",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := new(pb.FindFullHashesResponse)\n\treturn resp, a.doRequest(ctx, findHashPath, req, resp)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " (resp *pb.StopPodSandboxResponse, err error) {\n\t// platform dependent call\n\treturn s.stopPodSandbox(ctx, req)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (a *JSONAttachment) MarshalJSON() ([]byte, error) {\n\ttype EmbeddedJSONAttachment JSONAttachment\n\treturn json.Marshal(&struct {\n\t\tDuration float64 `json:\"duration_in_seconds,omitempty\"`\n\t\t*EmbeddedJSONAttachment\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t}{\n\t\tEmbeddedJSONAttachment: (*EmbeddedJSONAttachment)(a),\n\t\tDuration: a.Duration.Seconds(),\n\t})\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\treturn err\n\t}\n\n\tif raw.Duration > 0 {\n\t\tnsec := int64(raw.Duration * float64(time.Second))\n\t\traw.EmbeddedJSONAttachment.Duration = time.Duration(nsec)\n\t}\n\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (a *JSONAttachment) UnmarshalJSON(data []byte) error {\n\ttype EmbeddedJSONAttachment JSONAttachment\n\tvar raw struct {\n\t\tDuration float64 `json:\"duration_in_seconds,omitempty\"`\n\t\t*EmbeddedJSONAttachment\n\t}\n\traw.EmbeddedJSONAttachment = (*EmbeddedJSONAttachme... | {
"audio": "",
"image": "",
"text": "\n\t\treturn err\n\t}\n\n\tif raw.Duration > 0 {\n\t\tnsec := int64(raw.Duration * float64(time.Second))\n\t\traw.EmbeddedJSONAttachment.Duration = time.Duration(nsec)\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " `{\"key\":\"` + string(data) + `\"}`\n\traw := Raw([]byte(d))\n\treturn &raw\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f *JSONFeed) ToJSON() (string, error) {\n\tdata, err := json.MarshalIndent(f, \"\", \" \")\n\tif err != nil",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\t\treturn \"\", err\n\t}\n\n\treturn string(data), nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\n\t// Make sure the directory exists.\n\tif err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {\n\t\treturn err\n\t}\n\n\t// Marshal the JSON data\n\tdata, err := json.MarshalIndent(p, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Write the data to th... |
{
"audio": "",
"image": "",
"text": "func (f *JSON) JSONFeed() *JSONFeed {\n\tfeed := &JSONFeed{\n\t\tVersion: jsonFeedVersion,\n\t\tTitle: f.Title,\n\t\tDescription: f.Description,\n\t}\n\n\tif f.Link != nil {\n\t\tfeed.HomePageUrl = f.Link.Href\n\t}\n\tif f.Author != nil {\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tfeed.Author = &JSONAuthor{\n\t\t\tName: f.Author.Name,\n\t\t}\n\t}\n\tfor _, e := range f.Items {\n\t\tfeed.Items = append(feed.Items, newJSONItem(e))\n\t}\n\treturn feed\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " fmt.Errorf(\"invalid resulting offset: %d\", off)\n\t}\n\n\tif f.offset != off {\n\t\tf.offset = off\n\t\tif f.blockReader != nil {\n\t\t\tf.blockReader.Close()\n\t\t\tf.blockReader = nil\n\t\t}\n\t}\n\treturn f.offset, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func newRssItem(i *Item) *RssItem {\n\titem := &RssItem{\n\t\tTitle: i.Title,\n\t\tLink: i.Link.Href,\n\t\tDescription: i.Description,\n\t\tGuid: i.Id,\n\t\tPubDate: anyTimeFormat(time.RFC1123Z, i.Created, i.Updated),\n\t}\n\tif len(i.Content) > 0 {\n\t... | {
"audio": "",
"image": "",
"text": " i.Content}\n\t}\n\tif i.Source != nil {\n\t\titem.Source = i.Source.Href\n\t}\n\n\t// Define a closure\n\tif i.Enclosure != nil && i.Enclosure.Type != \"\" && i.Enclosure.Length != \"\" {\n\t\titem.Enclosure = &RssEnclosure{Url: i.Enclosure.Url, Type: i.Enclosure.Type, Length... | {
"audio": "",
"image": "",
"text": " state.Buffer[i]\n\t\tif f(c) {\n\t\t\tif !first {\n\t\t\t\ti++\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tfirst = notfirst\n\t}\n\tif i < 0 {\n\t\ti = 0\n\t}\n\treturn i\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *Rss) RssFeed() *RssFeed {\n\tpub := anyTimeFormat(time.RFC1123Z, r.Created, r.Updated)\n\tbuild := anyTimeFormat(time.RFC1123Z, r.Updated)\n\tauthor := \"\"\n\tif r.Author != nil {\n\t\tauthor = r.Author.Email\n\t\tif len(r.Author.Name) > 0 {\n\t\t\tauthor = fmt.Sprin... | {
"audio": "",
"image": "",
"text": " r.Title,\n\t\tLink: r.Link.Href,\n\t\tDescription: r.Description,\n\t\tManagingEditor: author,\n\t\tPubDate: pub,\n\t\tLastBuildDate: build,\n\t\tCopyright: r.Copyright,\n\t\tImage: image,\n\t}\n\tfor _, i := range r.Items {\n\t\tchannel.It... | {
"audio": "",
"image": "",
"text": "\n\t}\n\ts := \"\"\n\tswitch {\n\tcase r.Type[0] == '*':\n\t\ts = fmt.Sprintf(\"%s = (%s)(unsafe.Pointer(r0))\", r.Name, r.Type)\n\tcase r.Type == \"bool\":\n\t\ts = fmt.Sprintf(\"%s = r0 != 0\", r.Name)\n\tdefault:\n\t\ts = fmt.Sprintf(\"%s = %s(r0)\", r.Name, r.Type)\n\t}\n\... |
{
"audio": "",
"image": "",
"text": "func (f *Feed) Add(item *Item) {\n\tf.Items =",
"video": ""
} | {
"audio": "",
"image": "",
"text": " append(f.Items, item)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " Filters(func(f *mesos.Filters) {\n\t\tf.RefuseSeconds = &asFloat\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func anyTimeFormat(format string, times ...time.Time) string {\n\tfor _, t := range times {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tif !t.IsZero() {\n\t\t\treturn t.Format(format)\n\t\t}\n\t}\n\treturn \"\"\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " stop it.\n\tt.timer = time.AfterFunc(time.Hour, func() {\n\t\tw.Assert()\n\t})\n\tt.timer.Stop()\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f *Feed) ToAtom() (string, error) {\n\ta",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := &Atom{f}\n\treturn ToXML(a)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn func(f *Forwarder) error {\n\t\tf.httpForwarder.flushInterval = flushInterval\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f *Feed) WriteAtom(w io.Writer) error {\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " WriteXML(&Atom{f}, w)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " (HashTree, error) {\n\treturn getHashTree(storageRoot, func(w io.Writer) error {\n\t\treturn pachClient.GetTag(treeRef.Name, w)\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f *Feed) ToRss() (string, error) {\n\tr",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := &Rss{f}\n\treturn ToXML(r)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn func(f *Forwarder) error {\n\t\tf.httpForwarder.flushInterval = flushInterval\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f *Feed) WriteRss(w io.Writer) error {\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " WriteXML(&Rss{f}, w)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " (HashTree, error) {\n\treturn getHashTree(storageRoot, func(w io.Writer) error {\n\t\treturn pachClient.GetTag(treeRef.Name, w)\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f *Feed) ToJSON() (string, error) {\n\tj",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := &JSON{f}\n\treturn j.ToJSON()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn func(f *Forwarder) error {\n\t\tf.httpForwarder.flushInterval = flushInterval\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f *Feed) WriteJSON(w io.Writer) error {\n\tj := &JSON{f}\n\tfeed",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := j.JSONFeed()\n\n\te := json.NewEncoder(w)\n\te.SetIndent(\"\", \" \")\n\treturn e.Encode(feed)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := &JSON{f}\n\treturn j.ToJSON()\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f *Feed) Sort(less func(a, b *Item) bool) {\n\tlessFunc := func(i,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " j int) bool {\n\t\treturn less(f.Items[i], f.Items[j])\n\t}\n\tsort.SliceStable(f.Items, lessFunc)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " nil\n\t}\n\n\treturn filter(rawResolved, func(a, b ast.Ref) bool {\n\t\treturn b.HasPrefix(a)\n\t}), nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewUUID() *UUID {\n\tu := &UUID{}\n\t_, err := rand.Read(u[:16])\n\tif err",
"video": ""
} | {
"audio": "",
"image": "",
"text": " != nil {\n\t\tpanic(err)\n\t}\n\n\tu[8] = (u[8] | 0x80) & 0xBf\n\tu[6] = (u[6] | 0x40) & 0x4f\n\treturn u\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " size)\n\tif _, err := rand.Read(bytes); err != nil {\n\t\treturn nil, err\n\t}\n\treturn bytes, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (a *Atom) AtomFeed() *AtomFeed {\n\tupdated := anyTimeFormat(time.RFC3339, a.Updated, a.Created)\n\tfeed := &AtomFeed{\n\t\tXmlns: ns,\n\t\tTitle: a.Title,\n\t\tLink: &AtomLink{Href: a.Link.Href, Rel: a.Link.Rel},\n\t\tSubtitle: a.Description,\n\t\tId: a.L... | {
"audio": "",
"image": "",
"text": " = &AtomAuthor{AtomPerson: AtomPerson{Name: a.Author.Name, Email: a.Author.Email}}\n\t}\n\tfor _, e := range a.Items {\n\t\tfeed.Entries = append(feed.Entries, newAtomEntry(e))\n\t}\n\treturn feed\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " time.Duration {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func add(p unsafe.Pointer, x uintptr, whySafe string) unsafe.Pointer {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn unsafe.Pointer(uintptr(p) + x)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tC.cvOrS(\n\t\tunsafe.Pointer(src),\n\t\t(C.CvScalar)(value),\n\t\tunsafe.Pointer(dst),\n\t\tunsafe.Pointer(mask),\n\t)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func discoverTypes() {\n\ttypes = make(map[string]reflect.Type)\n\tpackages = make(map[string]map[string]reflect.Type)\n\n\tver := runtime.Version()\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tif ver == \"go1.5\" || strings.HasPrefix(ver, \"go1.5.\") {\n\t\tloadGo15Types()\n\t} else if ver == \"go1.6\" || strings.HasPrefix(ver, \"go1.6.\") {\n\t\tloadGo15Types()\n\t} else {\n\t\tloadGo17Types()\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tobj := make(Object)\n\tfor _, n := range names {\n\t\tobj[n] = a.Params.Type.ToObject()[n]\n\t}\n\treturn &AttributeDefinition{Type: obj}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func TypeByName(typeName string) Type {\n\tinitOnce.Do(discoverTypes)\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn Type2(types[typeName])\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " len(parentNames) > 1 {\n\t\t\t\ttypename = \"*\" + FormatName(v.Slice[i-1]+\"_\"+currentNode)\n\t\t\t}\n\t\t}\n\t} else {\n\t\ttypename = \"interface{}\"\n\t}\n\treturn\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func TypeByPackageName(pkgPath string, name string) Type {\n\tinitOnce.Do(discoverTypes)",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tpkgTypes := packages[pkgPath]\n\tif pkgTypes == nil {\n\t\treturn nil\n\t}\n\treturn Type2(pkgTypes[name])\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string, _ string) (string, error) {\n\treturn \"\", nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Connection) DynamicLargeObjectCreateFile(opts *LargeObjectOpts) (LargeObjectFile, error) {\n\tlo, err := c.largeObjectCreate(opts)",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn withBuffer(opts, &DynamicLargeObjectCreateFile{\n\t\tlargeObjectCreateFile: *lo,\n\t}), nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " Option {\n\treturn func(opts *options) error {\n\t\topts.Service = service\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Connection) DynamicLargeObjectCreate(opts *LargeObjectOpts) (LargeObjectFile,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " error) {\n\topts.Flags = os.O_TRUNC | os.O_CREATE\n\treturn c.DynamicLargeObjectCreateFile(opts)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn func(opts *options) {\n\t\topts.rollbackReq.CleanupOnFail = cleanupOnFail\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Connection) DynamicLargeObjectDelete(container string, path string) error",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn c.LargeObjectDelete(container, path)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tfilepath.Walk(rootPath, func(path string, info os.FileInfo, err error) error {\n\t\t\t\tmatched, err := filepath.Match(\"*.json\", info.Name())\n\t\t\t\tif err != nil {\n\t\t\t\t\twarn(err)\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tif matched {\n\t\t\t\t\tc <- path\n\t\t\t... |
{
"audio": "",
"image": "",
"text": "func (c *Connection) DynamicLargeObjectMove(srcContainer string, srcObjectName string, dstContainer string, dstObjectName string) error {\n\tinfo, headers, err := c.Object(dstContainer, srcObjectName)\n\tif err != nil {\n\t\treturn err",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t}\n\n\tsegmentContainer, segmentPath := parseFullPath(headers[\"X-Object-Manifest\"])\n\tif err := c.createDLOManifest(dstContainer, dstObjectName, segmentContainer+\"/\"+segmentPath, info.ContentType); err != nil {\n\t\treturn err\n\t}\n\n\tif err := c.ObjectDelete(srcCon... | {
"audio": "",
"image": "",
"text": " string, _ string) (string, error) {\n\treturn \"\", nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Connection) createDLOManifest(container string, objectName string, prefix string, contentType string) error {\n\theaders := make(Headers)\n\theaders[\"X-Object-Manifest\"] = prefix\n\tmanifest, err := c.ObjectCreate(container, objectName, false,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " \"\", contentType, headers)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := manifest.Close(); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string, _ string) (string, error) {\n\treturn \"\", nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func newAuth(c *Connection) (Authenticator, error) {\n\tAuthVersion := c.AuthVersion\n\tif AuthVersion == 0 {\n\t\tif strings.Contains(c.AuthUrl, \"v3\") {\n\t\t\tAuthVersion = 3\n\t\t} else if strings.Contains(c.AuthUrl, \"v2\") {\n\t\t\tAuthVersion = 2\n\t\t} else if strings... | {
"audio": "",
"image": "",
"text": "\t\treturn &v2Auth{\n\t\t\t// Guess as to whether using API key or\n\t\t\t// password it will try both eventually so\n\t\t\t// this is just an optimization.\n\t\t\tuseApiKey: len(c.ApiKey) >= 32,\n\t\t}, nil\n\tcase 3:\n\t\treturn &v3Auth{}, nil\n\t}\n\treturn nil, newErrorf(5... | {
"audio": "",
"image": "",
"text": " != \"\" {\n\t\tif strings.Contains(contentType, \"gzip\") {\n\t\t\treturn minio.SelectCompressionGZIP\n\t\t} else if strings.Contains(contentType, \"bzip\") {\n\t\t\treturn minio.SelectCompressionBZIP\n\t\t}\n\t}\n\treturn minio.SelectCompressionNONE\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (auth *v1Auth) Request(c *Connection) (*http.Request, error) {\n\treq, err := http.NewRequest(\"GET\", c.AuthUrl, nil)\n\tif",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Set(\"User-Agent\", c.UserAgent)\n\treq.Header.Set(\"X-Auth-Key\", c.ApiKey)\n\treq.Header.Set(\"X-Auth-User\", c.UserName)\n\treturn req, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(responseWriter http.ResponseWriter, request *http.Request) {\n\t\thttp.ServeFile(responseWriter, request, filePath)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (auth *v1Auth) Response(resp *http.Response)",
"video": ""
} | {
"audio": "",
"image": "",
"text": " error {\n\tauth.Headers = resp.Header\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\tgo func() {\n\t\t\t\tfor txResp := range txResponses {\n\t\t\t\t\tresp := Response{}\n\t\t\t\t\tresp.Response = txResp\n\t\t\t\t\ttransitionResponses <- resp\n\t\t\t\t}\n\t\t\t\tclose(transitionResponses)\n\t\t\t}()\n\t\t}\n\t})\n\treturn transitionResponses\n}",
"vide... |
{
"audio": "",
"image": "",
"text": "func (auth *v1Auth) StorageUrl(Internal bool) string {\n\tstorageUrl := auth.Headers.Get(\"X-Storage-Url\")\n\tif Internal {\n\t\tnewUrl, err := url.Parse(storageUrl)\n\t\tif err != nil {\n\t\t\treturn storageUrl",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\t}\n\t\tnewUrl.Host = \"snet-\" + newUrl.Host\n\t\tstorageUrl = newUrl.String()\n\t}\n\treturn storageUrl\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn internal.WithCallOverride(ctx, internal.CallOverrideFunc(f))\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (auth *v2Auth) Request(c *Connection) (*http.Request, error) {\n\tauth.Region = c.Region\n\t// Toggle useApiKey if not first run and not OK yet\n\tif auth.notFirst && !auth.useApiKeyOk {\n\t\tauth.useApiKey = !auth.useApiKey\n\t}\n\tauth.notFirst = true\n\t// Create a V2 ... | {
"audio": "",
"image": "",
"text": "\tv2.Auth.Tenant = c.Tenant\n\t\tv2.Auth.TenantId = c.TenantId\n\t\tv2i = v2\n\t} else {\n\t\t// Rackspace special with API Key\n\t\tv2 := v2AuthRequestRackspace{}\n\t\tv2.Auth.ApiKeyCredentials.UserName = c.UserName\n\t\tv2.Auth.ApiKeyCredentials.ApiKey = c.ApiKey\n\t\tv2.Aut... | {
"audio": "",
"image": "",
"text": "\n\t\tauth.Password == \"\" &&\n\t\tauth.Email == \"\" &&\n\t\tauth.ServerAddress == \"\"\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (auth *v2Auth) Response(resp *http.Response) error {\n\tauth.Auth = new(v2AuthResponse)\n\terr := readJson(resp, auth.Auth)\n\t// If successfully read Auth then no",
"video": ""
} | {
"audio": "",
"image": "",
"text": " need to toggle useApiKey any more\n\tif err == nil {\n\t\tauth.useApiKeyOk = true\n\t}\n\treturn err\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tauth.Password == \"\" &&\n\t\tauth.Email == \"\" &&\n\t\tauth.ServerAddress == \"\"\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (auth *v2Auth) endpointUrl(Type string, endpointType EndpointType) string {\n\tfor _, catalog := range auth.Auth.Access.ServiceCatalog {\n\t\tif catalog.Type == Type {\n\t\t\tfor _, endpoint := range catalog.Endpoints {\n\t\t\t\tif auth.Region == \"\" || (auth.Region == e... | {
"audio": "",
"image": "",
"text": " EndpointTypePublic:\n\t\t\t\t\t\treturn endpoint.PublicUrl\n\t\t\t\t\tcase EndpointTypeAdmin:\n\t\t\t\t\t\treturn endpoint.AdminUrl\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn \"\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\"\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tauth.Password == \"\" &&\n\t\tauth.Email == \"\" &&\n\t\tauth.ServerAddress == \"\"\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (auth *v2Auth) Expires() time.Time {\n\tt, err := time.Parse(time.RFC3339, auth.Auth.Access.Token.Expires)\n\tif err != nil {\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn time.Time{} // return Zero if not parsed\n\t}\n\treturn t\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\texpires = now.Add(lifetime)\n\t} else {\n\t\texpiresHeader := r.Header.Get(\"Expires\")\n\t\tif expiresHeader != \"\" {\n\t\t\texpires, err = time.Parse(time.RFC1123, expiresHeader)\n\t\t\tif err != nil {\n\t\t\t\texpires = now\n\t\t\t}\n\t\t}\n\t}\n\treturn expires\n}",
"... |
{
"audio": "",
"image": "",
"text": "func newTimeoutReader(reader io.ReadCloser, timeout time.Duration, cancel func())",
"video": ""
} | {
"audio": "",
"image": "",
"text": " *timeoutReader {\n\treturn &timeoutReader{\n\t\treader: reader,\n\t\ttimeout: timeout,\n\t\tcancel: cancel,\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn func(opts *options) {\n\t\topts.instReq.Timeout = timeout\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func newWatchdogReader(reader io.Reader, timeout time.Duration, timer *time.Timer) *watchdogReader {\n\treturn &watchdogReader{\n\t\ttimeout: ",
"video": ""
} | {
"audio": "",
"image": "",
"text": " timeout,\n\t\treader: reader,\n\t\ttimer: timer,\n\t\tchunkSize: watchdogChunkSize,\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\ttimeout time.Duration,\n) *acceptAvailablePods {\n\treturn &acceptAvailablePods{\n\t\tout: out,\n\t\tkclient: kclient,\n\t\ttimeout: timeout,\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Connection) StaticLargeObjectCreateFile(opts *LargeObjectOpts) (LargeObjectFile, error) {\n\tinfo, err := c.cachedQueryInfo()\n\tif err != nil || !info.SupportsSLO() {\n\t\treturn nil, SLONotSupported\n\t}\n\trealMinChunkSize := info.SLOMinSegmentSize()\n\tif realMinC... | {
"audio": "",
"image": "",
"text": "\n\tlo, err := c.largeObjectCreate(opts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn withBuffer(opts, &StaticLargeObjectCreateFile{\n\t\tlargeObjectCreateFile: *lo,\n\t}), nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " Option {\n\treturn func(opts *options) error {\n\t\topts.Service = service\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Connection) StaticLargeObjectCreate(opts *LargeObjectOpts) (LargeObjectFile,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " error) {\n\topts.Flags = os.O_TRUNC | os.O_CREATE\n\treturn c.StaticLargeObjectCreateFile(opts)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn func(opts *options) {\n\t\topts.rollbackReq.CleanupOnFail = cleanupOnFail\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Connection) StaticLargeObjectDelete(container string, path string) error {\n\tinfo, err := c.cachedQueryInfo()\n\tif err != nil || !info.SupportsSLO()",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\t\treturn SLONotSupported\n\t}\n\treturn c.LargeObjectDelete(container, path)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tfilepath.Walk(rootPath, func(path string, info os.FileInfo, err error) error {\n\t\t\t\tmatched, err := filepath.Match(\"*.json\", info.Name())\n\t\t\t\tif err != nil {\n\t\t\t\t\twarn(err)\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tif matched {\n\t\t\t\t\tc <- path\n\t\t\t... |
{
"audio": "",
"image": "",
"text": "func (c *Connection) StaticLargeObjectMove(srcContainer string, srcObjectName string, dstContainer string, dstObjectName string) error {\n\tswiftInfo, err := c.cachedQueryInfo()\n\tif err != nil || !swiftInfo.SupportsSLO() {\n\t\treturn SLONotSupported\n\t}\n\tinfo, headers, e... | {
"audio": "",
"image": "",
"text": " safe for copying)\n\theaders = headers.ObjectMetadata().ObjectHeaders()\n\n\tif err := c.createSLOManifest(dstContainer, dstObjectName, info.ContentType, container, segments, headers); err != nil {\n\t\treturn err\n\t}\n\n\tif err := c.ObjectDelete(srcContainer, srcObjectName... | {
"audio": "",
"image": "",
"text": "\t\tfilepath.Walk(rootPath, func(path string, info os.FileInfo, err error) error {\n\t\t\t\tmatched, err := filepath.Match(\"*.json\", info.Name())\n\t\t\t\tif err != nil {\n\t\t\t\t\twarn(err)\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tif matched {\n\t\t\t\t\tc <- path\n\t\t\t... |
{
"audio": "",
"image": "",
"text": "func (c *Connection) createSLOManifest(container string, path string, contentType string, segmentContainer string, segments []Object, h Headers) error {\n\tsloSegments := make([]swiftSegment, len(segments))\n\tfor i, segment := range segments {\n\t\tsloSegments[i].Path = fmt.S... | {
"audio": "",
"image": "",
"text": "\n\t\tsloSegments[i].Etag = segment.Hash\n\t\tsloSegments[i].Size = segment.Bytes\n\t}\n\n\tcontent, err := json.Marshal(sloSegments)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvalues := url.Values{}\n\tvalues.Set(\"multipart-manifest\", \"put\")\n\tif _, err := c.objectPut(... | {
"audio": "",
"image": "",
"text": " string, _ string) (string, error) {\n\treturn \"\", nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *RsConnection) manage(p swift.RequestOpts) (resp *http.Response, headers swift.Headers, err error) {\n\tp.OnReAuth = func() (string, error) {\n\t\tif c.cdnUrl == \"\" {\n\t\t\tc.cdnUrl = c.Auth.CdnUrl()\n\t\t}\n\t\tif c.cdnUrl == \"\" {\n\t\t\treturn \"\", errors.New(\... | {
"audio": "",
"image": "",
"text": " not exist on the authenticated platform\")\n\t\t}\n\t\treturn c.cdnUrl, nil\n\t}\n\tif c.Authenticated() {\n\t\t_, err = p.OnReAuth()\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t}\n\treturn c.Connection.Call(c.cdnUrl, p)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " to bind specified\")\n\t}\n\tif c.TLSCertPath == \"\" {\n\t\treturn errors.New(\"no tls certificate\")\n\t}\n\tif c.TLSPrivateKeyPath == \"\" {\n\t\treturn errors.New(\"no private key\")\n\t}\n\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *RsConnection) ContainerCDNDisable(container string) error {\n\th := swift.Headers{\"X-CDN-Enabled\": \"false\"}\n\n\t_, _,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err := c.manage(swift.RequestOpts{\n\t\tContainer: container,\n\t\tOperation: \"PUT\",\n\t\tErrorMap: swift.ContainerErrorMap,\n\t\tNoResponse: true,\n\t\tHeaders: h,\n\t})\n\treturn err\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn func(h echo.Handler) echo.Handler {\n\t\treturn echo.HandlerFunc(func(c echo.Context) error {\n\t\t\tacquire() // before request\n\t\t\terr := h.Handle(c)\n\t\t\trelease() // after request\n\t\t\treturn err\n\t\t})\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func cancelRequest(transport http.RoundTripper, req *http.Request) {\n\tif",
"video": ""
} | {
"audio": "",
"image": "",
"text": " tr, ok := transport.(interface {\n\t\tCancelRequest(*http.Request)\n\t}); ok {\n\t\ttr.CancelRequest(req)\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(responseWriter http.ResponseWriter, request *http.Request) {\n\t\thttp.ServeFile(responseWriter, request, filePath)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func resetTimer(t *time.Timer,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " d time.Duration) {\n\tt.Reset(d)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " *time.Duration {\n\tCommandLine.FlagLong(&value, \"\", name, helpvalue...)\n\treturn &value\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Connection) largeObjectCreate(opts *LargeObjectOpts) (*largeObjectCreateFile, error) {\n\tvar (\n\t\tsegmentPath string\n\t\tsegmentContainer string\n\t\tsegments []Object\n\t\tcurrentLength int64\n\t\terr error\n\t)\n\n\tif opts.SegmentPr... | {
"audio": "",
"image": "",
"text": "\tsegmentPath = gopath.Dir(segments[0].Name)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif err = c.ObjectMove(opts.Container, opts.ObjectName, opts.Container, getSegment(segmentPath, 1)); err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tsegments = append(segments, info)\n\... | {
"audio": "",
"image": "",
"text": "\tif opts.Path != \"\" {\n\t\t\tv.Set(\"path\", opts.Path)\n\t\t}\n\t\tif opts.Delimiter != 0 {\n\t\t\tv.Set(\"delimiter\", string(opts.Delimiter))\n\t\t}\n\t\th = opts.Headers\n\t}\n\treturn v, h\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Connection) LargeObjectDelete(container string, objectName string) error {\n\t_, headers, err := c.Object(container, objectName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar objects [][]string\n\tif headers.IsLargeObject() {\n\t\tsegmentContainer, segments, err :=... | {
"audio": "",
"image": "",
"text": "\t\tfor i, obj := range objects {\n\t\t\tfilenames[i] = obj[0] + \"/\" + obj[1]\n\t\t}\n\t\t_, err = c.doBulkDelete(filenames)\n\t\t// Don't fail on ObjectNotFound because eventual consistency\n\t\t// makes this situation normal.\n\t\tif err != nil && err != Forbidden && err !... | {
"audio": "",
"image": "",
"text": "\n\tif setDiff := stringSetDiff(old.CanaryTags, new.CanaryTags, \"CanaryTags\", contextual); setDiff != nil {\n\t\tdiff.Objects = append(diff.Objects, setDiff)\n\t}\n\n\t// Tag diffs\n\tif setDiff := stringSetDiff(old.Tags, new.Tags, \"Tags\", contextual); setDiff != nil {\n\t... |
{
"audio": "",
"image": "",
"text": "func (file *largeObjectCreateFile) Seek(offset int64, whence int) (int64, error) {\n\tswitch whence {\n\tcase 0:\n\t\tfile.filePos = offset\n\tcase 1:\n\t\tfile.filePos += offset\n\tcase 2:\n\t\tfile.filePos = file.currentLength + offset\n\tdefault:\n\t\treturn -1,",
"video"... | {
"audio": "",
"image": "",
"text": " fmt.Errorf(\"invalid value for whence\")\n\t}\n\tif file.filePos < 0 {\n\t\treturn -1, fmt.Errorf(\"negative offset\")\n\t}\n\treturn file.filePos, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tblocks[i].Offset = offset\n\t\toffset += int64(blocks[i].Size)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (file *largeObjectCreateFile) Write(buf []byte) (int, error) {\n\tvar sz int64\n\tvar relativeFilePos int\n\twriteSegmentIdx := 0\n\tfor i, obj := range file.segments {\n\t\tif file.filePos < sz+obj.Bytes || (i == len(file.segments)-1 && file.filePos < sz+file.minChunkSiz... | {
"audio": "",
"image": "",
"text": "\n\t\tif writeSegmentIdx < len(file.segments) {\n\t\t\tfile.segments[writeSegmentIdx] = *newSegment\n\t\t} else {\n\t\t\tfile.segments = append(file.segments, *newSegment)\n\t\t}\n\t\toffset += n\n\t\twriteSegmentIdx++\n\t\trelativeFilePos = 0\n\t}\n\tfile.filePos += int64(siz... | {
"audio": "",
"image": "",
"text": "\tvar err error\n\tif fm.limit > 0 && fm.openedFDs >= fm.limit {\n\t\tfm.closeUnusedFiles(file.id)\n\t}\n\tfile.handle, err = openFileWithFlags(file.name, file.flags)\n\tif err == nil {\n\t\tatomic.StoreInt32(&file.state, fileInUse)\n\t\tfm.openedFDs++\n\t}\n\tfm.Unlock()\n\tr... |
{
"audio": "",
"image": "",
"text": "func (h Headers) Metadata(metaPrefix string) Metadata {\n\tm := Metadata{}\n\tmetaPrefix = http.CanonicalHeaderKey(metaPrefix)\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tfor key, value := range h {\n\t\tif strings.HasPrefix(key, metaPrefix) {\n\t\t\tmetaKey := strings.ToLower(key[len(metaPrefix):])\n\t\t\tm[metaKey] = value\n\t\t}\n\t}\n\treturn m\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " + name + \" is unavailable\")\n\t}\n\tcanonicalHeaders := make([]string, len(headers))\n\tfor i, h := range headers {\n\t\tcanonicalHeaders[i] = http.CanonicalHeaderKey(h)\n\t}\n\treturn &hmacAuth{hash, key, header, canonicalHeaders}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func nsToFloatString(ns int64) string {\n\tif ns < 0 {\n\t\treturn \"-\" + nsToFloatString(-ns)\n\t}\n\tresult := fmt.Sprintf(\"%010d\", ns)\n\tsplit := len(result) - 9\n\tresult, decimals := result[:split],",
"video": ""
} | {
"audio": "",
"image": "",
"text": " result[split:]\n\tdecimals = strings.TrimRight(decimals, \"0\")\n\tif decimals != \"\" {\n\t\tresult += \".\"\n\t\tresult += decimals\n\t}\n\treturn result\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " == nil {\n\t\tif ns := strings.TrimSpace(string(data)); len(ns) > 0 {\n\t\t\treturn ns\n\t\t}\n\t}\n\n\treturn environment.DefaultTillerNamespace\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func floatStringToNs(s string) (int64, error) {\n\tconst zeros = \"000000000\"\n\tif point := strings.IndexRune(s, '.'); point >= 0 {\n\t\ttail := s[point+1:]\n\t\tif fill := 9 - len(tail); fill < 0 {\n\t\t\ttail = tail[:9]\n\t\t} else {\n\t\t\ttail += zeros[:fill]\n\t\t}\n\t\... | {
"audio": "",
"image": "",
"text": "\t} else if len(s) > 0 { // Make sure empty string produces an error\n\t\ts += zeros\n\t}\n\treturn strconv.ParseInt(s, 10, 64)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tm += MEDIAL_BASE\n\tif t != 0 {\n\t\tt += TAIL_BASE - 1\n\t}\n\n\treturn\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func newError(StatusCode int, Text string) *Error",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn &Error{\n\t\tStatusCode: StatusCode,\n\t\tText: Text,\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\ttext = []byte(u.String())\n\treturn\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func newErrorf(StatusCode int, Text string, Parameters ...interface{}) *Error {\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " newError(StatusCode, fmt.Sprintf(Text, Parameters...))\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string, _ string) (string, error) {\n\treturn \"\", nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func drainAndClose(rd io.ReadCloser, err *error) {\n\tif rd == nil {\n\t\treturn\n\t}\n\n\t_, _ = io.Copy(ioutil.Discard, rd)",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tcerr := rd.Close()\n\tif err != nil && *err == nil {\n\t\t*err = cerr\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn utils.ClickableURL(rd.server.URL + rd.shortPath)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Connection) parseHeaders(resp *http.Response, errorMap errorMap) error {\n\tif errorMap != nil {\n\t\tif err, ok := errorMap[resp.StatusCode]; ok {\n\t\t\tdrainAndClose(resp.Body, nil)\n\t\t\treturn err\n\t\t}\n\t}\n\tif resp.StatusCode < 200 || resp.StatusCode",
"v... | {
"audio": "",
"image": "",
"text": " > 299 {\n\t\tdrainAndClose(resp.Body, nil)\n\t\treturn newErrorf(resp.StatusCode, \"HTTP Error: %d: %s\", resp.StatusCode, resp.Status)\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tdefer resp.Body.Close()\n\tif resp.StatusCode < 200 || resp.StatusCode >= 300 {\n\t\treturn fmt.Errorf(\"response not 2XX: %s\", resp.Status)\n\t}\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Connection) doTimeoutRequest(timer *time.Timer, req *http.Request) (*http.Response, error) {\n\t// Do the request in the background so we can check the timeout\n\ttype result struct {\n\t\tresp *http.Response\n\t\terr error\n\t}\n\tdone := make(chan result, 1)\n\tgo ... | {
"audio": "",
"image": "",
"text": "\n\t\treturn r.resp, r.err\n\tcase <-timer.C:\n\t\t// Kill the connection on timeout so we don't leak sockets or goroutines\n\t\tcancelRequest(c.Transport, req)\n\t\treturn nil, TimeoutError\n\t}\n\tpanic(\"unreachable\") // For Go 1.0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\t\tch <- err\n\t\tclient.wg.Done()\n\t\treturn\n\t}\n\n\tif packet.Release == \"\" {\n\t\tpacket.Release = release\n\t}\n\n\tif packet.Environment == \"\" {\n\t\tpacket.Environment = environment\n\t}\n\n\toutgoingPacket := &outgoingPacket{packet, ch}\n\n\t// Lazily start ... |
{
"audio": "",
"image": "",
"text": "func (c *Connection) setDefaults() {\n\tif c.UserAgent == \"\" {\n\t\tc.UserAgent = DefaultUserAgent\n\t}\n\tif c.Retries == 0 {\n\t\tc.Retries = DefaultRetries\n\t}\n\tif c.ConnectTimeout == 0 {\n\t\tc.ConnectTimeout = 10 * time.Second\n\t}\n\tif c.Timeout == 0 {\n\t\tc.Timeo... | {
"audio": "",
"image": "",
"text": " linux's default open files limit (1024).\n\t\t\tMaxIdleConnsPerHost: 512,\n\t\t}\n\t\tSetExpectContinueTimeout(t, 5*time.Second)\n\t\tc.Transport = t\n\t}\n\tif c.client == nil {\n\t\tc.client = &http.Client{\n\t\t\t//\t\tCheckRedirect: redirectPolicyFunc,\n\t\t\tTransport: c... | {
"audio": "",
"image": "",
"text": "\n\tif resp != nil {\n\t\tresp.Request = r\n\t}\n\n\tif c.emitErrorAfter > 0 {\n\t\tc.emitErrorAfter--\n\t} else if c.err != nil {\n\t\terr = c.err\n\t\tc.repeatError--\n\t\tif c.repeatError == 0 {\n\t\t\tc.err = nil\n\t\t}\n\t}\n\n\treturn\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Connection) Authenticate() (err error) {\n\tc.authLock.Lock()\n\tdefer",
"video": ""
} | {
"audio": "",
"image": "",
"text": " c.authLock.Unlock()\n\treturn c.authenticate()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\treturn c.err\n}",
"video": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.