anchor dict | positive dict | negative dict |
|---|---|---|
{
"audio": "",
"image": "",
"text": "func SetLogger(logDir string, quiet, debug, logJSON bool) {\n\tstderrHundler := logger.StderrHandler\n\tlogFormat := logger.LogfmtFormat()\n\tif logJSON {\n\t\tlogFormat = logger.JsonFormatEx(false, true)\n\t\tstderrHundler = logger.StreamHandler(os.Stderr, logFormat)\n\t}\n\n... | {
"audio": "",
"image": "",
"text": " {\n\t\t\tlogger.Error(\"Failed to create log directory\", \"err\", err)\n\t\t}\n\t}\n\tvar hundler logger.Handler\n\tif _, err := os.Stat(logDir); err == nil {\n\t\tlogPath := filepath.Join(logDir, \"cve-dictionary.log\")\n\t\thundler = logger.MultiHandler(\n\t\t\tlogger.Must... | {
"audio": "",
"image": "",
"text": "\n\tif globalLevelSet {\n\t\tlogger = logger.AtLevel(globalLevel)\n\t}\n\tglobalLogger = logger\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func Fatalf(format string, args ...interface{}) {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tlogger.Crit(fmt.Sprintf(format, args...))\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tif !b {\n\t\tlog.Fatalf(\"%+v\", errors.Errorf(format, args...))\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func Start(logDir string, driver db.DB) error {\n\te := echo.New()\n\te.Debug = config.Conf.Debug\n\n\t// Middleware\n\te.Use(middleware.Logger())\n\te.Use(middleware.Recover())\n\n\t// setup access logger\n\tlogPath := filepath.Join(logDir, \"access.log\")\n\tif _, err := os.... | {
"audio": "",
"image": "",
"text": "\n\te.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{\n\t\tOutput: f,\n\t}))\n\n\t// Routes\n\te.GET(\"/health\", health())\n\te.GET(\"/cves/:id\", getCve(driver))\n\te.POST(\"/cpes\", getCveByCpeName(driver))\n\n\tbindURL := fmt.Sprintf(\"%s:%s\", config.Conf.Bind, c... | {
"audio": "",
"image": "",
"text": "\treturn err\n\t}\n\n\tif err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {\n\t\treturn err\n\t}\n\n\tfh, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer fh.Close()\n\n\tif _, err := fh.Write(keyringB... |
{
"audio": "",
"image": "",
"text": "func NewRedis(dbType, dbpath string, debugSQL bool) (driver *RedisDriver, locked bool, err error) {\n\tdriver = &RedisDriver{\n\t\tname: dbType,\n\t}\n\tlog.Debugf(\"Opening DB",
"video": ""
} | {
"audio": "",
"image": "",
"text": " (%s).\", driver.Name())\n\tif err = driver.OpenDB(dbType, dbpath, debugSQL); err != nil {\n\t\treturn\n\t}\n\n\treturn\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\treturn NewRedis(dbType, dbpath, debugSQL)\n\t}\n\treturn nil, false, fmt.Errorf(\"Invalid database dialect, %s\", dbType)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *RedisDriver) InsertJvn(cves []models.CveDetail) error {\n\tlog.Infof(\"Inserting fetched CVEs...\")\n\tvar err error\n\tvar refreshedJvns []string\n\tbar := pb.New(len(cves))\n\tif c.Conf.Quiet {\n\t\tbar.SetWriter(ioutil.Discard)\n\t} else {\n\t\tbar.SetWriter(os.Std... | {
"audio": "",
"image": "",
"text": "\t); result.Err() != nil {\n\t\t\t\t\treturn fmt.Errorf(\"Failed to ZAdd cpe. err: %s\", result.Err())\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar jc []byte\n\t\t\tif jc, err = json.Marshal(cpes); err != nil {\n\t\t\t\treturn fmt.Errorf(\"Failed to marshal json. err: %s\", err)\n\t\t\t}\n\... | {
"audio": "",
"image": "",
"text": "\tvar name string\n\toutfmt := []interface{}{name}\n\tresult, err := queryScan(c.db, q, inargs, outfmt)\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\n\tresponse := []string{}\n\tfor _, r := range result {\n\t\tresponse = append(response, r[0].(string))\n\t}\n\n\tretur... |
{
"audio": "",
"image": "",
"text": "func (r *RedisDriver) GetFetchedFeedMeta(url string) (*models.FeedMeta, error) {\n\tvar result *redis.StringStringMapCmd\n\tif result = r.conn.HGetAll(hashKeyPrefix + \"Meta\"); result.Err() != nil {\n\t\treturn nil, result.Err()\n\t}\n\tmeta := &models.FeedMeta{}\n\tif s,",
... | {
"audio": "",
"image": "",
"text": " ok := result.Val()[url]; ok {\n\t\tif err := json.Unmarshal([]byte(s), meta); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn meta, nil\n\t}\n\treturn meta, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " response.StatusCode != http.StatusOK {\n\t\treturn nil, aws.ParseError(response)\n\t}\n\n\t// Parse success response.\n\tbody, err := ioutil.ReadAll(response.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar list struct {\n\t\tArchiveDescription string\n\t\tCreation... |
{
"audio": "",
"image": "",
"text": "func (r *RedisDriver) UpsertFeedHash(m models.FeedMeta) error {\n\tjn, err := json.Marshal(m)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to marshal json. err: %s\", err)\n\t}\n\n\tvar pipe redis.Pipeliner\n\tpipe = r.conn.Pipeline()\n\tif result := pipe.HSet(hashKeyPre... | {
"audio": "",
"image": "",
"text": " fmt.Errorf(\"Failed to HSet META. err: %s\", result.Err())\n\t}\n\tif _, err := pipe.Exec(); err != nil {\n\t\treturn fmt.Errorf(\"Failed to exec pipeline. err: %s\", err)\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := json.Marshal(optionsForDriver)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to marshal spec, error: %s\", err.Error())\n\t}\n\n\tdc.Append(string(jsonBytes))\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f FeedMeta) UpToDate() bool {\n\treturn !f.Newly()",
"video": ""
} | {
"audio": "",
"image": "",
"text": " && f.Hash == f.LatestHash\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(a ma.Multiaddr) bool {\n\t\treturn !f(a)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f FeedMeta) OutDated() bool {\n\treturn !f.Newly()",
"video": ""
} | {
"audio": "",
"image": "",
"text": " && f.Hash != f.LatestHash\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(a ma.Multiaddr) bool {\n\t\treturn !f(a)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f FeedMeta) StatusForStdout() string {\n\tif f.Newly() {\n\t\treturn \"Newly\"\n\t} else if f.OutDated() {\n\t\tred :=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " color.New(color.FgRed, color.Bold).SprintFunc()\n\t\treturn red(\"Out-Dated\")\n\t} else if f.UpToDate() {\n\t\treturn color.GreenString(\"Up-to-Date\")\n\t}\n\treturn \"Unknown\"\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 FeedMeta) Year() (year string, xml bool, err error) {\n\tswitch f.source() {\n\tcase nvdxml:\n\t\treturn strings.TrimSuffix(\n\t\t\tstrings.Split(f.URL, \"nvdcve-2.0-\")[1], \".xml.gz\"), true, nil\n\tcase nvdjson:\n\t\treturn strings.TrimSuffix(\n\t\t\tstrings.Split(f... | {
"audio": "",
"image": "",
"text": " nil\n\tcase jvn:\n\t\tif strings.HasSuffix(f.URL, \"jvndb.rdf\") {\n\t\t\treturn \"modified\", true, nil\n\t\t} else if strings.HasSuffix(f.URL, \"jvndb_new.rdf\") {\n\t\t\treturn \"recent\", true, nil\n\t\t} else {\n\t\t\treturn strings.TrimSuffix(\n\t\t\t\tstrings.Split(f.U... | {
"audio": "",
"image": "",
"text": " strings.Split(f.ComputedPackage, \".\")\n\treturn filepath.Join(parts...)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f FeedMeta) ToTableWriterRow() []string {\n\ty, _, _ := f.Year()\n\tfetched, latest := f.modifiedTimesToStrs()",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn []string{\n\t\tf.color(f.source()),\n\t\tf.color(y),\n\t\tf.StatusForStdout(),\n\t\tf.color(fetched),\n\t\tf.color(latest),\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " Filters(func(f *mesos.Filters) {\n\t\tf.RefuseSeconds = &asFloat\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func FetchConvert(metas []models.FeedMeta) (cves []models.CveDetail, err error) {\n\treqs := []fetcher.FetchRequest{}\n\tfor _, meta := range metas {\n\t\treqs = append(reqs, fetcher.FetchRequest{\n\t\t\tURL: meta.URL,\n\t\t\tGZIP: true,\n\t\t})\n\t}\n\n\tresults, err := fetc... | {
"audio": "",
"image": "",
"text": " nil, fmt.Errorf(\n\t\t\t\t\"Failed to unmarshal. url: %s, err: %s\",\n\t\t\t\tres.URL, err)\n\t\t}\n\t\tfor _, item := range nvd.CveItems {\n\t\t\tcve, err := convertToModel(&item)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"Failed to convert to model. cve: %s, e... | {
"audio": "",
"image": "",
"text": " req.Year,\n\t\t\t\t\tURL: req.URL,\n\t\t\t\t\tBody: body,\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}\n\n\terrs := []error{}\n\ttimeout := time.After(10 * 60 * time.Second)\n\tfor range reqs {\n\t\tselect {\n\t\tcase res := <-resChan:\n\t\t\tresults = append(results, res)\... |
{
"audio": "",
"image": "",
"text": "func (c *Collection) Register(fns ...func(DB) error) error {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn c.register(false, fns...)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(_ *Client, c *RemoteContext) error {\n\t\tc.Snapshotter = snapshotterName\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Collection) RegisterTx(fns ...func(DB) error) error {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn c.register(true, fns...)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(_ *Client, c *RemoteContext) error {\n\t\tc.Snapshotter = snapshotterName\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Collection) DiscoverSQLMigrations(dir string) error {\n\tdir, err := filepath.Abs(dir)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif c.isVisitedDir(dir) {\n\t\treturn nil\n\t}\n\n\tif _, err := os.Stat(dir); os.IsNotExist(err) {\n\t\treturn nil\n\t}\n\n\tvar ms []*M... | {
"audio": "",
"image": "",
"text": "\n\n\t\tm := newMigration(version)\n\t\tfilePath := filepath.Join(dir, fileName)\n\n\t\tif strings.HasSuffix(fileName, \".up.sql\") {\n\t\t\tif m.Up != nil {\n\t\t\t\treturn fmt.Errorf(\"migration=%d already has Up func\", version)\n\t\t\t}\n\t\t\tm.UpTx = strings.HasSuffix(fi... | {
"audio": "",
"image": "",
"text": " entry)\n\t\tdirs[filepath.Dir(filename)] = struct{}{}\n\n\t\tif err := s.fsckCheckFile(ctx, filename); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tfor dir := range dirs {\n\t\tif err := s.fsckCheckDir(ctx, dir); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}"... |
{
"audio": "",
"image": "",
"text": "func (r Result) Format(s fmt.State, verb rune) {\n\tswitch verb {\n\tcase 'v':\n\t\tif s.Flag('+') {\n\t\t\tvar buf bytes.Buffer\n\t\t\tfmt.Fprintf(&buf, \"DNS lookup: %4d ms\\n\",\n\t\t\t\tint(r.DNSLookup/time.Millisecond))\n\t\t\tfmt.Fprintf(&buf, \"TCP connection: ... | {
"audio": "",
"image": "",
"text": "\tif r.total > 0 {\n\t\t\t\tfmt.Fprintf(&buf, \"Total: %4d ms\\n\",\n\t\t\t\t\tint(r.total/time.Millisecond))\n\t\t\t} else {\n\t\t\t\tfmt.Fprintf(&buf, \"Total: %4s ms\\n\", \"-\")\n\t\t\t}\n\t\t\tio.WriteString(s, buf.String())\n\t\t\treturn\n\t\t}\n\n\t\tf... | {
"audio": "",
"image": "",
"text": "\t}\n\tif fullTimestamps {\n\t\tfmt.Fprintf(w, \"%s\\t\", commitInfo.Started.String())\n\t} else {\n\t\tfmt.Fprintf(w, \"%s\\t\", pretty.Ago(commitInfo.Started))\n\t}\n\tif commitInfo.Finished != nil {\n\t\tfmt.Fprintf(w, fmt.Sprintf(\"%s\\t\", pretty.TimeDifference(commitInfo... |
{
"audio": "",
"image": "",
"text": "func WithHTTPStat(ctx context.Context, r *Result) context.Context {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn withClientTrace(ctx, r)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tif o.Context == nil {\n\t\t\to.Context = context.Background()\n\t\t}\n\t\to.Context = context.WithValue(o.Context, maxMessagesKey{}, max)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (w *worker) run() {\n\tdefer func() {\n\t\tw.logFunc(LogInfo, \"worker done.\")\n\t\tw.wg.Done()\n\t}()\n\n\t// Enter loop to process URLs until stop signal is received\n\tfor {\n\t\tvar idleChan <-chan time.Time\n\n\t\tw.logFunc(LogInfo, \"waiting for pop...\")\n\n\t\t//... | {
"audio": "",
"image": "",
"text": "\n\t\t\t\t} else if w.isAllowedPerRobotsPolicies(ctx.url) {\n\t\t\t\t\tw.requestURL(ctx, ctx.HeadBeforeGet)\n\t\t\t\t} else {\n\t\t\t\t\t// Must still notify Crawler that this URL was processed, although not visited\n\t\t\t\t\tw.opts.Extender.Disallowed(ctx)\n\t\t\t\t\tw.sendR... | {
"audio": "",
"image": "",
"text": "\tw.Perform(job)\n\t\tcase <-w.ctx.Done():\n\t\t\tw.cancel()\n\t\t}\n\t}()\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (w *worker) isAllowedPerRobotsPolicies(u *url.URL) bool {\n\tif w.robotsGroup != nil {\n\t\t// Is this URL allowed per robots.txt policy?\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tok := w.robotsGroup.Test(u.Path)\n\t\tif !ok {\n\t\t\tw.logFunc(LogIgnored, \"ignored on robots.txt policy: %s\", u.String())\n\t\t}\n\t\treturn ok\n\t}\n\n\t// No robots.txt = everything is allowed\n\treturn true\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\t\t\t} else if w.isAllowedPerRobotsPolicies(ctx.url) {\n\t\t\t\t\tw.requestURL(ctx, ctx.HeadBeforeGet)\n\t\t\t\t} else {\n\t\t\t\t\t// Must still notify Crawler that this URL was processed, although not visited\n\t\t\t\t\tw.opts.Extender.Disallowed(ctx)\n\t\t\t\t\tw.sendR... |
{
"audio": "",
"image": "",
"text": "func (w *worker) requestURL(ctx *URLContext, headRequest bool) {\n\tif res, ok := w.fetchURL(ctx, w.opts.UserAgent, headRequest); ok {\n\t\tvar harvested interface{}\n\t\tvar visited bool\n\n\t\t// Close the body on function end\n\t\tdefer res.Body.Close()\n\n\t\t// Any 2xx st... | {
"audio": "",
"image": "",
"text": "\t} else {\n\t\t\t// Error based on status code received\n\t\t\tw.opts.Extender.Error(newCrawlErrorMessage(ctx, res.Status, CekHttpStatusCode))\n\t\t\tw.logFunc(LogError, \"ERROR status code for %s: %s\", ctx.url, res.Status)\n\t\t}\n\t\tw.sendResponse(ctx, visited, harvested,... | {
"audio": "",
"image": "",
"text": "\n\t\t\t\t} else if w.isAllowedPerRobotsPolicies(ctx.url) {\n\t\t\t\t\tw.requestURL(ctx, ctx.HeadBeforeGet)\n\t\t\t\t} else {\n\t\t\t\t\t// Must still notify Crawler that this URL was processed, although not visited\n\t\t\t\t\tw.opts.Extender.Disallowed(ctx)\n\t\t\t\t\tw.sendR... |
{
"audio": "",
"image": "",
"text": "func (w *worker) requestRobotsTxt(ctx *URLContext) {\n\t// Ask if it should be fetched\n\tif robData, reqRob := w.opts.Extender.RequestRobots(ctx, w.opts.RobotUserAgent); !reqRob {\n\t\tw.logFunc(LogInfo, \"using robots.txt from cache\")\n\t\tw.robotsGroup = w.getRobotsTxtGrou... | {
"audio": "",
"image": "",
"text": " := w.fetchURL(ctx, w.opts.UserAgent, false); ok {\n\t\t// Close the body on function end\n\t\tdefer res.Body.Close()\n\t\tw.robotsGroup = w.getRobotsTxtGroup(ctx, nil, res)\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tok := w.robotsGroup.Test(u.Path)\n\t\tif !ok {\n\t\t\tw.logFunc(LogIgnored, \"ignored on robots.txt policy: %s\", u.String())\n\t\t}\n\t\treturn ok\n\t}\n\n\t// No robots.txt = everything is allowed\n\treturn true\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (w *worker) getRobotsTxtGroup(ctx *URLContext, b []byte, res *http.Response) (g *robotstxt.Group) {\n\tvar data *robotstxt.RobotsData\n\tvar e error\n\n\tif res != nil {\n\t\tvar buf bytes.Buffer\n\t\tio.Copy(&buf, res.Body)\n\t\tres.Body = ioutil.NopCloser(bytes.NewReade... | {
"audio": "",
"image": "",
"text": " be parsed, will return nil, which will allow access by default.\n\t// Reasonable, since by default no robots.txt means full access, so invalid\n\t// robots.txt is similar behavior.\n\tif e != nil {\n\t\tw.opts.Extender.Error(newCrawlError(nil, e, CekParseRobots))\n\t\tw.logFu... | {
"audio": "",
"image": "",
"text": "\n\t\tbytes.NewReader(body),\n\t\tapi.client.options.TokenOptions)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer res.Body.Close()\n\n\ttask, err = getTask(getError(res))\n\treturn\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (w *worker) setCrawlDelay() {\n\tvar robDelay time.Duration\n\n\tif w.robotsGroup != nil {\n\t\trobDelay = w.robotsGroup.CrawlDelay\n\t}\n\tw.lastCrawlDelay =",
"video": ""
} | {
"audio": "",
"image": "",
"text": " w.opts.Extender.ComputeDelay(w.host,\n\t\t&DelayInfo{\n\t\t\tw.opts.CrawlDelay,\n\t\t\trobDelay,\n\t\t\tw.lastCrawlDelay,\n\t\t},\n\t\tw.lastFetch)\n\tw.logFunc(LogInfo, \"using crawl-delay: %v\", w.lastCrawlDelay)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tok := w.robotsGroup.Test(u.Path)\n\t\tif !ok {\n\t\t\tw.logFunc(LogIgnored, \"ignored on robots.txt policy: %s\", u.String())\n\t\t}\n\t\treturn ok\n\t}\n\n\t// No robots.txt = everything is allowed\n\treturn true\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (w *worker) fetchURL(ctx *URLContext, agent string, headRequest bool) (res *http.Response, ok bool) {\n\tvar e error\n\tvar silent bool\n\n\tfor {\n\t\t// Wait for crawl delay, if one is pending.\n\t\tw.logFunc(LogTrace, \"waiting for crawl delay\")\n\t\tif w.wait != nil ... | {
"audio": "",
"image": "",
"text": " set to nil\n\t\t\tw.lastFetch = nil\n\n\t\t\tif !silent {\n\t\t\t\t// Notify error\n\t\t\t\tw.opts.Extender.Error(newCrawlError(ctx, e, CekFetch))\n\t\t\t\tw.logFunc(LogError, \"ERROR fetching %s: %s\", ctx.url, e)\n\t\t\t}\n\n\t\t\t// Return from this URL crawl\n\t\t\tw.send... | {
"audio": "",
"image": "",
"text": "\n\t\t\t\t} else if w.isAllowedPerRobotsPolicies(ctx.url) {\n\t\t\t\t\tw.requestURL(ctx, ctx.HeadBeforeGet)\n\t\t\t\t} else {\n\t\t\t\t\t// Must still notify Crawler that this URL was processed, although not visited\n\t\t\t\t\tw.opts.Extender.Disallowed(ctx)\n\t\t\t\t\tw.sendR... |
{
"audio": "",
"image": "",
"text": "func (w *worker) sendResponse(ctx *URLContext, visited bool, harvested interface{}, idleDeath bool) {\n\t// Push harvested urls back to crawler, even if empty (uses the channel communication\n\t// to decrement reference count of pending URLs)\n\tif ctx == nil || !isRobotsURL(c... | {
"audio": "",
"image": "",
"text": "\tw.logFunc(LogInfo, \"ignoring send response, will stop.\")\n\t\t\treturn\n\t\tdefault:\n\t\t\t// Nothing, just continue...\n\t\t}\n\n\t\t// No stop signal, send the response\n\t\tres := &workerResponse{\n\t\t\tctx,\n\t\t\tvisited,\n\t\t\tharvested,\n\t\t\tw.host,\n\t\t\tidle... | {
"audio": "",
"image": "",
"text": "\n\t\t\t\t} else if w.isAllowedPerRobotsPolicies(ctx.url) {\n\t\t\t\t\tw.requestURL(ctx, ctx.HeadBeforeGet)\n\t\t\t\t} else {\n\t\t\t\t\t// Must still notify Crawler that this URL was processed, although not visited\n\t\t\t\t\tw.opts.Extender.Disallowed(ctx)\n\t\t\t\t\tw.sendR... |
{
"audio": "",
"image": "",
"text": "func (w *worker) visitURL(ctx *URLContext, res *http.Response) interface{} {\n\tvar doc *goquery.Document\n\tvar harvested interface{}\n\tvar doLinks bool\n\n\t// Load a goquery document and call the visitor function\n\tif bd, e := ioutil.ReadAll(res.Body); e != nil {\n\t\tw.o... | {
"audio": "",
"image": "",
"text": "\t\t// Links were not processed by the visitor, so process links\n\t\tif doc != nil {\n\t\t\tharvested = w.processLinks(doc)\n\t\t} else {\n\t\t\tw.opts.Extender.Error(newCrawlErrorMessage(ctx, \"No goquery document to process links.\", CekProcessLinks))\n\t\t\tw.logFunc(LogEr... | {
"audio": "",
"image": "",
"text": "\n\t\t\t\t} else if w.isAllowedPerRobotsPolicies(ctx.url) {\n\t\t\t\t\tw.requestURL(ctx, ctx.HeadBeforeGet)\n\t\t\t\t} else {\n\t\t\t\t\t// Must still notify Crawler that this URL was processed, although not visited\n\t\t\t\t\tw.opts.Extender.Disallowed(ctx)\n\t\t\t\t\tw.sendR... |
{
"audio": "",
"image": "",
"text": "func (w *worker) processLinks(doc *goquery.Document) (result []*url.URL) {\n\tbaseURL, _ := doc.Find(\"base[href]\").Attr(\"href\")\n\turls := doc.Find(\"a[href]\").Map(func(_ int, s *goquery.Selection) string {\n\t\tval, _ := s.Attr(\"href\")\n\t\tif baseURL != \"\" {\n\t\t\t... | {
"audio": "",
"image": "",
"text": " to parse anyway)\n\t\tif len(s) > 0 && !strings.HasPrefix(s, \"#\") {\n\t\t\tif parsed, e := url.Parse(s); e == nil {\n\t\t\t\tparsed = doc.Url.ResolveReference(parsed)\n\t\t\t\tresult = append(result, parsed)\n\t\t\t} else {\n\t\t\t\tw.logFunc(LogIgnored, \"ignore on unparsa... | {
"audio": "",
"image": "",
"text": "\t\t\tn.Attr = append(n.Attr, html.Attribute{Key: attrName, Val: val})\n\t\t} else {\n\t\t\tattr.Val = val\n\t\t}\n\t}\n\n\treturn s\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (de *DefaultExtender) Log(logFlags LogFlags, msgLevel LogFlags, msg string) {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tif logFlags&msgLevel == msgLevel {\n\t\tlog.Println(msg)\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tmsg = fmt.Sprintln(r)\n\t}\n\tl.Log.Message(msg + \"\\n{\" + string(stack) + \"}\")\n\tl.Log.Priority = PanicPrio\n\tl.commit()\n\tif !cont {\n\t\tl.Writter.Close()\n\t\tl.Exiter(1)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (de *DefaultExtender) ComputeDelay(host string, di *DelayInfo, lastFetch *FetchInfo) time.Duration {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tif di.RobotsDelay > 0 {\n\t\treturn di.RobotsDelay\n\t}\n\treturn di.OptsDelay\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn time.Duration(1<<uint(i)) * time.Second\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (de *DefaultExtender) Visit(ctx *URLContext, res *http.Response,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " doc *goquery.Document) (harvested interface{}, findLinks bool) {\n\treturn nil, true\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " (*http.Response, error) {\n\treturn d(req)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewCrawlerWithOptions(opts *Options) *Crawler {\n\tret :=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " new(Crawler)\n\tret.Options = opts\n\treturn ret\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 *Crawler) init(ctxs []*URLContext) {\n\t// Initialize the internal hosts map\n\tc.hosts = make(map[string]struct{}, len(ctxs))\n\tfor _, ctx := range ctxs {\n\t\t// Add this normalized URL's host if it is not already there.\n\t\tif _, ok := c.hosts[ctx.normalizedURL.Ho... | {
"audio": "",
"image": "",
"text": "\t// Create a shiny new WaitGroup\n\tc.wg = new(sync.WaitGroup)\n\n\t// Initialize the visits fields\n\tc.visited = make(map[string]struct{}, l)\n\tc.pushPopRefCount, c.visits = 0, 0\n\n\t// Create the workers map and the push channel (the channel used by workers\n\t// to comm... | {
"audio": "",
"image": "",
"text": " hosts\n\t}\n\n\tfor _, cachedHost := range c.hostsCache {\n\t\thosts = append(hosts, cachedHost.get())\n\t}\n\treturn hosts\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Crawler) setExtenderEnqueueChan() {\n\tdefer func() {\n\t\tif err := recover(); err != nil {\n\t\t\t// Panic can happen if the field exists on a pointer struct, but that\n\t\t\t// pointer is nil.\n\t\t\tc.logFunc(LogError, \"cannot set the enqueue channel: %s\", err)\... | {
"audio": "",
"image": "",
"text": "\n\t\tc.logFunc(LogInfo, \"extender is not a struct, cannot set the enqueue channel\")\n\t\treturn\n\t}\n\tec := el.FieldByName(\"EnqueueChan\")\n\tif !ec.IsValid() {\n\t\tc.logFunc(LogInfo, \"extender.EnqueueChan does not exist, cannot set the enqueue channel\")\n\t\treturn\n... | {
"audio": "",
"image": "",
"text": " a pointer to the value.\n\t\trv2 := reflect.New(rv.Type())\n\t\trv2.Elem().Set(rv)\n\t\tv = rv2.Interface()\n\tcase reflect.Ptr:\n\t\t// Represent slice types as the value itself.\n\t\tswitch rv.Type().Elem().Kind() {\n\t\tcase reflect.Slice:\n\t\t\tif rv.IsNil() {\n\t\t\t\tv... |
{
"audio": "",
"image": "",
"text": "func (c *Crawler) launchWorker(ctx *URLContext) *worker {\n\t// Initialize index and channels\n\ti := len(c.workers) + 1\n\tpop := newPopChannel()\n\n\t// Create the worker\n\tw := &worker{\n\t\thost: ctx.normalizedURL.Host,\n\t\tindex: i,\n\t\tpush: c.push,\n\t\tpop: ... | {
"audio": "",
"image": "",
"text": " c.Options.LogFlags, i),\n\t\topts: c.Options,\n\t}\n\n\t// Increment wait group count\n\tc.wg.Add(1)\n\n\t// Launch worker\n\tgo w.run()\n\tc.logFunc(LogInfo, \"worker %d launched for host %s\", i, w.host)\n\tc.workers[w.host] = w\n\n\treturn w\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn c.p, c.i, c.d\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Crawler) isSameHost(ctx *URLContext) bool {\n\t// If there is a source URL, then just check if the new URL is from the same host\n\tif ctx.normalizedSourceURL != nil {\n\t\treturn ctx.normalizedURL.Host == ctx.normalizedSourceURL.Host",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t}\n\n\t// Otherwise, check if the URL is from one of the seed hosts\n\t_, ok := c.hosts[ctx.normalizedURL.Host]\n\treturn ok\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\tfmt.Printf(\">>>>> STOP URL %s\\n\", ctx.Cmd.URL())\n\t\t\t// generally not a good idea to stop/block from a handler goroutine\n\t\t\t// so do it in a separate goroutine\n\t\t\tgo func() {\n\t\t\t\tif cancel {\n\t\t\t\t\tctx.Q.Cancel()\n\t\t\t\t} else {\n\t\t\t\t\tctx.Q.... |
{
"audio": "",
"image": "",
"text": "func (c *Crawler) enqueueUrls(ctxs []*URLContext) (cnt int) {\n\tfor _, ctx := range ctxs {\n\t\tvar isVisited, enqueue bool\n\n\t\t// Cannot directly enqueue a robots.txt URL, since it is managed as a special case\n\t\t// in the worker (doesn't return a response to crawler).\... | {
"audio": "",
"image": "",
"text": " host of the normalized URL\n\t\t\tw, ok := c.workers[ctx.normalizedURL.Host]\n\t\t\tif !ok {\n\t\t\t\t// No worker exists for this host, launch a new one\n\t\t\t\tw = c.launchWorker(ctx)\n\t\t\t\t// Automatically enqueue the robots.txt URL as first in line\n\t\t\t\tif robCtx,... | {
"audio": "",
"image": "",
"text": "\t\tok := w.robotsGroup.Test(u.Path)\n\t\tif !ok {\n\t\t\tw.logFunc(LogIgnored, \"ignored on robots.txt policy: %s\", u.String())\n\t\t}\n\t\treturn ok\n\t}\n\n\t// No robots.txt = everything is allowed\n\treturn true\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Crawler) collectUrls() error {\n\tdefer func() {\n\t\tc.logFunc(LogInfo, \"waiting for goroutines to complete...\")\n\t\tc.wg.Wait()\n\t\tc.logFunc(LogInfo, \"crawler done.\")\n\t}()\n\n\tfor {\n\t\t// By checking this after each channel reception, there is a bug if t... | {
"audio": "",
"image": "",
"text": " STOP signals...\")\n\t\t\tclose(c.stop)\n\t\t\treturn nil\n\t\t}\n\n\t\tselect {\n\t\tcase res := <-c.push:\n\t\t\t// Received a response, check if it contains URLs to enqueue\n\t\t\tif res.visited {\n\t\t\t\tc.visits++\n\t\t\t\tif c.Options.MaxVisits > 0 && c.visits >= c.Opt... | {
"audio": "",
"image": "",
"text": "\t// the monitoring goroutine may be in a select on the lockCh, so we need to\n\t// wait for it to return before changing the value.\n\tc.monitorWG.Wait()\n\tc.lockCh = nil\n\n\t// This is only cleanup, and will fail if the lock was immediately taken by\n\t// another client, s... |
{
"audio": "",
"image": "",
"text": "func (c *Crawler) Stop() {\n\tdefer func() {\n\t\tif err := recover(); err != nil {\n\t\t\tc.logFunc(LogError,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " \"error when manually stopping crawler: %s\", err)\n\t\t}\n\t}()\n\n\t// this channel may be closed already\n\tclose(c.stop)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " Option {\n\treturn func(c *Config) {\n\t\tc.Daemon.DriverCfg[networkType] = config\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (ce CrawlError) Error() string {\n\tif",
"video": ""
} | {
"audio": "",
"image": "",
"text": " ce.Err != nil {\n\t\treturn ce.Err.Error()\n\t}\n\treturn ce.msg\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " of closed network connection\" {\n\t\t\tclose(l.acceptQueue)\n\t\t}\n\t}\n\treturn ce.conn, ce.err\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func newCrawlError(ctx *URLContext, e error, kind CrawlErrorKind) *CrawlError {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn &CrawlError{ctx, e, kind, \"\"}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\"nobody\",\n\t\tfalse,\n\t\tfunc(e Export) UserMapping { return e.MapRoot },\n\t\tfunc(e Export, m UserMapping) { e.MapRoot = m })\n\n\treturn api.ExportUpdate(ctx, c.API, nex)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func newCrawlErrorMessage(ctx *URLContext, msg string, kind CrawlErrorKind) *CrawlError {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn &CrawlError{ctx, nil, kind, msg}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string, _ string) (string, error) {\n\treturn \"\", nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (uc *URLContext) cloneForRedirect(dst *url.URL, normFlags purell.NormalizationFlags) *URLContext {\n\tvar src, normalizedSrc *url.URL\n\tif uc.sourceURL != nil {\n\t\tsrc = &url.URL{}\n\t\t*src = *uc.sourceURL\n\t}\n\tif src == nil && uc.url != nil {\n\t\t// if the curren... | {
"audio": "",
"image": "",
"text": " {\n\t\tnormalizedSrc = &url.URL{}\n\t\t*normalizedSrc = *uc.normalizedURL\n\t}\n\n\trawDst := &url.URL{}\n\t*rawDst = *dst\n\tpurell.NormalizeURL(dst, normFlags)\n\treturn &URLContext{\n\t\tHeadBeforeGet: uc.HeadBeforeGet,\n\t\tState: uc.State,\n\t\turl: ... | {
"audio": "",
"image": "",
"text": "\t\turl = url + \"?\" + data.Encode()\n\t}\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn c.doHTTP(req)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewOptions(ext Extender) *Options {\n\t// Use defaults except for Extender\n\treturn &Options{\n\t\tDefaultUserAgent,\n\t\tDefaultRobotUserAgent,\n\t\t0,\n\t\tDefaultEnqueueChanBuffer,\n\t\tDefaultHostBufferFactor,",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tDefaultCrawlDelay,\n\t\tDefaultIdleTTL,\n\t\ttrue,\n\t\tfalse,\n\t\tDefaultNormalizationFlags,\n\t\tLogError,\n\t\text,\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " extender %s should have a positive weight applied to it\", extender.URLPrefix))\n\t\t}\n\t\tif extender.BindVerb != \"\" {\n\t\t\tbinders++\n\t\t}\n\t\tfor _, resource := range extender.ManagedResources {\n\t\t\terrs := validateExtendedResourceName(resource.Name)\n\t\t\tif le... |
{
"audio": "",
"image": "",
"text": "func toCamelInitCase(s string, initCase bool) string {\n\ts = addWordBoundariesToNumbers(s)\n\ts = strings.Trim(s, \" \")\n\tn := \"\"\n\tcapNext := initCase\n\tfor _, v := range s {\n\t\tif v >= 'A' && v <= 'Z' {\n\t\t\tn += string(v)\n\t\t}\n\t\tif v >= '0' && v <= '9' {\n\t... | {
"audio": "",
"image": "",
"text": " 'z' {\n\t\t\tif capNext {\n\t\t\t\tn += strings.ToUpper(string(v))\n\t\t\t} else {\n\t\t\t\tn += string(v)\n\t\t\t}\n\t\t}\n\t\tif v == '_' || v == ' ' || v == '-' {\n\t\t\tcapNext = true\n\t\t} else {\n\t\t\tcapNext = false\n\t\t}\n\t}\n\treturn n\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tMap(int64ToInt).\n\t\tWithShrinker(IntShrinker).\n\t\tSuchThat(func(v int) bool {\n\t\t\treturn v >= min && v <= max\n\t\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func ToLowerCamel(s string) string {\n\tif s == \"\" {\n\t\treturn s\n\t}\n\tif r := rune(s[0]); r >= 'A' && r <= 'Z' {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\ts = strings.ToLower(string(r)) + s[1:]\n\t}\n\treturn toCamelInitCase(s, 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 (s *Session) Call(name string, a ...interface{}) error {\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " s.Command(name, a...).Run()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " = NewRouter(f)\n\n\t// Setup the default error handler\n\tf.SetHTTPErrorHandler(f.defaultErrorHandler)\n\n\t// Setup a new context pool\n\tf.pool.New = func() interface{} {\n\t\treturn NewContext(new(Request), new(Response), f)\n\t}\n\n\treturn\n\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *Session) UnmarshalJSON(data interface{}) (err error) {\n\tbufrw := bytes.NewBuffer(nil)\n\ts.Stdout = bufrw\n\tif err = s.Run();",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err != nil {\n\t\treturn\n\t}\n\treturn json.NewDecoder(bufrw).Decode(data)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " b bytes.Buffer\n\ts.Stdout = &b\n\terr := s.Run(cmd)\n\treturn b.Bytes(), err\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *Session) UnmarshalXML(data interface{}) (err error) {\n\tbufrw := bytes.NewBuffer(nil)\n\ts.Stdout = bufrw\n\tif err = s.Run();",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err != nil {\n\t\treturn\n\t}\n\treturn xml.NewDecoder(bufrw).Decode(data)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " b bytes.Buffer\n\ts.Stdout = &b\n\terr := s.Run(cmd)\n\treturn b.Bytes(), err\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewEncoder(w io.WriteSeeker, sampleRate, bitDepth, numChans, audioFormat int) *Encoder {\n\treturn &Encoder{\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tw: w,\n\t\tSampleRate: sampleRate,\n\t\tBitDepth: bitDepth,\n\t\tNumChans: numChans,\n\t\tWavAudioFormat: audioFormat,\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " w.write(func() error {\n\t\te := json.NewEncoder(w.writer)\n\t\treturn e.Encode(data)\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (e *Encoder) AddLE(src interface{}) error {\n\te.WrittenBytes += binary.Size(src)\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " binary.Write(e.w, binary.LittleEndian, src)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " w.write(func() error {\n\t\te := json.NewEncoder(w.writer)\n\t\treturn e.Encode(data)\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (e *Encoder) AddBE(src interface{}) error {\n\te.WrittenBytes += binary.Size(src)\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " binary.Write(e.w, binary.BigEndian, src)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " w.write(func() error {\n\t\te := json.NewEncoder(w.writer)\n\t\treturn e.Encode(data)\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (e *Encoder) WriteFrame(value interface{}) error {\n\tif !e.wroteHeader {\n\t\te.writeHeader()\n\t}\n\tif !e.pcmChunkStarted {\n\t\t// sound header\n\t\tif err := e.AddLE(riff.DataFormatID); err != nil {\n\t\t\treturn fmt.Errorf(\"error encoding sound header %v\", err)\n\... | {
"audio": "",
"image": "",
"text": " a temporary chunksize\n\t\te.pcmChunkSizePos = e.WrittenBytes\n\t\tif err := e.AddLE(uint32(42)); err != nil {\n\t\t\treturn fmt.Errorf(\"%v when writing wav data chunk size header\", err)\n\t\t}\n\t}\n\n\te.frames++\n\treturn e.AddLE(value)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tif !e.oneshot {\n\t\t\te.err = e.Emitter.EmitArrayEnd()\n\t\t}\n\t}\n\n\treturn e.err\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func DecodeCueChunk(d *Decoder, ch *riff.Chunk) error {\n\tif ch == nil {\n\t\treturn fmt.Errorf(\"can't decode a nil chunk\")\n\t}\n\tif d == nil {\n\t\treturn fmt.Errorf(\"nil decoder\")\n\t}\n\tif ch.ID == CIDCue {\n\t\t// read the entire chunk in memory\n\t\tbuf := make([]... | {
"audio": "",
"image": "",
"text": "\t\t\tcopy(c.ID[:], scratch[:4])\n\t\t\t\tif err := binary.Read(r, binary.LittleEndian, &c.Position); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif _, err = r.Read(scratch); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to read the data chunk id\")\n\t\t\t\t}\... | {
"audio": "",
"image": "",
"text": " pointer\")\n\t}\n\tif ch.IsFullyRead() {\n\t\treturn io.EOF\n\t}\n\tch.Pos += binary.Size(dst)\n\treturn binary.Read(ch.R, binary.LittleEndian, dst)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewDecoder(r io.ReadSeeker) *Decoder {\n\treturn &Decoder{\n\t\tr: ",
"video": ""
} | {
"audio": "",
"image": "",
"text": " r,\n\t\tparser: riff.New(r),\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " = json.NewDecoder(r.Body).Decode(&sstls)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *Decoder) Seek(offset int64, whence int) (int64, error) {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn d.r.Seek(offset, whence)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " []*vtgatepb.IdKeyspaceId) (int64, error) {\n\tpanic(\"not implemented\")\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *Decoder) Err() error {\n\tif d.err == io.EOF {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\treturn nil\n\t}\n\treturn d.err\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func() bool {\n\t\t\treturn d.currState == \"leader\"\n\t\t}\n\t\tnetworkpolicy.InitK8SServiceWatch(d.ControlURL, isLeader)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *Decoder) EOF() bool {\n\tif d ==",
"video": ""
} | {
"audio": "",
"image": "",
"text": " nil || d.err == io.EOF {\n\t\treturn true\n\t}\n\treturn false\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func() bool {\n\t\t\treturn d.currState == \"leader\"\n\t\t}\n\t\tnetworkpolicy.InitK8SServiceWatch(d.ControlURL, isLeader)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *Decoder) ReadMetadata() {\n\tif d.Metadata != nil {\n\t\treturn\n\t}\n\td.ReadInfo()\n\tif d.Err() != nil || d.Metadata != nil {\n\t\treturn\n\t}\n\tvar (\n\t\tchunk *riff.Chunk\n\t\terr error\n\t)\n\tfor err == nil {\n\t\tchunk, err = d.parser.NextChunk()\n\t\tif e... | {
"audio": "",
"image": "",
"text": " DecodeSamplerChunk(d, chunk); err != nil {\n\t\t\t\tif err != io.EOF {\n\t\t\t\t\td.err = err\n\t\t\t\t}\n\t\t\t}\n\t\tcase CIDCue:\n\t\t\tif err = DecodeCueChunk(d, chunk); err != nil {\n\t\t\t\tif err != io.EOF {\n\t\t\t\t\td.err = err\n\t\t\t\t}\n\t\t\t}\n\t\tdefault:\n\t\... | {
"audio": "",
"image": "",
"text": " subvolDelete(d.subvolumesDir(), id, d.quotaEnabled); err != nil {\n\t\treturn err\n\t}\n\tif err := system.EnsureRemoveAll(dir); err != nil {\n\t\treturn err\n\t}\n\tif err := d.subvolRescanQuota(); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *Decoder) Duration() (time.Duration, error) {\n\tif d == nil || d.parser == nil {\n\t\treturn 0, errors.New(\"can't calculate",
"video": ""
} | {
"audio": "",
"image": "",
"text": " the duration of a nil pointer\")\n\t}\n\treturn d.parser.Duration()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " || len(d.errors) == 0 {\n\t\treturn nil\n\t}\n\treturn d.errors[0]\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *Decoder) readHeaders() error {\n\tif d == nil || d.NumChans > 0 {\n\t\treturn nil\n\t}\n\n\tid, size, err := d.parser.IDnSize()\n\tif err != nil {\n\t\treturn err\n\t}\n\td.parser.ID = id\n\tif d.parser.ID != riff.RiffID {\n\t\treturn fmt.Errorf(\"%s - %s\", d.parser.... | {
"audio": "",
"image": "",
"text": " footer\n\t\t\t// because so many players don't support that chunk properly\n\t\t\t// it is recommended to have it at the end of the file.\n\t\t\tDecodeListChunk(d, chunk)\n\t\t\t// unexpected chunk order, might be a bext chunk\n\t\t\trewindBytes += int64(chunk.Size) + 8\n\t\t... | {
"audio": "",
"image": "",
"text": "\tif typ, err = d.Parser.ParseType(); err != nil {\n\t\treturn\n\t}\n\n\terr = d.decodeMapImpl(typ, f)\n\treturn\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func sampleFloat64DecodeFunc(bitsPerSample int) (func([]byte) float64, error) {\n\tbytesPerSample := bitsPerSample / 8\n\tswitch bytesPerSample {\n\tcase 1:\n\t\t// 8bit values are unsigned\n\t\treturn func(s []byte) float64 {\n\t\t\treturn float64(uint8(s[0]))\n\t\t}, nil\n\t... | {
"audio": "",
"image": "",
"text": " nil\n\tcase 3:\n\t\treturn func(s []byte) float64 {\n\t\t\tvar output int32\n\t\t\toutput |= int32(s[2]) << 0\n\t\t\toutput |= int32(s[1]) << 8\n\t\t\toutput |= int32(s[0]) << 16\n\t\t\treturn float64(output)\n\t\t}, nil\n\tcase 4:\n\t\t// TODO: fix the float64 conversion (cu... | {
"audio": "",
"image": "",
"text": " -1 {\n\t\treturn formulaTable[fmtForms(FormsTable[idx].Value)]\n\t}\n\treturn func(n int) int {\n\t\treturn n\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func Diff(a, b interface{}) (desc []string) {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tPdiff((*sbuf)(&desc), a, b)\n\treturn desc\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 Fdiff(w io.Writer, a, b interface{}) {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tPdiff(&wprintfer{w}, a, b)\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 Pdiff(p Printfer, a, b interface{}) {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tdiffPrinter{w: p}.diff(reflect.ValueOf(a), reflect.ValueOf(b))\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 Ldiff(l Logfer, a, b interface{}) {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tPdiff(&logprintfer{l}, a, b)\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 keyEqual(av, bv reflect.Value) bool {\n\tif !av.IsValid() && !bv.IsValid() {\n\t\treturn true\n\t}\n\tif !av.IsValid() || !bv.IsValid() || av.Type() != bv.Type() {\n\t\treturn false\n\t}\n\tswitch kind := av.Kind(); kind {\n\tcase reflect.Bool:\n\t\ta, b := av.Bool(), bv.... | {
"audio": "",
"image": "",
"text": "\t\treturn true\n\tcase reflect.Chan, reflect.UnsafePointer, reflect.Ptr:\n\t\ta, b := av.Pointer(), bv.Pointer()\n\t\treturn a == b\n\tcase reflect.Interface:\n\t\treturn keyEqual(av.Elem(), bv.Elem())\n\tcase reflect.String:\n\t\ta, b := av.String(), bv.String()\n\t\treturn ... | {
"audio": "",
"image": "",
"text": " += s\n\t\t\t}\n\t\t\treturn sum\n\t\t}\n\n\tcase reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,\n\t\treflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,\n\t\treflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128:\n\t\treturn int(t.Size... |
{
"audio": "",
"image": "",
"text": "func TokenErrorf(token *scanner.Token, format string, args ...interface{}) error {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn Errorf(token.Pos, format, args...)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string, vlanId string) error {\n\treturn hyperv.SetNetworkAdapterVlanId(switchName, vlanId)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func ParseWithPosition(v string, pos ast.Pos) (ast.Node, error) {\n\tch",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := scanner.Scan(v, pos)\n\treturn parser.Parse(ch)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tif node, ok := file.Scope.Objects[n.String()]; ok {\n\t\t\treturn node.Kind != ast.Var && node.Kind != ast.Fun\n\t\t}\n\t}\n\treturn false\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *Peeker) Peek() *Token {\n\tif p.peeked",
"video": ""
} | {
"audio": "",
"image": "",
"text": " == nil {\n\t\tp.peeked = <-p.ch\n\t}\n\treturn p.peeked\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn func(p *ProgressBar) {\n\t\tp.config.width = s\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *Peeker) Read() *Token {\n\ttoken := p.Peek()\n\n\t// As a special case, we will produce the EOF token forever once\n\t// it",
"video": ""
} | {
"audio": "",
"image": "",
"text": " is reached.\n\tif token.Type != EOF {\n\t\tp.peeked = nil\n\t}\n\n\treturn token\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " a.expireIn,\n\t\ta.clientName, a.clientVersion)\n\n\t// sign the token\n\tsignature, err := a.signer.SignToString(ctx, token.Bytes())\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// reset the ticker\n\trefreshSeconds := a.expireIn / 2\n\tif refreshSeconds < AuthTokenMin... |
{
"audio": "",
"image": "",
"text": "func (p *Peeker) Close() {\n\tfor _ = range p.ch {\n\t\t// discard\n\t}\n\t// Install a synthetic EOF token in 'peeked' in case someone\n\t// erroneously calls",
"video": ""
} | {
"audio": "",
"image": "",
"text": " Peek() or Read() after we've closed.\n\tp.peeked = &Token{\n\t\tType: EOF,\n\t\tContent: \"\",\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " file := range indexMap.FilesFor(p.Sha1) {\n\t\t\t\t// Append a new *WrappedPointer that combines the data\n\t\t\t\t// from the index file, and the pointer \"p\".\n\t\t\t\tch <- gitscannerResult{\n\t\t\t\t\tPointer: &WrappedPointer{\n\t\t\t\t\t\tSha1: p.Sha1,\n\t\t\t\t\t\tN... |
{
"audio": "",
"image": "",
"text": "func (p *parser) parseInterpolationSeq(quoted bool) (ast.Node, error) {\n\tliteralType := scanner.LITERAL\n\tendType := scanner.EOF\n\tif quoted {\n\t\t// exceptions for quoted sequences\n\t\tliteralType = scanner.STRING\n\t\tendType = scanner.CQUOTE\n\t}\n\n\tstartPos := p.pe... | {
"audio": "",
"image": "",
"text": "\t}\n\t}\n\n\tif len(exprs) == 0 {\n\t\t// If we have no parts at all then the input must've\n\t\t// been an empty string.\n\t\texprs = append(exprs, &ast.LiteralNode{\n\t\t\tValue: \"\",\n\t\t\tTypex: ast.TypeString,\n\t\t\tPosx: startPos,\n\t\t})\n\t}\n\n\t// As a special c... | {
"audio": "",
"image": "",
"text": " return it.\n\tif p.n != 0 {\n\t\tp.n = 0\n\t\treturn p.tok\n\t}\n\n\tp.tok = p.sc.Scan()\n\treturn p.tok\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *parser) parseStringToken(tok *scanner.Token) (string, error) {\n\tvar backslashes bool\n\tswitch tok.Type {\n\tcase scanner.LITERAL:\n\t\tbackslashes = false\n\tcase scanner.STRING:\n\t\tbackslashes = true\n\tdefault:\n\t\tpanic(\"unsupported string token type\")\n\t}... | {
"audio": "",
"image": "",
"text": "\t`unfinished backslash escape sequence`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tescapeType := raw[i+1]\n\t\t\tswitch escapeType {\n\t\t\tcase '\\\\':\n\t\t\t\t// skip over the second slash\n\t\t\t\ti++\n\t\t\tcase 'n':\n\t\t\t\tb = '\\n'\n\t\t\t\ti++\n\t\t\tcase '\"':\n\t\t\t\tb = '\"'\n... | {
"audio": "",
"image": "",
"text": " n.ID,\n\t\t\tClass: TokenClass(n.Class),\n\t\t\tStart: n.Start,\n\t\t\tEnd: n.Start + utf8.RuneCountInString(n.Surface),\n\t\t\tSurface: n.Surface,\n\t\t\tdic: t.dic,\n\t\t\tudic: t.udic,\n\t\t}\n\t\tif tok.ID == lattice.BosEosID {\n\t\t\tif i == 0 {\n\t\t\t\tt... |
{
"audio": "",
"image": "",
"text": "func (p *parser) parseBinaryOps(ops []map[scanner.TokenType]ast.ArithmeticOp) (ast.Node, error) {\n\tif len(ops) == 0 {\n\t\t// We've run out of operators, so now we'll just try to parse a term.\n\t\treturn p.ParseExpressionTerm()\n\t}\n\n\tthisLevel := ops[0]\n\tremaining := ... | {
"audio": "",
"image": "",
"text": " := p.peeker.Peek()\n\t\tvar newOperator ast.ArithmeticOp\n\t\tvar ok bool\n\t\tif newOperator, ok = thisLevel[next.Type]; !ok {\n\t\t\tbreak\n\t\t}\n\n\t\t// Are we extending an expression started on\n\t\t// the previous iteration?\n\t\tif operator != ast.ArithmeticOpInvalid ... | {
"audio": "",
"image": "",
"text": " be \"planned\", but we'll\n\t\t\t\t\t// do this anyway for the sake of completeness.\n\t\t\t\t\tif obj.Status == ObjectPlanned {\n\t\t\t\t\t\tms.ForgetResourceInstanceDeposed(instAddr, dk)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// We may have deleted some objects, whi... |
{
"audio": "",
"image": "",
"text": "func internalEval(root ast.Node, config *EvalConfig) (interface{}, ast.Type, error) {\n\t// Copy the scope so we can add our builtins\n\tif config == nil {\n\t\tconfig = new(EvalConfig)\n\t}\n\tscope := registerBuiltins(config.GlobalScope)\n\timplicitMap := map[ast.Type]map[as... | {
"audio": "",
"image": "",
"text": "\t\t\tast.TypeFloat: \"__builtin_StringToFloat\",\n\t\t\tast.TypeBool: \"__builtin_StringToBool\",\n\t\t},\n\t\tast.TypeBool: {\n\t\t\tast.TypeString: \"__builtin_BoolToString\",\n\t\t},\n\t}\n\n\t// Build our own semantic checks that we always run\n\ttv := &TypeCheck{Scope: ... | {
"audio": "",
"image": "",
"text": "\n\t\tif node, ok := file.Scope.Objects[n.String()]; ok {\n\t\t\treturn node.Kind != ast.Var && node.Kind != ast.Fun\n\t\t}\n\t}\n\treturn false\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func evalNode(raw ast.Node) (EvalNode, error) {\n\tswitch n := raw.(type) {\n\tcase *ast.Index:\n\t\treturn &evalIndex{n}, nil\n\tcase *ast.Call:\n\t\treturn &evalCall{n}, nil\n\tcase *ast.Conditional:\n\t\treturn &evalConditional{n}, nil\n\tcase *ast.Output:\n\t\treturn &eval... | {
"audio": "",
"image": "",
"text": "\tcase *ast.VariableAccess:\n\t\treturn &evalVariableAccess{n}, nil\n\tdefault:\n\t\ten, ok := n.(EvalNode)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"node doesn't support evaluation: %#v\", raw)\n\t\t}\n\n\t\treturn en, nil\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tcase *ast.SelectStmt:\n\t\treturn selectBind(x, hintedStmt.(*ast.SelectStmt))\n\tdefault:\n\t\treturn originStmt\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewLiteralNode(value interface{}, pos Pos) (*LiteralNode, error) {\n\tgoType := reflect.TypeOf(value)\n\tvar hilType Type\n\n\tswitch goType.Kind() {\n\tcase reflect.Bool:\n\t\thilType = TypeBool\n\tcase reflect.Int:\n\t\thilType = TypeInt\n\tcase reflect.Float64:\n\t\thi... | {
"audio": "",
"image": "",
"text": "\t\thilType = TypeString\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported literal node type: %T\", value)\n\t}\n\n\treturn &LiteralNode{\n\t\tValue: value,\n\t\tTypex: hilType,\n\t\tPosx: pos,\n\t}, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " += s\n\t\t\t}\n\t\t\treturn sum\n\t\t}\n\n\tcase reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,\n\t\treflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,\n\t\treflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128:\n\t\treturn int(t.Size... |
{
"audio": "",
"image": "",
"text": "func MustNewLiteralNode(value interface{}, pos Pos) *LiteralNode",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tnode, err := NewLiteralNode(value, pos)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn node\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " sc.rest\n\tval.raw = \"\"\n\tval.pos = sc.pos\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (n *LiteralNode) IsUnknown() bool {\n\treturn IsUnknown(Variable{\n\t\tType:",
"video": ""
} | {
"audio": "",
"image": "",
"text": " n.Typex,\n\t\tValue: n.Value,\n\t})\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\toutput[index] = ast.Variable{\n\t\t\tType: ast.TypeString,\n\t\t\tValue: value,\n\t\t}\n\t}\n\treturn output\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func IsUnknown(v Variable) bool {\n\t// If it is unknown itself, return true\n\tif v.Type == TypeUnknown {\n\t\treturn true\n\t}\n\n\t// If it is a container type, check the values\n\tswitch v.Type {\n\tcase TypeList:\n\t\tfor _, el := range v.Value.([]Variable) {\n\t\t\tif Is... | {
"audio": "",
"image": "",
"text": " := range v.Value.(map[string]Variable) {\n\t\t\tif IsUnknown(el) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\tdefault:\n\t}\n\n\t// Not a container type or survive the above checks\n\treturn false\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " let's see if it is valid.\n\tfor _, itype := range allInstanceTypes {\n\t\tif itype.Name == *cons.InstanceType {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func Walk(v interface{}, cb WalkFn) error {\n\twalker := &interpolationWalker{F: cb}\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn reflectwalk.Walk(v, walker)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn func(o *Options) error {\n\t\to.ClosedCB = cb\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func Scan(s string, startPos ast.Pos) <-chan *Token",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tch := make(chan *Token)\n\tgo scan(s, ch, startPos)\n\treturn ch\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 scanIdentifier(s string) (string, int) {\n\tbyteLen := 0\n\truneLen := 0\n\tfor {\n\t\tif byteLen >= len(s) {\n\t\t\tbreak\n\t\t}\n\n\t\tnextRune, size := utf8.DecodeRuneInString(s[byteLen:])\n\t\tif !(nextRune == '_' ||\n\t\t\tnextRune == '-' ||\n\t\t\tnextRune == '.' ||... | {
"audio": "",
"image": "",
"text": "\tbreak\n\t\t}\n\n\t\t// If we reach a star, it must be between periods to be part\n\t\t// of the same identifier.\n\t\tif nextRune == '*' && s[byteLen-1] != '.' {\n\t\t\tbreak\n\t\t}\n\n\t\t// If our previous character was a star, then the current must\n\t\t// be period. Othe... | {
"audio": "",
"image": "",
"text": " || r == '_' ||\n\t\tr >= 0x80 && unicode.IsLetter(r)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewVariable(v interface{}) (result Variable, err error) {\n\tswitch v := reflect.ValueOf(v); v.Kind() {\n\tcase reflect.String:\n\t\tresult.Type = TypeString",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tdefault:\n\t\terr = fmt.Errorf(\"Unknown type: %s\", v.Kind())\n\t}\n\n\tresult.Value = v\n\treturn\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " a pointer to the value.\n\t\trv2 := reflect.New(rv.Type())\n\t\trv2.Elem().Set(rv)\n\t\tv = rv2.Interface()\n\tcase reflect.Ptr:\n\t\t// Represent slice types as the value itself.\n\t\tswitch rv.Type().Elem().Kind() {\n\t\tcase reflect.Slice:\n\t\t\tif rv.IsNil() {\n\t\t\t\tv... |
{
"audio": "",
"image": "",
"text": "func (v Variable) String() string {\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " fmt.Sprintf(\"{Variable (%s): %+v}\", v.Type, v.Value)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string {\n\tif v := s.GetString(key); v != \"\" {\n\t\treturn v\n\t}\n\n\treturn defaultValue\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewAvx512(a512srv *Avx512Server) hash.Hash {\n\tuid := atomic.AddUint64(&uidCounter, 1)\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " &Avx512Digest{uid: uid, a512srv: a512srv}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\thash *= prime64\n\t\thash ^= uint64(c)\n\t}\n\treturn hash\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *Avx512Digest) Reset() {\n\td.a512srv.blocksCh <- blockInput{uid: d.uid, reset:",
"video": ""
} | {
"audio": "",
"image": "",
"text": " true}\n\td.nx = 0\n\td.len = 0\n\td.final = false\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " []byte) {\n\tw.dict = dict\n\tw.d.reset(dst)\n\tw.d.fillWindow(w.dict)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *Avx512Digest) Write(p []byte) (nn int, err error) {\n\n\tif d.final {\n\t\treturn 0, errors.New(\"Avx512Digest already finalized. Reset first before writing again\")\n\t}\n\n\tnn = len(p)\n\td.len += uint64(nn)\n\tif d.nx > 0 {\n\t\tn := copy(d.x[d.nx:], p)\n\t\td.nx ... | {
"audio": "",
"image": "",
"text": "\t\tp = p[n:]\n\t}\n\tif len(p) >= chunk {\n\t\tn := len(p) &^ (chunk - 1)\n\t\td.a512srv.blocksCh <- blockInput{uid: d.uid, msg: p[:n]}\n\t\tp = p[n:]\n\t}\n\tif len(p) > 0 {\n\t\td.nx = copy(d.x[:], p)\n\t}\n\treturn\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\td.t[1] = 0\n\td.f[0] = 0\n\td.f[1] = 0\n\td.nx = 0\n\tif d.isKeyed {\n\t\td.Write(d.paddedKey[:])\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *Avx512Digest) Sum(in []byte) (result []byte) {\n\n\tif d.final {\n\t\treturn append(in, d.result[:]...)\n\t}\n\n\ttrail := make([]byte, 0, 128)\n\n\tlen := d.len\n\t// Padding. Add a 1 bit and 0 bits until 56 bytes mod 64.\n\tvar tmp [64]byte\n\ttmp[0] = 0x80\n\tif l... | {
"audio": "",
"image": "",
"text": " {\n\t\ttmp[i] = byte(len >> (56 - 8*i))\n\t}\n\ttrail = append(trail, tmp[0:8]...)\n\n\tsumCh := make(chan [Size]byte)\n\td.a512srv.blocksCh <- blockInput{uid: d.uid, msg: trail, final: true, sumCh: sumCh}\n\td.result = <-sumCh\n\td.final = true\n\treturn append(in, d.result[... | {
"audio": "",
"image": "",
"text": " payload {\n\t\tif v < 48 || v >= 120 {\n\t\t\tp.SetErr(context, \"data byte\")\n\t\t\treturn nil\n\t\t}\n\n\t\td := v - 48\n\t\tif d > 40 {\n\t\t\td -= 8\n\t\t}\n\n\t\tfor i := 5; i >= 0 && resultIndex < len(result); i-- {\n\t\t\tresult[resultIndex] = (d >> uint(i)) & 1\n\t\t... |
{
"audio": "",
"image": "",
"text": "func blockAvx512(digests *[512]byte, input [16][]byte, mask []uint64) [16][Size]byte {\n\n\tscratch := [512]byte{}\n\tsha256X16Avx512(digests, &scratch, &table, mask, input)\n\n\toutput := [16][Size]byte{}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tfor i := 0; i < 16; i++ {\n\t\toutput[i] = getDigest(i, digests[:])\n\t}\n\n\treturn output\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " defaultMaskVal\n\t}\n\n\t// Mask input and prompt custom maskVal.\n\tif o.MaskVal != \"\" {\n\t\tmaskVal = o.MaskVal\n\t}\n\n\treturn &readOptions{\n\t\tmask: mask,\n\t\tmaskVal: maskVal,\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewAvx512Server() *Avx512Server {\n\ta512srv := &Avx512Server{}\n\ta512srv.digests = make(map[uint64][Size]byte)\n\ta512srv.blocksCh = make(chan blockInput)\n\n\t// Start",
"video": ""
} | {
"audio": "",
"image": "",
"text": " a single thread for reading from the input channel\n\tgo a512srv.Process()\n\treturn a512srv\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " make(chan chan struct{}),\n\t\tretryPolicy: retryPolicy,\n\t\tconnectionFactory: driver,\n\t\topRequests: make(chan opClientRequest),\n\t}\n\tgo client.loop() // start the main loop that listens for requests\n\treturn client, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (a512srv *Avx512Server) Process() {\n\tfor {\n\t\tselect {\n\t\tcase block := <-a512srv.blocksCh:\n\t\t\tif block.reset {\n\t\t\t\ta512srv.reset(block.uid)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tindex := block.uid & 0xf\n\t\t\t// fmt.Println(\"Adding message:\", block.uid, ind... | {
"audio": "",
"image": "",
"text": " {\n\t\t\t\t// fmt.Println(\"Invoking Blocks() while FULL: \")\n\t\t\t\ta512srv.blocks()\n\t\t\t}\n\n\t\t\t// TODO: test with larger timeout\n\t\tcase <-time.After(1 * time.Microsecond):\n\t\t\tfor _, lane := range a512srv.lanes {\n\t\t\t\tif lane.block != nil { // check if th... | {
"audio": "",
"image": "",
"text": "\tfmt.Println(err)\n\t\treturn nil\n\t}\n\t// decode pem\n\tblock, _ := pem.Decode(derBytes)\n\tif block != nil {\n\t\tderBytes = block.Bytes\n\t}\n\treturn derBytes\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (a512srv *Avx512Server) reset(uid uint64) {\n\n\t// Check if there is a message still waiting to be processed (and remove if so)\n\tfor i, lane := range a512srv.lanes {\n\t\tif lane.uid == uid {\n\t\t\tif lane.block != nil {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\t\ta512srv.lanes[i] = Avx512LaneInfo{} // clear message\n\t\t\t\ta512srv.totalIn--\n\t\t\t}\n\t\t}\n\t}\n\n\t// Delete entry from hash map\n\tdelete(a512srv.digests, uid)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t})\n\tif err == nil {\n\t\tfor _, uid := range uids {\n\t\t\tv.invalidateCh <- uid\n\t\t}\n\t}\n\treturn err\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (a512srv *Avx512Server) blocks() (err error) {\n\n\tinputs := [16][]byte{}\n\tfor i := range inputs {\n\t\tinputs[i] = a512srv.lanes[i].block\n\t}\n\n\tmask := expandMask(genMask(inputs))\n\toutputs := blockAvx512(a512srv.getDigests(), inputs, mask)\n\n\ta512srv.totalIn =... | {
"audio": "",
"image": "",
"text": " outputCh := a512srv.lanes[i].uid, a512srv.lanes[i].outputCh\n\t\ta512srv.digests[uid] = outputs[i]\n\t\ta512srv.lanes[i] = Avx512LaneInfo{}\n\n\t\tif outputCh != nil {\n\t\t\t// Send back result\n\t\t\toutputCh <- outputs[i]\n\t\t\tdelete(a512srv.digests, uid) // Delete entry... | {
"audio": "",
"image": "",
"text": " := func() error {\n\t\t\tfor i := range indices {\n\t\t\t\terr := bt.readyWorker(\n\t\t\t\t\tgroupCtx, id, bcache, rp, bps, pathsFromRoot, makeSync,\n\t\t\t\t\ti, level, &lock, oldPtrs, donePtrs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn... |
{
"audio": "",
"image": "",
"text": "func (a512srv *Avx512Server) Sum(uid uint64, p []byte) [32]byte {\n\tsumCh := make(chan [32]byte)\n\ta512srv.blocksCh <-",
"video": ""
} | {
"audio": "",
"image": "",
"text": " blockInput{uid: uid, msg: p, final: true, sumCh: sumCh}\n\treturn <-sumCh\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " [32]byte\n\tcopy(key[:], s.keys[0])\n\n\tbox := secretbox.Seal(nonce[:], msg, &nonce, &key)\n\n\tdata := make([]byte, base64.RawStdEncoding.EncodedLen(len(box)))\n\tbase64.RawStdEncoding.Encode(data, box)\n\n\treturn data, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *digest) Reset() {\n\td.h[0] = init0\n\td.h[1] = init1\n\td.h[2] = init2\n\td.h[3] = init3\n\td.h[4] = init4\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\td.h[5] = init5\n\td.h[6] = init6\n\td.h[7] = init7\n\td.nx = 0\n\td.len = 0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\td.t[1] = 0\n\td.f[0] = 0\n\td.f[1] = 0\n\td.nx = 0\n\tif d.isKeyed {\n\t\td.Write(d.paddedKey[:])\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func New() hash.Hash {\n\tif blockfunc != blockfuncGeneric {\n\t\td := new(digest)\n\t\td.Reset()\n\t\treturn d\n\t}\n\t// Fallback",
"video": ""
} | {
"audio": "",
"image": "",
"text": " to the standard golang implementation\n\t// if no features were found.\n\treturn sha256.New()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " new(Device)\n\td.FromPb(in)\n\treturn d\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func Sum256(data []byte) (result [Size]byte) {\n\tvar d digest\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\td.Reset()\n\td.Write(data)\n\tresult = d.checkSum()\n\treturn\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " range data {\n\t\taccumulator += v\n\t\td = append(d, accumulator)\n\t}\n\treturn d\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *digest) Sum(in []byte) []byte {\n\t// Make a copy of d0 so that caller can keep writing and summing.\n\td0 :=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " *d\n\thash := d0.checkSum()\n\treturn append(in, hash[:]...)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\thash.Write(bytes)\n\thash.Write([]byte(pipelineInfo.Pipeline.Name))\n\thash.Write([]byte(pipelineInfo.ID))\n\thash.Write([]byte(strconv.Itoa(int(pipelineInfo.Version))))\n\n\t// Note in 1.5.0 this function was called HashPipelineID, it's now called\n\t// HashPipelineName but... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.