{ // 获取包含Hugging Face文本的span元素 const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap'); spans.forEach(span => { if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) { span.textContent = 'AI快站'; } }); }); // 替换logo图片的alt属性 document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => { if (img.alt.match(/Hugging\s*Face/i)) { img.alt = 'AI快站 logo'; } }); } // 替换导航栏中的链接 function replaceNavigationLinks() { // 已替换标记,防止重复运行 if (window._navLinksReplaced) { return; } // 已经替换过的链接集合,防止重复替换 const replacedLinks = new Set(); // 只在导航栏区域查找和替换链接 const headerArea = document.querySelector('header') || document.querySelector('nav'); if (!headerArea) { return; } // 在导航区域内查找链接 const navLinks = headerArea.querySelectorAll('a'); navLinks.forEach(link => { // 如果已经替换过,跳过 if (replacedLinks.has(link)) return; const linkText = link.textContent.trim(); const linkHref = link.getAttribute('href') || ''; // 替换Spaces链接 - 仅替换一次 if ( (linkHref.includes('/spaces') || linkHref === '/spaces' || linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) && linkText !== 'PDF TO Markdown' && linkText !== 'PDF TO Markdown' ) { link.textContent = 'PDF TO Markdown'; link.href = 'https://fast360.xyz'; link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); replacedLinks.add(link); } // 删除Posts链接 else if ( (linkHref.includes('/posts') || linkHref === '/posts' || linkText === 'Posts' || linkText.match(/^s*Postss*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } // 替换Docs链接 - 仅替换一次 else if ( (linkHref.includes('/docs') || linkHref === '/docs' || linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) && linkText !== 'Voice Cloning' ) { link.textContent = 'Voice Cloning'; link.href = 'https://vibevoice.info/'; replacedLinks.add(link); } // 删除Enterprise链接 else if ( (linkHref.includes('/enterprise') || linkHref === '/enterprise' || linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } }); // 查找可能嵌套的Spaces和Posts文本 const textNodes = []; function findTextNodes(element) { if (element.nodeType === Node.TEXT_NODE) { const text = element.textContent.trim(); if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') { textNodes.push(element); } } else { for (const child of element.childNodes) { findTextNodes(child); } } } // 只在导航区域内查找文本节点 findTextNodes(headerArea); // 替换找到的文本节点 textNodes.forEach(node => { const text = node.textContent.trim(); if (text === 'Spaces') { node.textContent = node.textContent.replace(/Spaces/g, 'PDF TO Markdown'); } else if (text === 'Posts') { // 删除Posts文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } else if (text === 'Enterprise') { // 删除Enterprise文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } }); // 标记已替换完成 window._navLinksReplaced = true; } // 替换代码区域中的域名 function replaceCodeDomains() { // 特别处理span.hljs-string和span.njs-string元素 document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换hljs-string类的span中的域名(移除多余的转义符号) document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换pre和code标签中包含git clone命令的域名 document.querySelectorAll('pre, code').forEach(element => { if (element.textContent && element.textContent.includes('git clone')) { const text = element.innerHTML; if (text.includes('huggingface.co')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 处理特定的命令行示例 document.querySelectorAll('pre, code').forEach(element => { const text = element.innerHTML; if (text.includes('huggingface.co')) { // 针对git clone命令的专门处理 if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 特别处理模型下载页面上的代码片段 document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => { const content = container.innerHTML; if (content && content.includes('huggingface.co')) { container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 特别处理模型仓库克隆对话框中的代码片段 try { // 查找包含"Clone this model repository"标题的对话框 const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]'); if (cloneDialog) { // 查找对话框中所有的代码片段和命令示例 const codeElements = cloneDialog.querySelectorAll('pre, code, span'); codeElements.forEach(element => { if (element.textContent && element.textContent.includes('huggingface.co')) { if (element.innerHTML.includes('huggingface.co')) { element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); } // 更精确地定位克隆命令中的域名 document.querySelectorAll('[data-target]').forEach(container => { const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string'); codeBlocks.forEach(block => { if (block.textContent && block.textContent.includes('huggingface.co')) { if (block.innerHTML.includes('huggingface.co')) { block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); }); } catch (e) { // 错误处理但不打印日志 } } // 当DOM加载完成后执行替换 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); }); } else { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); } // 增加一个MutationObserver来处理可能的动态元素加载 const observer = new MutationObserver(mutations => { // 检查是否导航区域有变化 const hasNavChanges = mutations.some(mutation => { // 检查是否存在header或nav元素变化 return Array.from(mutation.addedNodes).some(node => { if (node.nodeType === Node.ELEMENT_NODE) { // 检查是否是导航元素或其子元素 if (node.tagName === 'HEADER' || node.tagName === 'NAV' || node.querySelector('header, nav')) { return true; } // 检查是否在导航元素内部 let parent = node.parentElement; while (parent) { if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') { return true; } parent = parent.parentElement; } } return false; }); }); // 只在导航区域有变化时执行替换 if (hasNavChanges) { // 重置替换状态,允许再次替换 window._navLinksReplaced = false; replaceHeaderBranding(); replaceNavigationLinks(); } }); // 开始观察document.body的变化,包括子节点 if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } else { document.addEventListener('DOMContentLoaded', () => { observer.observe(document.body, { childList: true, subtree: true }); }); } })(); \")\n\treturn buffer.String()\n}","func index(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprint(w, \"index de uma função\")\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\ttodosOsProdutos := models.BuscaTodosOsProdutos()\n\t//EXECUTA NO TEMPLATE\n\ttemp.ExecuteTemplate(w, \"Index\", todosOsProdutos)\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintln(w, \"Welcome francis!\")\n}","func indexHandler(w http.ResponseWriter, r *http.Request) {\n\tif r.URL.Path != \"/\" {\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\n\thttp.ServeFile(w, r, \"pages/main.html\")\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\t//index_routes := []string{\"providers\"}\n\tvar index_routes []string\n\tindex_routes = GetJobs()\n\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tw.WriteHeader(http.StatusOK)\n\tif err := json.NewEncoder(w).Encode(index_routes); err != nil {\n\t\tpanic(err)\n\t}\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\tdb := dbConn()\n\tselDB, err := db.Query(\"SELECT * FROM Employee ORDER BY id DESC\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\temp := Employee{}\n\tres := []Employee{}\n\tfor selDB.Next() {\n\t\tvar id int\n\t\tvar name, city string\n\t\terr = selDB.Scan(&id, &name, &city)\n\t\tif err != nil {\n\t\t\tpanic(err.Error())\n\t\t}\n\t\temp.Id = id\n\t\temp.Name = name\n\t\temp.City = city\n\t\tres = append(res, emp)\n\t}\n\tgetTemplates().ExecuteTemplate(w, \"Index\", res)\n\tdefer db.Close()\n}","func (s *Server) indexHandler(w http.ResponseWriter, r *http.Request) {\n\tb, _ := s.static.Find(\"index.html\")\n\tw.Write(b)\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\n\tfmt.Fprintln(w, \"Steve and Kyle Podcast: #api\")\n\tfmt.Fprintln(w, \"Number of episodes in database:\", EpCount())\n\tfmt.Fprintln(w, \"Created by Derek Slenk\")\n\tfmt.Println(\"Endpoint Hit: Index\")\n}","func index(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprint(w, \"Welcome!\\n\")\n}","func Index(c *gin.Context) {\n\n\tw := c.Writer\n\tr := c.Request\n\tw.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n\tp, lastMod, err := tools.ReadFileIfModified(time.Time{})\n\tif err != nil {\n\t\tp = []byte(err.Error())\n\t\tlastMod = time.Unix(0, 0)\n\t}\n\tvar v = struct {\n\t\tHost string\n\t\tData string\n\t\tLastMod string\n\t}{\n\t\tr.Host,\n\t\tstring(p),\n\t\tstrconv.FormatInt(lastMod.UnixNano(), 16),\n\t}\n\tindexTempl.Execute(w, &v)\n}","func index(w http.ResponseWriter, r *http.Request) {\n\tInfo.Println(\"Received request: \", r) // logging\n\n\tw.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n\n\tfmt.Fprintf(w, \"Hello Gopher! Static Page Static Content\")\n}","func indexHandler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprint(w, \"Whoa, Nice!\")\n}","func (c *Controller) Index(w http.ResponseWriter, r *http.Request) {\n\tw.Write([]byte(\"listing users\"))\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\ta := \"hello from index router\"\n\tfmt.Fprintln(w, a)\n}","func rootIndexHandler(w http.ResponseWriter, r *http.Request) {\n\tvar data map[string]*Record\n\tq := r.FormValue(\"q\")\n\tp := r.FormValue(\"p\")\n\n\tif q != \"\" { // GET /?q=query\n\t\tif len(q) >= 3 {\n\t\t\tdata = db.find(q)\n\t\t} else {\n\t\t\thttp.Error(w, http.StatusText(422), 422)\n\t\t\treturn\n\t\t}\n\t} else if p == \"1\" { // GET /?p=1\n\t\tdata = db.getPaused()\n\t}\n\n\ttotalCount, err := db.keyCount()\n\tif err != nil {\n\t\tlog.Printf(\"db.keyCount() Error: %s\\n\", err)\n\t\thttp.Error(w, http.StatusText(500), 500)\n\t\treturn\n\t}\n\n\ttmpl, err := template.New(\"index\").Parse(indexTmpl)\n\tif err != nil {\n\t\tlog.Printf(\"template.ParseFiles() Error: %s\\n\", err)\n\t\thttp.Error(w, http.StatusText(500), 500)\n\t\treturn\n\t}\n\n\tif err = tmpl.Execute(w, H{\"data\": data, \"isDisabled\": isDisabled, \"totalCount\": totalCount, \"q\": q, \"p\": p}); err != nil {\n\t\tlog.Printf(\"tmpl.Execute() Error: %s\\n\", err)\n\t\thttp.Error(w, http.StatusText(500), 500)\n\t}\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\tif (!Auth(w, r)) {\n\t\treturn\n\t}\n\tfmt.Fprintln(w, \"Welcome to the REST Businesses API!\")\n\tfmt.Fprintln(w, \"Usage:\")\n\tfmt.Fprintln(w, `GET /businesses?page={number}&size={number}\nFetch list of businesses with pagination.`)\n\tfmt.Fprintln(w, \"\")\n\tfmt.Fprintln(w, `GET /business/{id}\nFetch a specific business as a JSON object`)\n}","func (uc UserController) Index(w http.ResponseWriter, r *http.Request, params httprouter.Params) {\n\n\tfmt.Fprintln(w, \"Welcome to Index!\")\n\n}","func index(writer http.ResponseWriter, request *http.Request) {\n\tloggedin(writer, request)\n\tt := parseTemplateFiles(\"layout\", \"public.navbar\", \"index\")\n\tconversations, err := data.Conversations(); if err != nil {\n\t\terror_message(writer, request, \"Cannot get conversations\")\n\t} else {\n\t\tt.Execute(writer, conversations)\n\t}\n}","func (a *App) Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\trawBankStatements, err := models.AllRawBankStatements(a.db)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\thttp.Error(w, http.StatusText(500), 500)\n\t\treturn\n\t}\n\n\tdata, err := json.Marshal(rawBankStatements)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\thttp.Error(w, http.StatusText(500), 500)\n\t\treturn\n\t}\n\tw.Write(data)\n\tfmt.Println(\"Index\")\n}","func GetIndex(w http.ResponseWriter, req *http.Request, app *App) {\n\tscheme := \"http\"\n\tif req.TLS != nil {\n\t\tscheme = \"https\"\n\t}\n\tbase := []string{scheme, \"://\", req.Host, app.Config.General.Prefix}\n\trender(w, \"index\", map[string]interface{}{\"base\": strings.Join(base, \"\"), \"hideNav\": true}, app)\n}"],"string":"[\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\t// Fill out the page data for index\\n\\tpd := PageData{\\n\\t\\tTitle: \\\"Index Page\\\",\\n\\t\\tBody: \\\"This is the body of the index page.\\\",\\n\\t}\\n\\n\\t// Render a template with our page data\\n\\ttmpl, err := render(pd)\\n\\n\\t// if we get an error, write it out and exit\\n\\tif err != nil {\\n\\t\\tw.WriteHeader(http.StatusBadRequest)\\n\\t\\tw.Write([]byte(err.Error()))\\n\\t\\treturn\\n\\t}\\n\\n\\t// All went well, so write out the template\\n\\tw.Write([]byte(tmpl))\\n\\n\\t//fmt.Fprintf(w, \\\"Hello world from %q\\\", html.EscapeString(r.URL.Path))\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\\n\\tdata, err := newPageData(1)\\n\\tif err != nil {\\n\\t\\thttp.NotFound(w, r)\\n\\t}\\n\\terr = t.ExecuteTemplate(w, \\\"index\\\", data)\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n}\",\n \"func index(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {\\n\\terr := tpl.ExecuteTemplate(w, \\\"index.html\\\", nil)\\n\\tif err != nil {\\n\\t\\thttp.Error(w, err.Error(), http.StatusInternalServerError)\\n\\t\\tlog.Fatalln(err)\\n\\t}\\n\\tfmt.Println(\\\"HERE INDEX\\\")\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\t// @todo: check setup required\\n\\n\\t// @todo: check user is logged in\\n\\n\\trender.HTML(w, \\\"index.html\\\", struct{}{})\\n}\",\n \"func Index(c echo.Context) error {\\n\\treturn c.Render(http.StatusOK, \\\"index\\\", echo.Map{})\\n}\",\n \"func index(w http.ResponseWriter, r *http.Request){\\n\\terr := templ.ExecuteTemplate(w, \\\"index\\\", nil)\\n\\tif err != nil {\\n\\t\\tfmt.Print(err.Error())\\n\\t}\\n}\",\n \"func Index(w http.ResponseWriter, data *IndexData) {\\n\\trender(tpIndex, w, data)\\n}\",\n \"func Index(w http.ResponseWriter, data *IndexData) {\\n\\trender(tpIndex, w, data)\\n}\",\n \"func Index(w http.ResponseWriter, data interface{}) {\\n\\trender(tpIndex, w, data)\\n}\",\n \"func index(w http.ResponseWriter, req *http.Request, ctx httputil.Context) (e *httputil.Error) {\\n\\tif req.URL.Path != \\\"/\\\" {\\n\\t\\tnotFound(w, req)\\n\\t\\treturn\\n\\t}\\n\\tm := newManager(ctx)\\n\\n\\tres, err := m.Index()\\n\\tif err != nil {\\n\\t\\te = httputil.Errorf(err, \\\"couldn't query for test results\\\")\\n\\t\\treturn\\n\\t}\\n\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"text/html\\\")\\n\\tif err := T(\\\"index/index.html\\\").Execute(w, res); err != nil {\\n\\t\\te = httputil.Errorf(err, \\\"error executing index template\\\")\\n\\t}\\n\\treturn\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\t//shows 404 not found\\n\\tif r.URL.Path != \\\"/\\\" {\\n\\t\\tNotFound(w, r)\\n\\t} else {\\n\\t\\ttemplate, err := template.ParseFiles(\\\"../htmls/index.html\\\")\\n\\t\\tif err != nil {\\n\\t\\t\\tlogger.ErrLogger(err)\\n\\t\\t} else {\\n\\t\\t\\ttemplate.Execute(w, nil)\\n\\t\\t}\\n\\t}\\n}\",\n \"func (c App) Index() revel.Result {\\n\\treturn c.Render()\\n}\",\n \"func (c App) Index() revel.Result {\\n\\treturn c.Render()\\n}\",\n \"func indexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tdata := &Index{\\n\\t\\tTitle: \\\"Image gallery\\\",\\n\\t\\tBody: \\\"Welcome to the image gallery.\\\",\\n\\t}\\n\\tfor name, img := range images {\\n\\t\\tdata.Links = append(data.Links, Link{\\n\\t\\t\\tURL: \\\"/image/\\\" + name,\\n\\t\\t\\tTitle: img.Title,\\n\\t\\t})\\n\\t}\\n\\tif err := indexTemplate.Execute(w, data); err != nil {\\n\\t\\tlog.Println(err)\\n\\t}\\n}\",\n \"func indexHandler(res http.ResponseWriter, req *http.Request) {\\n\\n\\t// Execute the template and respond with the index page.\\n\\ttemplates.ExecuteTemplate(res, \\\"index\\\", nil)\\n}\",\n \"func showIndex(c *gin.Context) {\\n\\trender(\\n\\t\\tc,\\n\\t\\tgin.H{\\n\\t\\t\\t\\\"title\\\": \\\"Home Page\\\",\\n\\t\\t\\t\\\"payload\\\": films,\\n\\t\\t},\\n\\t\\ttemplates.Index,\\n\\t)\\n}\",\n \"func (app *Application) Index(w http.ResponseWriter, r *http.Request) {\\n\\tdata := struct {\\n\\t\\tTime int64\\n\\t}{\\n\\t\\tTime: time.Now().Unix(),\\n\\t}\\n\\n\\tt, err := template.ParseFiles(\\\"views/index.tpl\\\")\\n\\n\\tif err != nil {\\n\\t\\tlog.Println(\\\"Template.Parse:\\\", err)\\n\\t\\thttp.Error(w, \\\"Internal Server Error 0x0178\\\", http.StatusInternalServerError)\\n\\t}\\n\\n\\tif err := t.Execute(w, data); err != nil {\\n\\t\\tlog.Println(\\\"Template.Execute:\\\", err)\\n\\t\\thttp.Error(w, \\\"Internal Server Error 0x0183\\\", http.StatusInternalServerError)\\n\\t}\\n}\",\n \"func index(w http.ResponseWriter, r *http.Request) {\\n\\tdata := page{Title: \\\"School Database\\\", Header: \\\"Welcome, please select an option\\\"}\\n\\ttemplateInit(w, \\\"index.html\\\", data)\\n\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tmessage := \\\"Welcome to Recipe Book!\\\"\\n\\tindexT.Execute(w, message)\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\n\\t// Render the \\\"Index.gtpl\\\"\\n\\tgoTmpl.ExecuteTemplate(w, \\\"Index\\\", nil)\\n\\n\\t//name := r.FormValue(\\\"name\\\")\\n\\n\\t// Logging the Action\\n\\tlog.Println(\\\"Render: Index.gtpl\\\")\\n\\n}\",\n \"func indexHandler(w http.ResponseWriter, req *http.Request) {\\n\\tlayout, err := template.ParseFile(PATH_PUBLIC + TEMPLATE_LAYOUT)\\n\\tif err != nil {\\n\\t\\thttp.Error(w, ERROR_TEMPLATE_NOT_FOUND, http.StatusNotFound)\\n\\t\\treturn\\n\\t}\\n\\tindex, err := template.ParseFile(PATH_PUBLIC + TEMPLATE_INDEX)\\n\\t//artical, err := template.ParseFile(PATH_PUBLIC + TEMPLATE_ARTICAL)\\n\\tif err != nil {\\n\\t\\thttp.Error(w, ERROR_TEMPLATE_NOT_FOUND, http.StatusNotFound)\\n\\t\\treturn\\n\\t}\\n\\tmapOutput := map[string]interface{}{\\\"Title\\\": \\\"炫酷的网站技术\\\" + TITLE, \\\"Keyword\\\": KEYWORD, \\\"Description\\\": DESCRIPTION, \\\"Base\\\": BASE_URL, \\\"Url\\\": BASE_URL, \\\"Carousel\\\": getAddition(PREFIX_INDEX), \\\"Script\\\": getAddition(PREFIX_SCRIPT), \\\"Items\\\": leveldb.GetRandomContents(20, &Filter{})}\\n\\tcontent := []byte(index.RenderInLayout(layout, mapOutput))\\n\\tw.Write(content)\\n\\tgo cacheFile(\\\"index\\\", content)\\n}\",\n \"func (h *Handlers) Index(w http.ResponseWriter, r *http.Request, _ map[string]string) {\\n\\tfile := path.Join(\\\"index.html\\\")\\n\\n\\tdata := struct{ Host string }{Host: h.Host}\\n\\n\\ttemp, _ := template.ParseFiles(file)\\n\\ttemp.Execute(w, &data)\\n}\",\n \"func (app *App) RenderIndex(w http.ResponseWriter, r *http.Request) {\\n\\ttmplList := []string{\\\"./web/views/base.html\\\",\\n\\t\\t\\\"./web/views/index.html\\\"}\\n\\tres, err := app.TplParser.ParseTemplate(tmplList, nil)\\n\\tif err != nil {\\n\\t\\tapp.Log.Info(err)\\n\\t}\\n\\tio.WriteString(w, res)\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprintf(w, \\\"Hello from our index page\\\")\\n}\",\n \"func IndexHandler(w http.ResponseWriter, r *http.Request) {\\n page := &Data{Title:\\\"Home page\\\", Body:\\\"This is the home page.\\\"}\\n\\tt, _ := template.ParseFiles(\\\"templates/index.html\\\")\\n t.Execute(w, page)\\n}\",\n \"func showIndex(res http.ResponseWriter, req *http.Request, params httprouter.Params) {\\n\\tServeTemplateWithParams(res, req, \\\"index.html\\\", nil)\\n}\",\n \"func index(res http.ResponseWriter, req *http.Request) {\\n\\ttpl, err := template.ParseFiles(\\\"index.html\\\")\\n\\tif err != nil { // if file does not exist, give user a error\\n\\t\\tlog.Fatalln(err) // stops program if file does not exist\\n\\t}\\n\\ttpl.Execute(res, nil) // execute the html file\\n}\",\n \"func IndexHandler(c *gin.Context) {\\n\\tc.HTML(200, \\\"index.tmpl\\\", nil)\\n}\",\n \"func IndexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tw.WriteHeader(http.StatusOK)\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"text/html\\\")\\n\\n\\tt, err := template.ParseFiles(path.Join(\\\"templates\\\", \\\"index.html\\\"))\\n\\tif err != nil {\\n\\t\\thttp.Error(w, err.Error(), 500)\\n\\t\\tError.Printf(\\\"error parsing the template %v\\\", err)\\n\\t}\\n\\n\\terr = t.Execute(w, nil)\\n\\tif err != nil {\\n\\t\\thttp.Error(w, err.Error(), 500)\\n\\t\\tError.Printf(\\\"error executing the template %v\\\", err)\\n\\t}\\n}\",\n \"func index(w http.ResponseWriter, req *http.Request) {\\n\\thttp.ServeFile(w, req, \\\"./templates/index.html\\\")\\n}\",\n \"func IndexHandler(c buffalo.Context) error {\\n\\treturn c.Render(200, r.HTML(\\\"index.html\\\"))\\n}\",\n \"func getIndexPage(w http.ResponseWriter, r *http.Request) {\\n\\t// Get DB information\\n\\trows, err := model.GetAllUsers()\\n\\t\\n\\t// Error Handling\\n\\tif err != nil {\\n\\t\\tw.WriteHeader(http.StatusInternalServerError)\\n\\t\\tlog.Print(\\\"Error: Execute database query: \\\", err)\\n\\t\\treturn\\n\\t}\\n\\t\\n\\tvar users []types.User\\n\\t\\n\\tfor rows.Next() {\\n\\t\\tvar uid, name, email, username, photoUrl string\\n\\t\\terr := rows.Scan(&uid, &name, &username, &email, &photoUrl)\\n\\t\\n\\t\\tif err != nil {\\n\\t\\t\\tfmt.Println(err)\\n\\t\\t}\\n\\t\\tusers = append(users, types.User{ username, uid, email, name, photoUrl })\\n\\t}\\n\\t\\n\\tPageData := SiteData{\\n\\t\\tTitle: \\\"Test\\\",\\n\\t\\tDescription: \\\"This is test for DB connection, read and write.\\\",\\n\\t\\tPageTitle: \\\"Users\\\",\\n\\t\\tReactFilePath: \\\"\\\",\\n\\t\\tUsers: users,\\n\\t}\\n\\t\\n\\tt, err := template.ParseFiles(\\\"templates/index.html.tpl\\\")\\n\\t\\n\\tif err != nil {\\n\\t\\tlog.Printf(\\\"Could not find template file: %v\\\", err)\\n\\t}\\n\\t\\n\\tif err := t.Execute(w, PageData); err != nil {\\n\\t\\tlog.Printf(\\\"Failed to execute template: %v\\\", err)\\n\\t}\\n\\t\\n}\",\n \"func indexHandler(res http.ResponseWriter, req *http.Request) {\\n\\tfmt.Println(\\\"website index\\\")\\n\\t//grab all partials\\n\\tpartials, err := loadPartials()\\n\\tif err != nil {\\n\\t\\thttp.Error(res, err.Error(), http.StatusInternalServerError)\\n\\t\\treturn\\n\\t}\\n\\t//get template function based on index and execute to load page\\n\\tt, _ := template.ParseFiles(\\\"../index.html\\\")\\n\\tt.Execute(res, partials)\\n}\",\n \"func IndexView(ctx *fiber.Ctx) error {\\n\\t// load records\\n\\tquery := bson.D{{}}\\n\\tcursor, queryError := Instance.Database.Collection(\\\"Todos\\\").Find(ctx.Context(), query)\\n\\tif queryError != nil {\\n\\t\\treturn utilities.Response(utilities.ResponseParams{\\n\\t\\t\\tCtx: ctx,\\n\\t\\t\\tInfo: configuration.ResponseMessages.InternalServerError,\\n\\t\\t\\tStatus: fiber.StatusInternalServerError,\\n\\t\\t})\\n\\t}\\n\\n\\tvar todos []Todo = make([]Todo, 0)\\n\\n\\t// iterate the cursor and decode each item into a Todo\\n\\tif err := cursor.All(ctx.Context(), &todos); err != nil {\\n\\t\\treturn utilities.Response(utilities.ResponseParams{\\n\\t\\t\\tCtx: ctx,\\n\\t\\t\\tInfo: configuration.ResponseMessages.InternalServerError,\\n\\t\\t\\tStatus: fiber.StatusInternalServerError,\\n\\t\\t})\\n\\t}\\n\\n\\t// caclulate the latency\\n\\tinitial := ctx.Context().Time()\\n\\tlatency := utilities.MakeTimestamp() - (initial.UnixNano() / 1e6)\\n\\n\\t// send response: render the page\\n\\treturn ctx.Render(\\n\\t\\t\\\"index\\\",\\n\\t\\tfiber.Map{\\n\\t\\t\\t\\\"Latency\\\": latency,\\n\\t\\t\\t\\\"Todos\\\": todos,\\n\\t\\t},\\n\\t\\t\\\"layouts/main\\\",\\n\\t)\\n}\",\n \"func (c App) Index() revel.Result {\\n\\tusername, _ := c.Session.Get(\\\"user\\\")\\n\\tfulluser, _ := c.Session.Get(\\\"fulluser\\\")\\n\\treturn c.Render(username, fulluser)\\n}\",\n \"func IndexHandler(w http.ResponseWriter, r *http.Request) {\\n heading := \\\"Welcome to Hats for cats!\\\"\\n text := \\\"On this page you can put funny hats on your cat pictures! Create an account and upload your favorite pictures of your (or someone else's) cat today. Get some inspiration from the latest cats below.\\\"\\n\\ttv := &TextView{heading, text}\\n template.Must(template.ParseFiles(\\\"static/index.html\\\", \\\"static/templates/latestCats.tmp\\\")).Execute(w, tv)\\n}\",\n \"func IndexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tpage := Page{Title: Environ.Config.Title, Logo: Environ.Config.Logo}\\n\\n\\t// Set the document root based on the type of interface that is to be served\\n\\tvar path []string\\n\\tif Environ.Config.Interface == InterfaceTypeAdmin {\\n\\t\\tpath = []string{Environ.Config.DocRootAdmin, indexTemplate}\\n\\t} else {\\n\\t\\tpath = []string{Environ.Config.DocRootUser, indexTemplate}\\n\\t}\\n\\n\\tt, err := template.ParseFiles(strings.Join(path, \\\"\\\"))\\n\\tif err != nil {\\n\\t\\tlog.Printf(\\\"Error loading the application template: %v\\\\n\\\", err)\\n\\t\\thttp.Error(w, err.Error(), http.StatusInternalServerError)\\n\\t\\treturn\\n\\t}\\n\\terr = t.Execute(w, page)\\n\\tif err != nil {\\n\\t\\thttp.Error(w, err.Error(), http.StatusInternalServerError)\\n\\t}\\n}\",\n \"func index(ctx *gin.Context) {\\n\\tctx.Header(\\\"Content-Type\\\", \\\"text/html\\\")\\n\\tctx.String(\\n\\t\\thttp.StatusOK,\\n\\t\\t\\\"

Rasse Server

Wel come to the api server.

%v

\\\",nil)\\n}\",\n \"func (a *Ctl) Index(res http.ResponseWriter, req *http.Request) {\\n\\ttype pageData struct {\\n\\t\\tUser User\\n\\t}\\n\\td := pageData{\\n\\t\\tUser: a.getUser(res, req),\\n\\t}\\n\\ta.Template.ExecuteTemplate(res, \\\"index.html\\\", d)\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\\n p, _ := loadPage(\\\"/src/github.com/mrgirlyman/watcher/frontman/build/index.html\\\")\\n\\n fmt.Fprintf(w, string(p.Body))\\n // log.Fatal(err)\\n\\n // if (err != nil) {\\n // fmt.Fprintf(w, string(p.Body))\\n // } else {\\n // fmt.Fprintf(w, \\\"Error reading index.html\\\")\\n // }\\n}\",\n \"func index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\\n\\tasset, err := Asset(\\\"static/templates/index.html\\\")\\n\\tif err != nil {\\n\\t\\tlog.Panic(\\\"Unable to read file from bindata: \\\", err)\\n\\t}\\n\\tfmt.Fprint(w, string(asset))\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"text/html\\\")\\n\\tt, _ := template.ParseFiles(\\\"templates/index.html\\\")\\n\\tt.Execute(w, mails)\\n}\",\n \"func (c *AppController) Index() {\\n\\tdata := aah.Data{\\n\\t\\t\\\"Greet\\\": models.Greet{\\n\\t\\t\\tMessage: \\\"Welcome to aah framework - Web Application\\\",\\n\\t\\t},\\n\\t}\\n\\n\\tc.Reply().Ok().HTML(data)\\n}\",\n \"func (controller *BuoyController) Index() {\\n\\tbuoyStations, err := buoyService.AllStation(&controller.Service)\\n\\tif err != nil {\\n\\t\\tcontroller.ServeError(err)\\n\\t\\treturn\\n\\t}\\n\\n\\tcontroller.Data[\\\"Stations\\\"] = buoyStations\\n\\tcontroller.Layout = \\\"shared/basic-layout.html\\\"\\n\\tcontroller.TplName = \\\"buoy/content.html\\\"\\n\\tcontroller.LayoutSections = map[string]string{}\\n\\tcontroller.LayoutSections[\\\"PageHead\\\"] = \\\"buoy/page-head.html\\\"\\n\\tcontroller.LayoutSections[\\\"Header\\\"] = \\\"shared/header.html\\\"\\n\\tcontroller.LayoutSections[\\\"Modal\\\"] = \\\"shared/modal.html\\\"\\n}\",\n \"func Index(txn *cheshire.Txn) {\\n\\t//create a context map to be passed to the template\\n\\tcontext := make(map[string]interface{})\\n\\tcontext[\\\"services\\\"] = Servs.RouterTables()\\n\\tcheshire.RenderInLayout(txn, \\\"/index.html\\\", \\\"/template.html\\\", context)\\n}\",\n \"func index(w http.ResponseWriter, req *http.Request) {\\n\\t// Get user and session state\\n\\tuserData, _ := getUserAndSession(w, req)\\n\\n\\t// Redirect to login page if user is logged out\\n\\tif !userData.LoggedIn {\\n\\t\\thttp.Redirect(w, req, \\\"/login\\\", http.StatusSeeOther)\\n\\t\\treturn\\n\\t}\\n\\n\\ttpl.ExecuteTemplate(w, \\\"index.gohtml\\\", userData)\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprintf(w, \\\"Hola, este es el inicio\\\")\\n}\",\n \"func indexHandler(c *fiber.Ctx) error {\\n\\treturn common.HandleTemplate(c, \\\"index\\\",\\n\\t\\t\\\"me\\\", nil, 200)\\n}\",\n \"func indexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tsession, _ := store.Get(r, \\\"session-name\\\")\\n\\n\\tvar fname, lname, email string\\n\\tvar id int64\\n\\n\\tif _, ok := session.Values[\\\"id\\\"].(int64); ok {\\n\\t\\tfname = session.Values[\\\"fname\\\"].(string)\\n\\t\\tlname = session.Values[\\\"lname\\\"].(string)\\n\\t\\temail = session.Values[\\\"email\\\"].(string)\\n\\t\\tid = session.Values[\\\"id\\\"].(int64)\\n\\t} else {\\n\\t\\tfname = \\\"\\\"\\n\\t\\tlname = \\\"\\\"\\n\\t\\temail = \\\"\\\"\\n\\t\\tid = 0\\n\\t}\\n\\tp1 := &Page{Title: \\\"index\\\", Body: []byte(\\\"\\\"), User: Researcher{ID: id, Email: email, Name: Name{First: fname, Last: lname}}}\\n\\n\\tgenTemplate(w, \\\"index\\\", p1)\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\t// validate the passed-in arguments\\n\\tvars, err := wdp.ValidateApiArgs(r)\\n\\tif err != nil {\\n\\t\\tlog.Print(\\\"error validating API arguments: \\\", err)\\n\\t}\\n\\n\\t// parse the template at index.html\\n\\t// NOTE: SWITCH WHICH OF THESE STATEMENTS IS COMMENTED OUT TO RUN ON CLOUD VPS VS LOCALLY\\n\\t// t, err := template.ParseFiles(\\\"templates/index.html\\\") // LOCAL\\n\\tt, err := template.ParseFiles(\\\"/etc/diff-privacy-beam/index.html\\\") // CLOUD VPS\\n\\tif err != nil {\\n\\t\\tlog.Print(\\\"error parsing template index_go.html: \\\", err)\\n\\t}\\n\\n\\t// execute the template to serve it back to the client\\n\\terr = t.Execute(w, vars)\\n\\tif err != nil {\\n\\t\\tlog.Print(\\\"error executing template index_go.html: \\\", err)\\n\\t}\\n}\",\n \"func IndexHandler(w http.ResponseWriter, r *http.Request) {\\n\\ttitle := \\\"Visualizing Wizard\\\"\\n buttonContent := \\\"Sätt igång\\\"\\n\\tbt := &ButtonText{title, buttonContent}\\n template.Must(template.ParseFiles(\\\"static/index.html\\\", \\\"static/templates/start.tmp\\\")).Execute(w, bt)\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request, p httprouter.Params) {\\n\\tfmt.Fprint(w, \\\"Welcome!\\\\n\\\")\\n}\",\n \"func (t tApp) Index(w http.ResponseWriter, r *http.Request) {\\n\\tvar h http.Handler\\n\\tc := App.New(w, r, \\\"App\\\", \\\"Index\\\")\\n\\tdefer func() {\\n\\t\\tif h != nil {\\n\\t\\t\\th.ServeHTTP(w, r)\\n\\t\\t}\\n\\t}()\\n\\tdefer App.After(c, w, r)\\n\\tif res := App.Before(c, w, r); res != nil {\\n\\t\\th = res\\n\\t\\treturn\\n\\t}\\n\\tif res := c.Index(); res != nil {\\n\\t\\th = res\\n\\t\\treturn\\n\\t}\\n}\",\n \"func indexHandler(w http.ResponseWriter, r *http.Request) {\\r\\n t, _ := template.New(\\\"webpage\\\").Parse(indexPage) // parse embeded index page\\r\\n t.Execute(w, pd) // serve the index page (html template)\\r\\n}\",\n \"func (c *IndexController) IndexHandler(ctx *iris.Context) {\\n\\tif err := ctx.Render(\\\"index.html\\\", nil); err != nil {\\n\\t\\tfmt.Println(err.Error())\\n\\t\\tpanic(err)\\n\\t}\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tw.WriteHeader(http.StatusOK)\\n\\tw.Write([]byte(\\\"Hello World!\\\"))\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tc := flight.Context(w, r)\\n\\n\\t// Create a pagination instance with a max of 10 results.\\n\\tp := pagination.New(r, 10)\\n\\n\\tarticles, _, err := article.ByUserIDPaginate(c.DB, c.UserID, p.PerPage, p.Offset)\\n\\tif err != nil {\\n\\t\\tc.FlashErrorGeneric(err)\\n\\t\\tarticles = []article.Article{}\\n\\t}\\n\\n\\tcount, err := article.ByUserIDCount(c.DB, c.UserID)\\n\\tif err != nil {\\n\\t\\tc.FlashErrorGeneric(err)\\n\\t}\\n\\n\\t// Calculate the number of pages.\\n\\tp.CalculatePages(count)\\n\\n\\tv := c.View.New(\\\"article/index\\\")\\n\\tv.Vars[\\\"articles\\\"] = articles\\n\\tv.Vars[\\\"pagination\\\"] = p\\n\\tv.Render(w, r)\\n}\",\n \"func (s *Server) IndexHandler(w http.ResponseWriter, r *http.Request) {\\n\\t// Should we render the recent commits as an html fragment?\\n\\tfragmentParam := r.URL.Query().Get(\\\"fragment\\\")\\n\\tif fragmentParam == \\\"\\\" {\\n\\t\\tfragmentParam = \\\"false\\\"\\n\\t}\\n\\tfragment, _ := strconv.ParseBool(fragmentParam)\\n\\n\\t// Get recent commits.\\n\\tgroup := r.URL.Query().Get(\\\"group\\\")\\n\\tcommits, err := s.DB.RecentCommitsByGroup(group)\\n\\tif err != nil {\\n\\t\\tsentry.CaptureException(err)\\n\\t\\tfmt.Println(err)\\n\\t\\thttp.Error(w, \\\"oopsie, something went horribly wrong\\\", http.StatusInternalServerError)\\n\\t\\treturn\\n\\t}\\n\\n\\t// Render the template.\\n\\tif fragment {\\n\\t\\tw.Header().Set(\\\"Content-Type\\\", \\\"text/html; charset=utf-8\\\")\\n\\t\\ts.Templates.ExecuteTemplate(w, \\\"commits\\\", commits)\\n\\t\\treturn\\n\\t}\\n\\ts.Templates.ExecuteTemplate(w, \\\"index\\\", commits)\\n}\",\n \"func index(w http.ResponseWriter, r *http.Request) {\\n\\tif r.Method != \\\"GET\\\" {\\n\\t\\thttp.NotFound(w, r)\\n\\t\\treturn\\n\\t}\\n\\n\\tthreads, err := data.Threads()\\n\\tif err != nil {\\n\\t\\tRedirectToErrorPage(w, r, \\\"Cannot get threads\\\")\\n\\t\\treturn\\n\\t}\\n\\tif _, err := data.CheckSession(r); err == nil {\\n\\t\\tgenerateHTML(w, threads, []string{\\\"layout\\\", \\\"private.navbar\\\", \\\"index\\\"})\\n\\t} else {\\n\\t\\tgenerateHTML(w, threads, []string{\\\"layout\\\", \\\"public.navbar\\\", \\\"index\\\"})\\n\\t}\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\r\\n\\tfiles := []string{\\\"templates/layout.html\\\", \\\"templates/navbar.html\\\", \\\"templates/upload.index.html\\\"}\\r\\n\\tt, err := template.ParseFiles(files...)\\r\\n\\tif err != nil {\\r\\n\\t\\tpanic(err)\\r\\n\\t}\\r\\n\\tt.ExecuteTemplate(w, \\\"layout\\\", \\\"\\\")\\r\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\\n\\tfmt.Fprint(w, \\\"Welcome!\\\\n\\\")\\n}\",\n \"func (c Application) Index() revel.Result {\\n\\tif user := c.connected(); user != nil {\\n\\t\\treturn c.Redirect(routes.Dashboard.Index())\\n\\t}\\n\\treturn c.Render()\\n}\",\n \"func handleIndex(w http.ResponseWriter, r *http.Request) {\\n\\n\\tif r.URL.Path != \\\"/\\\" {\\n\\t\\thttp.NotFound(w, r)\\n\\t\\treturn\\n\\t}\\n\\n\\tc := appengine.NewContext(r)\\n\\tlog.Infof(c, \\\"Serving main page.\\\")\\n\\n\\ttmpl, _ := template.ParseFiles(\\\"web/tmpl/index.tmpl\\\")\\n\\n\\ttmpl.Execute(w, time.Since(initTime))\\n}\",\n \"func IndexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tt, _ := template.ParseFiles(\\\"templates/index.html\\\")\\n\\tt.Execute(w, nil)\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprintln(w, \\\"Welcome!\\\")\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprint(w, \\\"Welcome to this example API\\\\n\\\")\\n}\",\n \"func HomeIndex(res http.ResponseWriter, req *http.Request) {\\n\\tvar article model.Article\\n\\tapp.DB.First(&article, 1)\\n\\tapp.Render.HTML(res, http.StatusOK, \\\"home\\\", article)\\n}\",\n \"func IndexPage(w http.ResponseWriter, req *http.Request) {\\n\\tdashDir := getDashDir()\\n\\tif len(dashDir) != 0 {\\n\\t\\t// Serve the index page from disk if the env variable is set.\\n\\t\\thttp.ServeFile(w, req, path.Join(dashDir, \\\"index.html\\\"))\\n\\t} else {\\n\\t\\t// Otherwise serve it from the compiled resources.\\n\\t\\tb, _ := resources.Asset(\\\"index.html\\\")\\n\\t\\thttp.ServeContent(w, req, \\\"index.html\\\", time.Time{}, bytes.NewReader(b))\\n\\t}\\n\\treturn\\n}\",\n \"func (h *Root) Index(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {\\n\\tif claims, err := auth.ClaimsFromContext(ctx); err == nil && claims.HasAuth() {\\n\\t\\treturn h.indexDashboard(ctx, w, r, params)\\n\\t}\\n\\n\\treturn h.indexDefault(ctx, w, r, params)\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprint(w, \\\"Welcome!\\\\n\\\")\\n}\",\n \"func (h *MovieHandler) index(w http.ResponseWriter, r *http.Request) {\\n\\t// Call GetMovies to retrieve all movies from the database.\\n\\tif movies, err := h.MovieService.GetMovies(); err != nil {\\n\\t\\t// Render an error response and set status code.\\n\\t\\thttp.Error(w, \\\"Internal Server Error\\\", http.StatusInternalServerError)\\n\\t\\tlog.Println(\\\"Error:\\\", err)\\n\\t} else {\\n\\t\\t// Render a HTML response and set status code.\\n\\t\\trender.HTML(w, http.StatusOK, \\\"movie/index.html\\\", movies)\\n\\t}\\n}\",\n \"func (app *app) Index(w http.ResponseWriter, r *http.Request) {\\n\\tselDB, err := app.db.Query(\\\"select * from employee order by id desc\\\")\\n\\tif err != nil{\\n\\t\\tpanic(err.Error())\\n\\t}\\n\\temp := Employee{}\\n\\tres := []Employee{}\\n\\tfor selDB.Next(){\\n\\t\\tvar id uint\\n\\t\\tvar name, city string\\n\\t\\terr = selDB.Scan(&id, &name, &city)\\n\\t\\tif err != nil {\\n\\t\\t\\tpanic(err.Error())\\n\\t\\t}\\n\\t\\temp.Id=id\\n\\t\\temp.Name=name\\n\\t\\temp.City=city\\n\\t\\tres = append(res,emp)\\n\\t}\\n\\ttmpl.ExecuteTemplate(w, \\\"Index\\\", res)\\n\\t// defer app.db.Close()\\n}\",\n \"func IndexHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\\n\\tif pusher, ok := w.(http.Pusher); ok {\\n\\t\\tif err := pusher.Push(\\\"./web/css/app.css\\\", nil); err != nil {\\n\\t\\t\\tlog.Printf(\\\"Failed to push %v\\\\n\\\", err)\\n\\t\\t}\\n\\t}\\n\\tt, err := template.ParseFiles(\\\"./web/html/index.html\\\")\\n\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n\\n\\tt.Execute(w, nil)\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request, us httprouter.Params) {\\n\\tfmt.Fprint(w, \\\"WELCOMEEE!\\\")\\n}\",\n \"func (h *Root) indexDefault(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {\\n\\treturn h.Renderer.Render(ctx, w, r, tmplLayoutSite, \\\"site-index.gohtml\\\", web.MIMETextHTMLCharsetUTF8, http.StatusOK, nil)\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprint(w, \\\"s-senpai, please don't hurt me ;_;\\\\n\\\")\\n}\",\n \"func indexHandler(w http.ResponseWriter, r *http.Request, s *Server) {\\n\\tif r.Method == \\\"GET\\\" {\\n\\t\\t//create the source upload page with available languages and metrics\\n\\t\\tpage := &Page{Config: s.Config, Extensions: s.Analyzer.Extensions(), Metrics: s.Analyzer.Metrics, Languages: s.Analyzer.Languages}\\n\\n\\t\\t//display the source upload page\\n\\t\\ts.Template.ExecuteTemplate(w, \\\"index.html\\\", page)\\n\\t}\\n}\",\n \"func Index() (int, error) {\\n\\t\\tfmt.Println(\\\"Loading resources\\\")\\n\\t\\terr := InitDB()\\n\\t\\tif err != nil {\\n\\t\\t\\treturn 0, err\\n\\t\\t}\\n\\t\\tcoursesHTML, _ := ioutil.ReadFile(config.Local.DefaultFN)\\n\\t\\tdoc := soup.HTMLParse(string(coursesHTML))\\n\\t\\ttables := doc.FindAll(\\\"table\\\", \\\"class\\\", \\\"datadisplaytable\\\")\\n\\t\\tregistrar := start(tables)\\n\\t\\tif config.CatSecret != nil {\\n\\t\\t\\t\\tcat := handleCatalog()\\n\\t\\t\\t\\tindexCatalog(cat, registrar)\\n\\t\\t}\\n\\t\\tCommit(registrar)\\n\\t\\treturn 0, nil\\n}\",\n \"func ExecuteIndex(user models.User, w http.ResponseWriter, r *http.Request) error {\\n\\taccess := 0\\n\\n\\t// check if user is empty\\n\\tif user.ID != \\\"\\\" {\\n\\t\\taccess = user.GetAccess()\\n\\t} else {\\n\\t\\t// todo: normal auth page\\n\\t\\tw.Header().Set(\\\"Content-Type\\\", \\\"\\\")\\n\\t\\thttp.Redirect(w, r, \\\"/login\\\", http.StatusFound)\\n\\t\\treturn nil\\n\\t}\\n\\n\\t// getting all required data\\n\\tvoiceTime := \\\"\\\"\\n\\tvtd, err := user.GetVoiceTime()\\n\\tif err == nil {\\n\\t\\tvoiceTime = utils.FormatDuration(vtd)\\n\\t}\\n\\txbox := \\\"\\\"\\n\\txboxes, _ := user.GetXboxes()\\n\\tif len(xboxes) > 0 {\\n\\t\\txbox = xboxes[0].Xbox\\n\\t}\\n\\tjoinedAtTime, err := user.GetGuildJoinDate()\\n\\tjoinedAt := \\\"\\\"\\n\\tif err == nil {\\n\\t\\tdif := int(time.Now().Sub(joinedAtTime).Milliseconds()) / 1000 / 3600 / 24\\n\\t\\tdays := utils.FormatUnit(dif, utils.Days)\\n\\t\\tjoinedAt = fmt.Sprintf(\\\"%s (%s)\\\", utils.FormatDateTime(joinedAtTime), days)\\n\\t}\\n\\twarns, err := user.GetWarnings()\\n\\tif err != nil {\\n\\t\\twarns = []models.Warning{}\\n\\t}\\n\\n\\t// Preparing content and rendering\\n\\tcontent := IndexContent{\\n\\t\\tUsername: user.Username,\\n\\t\\tAvatar: user.AvatarURL,\\n\\t\\tJoinedAt: joinedAt,\\n\\t\\tXbox: xbox,\\n\\t\\tVoiceTime: voiceTime,\\n\\t\\tWarnsCount: len(warns),\\n\\t\\tWarnings: PrepareWarnings(warns),\\n\\t}\\n\\n\\ttmpl, err := template.ParseFiles(\\\"templates/layout.gohtml\\\", \\\"templates/index.gohtml\\\", \\\"templates/navbar.gohtml\\\")\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\n\\terr = tmpl.ExecuteTemplate(w, \\\"layout\\\", Layout{\\n\\t\\tTitle: \\\"Главная страница\\\",\\n\\t\\tPage: \\\"index\\\",\\n\\t\\tAccess: access,\\n\\t\\tContent: content,\\n\\t})\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\n\\treturn nil\\n}\",\n \"func (t tApp) Index(w http.ResponseWriter, r *http.Request) {\\n\\tvar h http.Handler\\n\\tc := App.newC(w, r, \\\"App\\\", \\\"Index\\\")\\n\\tdefer func() {\\n\\t\\t// If one of the actions (Before, After or Index) returned\\n\\t\\t// a handler, apply it.\\n\\t\\tif h != nil {\\n\\t\\t\\th.ServeHTTP(w, r)\\n\\t\\t}\\n\\t}()\\n\\tdefer App.after(c, w, r) // Call this at the very end, but before applying result.\\n\\tif res := App.before(c, w, r); res != nil {\\n\\t\\th = res\\n\\t\\treturn\\n\\t}\\n\\tif res := c.Index(); res != nil {\\n\\t\\th = res\\n\\t\\treturn\\n\\t}\\n}\",\n \"func index() string {\\n\\tvar buffer bytes.Buffer\\n\\tvar id = 0\\n\\tvar class = 0\\n\\tbuffer.WriteString(indexTemplate)\\n\\tlock.Lock()\\n\\tfor folderName, folder := range folders {\\n\\t\\tbuffer.WriteString(fmt.Sprintf(\\\"

%s

\\\", folderName))\\n\\t\\tfor _, source := range folder {\\n\\t\\t\\tif !anyNonRead(source) {\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\n\\t\\t\\tsort.Sort(source)\\n\\t\\t\\tbuffer.WriteString(fmt.Sprintf(\\\"

%s

\\\", source.Title))\\n\\t\\t\\tbuffer.WriteString(fmt.Sprintf(``, class))\\n\\t\\t\\tbuffer.WriteString(\\\"
    \\\")\\n\\n\\t\\t\\tfor _, entry := range source.Entries {\\n\\t\\t\\t\\tif entry.Read {\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tbuffer.WriteString(fmt.Sprintf(`
  • `, id))\\n\\t\\t\\t\\tbuffer.WriteString(fmt.Sprintf(` `, class, id, entry.Url))\\n\\t\\t\\t\\tbuffer.WriteString(fmt.Sprintf(`%s`, entry.Url, entry.Title))\\n\\t\\t\\t\\tbuffer.WriteString(\\\"
  • \\\")\\n\\t\\t\\t\\tid += 1\\n\\t\\t\\t}\\n\\t\\t\\tbuffer.WriteString(\\\"
\\\")\\n\\t\\t\\tclass += 1\\n\\t\\t}\\n\\t}\\n\\tlock.Unlock()\\n\\tbuffer.WriteString(\\\"\\\")\\n\\treturn buffer.String()\\n}\",\n \"func index(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprint(w, \\\"index de uma função\\\")\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\ttodosOsProdutos := models.BuscaTodosOsProdutos()\\n\\t//EXECUTA NO TEMPLATE\\n\\ttemp.ExecuteTemplate(w, \\\"Index\\\", todosOsProdutos)\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprintln(w, \\\"Welcome francis!\\\")\\n}\",\n \"func indexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tif r.URL.Path != \\\"/\\\" {\\n\\t\\thttp.NotFound(w, r)\\n\\t\\treturn\\n\\t}\\n\\n\\thttp.ServeFile(w, r, \\\"pages/main.html\\\")\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\t//index_routes := []string{\\\"providers\\\"}\\n\\tvar index_routes []string\\n\\tindex_routes = GetJobs()\\n\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"application/json; charset=UTF-8\\\")\\n\\tw.WriteHeader(http.StatusOK)\\n\\tif err := json.NewEncoder(w).Encode(index_routes); err != nil {\\n\\t\\tpanic(err)\\n\\t}\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tdb := dbConn()\\n\\tselDB, err := db.Query(\\\"SELECT * FROM Employee ORDER BY id DESC\\\")\\n\\tif err != nil {\\n\\t\\tpanic(err.Error())\\n\\t}\\n\\temp := Employee{}\\n\\tres := []Employee{}\\n\\tfor selDB.Next() {\\n\\t\\tvar id int\\n\\t\\tvar name, city string\\n\\t\\terr = selDB.Scan(&id, &name, &city)\\n\\t\\tif err != nil {\\n\\t\\t\\tpanic(err.Error())\\n\\t\\t}\\n\\t\\temp.Id = id\\n\\t\\temp.Name = name\\n\\t\\temp.City = city\\n\\t\\tres = append(res, emp)\\n\\t}\\n\\tgetTemplates().ExecuteTemplate(w, \\\"Index\\\", res)\\n\\tdefer db.Close()\\n}\",\n \"func (s *Server) indexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tb, _ := s.static.Find(\\\"index.html\\\")\\n\\tw.Write(b)\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\n\\tfmt.Fprintln(w, \\\"Steve and Kyle Podcast: #api\\\")\\n\\tfmt.Fprintln(w, \\\"Number of episodes in database:\\\", EpCount())\\n\\tfmt.Fprintln(w, \\\"Created by Derek Slenk\\\")\\n\\tfmt.Println(\\\"Endpoint Hit: Index\\\")\\n}\",\n \"func index(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprint(w, \\\"Welcome!\\\\n\\\")\\n}\",\n \"func Index(c *gin.Context) {\\n\\n\\tw := c.Writer\\n\\tr := c.Request\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"text/html; charset=utf-8\\\")\\n\\tp, lastMod, err := tools.ReadFileIfModified(time.Time{})\\n\\tif err != nil {\\n\\t\\tp = []byte(err.Error())\\n\\t\\tlastMod = time.Unix(0, 0)\\n\\t}\\n\\tvar v = struct {\\n\\t\\tHost string\\n\\t\\tData string\\n\\t\\tLastMod string\\n\\t}{\\n\\t\\tr.Host,\\n\\t\\tstring(p),\\n\\t\\tstrconv.FormatInt(lastMod.UnixNano(), 16),\\n\\t}\\n\\tindexTempl.Execute(w, &v)\\n}\",\n \"func index(w http.ResponseWriter, r *http.Request) {\\n\\tInfo.Println(\\\"Received request: \\\", r) // logging\\n\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"text/html; charset=utf-8\\\")\\n\\n\\tfmt.Fprintf(w, \\\"Hello Gopher! Static Page Static Content\\\")\\n}\",\n \"func indexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprint(w, \\\"Whoa, Nice!\\\")\\n}\",\n \"func (c *Controller) Index(w http.ResponseWriter, r *http.Request) {\\n\\tw.Write([]byte(\\\"listing users\\\"))\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\ta := \\\"hello from index router\\\"\\n\\tfmt.Fprintln(w, a)\\n}\",\n \"func rootIndexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tvar data map[string]*Record\\n\\tq := r.FormValue(\\\"q\\\")\\n\\tp := r.FormValue(\\\"p\\\")\\n\\n\\tif q != \\\"\\\" { // GET /?q=query\\n\\t\\tif len(q) >= 3 {\\n\\t\\t\\tdata = db.find(q)\\n\\t\\t} else {\\n\\t\\t\\thttp.Error(w, http.StatusText(422), 422)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t} else if p == \\\"1\\\" { // GET /?p=1\\n\\t\\tdata = db.getPaused()\\n\\t}\\n\\n\\ttotalCount, err := db.keyCount()\\n\\tif err != nil {\\n\\t\\tlog.Printf(\\\"db.keyCount() Error: %s\\\\n\\\", err)\\n\\t\\thttp.Error(w, http.StatusText(500), 500)\\n\\t\\treturn\\n\\t}\\n\\n\\ttmpl, err := template.New(\\\"index\\\").Parse(indexTmpl)\\n\\tif err != nil {\\n\\t\\tlog.Printf(\\\"template.ParseFiles() Error: %s\\\\n\\\", err)\\n\\t\\thttp.Error(w, http.StatusText(500), 500)\\n\\t\\treturn\\n\\t}\\n\\n\\tif err = tmpl.Execute(w, H{\\\"data\\\": data, \\\"isDisabled\\\": isDisabled, \\\"totalCount\\\": totalCount, \\\"q\\\": q, \\\"p\\\": p}); err != nil {\\n\\t\\tlog.Printf(\\\"tmpl.Execute() Error: %s\\\\n\\\", err)\\n\\t\\thttp.Error(w, http.StatusText(500), 500)\\n\\t}\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tif (!Auth(w, r)) {\\n\\t\\treturn\\n\\t}\\n\\tfmt.Fprintln(w, \\\"Welcome to the REST Businesses API!\\\")\\n\\tfmt.Fprintln(w, \\\"Usage:\\\")\\n\\tfmt.Fprintln(w, `GET /businesses?page={number}&size={number}\\nFetch list of businesses with pagination.`)\\n\\tfmt.Fprintln(w, \\\"\\\")\\n\\tfmt.Fprintln(w, `GET /business/{id}\\nFetch a specific business as a JSON object`)\\n}\",\n \"func (uc UserController) Index(w http.ResponseWriter, r *http.Request, params httprouter.Params) {\\n\\n\\tfmt.Fprintln(w, \\\"Welcome to Index!\\\")\\n\\n}\",\n \"func index(writer http.ResponseWriter, request *http.Request) {\\n\\tloggedin(writer, request)\\n\\tt := parseTemplateFiles(\\\"layout\\\", \\\"public.navbar\\\", \\\"index\\\")\\n\\tconversations, err := data.Conversations(); if err != nil {\\n\\t\\terror_message(writer, request, \\\"Cannot get conversations\\\")\\n\\t} else {\\n\\t\\tt.Execute(writer, conversations)\\n\\t}\\n}\",\n \"func (a *App) Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\\n\\trawBankStatements, err := models.AllRawBankStatements(a.db)\\n\\tif err != nil {\\n\\t\\tlog.Println(err)\\n\\t\\thttp.Error(w, http.StatusText(500), 500)\\n\\t\\treturn\\n\\t}\\n\\n\\tdata, err := json.Marshal(rawBankStatements)\\n\\tif err != nil {\\n\\t\\tlog.Println(err)\\n\\t\\thttp.Error(w, http.StatusText(500), 500)\\n\\t\\treturn\\n\\t}\\n\\tw.Write(data)\\n\\tfmt.Println(\\\"Index\\\")\\n}\",\n \"func GetIndex(w http.ResponseWriter, req *http.Request, app *App) {\\n\\tscheme := \\\"http\\\"\\n\\tif req.TLS != nil {\\n\\t\\tscheme = \\\"https\\\"\\n\\t}\\n\\tbase := []string{scheme, \\\"://\\\", req.Host, app.Config.General.Prefix}\\n\\trender(w, \\\"index\\\", map[string]interface{}{\\\"base\\\": strings.Join(base, \\\"\\\"), \\\"hideNav\\\": true}, app)\\n}\"\n]"},"negative_scores":{"kind":"list like","value":["0.80268294","0.790578","0.77338165","0.7715898","0.7689121","0.7684665","0.76702815","0.76702815","0.7656754","0.7542163","0.7517239","0.7509632","0.7509632","0.75040925","0.7436748","0.74282384","0.7349767","0.73343587","0.73327005","0.7326263","0.73177403","0.7304866","0.7275821","0.72579914","0.7216298","0.7169393","0.7164979","0.7164468","0.7141333","0.7127708","0.71245384","0.710656","0.7099273","0.70555234","0.7055481","0.7039714","0.7037446","0.70371425","0.7013888","0.7012538","0.70101404","0.7007724","0.7006772","0.69973075","0.69936067","0.698247","0.6967889","0.6944416","0.69417375","0.6934144","0.69246686","0.6917409","0.69160306","0.691399","0.69060457","0.6903803","0.68934405","0.6875425","0.68679684","0.6866903","0.6865839","0.68557686","0.68537176","0.6831742","0.6828569","0.6825229","0.6820908","0.6820558","0.68121725","0.67961967","0.6791418","0.67848283","0.6783686","0.67785496","0.67622095","0.67572725","0.67552716","0.6752654","0.6751508","0.6740243","0.6733264","0.67287946","0.67262775","0.67190534","0.6709589","0.6707917","0.6704465","0.6701847","0.6692577","0.66899353","0.6684525","0.668016","0.66731346","0.6655969","0.6643242","0.66185","0.6617404","0.66122353","0.6611395","0.66108817","0.6607039"],"string":"[\n \"0.80268294\",\n \"0.790578\",\n \"0.77338165\",\n \"0.7715898\",\n \"0.7689121\",\n \"0.7684665\",\n \"0.76702815\",\n \"0.76702815\",\n \"0.7656754\",\n \"0.7542163\",\n \"0.7517239\",\n \"0.7509632\",\n \"0.7509632\",\n \"0.75040925\",\n \"0.7436748\",\n \"0.74282384\",\n \"0.7349767\",\n \"0.73343587\",\n \"0.73327005\",\n \"0.7326263\",\n \"0.73177403\",\n \"0.7304866\",\n \"0.7275821\",\n \"0.72579914\",\n \"0.7216298\",\n \"0.7169393\",\n \"0.7164979\",\n \"0.7164468\",\n \"0.7141333\",\n \"0.7127708\",\n \"0.71245384\",\n \"0.710656\",\n \"0.7099273\",\n \"0.70555234\",\n \"0.7055481\",\n \"0.7039714\",\n \"0.7037446\",\n \"0.70371425\",\n \"0.7013888\",\n \"0.7012538\",\n \"0.70101404\",\n \"0.7007724\",\n \"0.7006772\",\n \"0.69973075\",\n \"0.69936067\",\n \"0.698247\",\n \"0.6967889\",\n \"0.6944416\",\n \"0.69417375\",\n \"0.6934144\",\n \"0.69246686\",\n \"0.6917409\",\n \"0.69160306\",\n \"0.691399\",\n \"0.69060457\",\n \"0.6903803\",\n \"0.68934405\",\n \"0.6875425\",\n \"0.68679684\",\n \"0.6866903\",\n \"0.6865839\",\n \"0.68557686\",\n \"0.68537176\",\n \"0.6831742\",\n \"0.6828569\",\n \"0.6825229\",\n \"0.6820908\",\n \"0.6820558\",\n \"0.68121725\",\n \"0.67961967\",\n \"0.6791418\",\n \"0.67848283\",\n \"0.6783686\",\n \"0.67785496\",\n \"0.67622095\",\n \"0.67572725\",\n \"0.67552716\",\n \"0.6752654\",\n \"0.6751508\",\n \"0.6740243\",\n \"0.6733264\",\n \"0.67287946\",\n \"0.67262775\",\n \"0.67190534\",\n \"0.6709589\",\n \"0.6707917\",\n \"0.6704465\",\n \"0.6701847\",\n \"0.6692577\",\n \"0.66899353\",\n \"0.6684525\",\n \"0.668016\",\n \"0.66731346\",\n \"0.6655969\",\n \"0.6643242\",\n \"0.66185\",\n \"0.6617404\",\n \"0.66122353\",\n \"0.6611395\",\n \"0.66108817\",\n \"0.6607039\"\n]"},"document_score":{"kind":"string","value":"0.0"},"document_rank":{"kind":"string","value":"-1"}}},{"rowIdx":105051,"cells":{"query":{"kind":"string","value":"ServeHTTP is a regular serve func except the first argument, passed as a copy, is unused. sse.Writer is there for writes."},"document":{"kind":"string","value":"func (sse *SSE) ServeHTTP(_ http.ResponseWriter, r *http.Request) {\n\tw := sse.Writer\n\tdata, _, err := Updates(r, sse.Params)\n\tif err != nil {\n\t\tif _, ok := err.(params.RenamedConstError); ok {\n\t\t\thttp.Redirect(w, r, err.Error(), http.StatusFound)\n\t\t\treturn\n\t\t}\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n\ttext, err := json.Marshal(data)\n\tif err != nil {\n\t\tsse.Errord = true\n\t\t// what would http.Error do\n\t\tif sse.SetHeader(\"Content-Type\", \"text/plain; charset=utf-8\") {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t}\n\t\tfmt.Fprintln(w, err.Error())\n\t\treturn\n\t}\n\tsse.SetHeader(\"Content-Type\", \"text/event-stream\")\n\tif _, err := w.Write(append(append([]byte(\"data: \"), text...), []byte(\"\\n\\n\")...)); err != nil {\n\t\tsse.Errord = true\n\t}\n}"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["func (mw *Stats) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {\n\tbeginning, recorder := mw.Begin(w)\n\n\tnext(recorder, r)\n\n\tmw.End(beginning, WithRecorder(recorder))\n}","func (f MiddlewareFunc) ServeHTTP(w http.ResponseWriter, r *http.Request, next func()) {\n\tf(w, r, next)\n}","func (m middleware) serve(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tm.fn(w, r, ps, m.next.serve)\n}","func (mux *ServeMux) ServeHTTP(w ResponseWriter, r *Request)","func (k *Kite) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\tk.muxer.ServeHTTP(w, req)\n}","func (s prodAssetServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\touturl := *s.url\n\torigPath := req.URL.Path\n\tif !strings.HasPrefix(origPath, \"/static/\") {\n\t\t// redirect everything to the main entry point.\n\t\torigPath = \"index.html\"\n\t}\n\n\touturl.Path = path.Join(outurl.Path, origPath)\n\toutreq, err := http.NewRequest(\"GET\", outurl.String(), bytes.NewBuffer(nil))\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t_, _ = w.Write([]byte(err.Error()))\n\t\treturn\n\t}\n\n\tcopyHeader(outreq.Header, req.Header)\n\toutres, err := http.DefaultClient.Do(outreq)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t_, _ = w.Write([]byte(err.Error()))\n\t\treturn\n\t}\n\n\tdefer func() {\n\t\t_ = outres.Body.Close()\n\t}()\n\n\tcopyHeader(w.Header(), outres.Header)\n\tw.WriteHeader(outres.StatusCode)\n\t_, _ = io.Copy(w, outres.Body)\n}","func (sw *subware) serve(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tsw.middleware.serve(w, r, ps)\n}","func (f HandlerFunc) ServeHttp(w ResponseWriter, r *Request){\n f(w, r)\n}","func (s *ConcurrentServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\ts.router.ServeHTTP(w, r)\n}","func (w HandlerFuncWrapper) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {\n\tw(next)(rw, r)\n}","func (s *Server) serveHTTP(w http.ResponseWriter, r *http.Request) {\n\ts.HTTP.Handler.ServeHTTP(w, r)\n}","func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tif h.Skip(r) {\n\t\th.Next.ServeHTTP(w, r)\n\t\treturn\n\t}\n\tvar written int64\n\tvar status = -1\n\n\twp := writerProxy{\n\t\th: func() http.Header {\n\t\t\treturn w.Header()\n\t\t},\n\t\tw: func(bytes []byte) (int, error) {\n\t\t\tbw, err := w.Write(bytes)\n\t\t\twritten += int64(bw)\n\t\t\treturn bw, err\n\t\t},\n\t\twh: func(code int) {\n\t\t\tstatus = code\n\t\t\tw.WriteHeader(code)\n\t\t},\n\t}\n\n\tstart := time.Now()\n\th.Next.ServeHTTP(wp, r)\n\tduration := time.Now().Sub(start)\n\n\t// Use default status.\n\tif status == -1 {\n\t\tstatus = 200\n\t}\n\n\th.Logger(r, status, written, duration)\n}","func (rh *RandomHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\t// Increment serveCounter every time we serve a page.\n\trh.serveCounter.Inc()\n\n\tn := rand.Float64()\n\t// Track the cumulative values served.\n\trh.valueCounter.Add(n)\n\n\tfmt.Fprintf(w, \"%v\", n)\n}","func (s *Service) serveHTTP() {\n\thandler := &Handler{\n\t\tDatabase: s.Database,\n\t\tRetentionPolicy: s.RetentionPolicy,\n\t\tPointsWriter: s.PointsWriter,\n\t\tLogger: s.Logger,\n\t\tstats: s.stats,\n\t}\n\tsrv := &http.Server{Handler: handler}\n\tsrv.Serve(s.httpln)\n}","func (t Telemetry) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tt.rCount.Mark(1)\n\tsw := MakeLogger(w)\n\n\tstart := time.Now()\n\tt.inner.ServeHTTP(sw, r)\n\tt.tmr.Update(int64(time.Since(start) / time.Millisecond))\n\n\tif sw.Status() >= 300 {\n\t\tt.fCount.Mark(1)\n\t} else {\n\t\tt.sCount.Mark(1)\n\t}\n\n}","func (w HandlerWrapper) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {\n\tw(next).ServeHTTP(rw, r)\n}","func (p *Proxy) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\tjob := p.stream.NewJob(\"proxy.serve\")\n\n\t// Add headers\n\tfor key, vals := range p.lastResponseHeaders {\n\t\tfor _, val := range vals {\n\t\t\tw.Header().Set(key, val)\n\t\t}\n\t}\n\tw.Header().Set(\"X-OpenBazaar\", \"Trade free!\")\n\n\t// Write body\n\t_, err := w.Write(p.lastResponseBody)\n\tif err != nil {\n\t\tjob.EventErr(\"write\", err)\n\t\tjob.Complete(health.Error)\n\t}\n\n\tjob.Complete(health.Success)\n}","func (t *Timer) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tdefer t.UpdateSince(time.Now())\n\tt.handler.ServeHTTP(w, r)\n}","func (s static) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\ts.handler.ServeHTTP(w, r)\n}","func (h HandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\th(context.TODO(), w, r)\n}","func serveHTTP(c *RequestContext, w http.ResponseWriter, r *http.Request) (int, error) {\n\t// Checks if the URL contains the baseURL and strips it. Otherwise, it just\n\t// returns a 404 error because we're not supposed to be here!\n\tp := strings.TrimPrefix(r.URL.Path, c.FM.BaseURL)\n\n\tif len(p) >= len(r.URL.Path) && c.FM.BaseURL != \"\" {\n\t\treturn http.StatusNotFound, nil\n\t}\n\n\tr.URL.Path = p\n\n\t// Check if this request is made to the service worker. If so,\n\t// pass it through a template to add the needed variables.\n\tif r.URL.Path == \"/sw.js\" {\n\t\treturn renderFile(\n\t\t\tw,\n\t\t\tc.FM.assets.MustString(\"sw.js\"),\n\t\t\t\"application/javascript\",\n\t\t\tc,\n\t\t)\n\t}\n\n\t// Checks if this request is made to the static assets folder. If so, and\n\t// if it is a GET request, returns with the asset. Otherwise, returns\n\t// a status not implemented.\n\tif matchURL(r.URL.Path, \"/static\") {\n\t\tif r.Method != http.MethodGet {\n\t\t\treturn http.StatusNotImplemented, nil\n\t\t}\n\n\t\treturn staticHandler(c, w, r)\n\t}\n\n\t// Checks if this request is made to the API and directs to the\n\t// API handler if so.\n\tif matchURL(r.URL.Path, \"/api\") {\n\t\tr.URL.Path = strings.TrimPrefix(r.URL.Path, \"/api\")\n\t\treturn apiHandler(c, w, r)\n\t}\n\n\t// Any other request should show the index.html file.\n\tw.Header().Set(\"x-frame-options\", \"SAMEORIGIN\")\n\tw.Header().Set(\"x-content-type\", \"nosniff\")\n\tw.Header().Set(\"x-xss-protection\", \"1; mode=block\")\n\n\treturn renderFile(\n\t\tw,\n\t\tc.FM.assets.MustString(\"index.html\"),\n\t\t\"text/html\",\n\t\tc,\n\t)\n}","func (h TestServerHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {\n\twriter.WriteHeader(h.StatusCode)\n\twriter.Header().Add(\"Content-Type\", \"text/plain\")\n\t_, _ = writer.Write([]byte(h.Content))\n}","func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) {\n\tf(w, r)\n}","func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) {\n\tf(w, r)\n}","func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) {\n\tf(w, r)\n}","func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) {\n\tf(w, r)\n}","func (b *backend) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n}","func (m hotdog) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintln(w, \"Any code in this func\")\n}","func (es *EventSource) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tvar startID int\n\tif start := r.Header.Get(\"Last-Event-ID\"); start != \"\" {\n\t\tif _, err := fmt.Sscanf(start, \"%d\", &startID); err != nil {\n\t\t\thttp.Error(w, \"bad Last-Event-ID\", http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\tstartID++\n\t}\n\n\tw.Header().Set(\"Content-Type\", ContentType)\n\tw.Header().Set(\"Connection\", \"keep-alive\")\n\tw.Header().Set(\"Cache-Control\", \"no-cache\")\n\tw.Header().Set(\"Transfer-Encoding\", \"chunked\")\n\tw.WriteHeader(200)\n\n\tflusher, ok := w.(http.Flusher)\n\tif !ok {\n\t\tpanic(\"esource: ServeHTTP called without a Flusher\")\n\t}\n\n\tlog.Printf(\"esource: [%s] starting stream\", r.RemoteAddr)\n\n\told, events := es.Tee(startID)\n\tfor _, event := range old {\n\t\tif _, err := event.WriteTo(w); err != nil {\n\t\t\tlog.Printf(\"esource: [%s] failed to write backlogged event %+v\", r.RemoteAddr, event)\n\t\t\treturn\n\t\t}\n\t}\n\tflusher.Flush()\n\n\tfor event := range events {\n\t\tif _, err := event.WriteTo(w); err != nil {\n\t\t\tlog.Printf(\"esource: [%s] failed to write event %+v\", r.RemoteAddr, event)\n\t\t\tfmt.Fprintln(w, \"\\nretry: 0\\n\")\n\t\t\treturn\n\t\t}\n\t\tflusher.Flush()\n\t}\n\n\tlog.Printf(\"esource: [%s] complete\", r.RemoteAddr)\n}","func (hw *CtxHandlerWraper) ServeHTTP(ctx context.Context, w http.ResponseWriter, req *http.Request) error {\n\treturn hw.Func(ctx, w, req)\n}","func (s *ServeSeq) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\ti := &intrespwriter{parent: w, written: false}\n\tfor idx, h := range s.handlers {\n\t\ti.canskip = (idx != len(s.handlers)-1)\n\t\ti.skip = false\n\t\th.ServeHTTP(i, r)\n\t\tif i.written {\n\t\t\treturn\n\t\t}\n\t}\n}","func (f HandlerFunc) ServeHTTP(ctx *Context) {\n\tf(ctx)\n}","func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request) {\n\ts.Handler.ServeHTTP(res, req)\n}","func (ot *openTelemetryWrapper) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error {\n\tn := &nextCall{\n\t\tnext: next,\n\t\terr: nil,\n\t}\n\tot.handler.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), nextCallCtxKey, n)))\n\n\treturn n.err\n}","func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\ts.Router().ServeHTTP(context.Wrap(w), req)\n}","func (ot *openTelemetryWrapper) serveHTTP(w http.ResponseWriter, r *http.Request) {\n\tctx := r.Context()\n\tot.propagators.Inject(ctx, propagation.HeaderCarrier(r.Header))\n\tspanCtx := trace.SpanContextFromContext(ctx)\n\tif spanCtx.IsValid() {\n\t\tif extra, ok := ctx.Value(caddyhttp.ExtraLogFieldsCtxKey).(*caddyhttp.ExtraLogFields); ok {\n\t\t\textra.Add(zap.String(\"traceID\", spanCtx.TraceID().String()))\n\t\t}\n\t}\n\tnext := ctx.Value(nextCallCtxKey).(*nextCall)\n\tnext.err = next.next.ServeHTTP(w, r)\n}","func (m *RegExpMux) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n}","func (handler Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tfmt.Printf(\"%s %s %s\\n\", r.RemoteAddr, r.Method, r.URL.Path)\n\tt1 := time.Now()\n\thandler.store.ExpireSessions()\n\treq := newReqImpl(w, r, handler.store)\n\thandler.serve(req)\n\tif req.html != \"\" {\n\t\tio.WriteString(w, req.html)\n\t} else if req.template != \"\" {\n\t\tt := template.New(\"\").Funcs(handler.funcmap)\n\t\tt, err := t.ParseGlob(handler.templatePattern)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\terr = t.ExecuteTemplate(w, req.template, req.model)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t} else if req.redirect != \"\" {\n\t\thttp.Redirect(w, r, req.redirect, http.StatusFound)\n\t} else if req.status != 0 {\n\t\tmsg := http.StatusText(req.status)\n\t\thttp.Error(w, msg, req.status)\n\t} else {\n\t\tio.WriteString(w, \"no result\")\n\t}\n\td := time.Since(t1)\n\tfmt.Printf(\"%s %s %s - %f s\\n\", r.RemoteAddr, r.Method, r.URL.Path, float64(d)/1e9)\n}","func (mx *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tmx.ServeHTTPContext(w, r, nil)\n}","func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tpanic(fmt.Sprintf(\"httpx: ServeHTTP called on %v\", h))\n}","func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tpanic(fmt.Sprintf(\"httpx: ServeHTTP called on %v\", h))\n}","func (f *Forwarder) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\tif f.log.GetLevel() >= log.DebugLevel {\n\t\tlogEntry := f.log.WithField(\"Request\", utils.DumpHttpRequest(req))\n\t\tlogEntry.Debug(\"vulcand/oxy/forward: begin ServeHttp on request\")\n\t\tdefer logEntry.Debug(\"vulcand/oxy/forward: completed ServeHttp on request\")\n\t}\n\n\tif f.stateListener != nil {\n\t\tf.stateListener(req.URL, StateConnected)\n\t\tdefer f.stateListener(req.URL, StateDisconnected)\n\t}\n\tif IsWebsocketRequest(req) {\n\t\tf.httpForwarder.serveWebSocket(w, req, f.handlerContext)\n\t} else {\n\t\tf.httpForwarder.serveHTTP(w, req, f.handlerContext)\n\t}\n}","func (serv *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\tc := serv.pool.Get().(*Context)\n\tc.reset(w, req)\n\n\tserv.handleHTTPRequest(c)\n\n\tserv.pool.Put(c)\n}","func (c *PingMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next traffic.NextMiddlewareFunc) (http.ResponseWriter, *http.Request) {\n if r.URL.Path == \"/ping\" {\n fmt.Fprint(w, \"pong\\n\")\n\n return w, r\n }\n\n if nextMiddleware := next(); nextMiddleware != nil {\n arw := w.(*traffic.AppResponseWriter)\n arw.SetVar(\"ping\", \"pong\")\n w, r = nextMiddleware.ServeHTTP(w, r, next)\n }\n\n return w, r\n}","func (m *metricsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tm.Handler.ServeHTTP(w, r)\n}","func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\ts.mux.ServeHTTP(w, r)\n}","func (h HttpHandlerPipe) ServeHttpPipe(w ResponseWriter, r *http.Request, f *Pipeline) {\n\th.ServeHTTP(w, r)\n\tf.Next(w, r)\n}","func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\tses := newSession(w, req)\n\ts.Sessions <- ses\n\t<-ses.end\n}","func (p *Proxy) HTTPServe() {\n\tvar prf interface {\n\t\tStop()\n\t}\n\n\t// We want to make sure the profile is stopped\n\t// exactly once (and only once), even if the\n\t// shutdown pre-hook does not run (which it may not)\n\tprofileStopOnce := sync.Once{}\n\n\tif p.enableProfiling {\n\t\tprofileStartOnce.Do(func() {\n\t\t\tprf = profile.Start()\n\t\t})\n\n\t\tdefer func() {\n\t\t\tprofileStopOnce.Do(prf.Stop)\n\t\t}()\n\t}\n\thttpSocket := bind.Socket(p.HTTPAddr)\n\tgraceful.Timeout(10 * time.Second)\n\tgraceful.PreHook(func() {\n\n\t\tif prf != nil {\n\t\t\tprofileStopOnce.Do(prf.Stop)\n\t\t}\n\n\t\tlog.Info(\"Terminating HTTP listener\")\n\t})\n\n\t// Ensure that the server responds to SIGUSR2 even\n\t// when *not* running under einhorn.\n\tgraceful.AddSignal(syscall.SIGUSR2, syscall.SIGHUP)\n\tgraceful.HandleSignals()\n\tgracefulSocket := graceful.WrapListener(httpSocket)\n\tlog.WithField(\"address\", p.HTTPAddr).Info(\"HTTP server listening\")\n\n\t// Signal that the HTTP server is listening\n\tatomic.AddInt32(p.numListeningHTTP, 1)\n\tdefer atomic.AddInt32(p.numListeningHTTP, -1)\n\tbind.Ready()\n\n\tif err := http.Serve(gracefulSocket, p.Handler()); err != nil {\n\t\tlog.WithError(err).Error(\"HTTP server shut down due to error\")\n\t}\n\tlog.Info(\"Stopped HTTP server\")\n\n\tgraceful.Shutdown()\n}","func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\ts.router.ServeHTTP(w, req)\n}","func serveHTTP(ech chan<- error, addr string) {\n\tif \"\" == addr || NO == addr {\n\t\treturn\n\t}\n\t/* Listen */\n\tl, err := net.Listen(\"tcp\", addr)\n\tif nil != err {\n\t\tech <- err\n\t\treturn\n\t}\n\tlog.Printf(\"Serving HTTP requests on %v\", l.Addr())\n\t/* Serve */\n\tech <- http.Serve(l, nil)\n}","func (m hotdog) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\tfmt.Fprintln(w,\"My power code here!\")\n}","func (a anything) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintln(w, \"Any code you want in this func\")\n}","func (e *Exporter) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\te.handler.ServeHTTP(w, r)\n}","func (engine *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tc := engine.pool.Get().(*Context)\n\tc.writermem.reset(w)\n\tc.Request = r\n\tc.reset()\n\n\tengine.handleHTTPRequest(c)\n\n\tengine.pool.Put(c)\n}","func (i indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tlog.Printf(\"You are all my minions, %v, beware %v, %v!\\n\", r.RemoteAddr, r.Method, r.URL)\n\tif r.URL.Path != \"/\" {\n\t\tlog.Printf(\"Sirree, this is a wrong URL path: %v!\\n\", r.URL.Path)\n\t\tw.WriteHeader(http.StatusNotFound)\n\t\tfmt.Fprintf(w, i.pageNotFound)\n\t\treturn\n\t}\n\tif r.Method != \"GET\" {\n\t\tlog.Printf(\"Madam, the method thou art using is wrong: %v!\\n\", r.Method)\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tfmt.Fprintf(w, i.pageBadRequest)\n\t\treturn\n\t}\n\tdata := pageData{\n\t\tTitle: \"Welcome\",\n\t\tVersion: fmt.Sprintf(\"This is version %v\", i.version),\n\t}\n\tif err := i.tmpl.Execute(w, data); err != nil {\n\t\tpanic(err)\n\t}\n}","func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tt := time.Now()\n\tww := buildLoggingWriter(w)\n\tif h.serveHTTP(ww, r) {\n\t\tww.LogAccess(r, time.Now().Sub(t))\n\t}\n}","func (s *SimpleStaticFilesServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tif s.testMode && strings.HasPrefix(r.URL.String(), GOPATH_PREFIX) {\n\t\tGopathLookup(w, r, strings.TrimPrefix(r.URL.String(), GOPATH_PREFIX))\n\t\treturn\n\t}\n\tlog.Printf(\"[STATIC CONTENT (%s)]: %v\", s.staticDir, r.URL.String())\n\ts.fs.ServeHTTP(w, r)\n}","func (a *Application) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\t// log all unhandled panic's\n\t// todo: check performance impact\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\ta.Emit(\"error\", r)\n\t\t\tpanic(r)\n\t\t}\n\t}()\n\n\tctx := makeCtx(req, w)\n\trequest := ctx.Req\n\tresponse := ctx.Res\n\n\tdefer response.flush()\n\n\t///////////////////////////////////////////////////////////////////\n\t// Catch Neo Assertions\n\t///////////////////////////////////////////////////////////////////\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr, ok := r.(*NeoAssertError)\n\n\t\t\tif ok {\n\t\t\t\tresponse.Raw(err.message, err.status)\n\t\t\t\ta.Emit(\"error\", r)\n\t\t\t} else {\n\t\t\t\t// bubble panic\n\t\t\t\tpanic(r)\n\t\t\t}\n\t\t}\n\t}()\n\n\t///////////////////////////////////////////////////////////////////\n\t// Static File Serving\n\t///////////////////////////////////////////////////////////////////\n\tif a.static != nil {\n\t\t// check if file can be served\n\t\tfile, err := a.static.match(req.URL.Path)\n\n\t\tif err == nil {\n\t\t\th := func(ctx *Ctx) {\n\t\t\t\tresponse.skipFlush()\n\t\t\t\tresponse.serveFile(file)\n\t\t\t}\n\n\t\t\tfn := compose(merge(a.middlewares, []appliable{handler(h)}))\n\t\t\tfn(ctx)\n\t\t\treturn\n\t\t}\n\n\t\tlog.Debug(\"result not found in static\")\n\t}\n\n\t///////////////////////////////////////////////////////////////////\n\t// Route Matching\n\t///////////////////////////////////////////////////////////////////\n\troute, err := a.match(request)\n\n\tif err != nil {\n\t\tlog.Debugf(\"route %s not found\", req.URL.Path)\n\n\t\t// dummy route handler\n\t\th := func(ctx *Ctx) {\n\t\t\tresponse.Status = http.StatusNotFound\n\t\t}\n\n\t\tcompose(merge(a.middlewares, []appliable{handler(h)}))(ctx)\n\t} else {\n\t\troute.fnChain(ctx)\n\t}\n}","func (s Thumbnails) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\ts.mux.ServeHTTP(w, r)\n}","func (h *Handler) ServeHTTP(ctx context.Context, event cloudevents.Event, resp *cloudevents.EventResponse) error {\n\t// Hand work off to the current multi channel fanout handler.\n\th.logger.Debug(\"ServeHTTP request received\")\n\treturn h.getMultiChannelFanoutHandler().ServeHTTP(ctx, event, resp)\n}","func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\ts.router.ServeHTTP(w, r)\n}","func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\ts.router.ServeHTTP(w, r)\n}","func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\ts.router.ServeHTTP(w, r)\n}","func (m *Module) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\n\t// Create a context from the response and request\n\tctx := web.NewContext(w, r)\n\n\t// Serve the app using the new context\n\tm.Serve(ctx)\n}","func (self *Direct) ServeHTTP(w http.ResponseWriter, r *http.Request) (err error) {\n\tif r.Method == \"CONNECT\" {\n\t\tglog.Println(\"this function can not handle CONNECT method\")\n\t\thttp.Error(w, r.Method, http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\tstart := time.Now()\n\n\t// Client.Do is different from DefaultTransport.RoundTrip ...\n\t// Client.Do will change some part of request as a new request of the server.\n\t// The underlying RoundTrip never changes anything of the request.\n\tresp, err := self.Tr.RoundTrip(r)\n\tif err != nil {\n\t\tif nerr, ok := err.(net.Error); ok && nerr.Timeout() {\n\t\t\tglog.Errorf(\"RoundTrip: %s, reproxy...\\n\", err.Error())\n\t\t\terr = ErrShouldProxy\n\t\t\treturn\n\t\t}\n\t\tglog.Errorf(\"RoundTrip: %s\\n\", err.Error())\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\n\t// please prepare header first and write them\n\tCopyHeader(w, resp)\n\tw.WriteHeader(resp.StatusCode)\n\n\tn, err := io.Copy(w, resp.Body)\n\tif err != nil {\n\t\tglog.Printf(\"Copy: %s\", err.Error())\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\td := BeautifyDuration(time.Since(start))\n\tndtos := BeautifySize(n)\n\tglog.Infof(\"RESPONSE %s %s in %s <-%s\", r.URL.Host, resp.Status, d, ndtos)\n\treturn\n}","func (h httpHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\tl := h.logger\n\tp := newPrinter(l)\n\tdefer p.flush()\n\n\tif hide := req.Context().Value(contextHide{}); hide != nil || p.checkFilter(req) {\n\t\th.next.ServeHTTP(w, req)\n\t\treturn\n\t}\n\n\tif p.logger.Time {\n\t\tdefer p.printTimeRequest()()\n\t}\n\n\tif !p.logger.SkipRequestInfo {\n\t\tp.printRequestInfo(req)\n\t}\n\n\tif p.logger.TLS {\n\t\tp.printTLSInfo(req.TLS, true)\n\t\tp.printIncomingClientTLS(req.TLS)\n\t}\n\n\tp.printRequest(req)\n\n\trec := &responseRecorder{\n\t\tResponseWriter: w,\n\n\t\tstatusCode: http.StatusOK,\n\n\t\tmaxReadableBody: l.MaxResponseBody,\n\t\tbuf: &bytes.Buffer{},\n\t}\n\n\tdefer p.printServerResponse(req, rec)\n\th.next.ServeHTTP(rec, req)\n}","func (h *SubscribeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tvar index, err = strconv.Atoi(r.Header.Get(\"Last-Event-ID\"))\n\tif r.Header.Get(\"Last-Event-ID\") != \"\" {\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\tindex += 1\n\t}\n\n\t// Create a channel for subscribing to database updates.\n\tch := h.db.Subscribe(index)\n\tcloseNotifier := w.(http.CloseNotifier).CloseNotify()\n\n\t// Mark this as an SSE event stream.\n\tw.Header().Set(\"Content-Type\", \"text/event-stream\")\n\n\t// Continually stream updates as they come.\nloop:\n\tfor {\n\t\tselect {\n\t\tcase <-closeNotifier:\n\t\t\tbreak loop\n\n\t\tcase row := <-ch:\n\t\t\t// Encode row as JSON.\n\t\t\tb, err := json.Marshal(row)\n\t\t\tif err != nil {\n\t\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\t\tbreak loop\n\t\t\t}\n\n\t\t\t// Send row as server-sent event.\n\t\t\tfmt.Fprintf(w, \"id: %d\\n\", row.Index())\n\t\t\tfmt.Fprintf(w, \"data: %s\\n\\n\", b)\n\t\t\tw.(http.Flusher).Flush()\n\t\t}\n\t}\n\n\t// Unsubscribe from the database when the connection is lost.\n\th.db.Unsubscribe(ch)\n}","func (avd avocado) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprint(w, \"brought you by a handler\")\n}","func (s *server) ServeHTTP(rw http.ResponseWriter, r *http.Request) {\n\ts.router.ServeHTTP(rw, r)\n}","func (t *Tunnel) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tt.proxy.ServeHTTP(w, r)\n}","func (_m *MockHandler) ServeHTTP(_a0 http.ResponseWriter, _a1 *http.Request) {\n\t_m.Called(_a0, _a1)\n}","func (con *Controller) ServeHTTP(res http.ResponseWriter, req *http.Request) {\n\tstartTime := time.Now()\n\n\tswitch con.Status {\n\tcase 0: // This will actually never show because this function won't run if the server is off\n\t\thttp.Error(res, \"The server is currently down and not serving requests.\", http.StatusServiceUnavailable)\n\t\treturn\n\tcase 1: // Normal\n\t\tbreak\n\tcase 2: // Maintenance mode\n\t\thttp.Error(res, \"The server is currently maintenance mode and not serving requests.\", http.StatusServiceUnavailable)\n\t\treturn\n\tcase 3: // This will actually never show because this function won't run if the server is off\n\t\thttp.Error(res, \"The server is currently restarting.\", http.StatusServiceUnavailable)\n\t\treturn\n\t}\n\n\tpath := req.URL.Path[1:]\n\tif len(path) == 0 {\n\t\tpath = (con.DocumentRoot + \"index.html\")\n\t} else {\n\t\tpath = (con.DocumentRoot + path)\n\t}\n\n\tf, err := os.Open(path)\n\n\tif err != nil {\n\t\tcon.PublicLogger.Write(path + \"::\" + strconv.Itoa(http.StatusNotFound) + \"::\" + err.Error())\n\t\trouting.HttpThrowStatus(http.StatusNotFound, res)\n\t\treturn\n\t}\n\n\tcontentType, err := routing.GetContentType(path)\n\n\tif err != nil {\n\t\tcon.PublicLogger.Write(path + \"::\" + strconv.Itoa(http.StatusUnsupportedMediaType) + \"::\" + err.Error())\n\t\trouting.HttpThrowStatus(http.StatusUnsupportedMediaType, res)\n\t\treturn\n\t}\n\n\tres.Header().Add(\"Content-Type\", contentType)\n\t_, err = io.Copy(res, f)\n\n\tif err != nil {\n\t\tcon.PublicLogger.Write(path + \"::\" + strconv.Itoa(http.StatusInternalServerError) + \"::\" + err.Error())\n\t\trouting.HttpThrowStatus(http.StatusInternalServerError, res)\n\t\treturn\n\t}\n\n\telapsedTime := time.Since(startTime)\n\tcon.LoadTimeLogger.Write(path + \" rendered in \" + strconv.FormatFloat(elapsedTime.Seconds(), 'f', 6, 64) + \" seconds\")\n}","func (b *Builder) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\tb.mux.ServeHTTP(w, req)\n}","func ServeHTTP(w http.ResponseWriter, r *http.Request, h HandlerFunc) error {\n\theaderSaver := saveHeaders(w.Header())\n\theaderHop := MakeHeaderHop()\n\n\theaderHop.Del(r.Header)\n\n\tlog.Printf(\"recv a requests to proxy to: %s\", r.RemoteAddr)\n\n\tif err := h(w, r); err != nil {\n\t\tlog.Printf(\"could not proxy: %v\\n\", err)\n\t\treturn err\n\t}\n\n\t// response to client\n\theaderHop.Del(w.Header())\n\theaderSaver.set(&r.Header)\n\n\treturn nil\n}","func (m *Module) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\n\t// Create a context from the response and request\n\tctx := newContext(w, r)\n\n\t// Serve the app using the new context\n\tm.Serve(ctx)\n}","func (s *StaticDataElement) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tswitch r.Method {\n\tcase \"GET\":\n\t\tfallthrough\n\tcase \"HEAD\":\n\t\tw.Header().Set(\"Last-Modified\", s.Time().UTC().Format(http.TimeFormat))\n\t\tif ims := r.Header.Get(\"If-Modified-Since\"); ims != \"\" {\n\t\t\tif t, e := time.Parse(http.TimeFormat, ims); e == nil && !t.Before(s.Time()) {\n\t\t\t\tw.WriteHeader(http.StatusNotModified)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tif r.Method == \"GET\" {\n\t\t\tw.Header().Set(\"Content-type\", s.Mime)\n\t\t\t_, _ = w.Write(s.Data)\n\t\t}\n\t\treturn\n\tcase \"POST\":\n\t\tw.Header().Set(\"Allow\", \"Get\")\n\t\tw.Header().Add(\"Allow\", \"Head\")\n\t\tw.WriteHeader(http.StatusMethodNotAllowed)\n\tdefault:\n\t\tw.WriteHeader(http.StatusNotImplemented)\n\t\treturn\n\t}\n\treturn\n}","func (s *Server) HTTPServe() {\n\tvar prf interface {\n\t\tStop()\n\t}\n\n\t// We want to make sure the profile is stopped\n\t// exactly once (and only once), even if the\n\t// shutdown pre-hook does not run (which it may not)\n\tprofileStopOnce := sync.Once{}\n\n\tif s.enableProfiling {\n\t\tprofileStartOnce.Do(func() {\n\t\t\tprf = profile.Start()\n\t\t})\n\n\t\tdefer func() {\n\t\t\tprofileStopOnce.Do(prf.Stop)\n\t\t}()\n\t}\n\thttpSocket := bind.Socket(s.HTTPAddr)\n\tgraceful.Timeout(10 * time.Second)\n\tgraceful.PreHook(func() {\n\n\t\tif prf != nil {\n\t\t\tprofileStopOnce.Do(prf.Stop)\n\t\t}\n\n\t\ts.logger.Info(\"Terminating HTTP listener\")\n\t})\n\n\t// Ensure that the server responds to SIGUSR2 even\n\t// when *not* running under einhorn.\n\tgraceful.AddSignal(syscall.SIGUSR2, syscall.SIGHUP)\n\tgraceful.HandleSignals()\n\tgracefulSocket := graceful.WrapListener(httpSocket)\n\ts.logger.WithField(\"address\", s.HTTPAddr).Info(\"HTTP server listening\")\n\n\t// Signal that the HTTP server is starting\n\tatomic.AddInt32(s.numListeningHTTP, 1)\n\tdefer atomic.AddInt32(s.numListeningHTTP, -1)\n\tbind.Ready()\n\n\tif err := http.Serve(gracefulSocket, s.Handler()); err != nil {\n\t\ts.logger.WithError(err).Error(\"HTTP server shut down due to error\")\n\t}\n\ts.logger.Info(\"Stopped HTTP server\")\n\n\tgraceful.Shutdown()\n}","func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\tengine.handleHTTPRequest(w, req)\n}","func (s *RegistryServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\ts.muxer.ServeHTTP(w, r)\n}","func (h stubbingHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request) {\n\th.mutex.Lock()\n\tdefer h.mutex.Unlock()\n\tresponses := h.holder.responses\n\tif len(responses) > 0 {\n\t\tresp := responses[0]\n\t\tw.WriteHeader(resp.responseCode)\n\t\t_, err := w.Write([]byte(resp.body))\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Can't write the response: %v\", err)\n\t\t}\n\n\t\tswitch resp.times {\n\t\tcase 0:\n\t\t\tbreak\n\t\tcase 1:\n\t\t\tshortened := responses[1:]\n\t\t\th.holder.responses = shortened\n\t\tdefault:\n\t\t\tresp.times--\n\t\t}\n\t} else {\n\t\tw.WriteHeader(http.StatusNotFound)\n\t}\n}","func (m *Macross) ServeHTTP(ctx *fasthttp.RequestCtx) {\n\tc := m.AcquireContext()\n\tc.Reset(ctx)\n\tc.handlers, c.pnames = m.find(string(ctx.Method()), string(ctx.Path()), c.pvalues)\n\tif err := c.Next(); err != nil {\n\t\tm.HandleError(c, err)\n\t}\n\tm.ReleaseContext(c)\n}","func (h spaHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\n\tpath, err := filepath.Abs(r.URL.Path)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tpath = filepath.Join(h.staticPath, r.URL.Path)\n\n\t_, err = os.Stat(path)\n\tif os.IsNotExist(err) {\n\t\thttp.ServeFile(w, r, filepath.Join(h.staticPath, h.indexPath))\n\t\treturn\n\t} else if err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\thttp.FileServer(http.Dir(h.staticPath)).ServeHTTP(w, r)\n}","func (m *MockedNextHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tm.hasBeenCalled = true\n\tm.request = r\n\tw.Write([]byte(\"Next handler has been called\"))\n\tw.WriteHeader(200)\n}","func ServeSingleHTTP(w http.ResponseWriter, r *http.Request) {\n\tif !webMux.routesSetup {\n\t\tinitRoutes()\n\t}\n\n\t// Allow cross-origin resource sharing.\n\tw.Header().Add(\"Access-Control-Allow-Origin\", \"*\")\n\n\twebMux.ServeHTTP(w, r)\n}","func (c *Controller) serveHTTP(w http.ResponseWriter, req *http.Request) {\n\tif strings.Contains(req.URL.Path, mutateWebHook) {\n\t\tc.processMutateRequest(w, req)\n\t} else {\n\t\thttp.Error(w, \"Unsupported request\", http.StatusNotFound)\n\t}\n}","func (s *server) ServeHTTP(rw http.ResponseWriter, r *http.Request) {\n\t// Get request and response from the pool.\n\n\treq := s.requestPool.Get().(*Request)\n\tres := s.responsePool.Get().(*Response)\n\n\t// Tie the request body and the standard request body together.\n\n\tr.Body = &requestBody{\n\t\tr: req,\n\t\thr: r,\n\t\trc: r.Body,\n\t}\n\n\t// Reset the request.\n\n\treq.Air = s.a\n\treq.SetHTTPRequest(r)\n\treq.res = res\n\treq.params = req.params[:0]\n\treq.routeParamNames = nil\n\treq.routeParamValues = nil\n\treq.parseRouteParamsOnce = &sync.Once{}\n\treq.parseOtherParamsOnce = &sync.Once{}\n\tfor key := range req.values {\n\t\tdelete(req.values, key)\n\t}\n\n\treq.localizedString = nil\n\n\t// Reset the response.\n\n\tres.Air = s.a\n\tres.SetHTTPResponseWriter(&responseWriter{\n\t\tr: res,\n\t\trw: rw,\n\t})\n\tres.Status = http.StatusOK\n\tres.ContentLength = -1\n\tres.Written = false\n\tres.Minified = false\n\tres.Gzipped = false\n\tres.req = req\n\tres.ohrw = rw\n\tres.servingContent = false\n\tres.serveContentError = nil\n\tres.reverseProxying = false\n\tres.deferredFuncs = res.deferredFuncs[:0]\n\n\t// Chain the gases stack.\n\n\th := func(req *Request, res *Response) error {\n\t\th := s.a.router.route(req)\n\t\tfor i := len(s.a.Gases) - 1; i >= 0; i-- {\n\t\t\th = s.a.Gases[i](h)\n\t\t}\n\n\t\treturn h(req, res)\n\t}\n\n\t// Chain the pregases stack.\n\n\tfor i := len(s.a.Pregases) - 1; i >= 0; i-- {\n\t\th = s.a.Pregases[i](h)\n\t}\n\n\t// Execute the chain.\n\n\tif err := h(req, res); err != nil {\n\t\tif !res.Written && res.Status < http.StatusBadRequest {\n\t\t\tres.Status = http.StatusInternalServerError\n\t\t}\n\n\t\ts.a.ErrorHandler(err, req, res)\n\t}\n\n\t// Execute the deferred functions.\n\n\tfor i := len(res.deferredFuncs) - 1; i >= 0; i-- {\n\t\tres.deferredFuncs[i]()\n\t}\n\n\t// Put the route param values back to the pool.\n\n\tif req.routeParamValues != nil {\n\t\ts.a.router.routeParamValuesPool.Put(req.routeParamValues)\n\t}\n\n\t// Put the request and response back to the pool.\n\n\ts.requestPool.Put(req)\n\ts.responsePool.Put(res)\n}","func (p pair) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\t// Serve data with a method of http.ResponseWriter.\n\tw.Write([]byte(\"You learned Go in Y minutes!\"))\n}","func (t *staticTemplateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tif err := t.templ.Execute(w, t.data); err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n}","func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Cache-Control\", \"no-cache\")\n\tw.Header().Set(\"Vary\", \"Accept\")\n\n\tif !h.acceptable(r.Header.Get(\"Accept\")) {\n\t\tw.WriteHeader(http.StatusNotAcceptable)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"text/event-stream\")\n\tw.WriteHeader(http.StatusOK)\n\n\tvar stop <-chan bool\n\n\tif notifier, ok := w.(http.CloseNotifier); ok {\n\t\tstop = notifier.CloseNotify()\n\t}\n\n\th(r.Header.Get(\"Last-Event-Id\"), NewEncoder(w), stop)\n}","func (srv *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\tif srv.handler != nil {\n\t\tsrv.handler.ServeHTTP(w, req)\n\t\treturn\n\t}\n\tsrv.routes.ServeHTTP(w, req)\n}","func (a *Router) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tvar err error\n\tdefer func() {\n\t\tif x := recover(); x != nil {\n\t\t\terr = fmt.Errorf(\"ws: %v\", x)\n\t\t}\n\t\tfinally(w, err)\n\t}()\n\n\tpath := r.URL.Path\n\tif len(path) < 1 || path[0] != '/' {\n\t\tpath = \"/\" + path\n\t}\n\tif r.Method == http.MethodOptions && path == \"/*\" {\n\t\tw.Header().Add(\"Allow\", allAllow)\n\t\terr = Status(http.StatusOK, \"\")\n\t\treturn\n\t}\n\n\tctx := ctxPool.Get().(*Context)\n\tdefer ctxPool.Put(ctx)\n\tctx.Request = r\n\tctx.ResponseWriter = w\n\tctx.Path = path\n\tctx.code = 0\n\tctx.datas = make(map[string]interface{})\n\tctx.params = make(map[string]string)\n\tctx.querys = nil\n\tctx.router = a\n\tctx.index = -len(a.middlewares)\n\terr = ctx.Next()\n}","func (handler ShortURLForwardingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tdefer r.Body.Close()\n\tif r.Method == http.MethodPut {\n\t\thandler.handleAddingNewShortURL(w, r)\n\t} else {\n\t\thandler.handleGettingShortURL(w, r)\n\t}\n}","func (m *Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tctx := r.Context()\n\n\tsession, state, err := m.initializeSession(r)\n\tif err != nil {\n\t\tm.Logger.Printf(\"couldn't initialise session: %+v\", err)\n\t\thttp.Error(w, \"couldn't initialise session\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tctx = context.WithValue(ctx, ctxStateKey, state)\n\tr = r.WithContext(ctx)\n\n\terr = m.setupAccessToken(ctx, w, r)\n\tif err != nil {\n\t\t// Access token is not set in request\n\t\tm.Logger.Printf(\"couldn't setup access token: %+v\", err)\n\t}\n\n\twriter := &sessionWriter{\n\t\tsessionStore: m.SessionStore,\n\t\tsession: session,\n\t\tstate: state,\n\t\tlogger: m.Logger,\n\t\tr: r,\n\t\tResponseWriter: w,\n\t}\n\tm.mux.ServeHTTP(writer, r)\n}","func (l *httpHandler) ServeHTTP(response http.ResponseWriter, request *http.Request) {\n\turi := request.RequestURI\n\n\tif uri == \"\" || uri == \"/\" || uri == URIIndexPrefix {\n\t\tresponseServerList(response)\n\n\t\treturn\n\t}\n\n\tif strings.HasPrefix(uri, URIIndexPrefix+\"/\") {\n\t\tserverID := uri[len(URIIndexPrefix)+1:]\n\t\t_, ok := serverDB[serverID]\n\n\t\tif !ok {\n\t\t\tresponse.WriteHeader(http.StatusNotFound)\n\n\t\t\treturn\n\t\t}\n\n\t\trouteToServerIndex(response, serverID)\n\n\t\treturn\n\t}\n\n\ttailServerID := \"\"\n\tif uri == URITailPrefix {\n\t\ttailServerID = DefaultServerID\n\t} else if strings.HasPrefix(uri, URITailPrefix+\"/\") {\n\t\ttailServerID = uri[len(URITailPrefix)+1:]\n\t\tif _, ok := serverDB[tailServerID]; !ok {\n\t\t\tresponse.WriteHeader(http.StatusNotFound)\n\n\t\t\treturn\n\t\t}\n\t}\n\n\tif tailServerID != \"\" {\n\t\tstartWebsocketTransfer(response, request, tailServerID)\n\n\t\treturn\n\t}\n\n\tresponseServerList(response)\n}","func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\tr.HandleFunc(w, req)\n}","func (h spaHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n // get the absolute path to prevent directory traversal\n\tpath, err := filepath.Abs(r.URL.Path)\n\tif err != nil {\n // if we failed to get the absolute path respond with a 400 bad request\n // and stop\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n // prepend the path with the path to the static directory\n\tpath = filepath.Join(h.staticPath, path)\n\n // check whether a file exists at the given path\n\t_, err = os.Stat(path)\n\tif os.IsNotExist(err) {\n\t\t// file does not exist, serve index.html\n\t\thttp.ServeFile(w, r, filepath.Join(h.staticPath, h.indexPath))\n\t\treturn\n\t} else if err != nil {\n // if we got an error (that wasn't that the file doesn't exist) stating the\n // file, return a 500 internal server error and stop\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n // otherwise, use http.FileServer to serve the static dir\n\thttp.FileServer(http.Dir(h.staticPath)).ServeHTTP(w, r)\n}","func serveHTTP(value interface{}, w http.ResponseWriter, r *http.Request) bool {\n\tswitch fn := value.(type) {\n\tcase func(http.ResponseWriter, *http.Request):\n\t\tfn(w, r)\n\t\treturn true\n\t}\n\treturn false\n}","func (s Sample) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n fmt.Fprint(w, \"

Welcome to Go.Land Server!

\")\n}","func (h *Handler) serveServers(w http.ResponseWriter, r *http.Request) {}"],"string":"[\n \"func (mw *Stats) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {\\n\\tbeginning, recorder := mw.Begin(w)\\n\\n\\tnext(recorder, r)\\n\\n\\tmw.End(beginning, WithRecorder(recorder))\\n}\",\n \"func (f MiddlewareFunc) ServeHTTP(w http.ResponseWriter, r *http.Request, next func()) {\\n\\tf(w, r, next)\\n}\",\n \"func (m middleware) serve(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\\n\\tm.fn(w, r, ps, m.next.serve)\\n}\",\n \"func (mux *ServeMux) ServeHTTP(w ResponseWriter, r *Request)\",\n \"func (k *Kite) ServeHTTP(w http.ResponseWriter, req *http.Request) {\\n\\tk.muxer.ServeHTTP(w, req)\\n}\",\n \"func (s prodAssetServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {\\n\\touturl := *s.url\\n\\torigPath := req.URL.Path\\n\\tif !strings.HasPrefix(origPath, \\\"/static/\\\") {\\n\\t\\t// redirect everything to the main entry point.\\n\\t\\torigPath = \\\"index.html\\\"\\n\\t}\\n\\n\\touturl.Path = path.Join(outurl.Path, origPath)\\n\\toutreq, err := http.NewRequest(\\\"GET\\\", outurl.String(), bytes.NewBuffer(nil))\\n\\tif err != nil {\\n\\t\\tw.WriteHeader(http.StatusInternalServerError)\\n\\t\\t_, _ = w.Write([]byte(err.Error()))\\n\\t\\treturn\\n\\t}\\n\\n\\tcopyHeader(outreq.Header, req.Header)\\n\\toutres, err := http.DefaultClient.Do(outreq)\\n\\tif err != nil {\\n\\t\\tw.WriteHeader(http.StatusInternalServerError)\\n\\t\\t_, _ = w.Write([]byte(err.Error()))\\n\\t\\treturn\\n\\t}\\n\\n\\tdefer func() {\\n\\t\\t_ = outres.Body.Close()\\n\\t}()\\n\\n\\tcopyHeader(w.Header(), outres.Header)\\n\\tw.WriteHeader(outres.StatusCode)\\n\\t_, _ = io.Copy(w, outres.Body)\\n}\",\n \"func (sw *subware) serve(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\\n\\tsw.middleware.serve(w, r, ps)\\n}\",\n \"func (f HandlerFunc) ServeHttp(w ResponseWriter, r *Request){\\n f(w, r)\\n}\",\n \"func (s *ConcurrentServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\ts.router.ServeHTTP(w, r)\\n}\",\n \"func (w HandlerFuncWrapper) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {\\n\\tw(next)(rw, r)\\n}\",\n \"func (s *Server) serveHTTP(w http.ResponseWriter, r *http.Request) {\\n\\ts.HTTP.Handler.ServeHTTP(w, r)\\n}\",\n \"func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tif h.Skip(r) {\\n\\t\\th.Next.ServeHTTP(w, r)\\n\\t\\treturn\\n\\t}\\n\\tvar written int64\\n\\tvar status = -1\\n\\n\\twp := writerProxy{\\n\\t\\th: func() http.Header {\\n\\t\\t\\treturn w.Header()\\n\\t\\t},\\n\\t\\tw: func(bytes []byte) (int, error) {\\n\\t\\t\\tbw, err := w.Write(bytes)\\n\\t\\t\\twritten += int64(bw)\\n\\t\\t\\treturn bw, err\\n\\t\\t},\\n\\t\\twh: func(code int) {\\n\\t\\t\\tstatus = code\\n\\t\\t\\tw.WriteHeader(code)\\n\\t\\t},\\n\\t}\\n\\n\\tstart := time.Now()\\n\\th.Next.ServeHTTP(wp, r)\\n\\tduration := time.Now().Sub(start)\\n\\n\\t// Use default status.\\n\\tif status == -1 {\\n\\t\\tstatus = 200\\n\\t}\\n\\n\\th.Logger(r, status, written, duration)\\n}\",\n \"func (rh *RandomHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\t// Increment serveCounter every time we serve a page.\\n\\trh.serveCounter.Inc()\\n\\n\\tn := rand.Float64()\\n\\t// Track the cumulative values served.\\n\\trh.valueCounter.Add(n)\\n\\n\\tfmt.Fprintf(w, \\\"%v\\\", n)\\n}\",\n \"func (s *Service) serveHTTP() {\\n\\thandler := &Handler{\\n\\t\\tDatabase: s.Database,\\n\\t\\tRetentionPolicy: s.RetentionPolicy,\\n\\t\\tPointsWriter: s.PointsWriter,\\n\\t\\tLogger: s.Logger,\\n\\t\\tstats: s.stats,\\n\\t}\\n\\tsrv := &http.Server{Handler: handler}\\n\\tsrv.Serve(s.httpln)\\n}\",\n \"func (t Telemetry) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tt.rCount.Mark(1)\\n\\tsw := MakeLogger(w)\\n\\n\\tstart := time.Now()\\n\\tt.inner.ServeHTTP(sw, r)\\n\\tt.tmr.Update(int64(time.Since(start) / time.Millisecond))\\n\\n\\tif sw.Status() >= 300 {\\n\\t\\tt.fCount.Mark(1)\\n\\t} else {\\n\\t\\tt.sCount.Mark(1)\\n\\t}\\n\\n}\",\n \"func (w HandlerWrapper) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {\\n\\tw(next).ServeHTTP(rw, r)\\n}\",\n \"func (p *Proxy) ServeHTTP(w http.ResponseWriter, req *http.Request) {\\n\\tjob := p.stream.NewJob(\\\"proxy.serve\\\")\\n\\n\\t// Add headers\\n\\tfor key, vals := range p.lastResponseHeaders {\\n\\t\\tfor _, val := range vals {\\n\\t\\t\\tw.Header().Set(key, val)\\n\\t\\t}\\n\\t}\\n\\tw.Header().Set(\\\"X-OpenBazaar\\\", \\\"Trade free!\\\")\\n\\n\\t// Write body\\n\\t_, err := w.Write(p.lastResponseBody)\\n\\tif err != nil {\\n\\t\\tjob.EventErr(\\\"write\\\", err)\\n\\t\\tjob.Complete(health.Error)\\n\\t}\\n\\n\\tjob.Complete(health.Success)\\n}\",\n \"func (t *Timer) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tdefer t.UpdateSince(time.Now())\\n\\tt.handler.ServeHTTP(w, r)\\n}\",\n \"func (s static) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\ts.handler.ServeHTTP(w, r)\\n}\",\n \"func (h HandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\th(context.TODO(), w, r)\\n}\",\n \"func serveHTTP(c *RequestContext, w http.ResponseWriter, r *http.Request) (int, error) {\\n\\t// Checks if the URL contains the baseURL and strips it. Otherwise, it just\\n\\t// returns a 404 error because we're not supposed to be here!\\n\\tp := strings.TrimPrefix(r.URL.Path, c.FM.BaseURL)\\n\\n\\tif len(p) >= len(r.URL.Path) && c.FM.BaseURL != \\\"\\\" {\\n\\t\\treturn http.StatusNotFound, nil\\n\\t}\\n\\n\\tr.URL.Path = p\\n\\n\\t// Check if this request is made to the service worker. If so,\\n\\t// pass it through a template to add the needed variables.\\n\\tif r.URL.Path == \\\"/sw.js\\\" {\\n\\t\\treturn renderFile(\\n\\t\\t\\tw,\\n\\t\\t\\tc.FM.assets.MustString(\\\"sw.js\\\"),\\n\\t\\t\\t\\\"application/javascript\\\",\\n\\t\\t\\tc,\\n\\t\\t)\\n\\t}\\n\\n\\t// Checks if this request is made to the static assets folder. If so, and\\n\\t// if it is a GET request, returns with the asset. Otherwise, returns\\n\\t// a status not implemented.\\n\\tif matchURL(r.URL.Path, \\\"/static\\\") {\\n\\t\\tif r.Method != http.MethodGet {\\n\\t\\t\\treturn http.StatusNotImplemented, nil\\n\\t\\t}\\n\\n\\t\\treturn staticHandler(c, w, r)\\n\\t}\\n\\n\\t// Checks if this request is made to the API and directs to the\\n\\t// API handler if so.\\n\\tif matchURL(r.URL.Path, \\\"/api\\\") {\\n\\t\\tr.URL.Path = strings.TrimPrefix(r.URL.Path, \\\"/api\\\")\\n\\t\\treturn apiHandler(c, w, r)\\n\\t}\\n\\n\\t// Any other request should show the index.html file.\\n\\tw.Header().Set(\\\"x-frame-options\\\", \\\"SAMEORIGIN\\\")\\n\\tw.Header().Set(\\\"x-content-type\\\", \\\"nosniff\\\")\\n\\tw.Header().Set(\\\"x-xss-protection\\\", \\\"1; mode=block\\\")\\n\\n\\treturn renderFile(\\n\\t\\tw,\\n\\t\\tc.FM.assets.MustString(\\\"index.html\\\"),\\n\\t\\t\\\"text/html\\\",\\n\\t\\tc,\\n\\t)\\n}\",\n \"func (h TestServerHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {\\n\\twriter.WriteHeader(h.StatusCode)\\n\\twriter.Header().Add(\\\"Content-Type\\\", \\\"text/plain\\\")\\n\\t_, _ = writer.Write([]byte(h.Content))\\n}\",\n \"func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) {\\n\\tf(w, r)\\n}\",\n \"func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) {\\n\\tf(w, r)\\n}\",\n \"func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) {\\n\\tf(w, r)\\n}\",\n \"func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) {\\n\\tf(w, r)\\n}\",\n \"func (b *backend) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n}\",\n \"func (m hotdog) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprintln(w, \\\"Any code in this func\\\")\\n}\",\n \"func (es *EventSource) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tvar startID int\\n\\tif start := r.Header.Get(\\\"Last-Event-ID\\\"); start != \\\"\\\" {\\n\\t\\tif _, err := fmt.Sscanf(start, \\\"%d\\\", &startID); err != nil {\\n\\t\\t\\thttp.Error(w, \\\"bad Last-Event-ID\\\", http.StatusBadRequest)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tstartID++\\n\\t}\\n\\n\\tw.Header().Set(\\\"Content-Type\\\", ContentType)\\n\\tw.Header().Set(\\\"Connection\\\", \\\"keep-alive\\\")\\n\\tw.Header().Set(\\\"Cache-Control\\\", \\\"no-cache\\\")\\n\\tw.Header().Set(\\\"Transfer-Encoding\\\", \\\"chunked\\\")\\n\\tw.WriteHeader(200)\\n\\n\\tflusher, ok := w.(http.Flusher)\\n\\tif !ok {\\n\\t\\tpanic(\\\"esource: ServeHTTP called without a Flusher\\\")\\n\\t}\\n\\n\\tlog.Printf(\\\"esource: [%s] starting stream\\\", r.RemoteAddr)\\n\\n\\told, events := es.Tee(startID)\\n\\tfor _, event := range old {\\n\\t\\tif _, err := event.WriteTo(w); err != nil {\\n\\t\\t\\tlog.Printf(\\\"esource: [%s] failed to write backlogged event %+v\\\", r.RemoteAddr, event)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t}\\n\\tflusher.Flush()\\n\\n\\tfor event := range events {\\n\\t\\tif _, err := event.WriteTo(w); err != nil {\\n\\t\\t\\tlog.Printf(\\\"esource: [%s] failed to write event %+v\\\", r.RemoteAddr, event)\\n\\t\\t\\tfmt.Fprintln(w, \\\"\\\\nretry: 0\\\\n\\\")\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tflusher.Flush()\\n\\t}\\n\\n\\tlog.Printf(\\\"esource: [%s] complete\\\", r.RemoteAddr)\\n}\",\n \"func (hw *CtxHandlerWraper) ServeHTTP(ctx context.Context, w http.ResponseWriter, req *http.Request) error {\\n\\treturn hw.Func(ctx, w, req)\\n}\",\n \"func (s *ServeSeq) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\ti := &intrespwriter{parent: w, written: false}\\n\\tfor idx, h := range s.handlers {\\n\\t\\ti.canskip = (idx != len(s.handlers)-1)\\n\\t\\ti.skip = false\\n\\t\\th.ServeHTTP(i, r)\\n\\t\\tif i.written {\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t}\\n}\",\n \"func (f HandlerFunc) ServeHTTP(ctx *Context) {\\n\\tf(ctx)\\n}\",\n \"func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request) {\\n\\ts.Handler.ServeHTTP(res, req)\\n}\",\n \"func (ot *openTelemetryWrapper) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error {\\n\\tn := &nextCall{\\n\\t\\tnext: next,\\n\\t\\terr: nil,\\n\\t}\\n\\tot.handler.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), nextCallCtxKey, n)))\\n\\n\\treturn n.err\\n}\",\n \"func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {\\n\\ts.Router().ServeHTTP(context.Wrap(w), req)\\n}\",\n \"func (ot *openTelemetryWrapper) serveHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tctx := r.Context()\\n\\tot.propagators.Inject(ctx, propagation.HeaderCarrier(r.Header))\\n\\tspanCtx := trace.SpanContextFromContext(ctx)\\n\\tif spanCtx.IsValid() {\\n\\t\\tif extra, ok := ctx.Value(caddyhttp.ExtraLogFieldsCtxKey).(*caddyhttp.ExtraLogFields); ok {\\n\\t\\t\\textra.Add(zap.String(\\\"traceID\\\", spanCtx.TraceID().String()))\\n\\t\\t}\\n\\t}\\n\\tnext := ctx.Value(nextCallCtxKey).(*nextCall)\\n\\tnext.err = next.next.ServeHTTP(w, r)\\n}\",\n \"func (m *RegExpMux) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n}\",\n \"func (handler Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Printf(\\\"%s %s %s\\\\n\\\", r.RemoteAddr, r.Method, r.URL.Path)\\n\\tt1 := time.Now()\\n\\thandler.store.ExpireSessions()\\n\\treq := newReqImpl(w, r, handler.store)\\n\\thandler.serve(req)\\n\\tif req.html != \\\"\\\" {\\n\\t\\tio.WriteString(w, req.html)\\n\\t} else if req.template != \\\"\\\" {\\n\\t\\tt := template.New(\\\"\\\").Funcs(handler.funcmap)\\n\\t\\tt, err := t.ParseGlob(handler.templatePattern)\\n\\t\\tif err != nil {\\n\\t\\t\\tpanic(err)\\n\\t\\t}\\n\\t\\terr = t.ExecuteTemplate(w, req.template, req.model)\\n\\t\\tif err != nil {\\n\\t\\t\\tpanic(err)\\n\\t\\t}\\n\\t} else if req.redirect != \\\"\\\" {\\n\\t\\thttp.Redirect(w, r, req.redirect, http.StatusFound)\\n\\t} else if req.status != 0 {\\n\\t\\tmsg := http.StatusText(req.status)\\n\\t\\thttp.Error(w, msg, req.status)\\n\\t} else {\\n\\t\\tio.WriteString(w, \\\"no result\\\")\\n\\t}\\n\\td := time.Since(t1)\\n\\tfmt.Printf(\\\"%s %s %s - %f s\\\\n\\\", r.RemoteAddr, r.Method, r.URL.Path, float64(d)/1e9)\\n}\",\n \"func (mx *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tmx.ServeHTTPContext(w, r, nil)\\n}\",\n \"func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tpanic(fmt.Sprintf(\\\"httpx: ServeHTTP called on %v\\\", h))\\n}\",\n \"func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tpanic(fmt.Sprintf(\\\"httpx: ServeHTTP called on %v\\\", h))\\n}\",\n \"func (f *Forwarder) ServeHTTP(w http.ResponseWriter, req *http.Request) {\\n\\tif f.log.GetLevel() >= log.DebugLevel {\\n\\t\\tlogEntry := f.log.WithField(\\\"Request\\\", utils.DumpHttpRequest(req))\\n\\t\\tlogEntry.Debug(\\\"vulcand/oxy/forward: begin ServeHttp on request\\\")\\n\\t\\tdefer logEntry.Debug(\\\"vulcand/oxy/forward: completed ServeHttp on request\\\")\\n\\t}\\n\\n\\tif f.stateListener != nil {\\n\\t\\tf.stateListener(req.URL, StateConnected)\\n\\t\\tdefer f.stateListener(req.URL, StateDisconnected)\\n\\t}\\n\\tif IsWebsocketRequest(req) {\\n\\t\\tf.httpForwarder.serveWebSocket(w, req, f.handlerContext)\\n\\t} else {\\n\\t\\tf.httpForwarder.serveHTTP(w, req, f.handlerContext)\\n\\t}\\n}\",\n \"func (serv *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {\\n\\tc := serv.pool.Get().(*Context)\\n\\tc.reset(w, req)\\n\\n\\tserv.handleHTTPRequest(c)\\n\\n\\tserv.pool.Put(c)\\n}\",\n \"func (c *PingMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next traffic.NextMiddlewareFunc) (http.ResponseWriter, *http.Request) {\\n if r.URL.Path == \\\"/ping\\\" {\\n fmt.Fprint(w, \\\"pong\\\\n\\\")\\n\\n return w, r\\n }\\n\\n if nextMiddleware := next(); nextMiddleware != nil {\\n arw := w.(*traffic.AppResponseWriter)\\n arw.SetVar(\\\"ping\\\", \\\"pong\\\")\\n w, r = nextMiddleware.ServeHTTP(w, r, next)\\n }\\n\\n return w, r\\n}\",\n \"func (m *metricsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tm.Handler.ServeHTTP(w, r)\\n}\",\n \"func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\ts.mux.ServeHTTP(w, r)\\n}\",\n \"func (h HttpHandlerPipe) ServeHttpPipe(w ResponseWriter, r *http.Request, f *Pipeline) {\\n\\th.ServeHTTP(w, r)\\n\\tf.Next(w, r)\\n}\",\n \"func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {\\n\\tses := newSession(w, req)\\n\\ts.Sessions <- ses\\n\\t<-ses.end\\n}\",\n \"func (p *Proxy) HTTPServe() {\\n\\tvar prf interface {\\n\\t\\tStop()\\n\\t}\\n\\n\\t// We want to make sure the profile is stopped\\n\\t// exactly once (and only once), even if the\\n\\t// shutdown pre-hook does not run (which it may not)\\n\\tprofileStopOnce := sync.Once{}\\n\\n\\tif p.enableProfiling {\\n\\t\\tprofileStartOnce.Do(func() {\\n\\t\\t\\tprf = profile.Start()\\n\\t\\t})\\n\\n\\t\\tdefer func() {\\n\\t\\t\\tprofileStopOnce.Do(prf.Stop)\\n\\t\\t}()\\n\\t}\\n\\thttpSocket := bind.Socket(p.HTTPAddr)\\n\\tgraceful.Timeout(10 * time.Second)\\n\\tgraceful.PreHook(func() {\\n\\n\\t\\tif prf != nil {\\n\\t\\t\\tprofileStopOnce.Do(prf.Stop)\\n\\t\\t}\\n\\n\\t\\tlog.Info(\\\"Terminating HTTP listener\\\")\\n\\t})\\n\\n\\t// Ensure that the server responds to SIGUSR2 even\\n\\t// when *not* running under einhorn.\\n\\tgraceful.AddSignal(syscall.SIGUSR2, syscall.SIGHUP)\\n\\tgraceful.HandleSignals()\\n\\tgracefulSocket := graceful.WrapListener(httpSocket)\\n\\tlog.WithField(\\\"address\\\", p.HTTPAddr).Info(\\\"HTTP server listening\\\")\\n\\n\\t// Signal that the HTTP server is listening\\n\\tatomic.AddInt32(p.numListeningHTTP, 1)\\n\\tdefer atomic.AddInt32(p.numListeningHTTP, -1)\\n\\tbind.Ready()\\n\\n\\tif err := http.Serve(gracefulSocket, p.Handler()); err != nil {\\n\\t\\tlog.WithError(err).Error(\\\"HTTP server shut down due to error\\\")\\n\\t}\\n\\tlog.Info(\\\"Stopped HTTP server\\\")\\n\\n\\tgraceful.Shutdown()\\n}\",\n \"func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {\\n\\ts.router.ServeHTTP(w, req)\\n}\",\n \"func serveHTTP(ech chan<- error, addr string) {\\n\\tif \\\"\\\" == addr || NO == addr {\\n\\t\\treturn\\n\\t}\\n\\t/* Listen */\\n\\tl, err := net.Listen(\\\"tcp\\\", addr)\\n\\tif nil != err {\\n\\t\\tech <- err\\n\\t\\treturn\\n\\t}\\n\\tlog.Printf(\\\"Serving HTTP requests on %v\\\", l.Addr())\\n\\t/* Serve */\\n\\tech <- http.Serve(l, nil)\\n}\",\n \"func (m hotdog) ServeHTTP(w http.ResponseWriter, req *http.Request) {\\n\\tfmt.Fprintln(w,\\\"My power code here!\\\")\\n}\",\n \"func (a anything) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprintln(w, \\\"Any code you want in this func\\\")\\n}\",\n \"func (e *Exporter) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\te.handler.ServeHTTP(w, r)\\n}\",\n \"func (engine *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tc := engine.pool.Get().(*Context)\\n\\tc.writermem.reset(w)\\n\\tc.Request = r\\n\\tc.reset()\\n\\n\\tengine.handleHTTPRequest(c)\\n\\n\\tengine.pool.Put(c)\\n}\",\n \"func (i indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tlog.Printf(\\\"You are all my minions, %v, beware %v, %v!\\\\n\\\", r.RemoteAddr, r.Method, r.URL)\\n\\tif r.URL.Path != \\\"/\\\" {\\n\\t\\tlog.Printf(\\\"Sirree, this is a wrong URL path: %v!\\\\n\\\", r.URL.Path)\\n\\t\\tw.WriteHeader(http.StatusNotFound)\\n\\t\\tfmt.Fprintf(w, i.pageNotFound)\\n\\t\\treturn\\n\\t}\\n\\tif r.Method != \\\"GET\\\" {\\n\\t\\tlog.Printf(\\\"Madam, the method thou art using is wrong: %v!\\\\n\\\", r.Method)\\n\\t\\tw.WriteHeader(http.StatusBadRequest)\\n\\t\\tfmt.Fprintf(w, i.pageBadRequest)\\n\\t\\treturn\\n\\t}\\n\\tdata := pageData{\\n\\t\\tTitle: \\\"Welcome\\\",\\n\\t\\tVersion: fmt.Sprintf(\\\"This is version %v\\\", i.version),\\n\\t}\\n\\tif err := i.tmpl.Execute(w, data); err != nil {\\n\\t\\tpanic(err)\\n\\t}\\n}\",\n \"func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tt := time.Now()\\n\\tww := buildLoggingWriter(w)\\n\\tif h.serveHTTP(ww, r) {\\n\\t\\tww.LogAccess(r, time.Now().Sub(t))\\n\\t}\\n}\",\n \"func (s *SimpleStaticFilesServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tif s.testMode && strings.HasPrefix(r.URL.String(), GOPATH_PREFIX) {\\n\\t\\tGopathLookup(w, r, strings.TrimPrefix(r.URL.String(), GOPATH_PREFIX))\\n\\t\\treturn\\n\\t}\\n\\tlog.Printf(\\\"[STATIC CONTENT (%s)]: %v\\\", s.staticDir, r.URL.String())\\n\\ts.fs.ServeHTTP(w, r)\\n}\",\n \"func (a *Application) ServeHTTP(w http.ResponseWriter, req *http.Request) {\\n\\t// log all unhandled panic's\\n\\t// todo: check performance impact\\n\\tdefer func() {\\n\\t\\tif r := recover(); r != nil {\\n\\t\\t\\ta.Emit(\\\"error\\\", r)\\n\\t\\t\\tpanic(r)\\n\\t\\t}\\n\\t}()\\n\\n\\tctx := makeCtx(req, w)\\n\\trequest := ctx.Req\\n\\tresponse := ctx.Res\\n\\n\\tdefer response.flush()\\n\\n\\t///////////////////////////////////////////////////////////////////\\n\\t// Catch Neo Assertions\\n\\t///////////////////////////////////////////////////////////////////\\n\\tdefer func() {\\n\\t\\tif r := recover(); r != nil {\\n\\t\\t\\terr, ok := r.(*NeoAssertError)\\n\\n\\t\\t\\tif ok {\\n\\t\\t\\t\\tresponse.Raw(err.message, err.status)\\n\\t\\t\\t\\ta.Emit(\\\"error\\\", r)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\t// bubble panic\\n\\t\\t\\t\\tpanic(r)\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}()\\n\\n\\t///////////////////////////////////////////////////////////////////\\n\\t// Static File Serving\\n\\t///////////////////////////////////////////////////////////////////\\n\\tif a.static != nil {\\n\\t\\t// check if file can be served\\n\\t\\tfile, err := a.static.match(req.URL.Path)\\n\\n\\t\\tif err == nil {\\n\\t\\t\\th := func(ctx *Ctx) {\\n\\t\\t\\t\\tresponse.skipFlush()\\n\\t\\t\\t\\tresponse.serveFile(file)\\n\\t\\t\\t}\\n\\n\\t\\t\\tfn := compose(merge(a.middlewares, []appliable{handler(h)}))\\n\\t\\t\\tfn(ctx)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\n\\t\\tlog.Debug(\\\"result not found in static\\\")\\n\\t}\\n\\n\\t///////////////////////////////////////////////////////////////////\\n\\t// Route Matching\\n\\t///////////////////////////////////////////////////////////////////\\n\\troute, err := a.match(request)\\n\\n\\tif err != nil {\\n\\t\\tlog.Debugf(\\\"route %s not found\\\", req.URL.Path)\\n\\n\\t\\t// dummy route handler\\n\\t\\th := func(ctx *Ctx) {\\n\\t\\t\\tresponse.Status = http.StatusNotFound\\n\\t\\t}\\n\\n\\t\\tcompose(merge(a.middlewares, []appliable{handler(h)}))(ctx)\\n\\t} else {\\n\\t\\troute.fnChain(ctx)\\n\\t}\\n}\",\n \"func (s Thumbnails) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\ts.mux.ServeHTTP(w, r)\\n}\",\n \"func (h *Handler) ServeHTTP(ctx context.Context, event cloudevents.Event, resp *cloudevents.EventResponse) error {\\n\\t// Hand work off to the current multi channel fanout handler.\\n\\th.logger.Debug(\\\"ServeHTTP request received\\\")\\n\\treturn h.getMultiChannelFanoutHandler().ServeHTTP(ctx, event, resp)\\n}\",\n \"func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\ts.router.ServeHTTP(w, r)\\n}\",\n \"func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\ts.router.ServeHTTP(w, r)\\n}\",\n \"func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\ts.router.ServeHTTP(w, r)\\n}\",\n \"func (m *Module) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\n\\t// Create a context from the response and request\\n\\tctx := web.NewContext(w, r)\\n\\n\\t// Serve the app using the new context\\n\\tm.Serve(ctx)\\n}\",\n \"func (self *Direct) ServeHTTP(w http.ResponseWriter, r *http.Request) (err error) {\\n\\tif r.Method == \\\"CONNECT\\\" {\\n\\t\\tglog.Println(\\\"this function can not handle CONNECT method\\\")\\n\\t\\thttp.Error(w, r.Method, http.StatusMethodNotAllowed)\\n\\t\\treturn\\n\\t}\\n\\tstart := time.Now()\\n\\n\\t// Client.Do is different from DefaultTransport.RoundTrip ...\\n\\t// Client.Do will change some part of request as a new request of the server.\\n\\t// The underlying RoundTrip never changes anything of the request.\\n\\tresp, err := self.Tr.RoundTrip(r)\\n\\tif err != nil {\\n\\t\\tif nerr, ok := err.(net.Error); ok && nerr.Timeout() {\\n\\t\\t\\tglog.Errorf(\\\"RoundTrip: %s, reproxy...\\\\n\\\", err.Error())\\n\\t\\t\\terr = ErrShouldProxy\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tglog.Errorf(\\\"RoundTrip: %s\\\\n\\\", err.Error())\\n\\t\\treturn\\n\\t}\\n\\tdefer resp.Body.Close()\\n\\n\\t// please prepare header first and write them\\n\\tCopyHeader(w, resp)\\n\\tw.WriteHeader(resp.StatusCode)\\n\\n\\tn, err := io.Copy(w, resp.Body)\\n\\tif err != nil {\\n\\t\\tglog.Printf(\\\"Copy: %s\\\", err.Error())\\n\\t\\thttp.Error(w, err.Error(), http.StatusInternalServerError)\\n\\t\\treturn\\n\\t}\\n\\n\\td := BeautifyDuration(time.Since(start))\\n\\tndtos := BeautifySize(n)\\n\\tglog.Infof(\\\"RESPONSE %s %s in %s <-%s\\\", r.URL.Host, resp.Status, d, ndtos)\\n\\treturn\\n}\",\n \"func (h httpHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {\\n\\tl := h.logger\\n\\tp := newPrinter(l)\\n\\tdefer p.flush()\\n\\n\\tif hide := req.Context().Value(contextHide{}); hide != nil || p.checkFilter(req) {\\n\\t\\th.next.ServeHTTP(w, req)\\n\\t\\treturn\\n\\t}\\n\\n\\tif p.logger.Time {\\n\\t\\tdefer p.printTimeRequest()()\\n\\t}\\n\\n\\tif !p.logger.SkipRequestInfo {\\n\\t\\tp.printRequestInfo(req)\\n\\t}\\n\\n\\tif p.logger.TLS {\\n\\t\\tp.printTLSInfo(req.TLS, true)\\n\\t\\tp.printIncomingClientTLS(req.TLS)\\n\\t}\\n\\n\\tp.printRequest(req)\\n\\n\\trec := &responseRecorder{\\n\\t\\tResponseWriter: w,\\n\\n\\t\\tstatusCode: http.StatusOK,\\n\\n\\t\\tmaxReadableBody: l.MaxResponseBody,\\n\\t\\tbuf: &bytes.Buffer{},\\n\\t}\\n\\n\\tdefer p.printServerResponse(req, rec)\\n\\th.next.ServeHTTP(rec, req)\\n}\",\n \"func (h *SubscribeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tvar index, err = strconv.Atoi(r.Header.Get(\\\"Last-Event-ID\\\"))\\n\\tif r.Header.Get(\\\"Last-Event-ID\\\") != \\\"\\\" {\\n\\t\\tif err != nil {\\n\\t\\t\\thttp.Error(w, err.Error(), http.StatusBadRequest)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tindex += 1\\n\\t}\\n\\n\\t// Create a channel for subscribing to database updates.\\n\\tch := h.db.Subscribe(index)\\n\\tcloseNotifier := w.(http.CloseNotifier).CloseNotify()\\n\\n\\t// Mark this as an SSE event stream.\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"text/event-stream\\\")\\n\\n\\t// Continually stream updates as they come.\\nloop:\\n\\tfor {\\n\\t\\tselect {\\n\\t\\tcase <-closeNotifier:\\n\\t\\t\\tbreak loop\\n\\n\\t\\tcase row := <-ch:\\n\\t\\t\\t// Encode row as JSON.\\n\\t\\t\\tb, err := json.Marshal(row)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\thttp.Error(w, err.Error(), http.StatusInternalServerError)\\n\\t\\t\\t\\tbreak loop\\n\\t\\t\\t}\\n\\n\\t\\t\\t// Send row as server-sent event.\\n\\t\\t\\tfmt.Fprintf(w, \\\"id: %d\\\\n\\\", row.Index())\\n\\t\\t\\tfmt.Fprintf(w, \\\"data: %s\\\\n\\\\n\\\", b)\\n\\t\\t\\tw.(http.Flusher).Flush()\\n\\t\\t}\\n\\t}\\n\\n\\t// Unsubscribe from the database when the connection is lost.\\n\\th.db.Unsubscribe(ch)\\n}\",\n \"func (avd avocado) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprint(w, \\\"brought you by a handler\\\")\\n}\",\n \"func (s *server) ServeHTTP(rw http.ResponseWriter, r *http.Request) {\\n\\ts.router.ServeHTTP(rw, r)\\n}\",\n \"func (t *Tunnel) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tt.proxy.ServeHTTP(w, r)\\n}\",\n \"func (_m *MockHandler) ServeHTTP(_a0 http.ResponseWriter, _a1 *http.Request) {\\n\\t_m.Called(_a0, _a1)\\n}\",\n \"func (con *Controller) ServeHTTP(res http.ResponseWriter, req *http.Request) {\\n\\tstartTime := time.Now()\\n\\n\\tswitch con.Status {\\n\\tcase 0: // This will actually never show because this function won't run if the server is off\\n\\t\\thttp.Error(res, \\\"The server is currently down and not serving requests.\\\", http.StatusServiceUnavailable)\\n\\t\\treturn\\n\\tcase 1: // Normal\\n\\t\\tbreak\\n\\tcase 2: // Maintenance mode\\n\\t\\thttp.Error(res, \\\"The server is currently maintenance mode and not serving requests.\\\", http.StatusServiceUnavailable)\\n\\t\\treturn\\n\\tcase 3: // This will actually never show because this function won't run if the server is off\\n\\t\\thttp.Error(res, \\\"The server is currently restarting.\\\", http.StatusServiceUnavailable)\\n\\t\\treturn\\n\\t}\\n\\n\\tpath := req.URL.Path[1:]\\n\\tif len(path) == 0 {\\n\\t\\tpath = (con.DocumentRoot + \\\"index.html\\\")\\n\\t} else {\\n\\t\\tpath = (con.DocumentRoot + path)\\n\\t}\\n\\n\\tf, err := os.Open(path)\\n\\n\\tif err != nil {\\n\\t\\tcon.PublicLogger.Write(path + \\\"::\\\" + strconv.Itoa(http.StatusNotFound) + \\\"::\\\" + err.Error())\\n\\t\\trouting.HttpThrowStatus(http.StatusNotFound, res)\\n\\t\\treturn\\n\\t}\\n\\n\\tcontentType, err := routing.GetContentType(path)\\n\\n\\tif err != nil {\\n\\t\\tcon.PublicLogger.Write(path + \\\"::\\\" + strconv.Itoa(http.StatusUnsupportedMediaType) + \\\"::\\\" + err.Error())\\n\\t\\trouting.HttpThrowStatus(http.StatusUnsupportedMediaType, res)\\n\\t\\treturn\\n\\t}\\n\\n\\tres.Header().Add(\\\"Content-Type\\\", contentType)\\n\\t_, err = io.Copy(res, f)\\n\\n\\tif err != nil {\\n\\t\\tcon.PublicLogger.Write(path + \\\"::\\\" + strconv.Itoa(http.StatusInternalServerError) + \\\"::\\\" + err.Error())\\n\\t\\trouting.HttpThrowStatus(http.StatusInternalServerError, res)\\n\\t\\treturn\\n\\t}\\n\\n\\telapsedTime := time.Since(startTime)\\n\\tcon.LoadTimeLogger.Write(path + \\\" rendered in \\\" + strconv.FormatFloat(elapsedTime.Seconds(), 'f', 6, 64) + \\\" seconds\\\")\\n}\",\n \"func (b *Builder) ServeHTTP(w http.ResponseWriter, req *http.Request) {\\n\\tb.mux.ServeHTTP(w, req)\\n}\",\n \"func ServeHTTP(w http.ResponseWriter, r *http.Request, h HandlerFunc) error {\\n\\theaderSaver := saveHeaders(w.Header())\\n\\theaderHop := MakeHeaderHop()\\n\\n\\theaderHop.Del(r.Header)\\n\\n\\tlog.Printf(\\\"recv a requests to proxy to: %s\\\", r.RemoteAddr)\\n\\n\\tif err := h(w, r); err != nil {\\n\\t\\tlog.Printf(\\\"could not proxy: %v\\\\n\\\", err)\\n\\t\\treturn err\\n\\t}\\n\\n\\t// response to client\\n\\theaderHop.Del(w.Header())\\n\\theaderSaver.set(&r.Header)\\n\\n\\treturn nil\\n}\",\n \"func (m *Module) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\n\\t// Create a context from the response and request\\n\\tctx := newContext(w, r)\\n\\n\\t// Serve the app using the new context\\n\\tm.Serve(ctx)\\n}\",\n \"func (s *StaticDataElement) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tswitch r.Method {\\n\\tcase \\\"GET\\\":\\n\\t\\tfallthrough\\n\\tcase \\\"HEAD\\\":\\n\\t\\tw.Header().Set(\\\"Last-Modified\\\", s.Time().UTC().Format(http.TimeFormat))\\n\\t\\tif ims := r.Header.Get(\\\"If-Modified-Since\\\"); ims != \\\"\\\" {\\n\\t\\t\\tif t, e := time.Parse(http.TimeFormat, ims); e == nil && !t.Before(s.Time()) {\\n\\t\\t\\t\\tw.WriteHeader(http.StatusNotModified)\\n\\t\\t\\t\\treturn\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tif r.Method == \\\"GET\\\" {\\n\\t\\t\\tw.Header().Set(\\\"Content-type\\\", s.Mime)\\n\\t\\t\\t_, _ = w.Write(s.Data)\\n\\t\\t}\\n\\t\\treturn\\n\\tcase \\\"POST\\\":\\n\\t\\tw.Header().Set(\\\"Allow\\\", \\\"Get\\\")\\n\\t\\tw.Header().Add(\\\"Allow\\\", \\\"Head\\\")\\n\\t\\tw.WriteHeader(http.StatusMethodNotAllowed)\\n\\tdefault:\\n\\t\\tw.WriteHeader(http.StatusNotImplemented)\\n\\t\\treturn\\n\\t}\\n\\treturn\\n}\",\n \"func (s *Server) HTTPServe() {\\n\\tvar prf interface {\\n\\t\\tStop()\\n\\t}\\n\\n\\t// We want to make sure the profile is stopped\\n\\t// exactly once (and only once), even if the\\n\\t// shutdown pre-hook does not run (which it may not)\\n\\tprofileStopOnce := sync.Once{}\\n\\n\\tif s.enableProfiling {\\n\\t\\tprofileStartOnce.Do(func() {\\n\\t\\t\\tprf = profile.Start()\\n\\t\\t})\\n\\n\\t\\tdefer func() {\\n\\t\\t\\tprofileStopOnce.Do(prf.Stop)\\n\\t\\t}()\\n\\t}\\n\\thttpSocket := bind.Socket(s.HTTPAddr)\\n\\tgraceful.Timeout(10 * time.Second)\\n\\tgraceful.PreHook(func() {\\n\\n\\t\\tif prf != nil {\\n\\t\\t\\tprofileStopOnce.Do(prf.Stop)\\n\\t\\t}\\n\\n\\t\\ts.logger.Info(\\\"Terminating HTTP listener\\\")\\n\\t})\\n\\n\\t// Ensure that the server responds to SIGUSR2 even\\n\\t// when *not* running under einhorn.\\n\\tgraceful.AddSignal(syscall.SIGUSR2, syscall.SIGHUP)\\n\\tgraceful.HandleSignals()\\n\\tgracefulSocket := graceful.WrapListener(httpSocket)\\n\\ts.logger.WithField(\\\"address\\\", s.HTTPAddr).Info(\\\"HTTP server listening\\\")\\n\\n\\t// Signal that the HTTP server is starting\\n\\tatomic.AddInt32(s.numListeningHTTP, 1)\\n\\tdefer atomic.AddInt32(s.numListeningHTTP, -1)\\n\\tbind.Ready()\\n\\n\\tif err := http.Serve(gracefulSocket, s.Handler()); err != nil {\\n\\t\\ts.logger.WithError(err).Error(\\\"HTTP server shut down due to error\\\")\\n\\t}\\n\\ts.logger.Info(\\\"Stopped HTTP server\\\")\\n\\n\\tgraceful.Shutdown()\\n}\",\n \"func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) {\\n\\tengine.handleHTTPRequest(w, req)\\n}\",\n \"func (s *RegistryServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\ts.muxer.ServeHTTP(w, r)\\n}\",\n \"func (h stubbingHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request) {\\n\\th.mutex.Lock()\\n\\tdefer h.mutex.Unlock()\\n\\tresponses := h.holder.responses\\n\\tif len(responses) > 0 {\\n\\t\\tresp := responses[0]\\n\\t\\tw.WriteHeader(resp.responseCode)\\n\\t\\t_, err := w.Write([]byte(resp.body))\\n\\t\\tif err != nil {\\n\\t\\t\\tfmt.Printf(\\\"Can't write the response: %v\\\", err)\\n\\t\\t}\\n\\n\\t\\tswitch resp.times {\\n\\t\\tcase 0:\\n\\t\\t\\tbreak\\n\\t\\tcase 1:\\n\\t\\t\\tshortened := responses[1:]\\n\\t\\t\\th.holder.responses = shortened\\n\\t\\tdefault:\\n\\t\\t\\tresp.times--\\n\\t\\t}\\n\\t} else {\\n\\t\\tw.WriteHeader(http.StatusNotFound)\\n\\t}\\n}\",\n \"func (m *Macross) ServeHTTP(ctx *fasthttp.RequestCtx) {\\n\\tc := m.AcquireContext()\\n\\tc.Reset(ctx)\\n\\tc.handlers, c.pnames = m.find(string(ctx.Method()), string(ctx.Path()), c.pvalues)\\n\\tif err := c.Next(); err != nil {\\n\\t\\tm.HandleError(c, err)\\n\\t}\\n\\tm.ReleaseContext(c)\\n}\",\n \"func (h spaHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\n\\tpath, err := filepath.Abs(r.URL.Path)\\n\\tif err != nil {\\n\\t\\thttp.Error(w, err.Error(), http.StatusBadRequest)\\n\\t\\treturn\\n\\t}\\n\\n\\tpath = filepath.Join(h.staticPath, r.URL.Path)\\n\\n\\t_, err = os.Stat(path)\\n\\tif os.IsNotExist(err) {\\n\\t\\thttp.ServeFile(w, r, filepath.Join(h.staticPath, h.indexPath))\\n\\t\\treturn\\n\\t} else if err != nil {\\n\\t\\thttp.Error(w, err.Error(), http.StatusInternalServerError)\\n\\t\\treturn\\n\\t}\\n\\n\\thttp.FileServer(http.Dir(h.staticPath)).ServeHTTP(w, r)\\n}\",\n \"func (m *MockedNextHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tm.hasBeenCalled = true\\n\\tm.request = r\\n\\tw.Write([]byte(\\\"Next handler has been called\\\"))\\n\\tw.WriteHeader(200)\\n}\",\n \"func ServeSingleHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tif !webMux.routesSetup {\\n\\t\\tinitRoutes()\\n\\t}\\n\\n\\t// Allow cross-origin resource sharing.\\n\\tw.Header().Add(\\\"Access-Control-Allow-Origin\\\", \\\"*\\\")\\n\\n\\twebMux.ServeHTTP(w, r)\\n}\",\n \"func (c *Controller) serveHTTP(w http.ResponseWriter, req *http.Request) {\\n\\tif strings.Contains(req.URL.Path, mutateWebHook) {\\n\\t\\tc.processMutateRequest(w, req)\\n\\t} else {\\n\\t\\thttp.Error(w, \\\"Unsupported request\\\", http.StatusNotFound)\\n\\t}\\n}\",\n \"func (s *server) ServeHTTP(rw http.ResponseWriter, r *http.Request) {\\n\\t// Get request and response from the pool.\\n\\n\\treq := s.requestPool.Get().(*Request)\\n\\tres := s.responsePool.Get().(*Response)\\n\\n\\t// Tie the request body and the standard request body together.\\n\\n\\tr.Body = &requestBody{\\n\\t\\tr: req,\\n\\t\\thr: r,\\n\\t\\trc: r.Body,\\n\\t}\\n\\n\\t// Reset the request.\\n\\n\\treq.Air = s.a\\n\\treq.SetHTTPRequest(r)\\n\\treq.res = res\\n\\treq.params = req.params[:0]\\n\\treq.routeParamNames = nil\\n\\treq.routeParamValues = nil\\n\\treq.parseRouteParamsOnce = &sync.Once{}\\n\\treq.parseOtherParamsOnce = &sync.Once{}\\n\\tfor key := range req.values {\\n\\t\\tdelete(req.values, key)\\n\\t}\\n\\n\\treq.localizedString = nil\\n\\n\\t// Reset the response.\\n\\n\\tres.Air = s.a\\n\\tres.SetHTTPResponseWriter(&responseWriter{\\n\\t\\tr: res,\\n\\t\\trw: rw,\\n\\t})\\n\\tres.Status = http.StatusOK\\n\\tres.ContentLength = -1\\n\\tres.Written = false\\n\\tres.Minified = false\\n\\tres.Gzipped = false\\n\\tres.req = req\\n\\tres.ohrw = rw\\n\\tres.servingContent = false\\n\\tres.serveContentError = nil\\n\\tres.reverseProxying = false\\n\\tres.deferredFuncs = res.deferredFuncs[:0]\\n\\n\\t// Chain the gases stack.\\n\\n\\th := func(req *Request, res *Response) error {\\n\\t\\th := s.a.router.route(req)\\n\\t\\tfor i := len(s.a.Gases) - 1; i >= 0; i-- {\\n\\t\\t\\th = s.a.Gases[i](h)\\n\\t\\t}\\n\\n\\t\\treturn h(req, res)\\n\\t}\\n\\n\\t// Chain the pregases stack.\\n\\n\\tfor i := len(s.a.Pregases) - 1; i >= 0; i-- {\\n\\t\\th = s.a.Pregases[i](h)\\n\\t}\\n\\n\\t// Execute the chain.\\n\\n\\tif err := h(req, res); err != nil {\\n\\t\\tif !res.Written && res.Status < http.StatusBadRequest {\\n\\t\\t\\tres.Status = http.StatusInternalServerError\\n\\t\\t}\\n\\n\\t\\ts.a.ErrorHandler(err, req, res)\\n\\t}\\n\\n\\t// Execute the deferred functions.\\n\\n\\tfor i := len(res.deferredFuncs) - 1; i >= 0; i-- {\\n\\t\\tres.deferredFuncs[i]()\\n\\t}\\n\\n\\t// Put the route param values back to the pool.\\n\\n\\tif req.routeParamValues != nil {\\n\\t\\ts.a.router.routeParamValuesPool.Put(req.routeParamValues)\\n\\t}\\n\\n\\t// Put the request and response back to the pool.\\n\\n\\ts.requestPool.Put(req)\\n\\ts.responsePool.Put(res)\\n}\",\n \"func (p pair) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\t// Serve data with a method of http.ResponseWriter.\\n\\tw.Write([]byte(\\\"You learned Go in Y minutes!\\\"))\\n}\",\n \"func (t *staticTemplateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tif err := t.templ.Execute(w, t.data); err != nil {\\n\\t\\thttp.Error(w, err.Error(), http.StatusInternalServerError)\\n\\t}\\n}\",\n \"func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tw.Header().Set(\\\"Cache-Control\\\", \\\"no-cache\\\")\\n\\tw.Header().Set(\\\"Vary\\\", \\\"Accept\\\")\\n\\n\\tif !h.acceptable(r.Header.Get(\\\"Accept\\\")) {\\n\\t\\tw.WriteHeader(http.StatusNotAcceptable)\\n\\t\\treturn\\n\\t}\\n\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"text/event-stream\\\")\\n\\tw.WriteHeader(http.StatusOK)\\n\\n\\tvar stop <-chan bool\\n\\n\\tif notifier, ok := w.(http.CloseNotifier); ok {\\n\\t\\tstop = notifier.CloseNotify()\\n\\t}\\n\\n\\th(r.Header.Get(\\\"Last-Event-Id\\\"), NewEncoder(w), stop)\\n}\",\n \"func (srv *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {\\n\\tif srv.handler != nil {\\n\\t\\tsrv.handler.ServeHTTP(w, req)\\n\\t\\treturn\\n\\t}\\n\\tsrv.routes.ServeHTTP(w, req)\\n}\",\n \"func (a *Router) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tvar err error\\n\\tdefer func() {\\n\\t\\tif x := recover(); x != nil {\\n\\t\\t\\terr = fmt.Errorf(\\\"ws: %v\\\", x)\\n\\t\\t}\\n\\t\\tfinally(w, err)\\n\\t}()\\n\\n\\tpath := r.URL.Path\\n\\tif len(path) < 1 || path[0] != '/' {\\n\\t\\tpath = \\\"/\\\" + path\\n\\t}\\n\\tif r.Method == http.MethodOptions && path == \\\"/*\\\" {\\n\\t\\tw.Header().Add(\\\"Allow\\\", allAllow)\\n\\t\\terr = Status(http.StatusOK, \\\"\\\")\\n\\t\\treturn\\n\\t}\\n\\n\\tctx := ctxPool.Get().(*Context)\\n\\tdefer ctxPool.Put(ctx)\\n\\tctx.Request = r\\n\\tctx.ResponseWriter = w\\n\\tctx.Path = path\\n\\tctx.code = 0\\n\\tctx.datas = make(map[string]interface{})\\n\\tctx.params = make(map[string]string)\\n\\tctx.querys = nil\\n\\tctx.router = a\\n\\tctx.index = -len(a.middlewares)\\n\\terr = ctx.Next()\\n}\",\n \"func (handler ShortURLForwardingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tdefer r.Body.Close()\\n\\tif r.Method == http.MethodPut {\\n\\t\\thandler.handleAddingNewShortURL(w, r)\\n\\t} else {\\n\\t\\thandler.handleGettingShortURL(w, r)\\n\\t}\\n}\",\n \"func (m *Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tctx := r.Context()\\n\\n\\tsession, state, err := m.initializeSession(r)\\n\\tif err != nil {\\n\\t\\tm.Logger.Printf(\\\"couldn't initialise session: %+v\\\", err)\\n\\t\\thttp.Error(w, \\\"couldn't initialise session\\\", http.StatusInternalServerError)\\n\\t\\treturn\\n\\t}\\n\\n\\tctx = context.WithValue(ctx, ctxStateKey, state)\\n\\tr = r.WithContext(ctx)\\n\\n\\terr = m.setupAccessToken(ctx, w, r)\\n\\tif err != nil {\\n\\t\\t// Access token is not set in request\\n\\t\\tm.Logger.Printf(\\\"couldn't setup access token: %+v\\\", err)\\n\\t}\\n\\n\\twriter := &sessionWriter{\\n\\t\\tsessionStore: m.SessionStore,\\n\\t\\tsession: session,\\n\\t\\tstate: state,\\n\\t\\tlogger: m.Logger,\\n\\t\\tr: r,\\n\\t\\tResponseWriter: w,\\n\\t}\\n\\tm.mux.ServeHTTP(writer, r)\\n}\",\n \"func (l *httpHandler) ServeHTTP(response http.ResponseWriter, request *http.Request) {\\n\\turi := request.RequestURI\\n\\n\\tif uri == \\\"\\\" || uri == \\\"/\\\" || uri == URIIndexPrefix {\\n\\t\\tresponseServerList(response)\\n\\n\\t\\treturn\\n\\t}\\n\\n\\tif strings.HasPrefix(uri, URIIndexPrefix+\\\"/\\\") {\\n\\t\\tserverID := uri[len(URIIndexPrefix)+1:]\\n\\t\\t_, ok := serverDB[serverID]\\n\\n\\t\\tif !ok {\\n\\t\\t\\tresponse.WriteHeader(http.StatusNotFound)\\n\\n\\t\\t\\treturn\\n\\t\\t}\\n\\n\\t\\trouteToServerIndex(response, serverID)\\n\\n\\t\\treturn\\n\\t}\\n\\n\\ttailServerID := \\\"\\\"\\n\\tif uri == URITailPrefix {\\n\\t\\ttailServerID = DefaultServerID\\n\\t} else if strings.HasPrefix(uri, URITailPrefix+\\\"/\\\") {\\n\\t\\ttailServerID = uri[len(URITailPrefix)+1:]\\n\\t\\tif _, ok := serverDB[tailServerID]; !ok {\\n\\t\\t\\tresponse.WriteHeader(http.StatusNotFound)\\n\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t}\\n\\n\\tif tailServerID != \\\"\\\" {\\n\\t\\tstartWebsocketTransfer(response, request, tailServerID)\\n\\n\\t\\treturn\\n\\t}\\n\\n\\tresponseServerList(response)\\n}\",\n \"func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {\\n\\tr.HandleFunc(w, req)\\n}\",\n \"func (h spaHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n // get the absolute path to prevent directory traversal\\n\\tpath, err := filepath.Abs(r.URL.Path)\\n\\tif err != nil {\\n // if we failed to get the absolute path respond with a 400 bad request\\n // and stop\\n\\t\\thttp.Error(w, err.Error(), http.StatusBadRequest)\\n\\t\\treturn\\n\\t}\\n\\n // prepend the path with the path to the static directory\\n\\tpath = filepath.Join(h.staticPath, path)\\n\\n // check whether a file exists at the given path\\n\\t_, err = os.Stat(path)\\n\\tif os.IsNotExist(err) {\\n\\t\\t// file does not exist, serve index.html\\n\\t\\thttp.ServeFile(w, r, filepath.Join(h.staticPath, h.indexPath))\\n\\t\\treturn\\n\\t} else if err != nil {\\n // if we got an error (that wasn't that the file doesn't exist) stating the\\n // file, return a 500 internal server error and stop\\n\\t\\thttp.Error(w, err.Error(), http.StatusInternalServerError)\\n\\t\\treturn\\n\\t}\\n\\n // otherwise, use http.FileServer to serve the static dir\\n\\thttp.FileServer(http.Dir(h.staticPath)).ServeHTTP(w, r)\\n}\",\n \"func serveHTTP(value interface{}, w http.ResponseWriter, r *http.Request) bool {\\n\\tswitch fn := value.(type) {\\n\\tcase func(http.ResponseWriter, *http.Request):\\n\\t\\tfn(w, r)\\n\\t\\treturn true\\n\\t}\\n\\treturn false\\n}\",\n \"func (s Sample) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n fmt.Fprint(w, \\\"

Welcome to Go.Land Server!

\\\")\\n}\",\n \"func (h *Handler) serveServers(w http.ResponseWriter, r *http.Request) {}\"\n]"},"negative_scores":{"kind":"list like","value":["0.6951916","0.6677218","0.66611326","0.6659163","0.66036826","0.65062517","0.6490767","0.6455201","0.6432141","0.64305204","0.64240736","0.6365968","0.635253","0.62759244","0.6265223","0.6240166","0.62350315","0.62345415","0.6224378","0.6202612","0.6189022","0.6154214","0.61497366","0.61497366","0.61497366","0.61497366","0.6145679","0.6140432","0.613213","0.61040795","0.6095694","0.6083812","0.6083305","0.6066852","0.6065363","0.60498524","0.60442346","0.6039158","0.60377496","0.60267794","0.60267794","0.6026457","0.60190797","0.60079604","0.60056275","0.59980524","0.5989811","0.5989404","0.59852654","0.59808105","0.59793234","0.5971335","0.59678435","0.596159","0.5939658","0.5930786","0.5927288","0.592442","0.59237385","0.5903532","0.5899209","0.58991826","0.58991826","0.58991826","0.5897835","0.58904666","0.5885631","0.5877298","0.5877219","0.58698004","0.5869217","0.5860292","0.58547825","0.58476716","0.5846107","0.5843574","0.5842439","0.5836007","0.5827333","0.58240193","0.5818226","0.5818002","0.58137965","0.5812305","0.5806882","0.580604","0.5802835","0.57985616","0.57882124","0.5787872","0.57876706","0.57865787","0.5782738","0.5781484","0.5770537","0.57643616","0.57626075","0.5762233","0.57603776","0.5757428"],"string":"[\n \"0.6951916\",\n \"0.6677218\",\n \"0.66611326\",\n \"0.6659163\",\n \"0.66036826\",\n \"0.65062517\",\n \"0.6490767\",\n \"0.6455201\",\n \"0.6432141\",\n \"0.64305204\",\n \"0.64240736\",\n \"0.6365968\",\n \"0.635253\",\n \"0.62759244\",\n \"0.6265223\",\n \"0.6240166\",\n \"0.62350315\",\n \"0.62345415\",\n \"0.6224378\",\n \"0.6202612\",\n \"0.6189022\",\n \"0.6154214\",\n \"0.61497366\",\n \"0.61497366\",\n \"0.61497366\",\n \"0.61497366\",\n \"0.6145679\",\n \"0.6140432\",\n \"0.613213\",\n \"0.61040795\",\n \"0.6095694\",\n \"0.6083812\",\n \"0.6083305\",\n \"0.6066852\",\n \"0.6065363\",\n \"0.60498524\",\n \"0.60442346\",\n \"0.6039158\",\n \"0.60377496\",\n \"0.60267794\",\n \"0.60267794\",\n \"0.6026457\",\n \"0.60190797\",\n \"0.60079604\",\n \"0.60056275\",\n \"0.59980524\",\n \"0.5989811\",\n \"0.5989404\",\n \"0.59852654\",\n \"0.59808105\",\n \"0.59793234\",\n \"0.5971335\",\n \"0.59678435\",\n \"0.596159\",\n \"0.5939658\",\n \"0.5930786\",\n \"0.5927288\",\n \"0.592442\",\n \"0.59237385\",\n \"0.5903532\",\n \"0.5899209\",\n \"0.58991826\",\n \"0.58991826\",\n \"0.58991826\",\n \"0.5897835\",\n \"0.58904666\",\n \"0.5885631\",\n \"0.5877298\",\n \"0.5877219\",\n \"0.58698004\",\n \"0.5869217\",\n \"0.5860292\",\n \"0.58547825\",\n \"0.58476716\",\n \"0.5846107\",\n \"0.5843574\",\n \"0.5842439\",\n \"0.5836007\",\n \"0.5827333\",\n \"0.58240193\",\n \"0.5818226\",\n \"0.5818002\",\n \"0.58137965\",\n \"0.5812305\",\n \"0.5806882\",\n \"0.580604\",\n \"0.5802835\",\n \"0.57985616\",\n \"0.57882124\",\n \"0.5787872\",\n \"0.57876706\",\n \"0.57865787\",\n \"0.5782738\",\n \"0.5781484\",\n \"0.5770537\",\n \"0.57643616\",\n \"0.57626075\",\n \"0.5762233\",\n \"0.57603776\",\n \"0.5757428\"\n]"},"document_score":{"kind":"string","value":"0.6446284"},"document_rank":{"kind":"string","value":"8"}}},{"rowIdx":105052,"cells":{"query":{"kind":"string","value":"IndexSSE serves SSE updates."},"document":{"kind":"string","value":"func (ss ServeSSE) IndexSSE(w http.ResponseWriter, r *http.Request) {\n\tsse := &SSE{Writer: w, Params: params.NewParams()}\n\tif LogHandler(ss.logRequests, sse).ServeHTTP(nil, r); sse.Errord {\n\t\treturn\n\t}\n\tfor { // loop is log-requests-free\n\n\t\tnow := time.Now()\n\t\ttime.Sleep(now.Truncate(time.Second).Add(time.Second).Sub(now))\n\t\t// TODO redo with some channel to receive from, pushed in lastCopy by CollectLoop or something\n\n\t\tif sse.ServeHTTP(nil, r); sse.Errord {\n\t\t\tbreak\n\t\t}\n\t}\n}"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["func (action *LedgerIndexAction) SSE(stream sse.Stream) {\n\taction.LoadRecords()\n\n\tif action.Err != nil {\n\t\tstream.Err(action.Err)\n\t\treturn\n\t}\n\n\trecords := action.Records[stream.SentCount():]\n\n\tfor _, record := range records {\n\t\tstream.Send(sse.Event{\n\t\t\tID: record.PagingToken(),\n\t\t\tData: NewLedgerResource(record),\n\t\t})\n\t}\n\n\tif stream.SentCount() >= int(action.Query.Limit) {\n\t\tstream.Done()\n\t}\n}","func (action *TransactionIndexAction) SSE(stream sse.Stream) {\n\taction.Setup(\n\t\taction.EnsureHistoryFreshness,\n\t\taction.loadParams,\n\t\taction.checkAllowed,\n\t\taction.ValidateCursorWithinHistory,\n\t)\n\taction.Do(\n\t\tfunc() {\n\t\t\t// we will reuse this variable in sse, so re-initializing is required\n\t\t\taction.Records = []history.Transaction{}\n\t\t},\n\t\taction.loadRecords,\n\t\tfunc() {\n\t\t\trecords := action.Records[:]\n\n\t\t\tfor _, record := range records {\n\t\t\t\tres := resource.PopulateTransaction(record)\n\t\t\t\tstream.Send(sse.Event{\n\t\t\t\t\tID: res.PagingToken(),\n\t\t\t\t\tData: res,\n\t\t\t\t})\n\t\t\t\taction.PagingParams.Cursor = res.PagingToken()\n\t\t\t}\n\t\t},\n\t)\n}","func (action *AccountIndexAction) SSE(stream sse.Stream) {\n\taction.Setup(action.LoadQuery)\n\taction.Do(\n\t\taction.LoadRecords,\n\t\tfunc() {\n\t\t\tstream.SetLimit(int(action.Query.Limit))\n\t\t\tvar res resource.HistoryAccount\n\t\t\tfor _, record := range action.Records[stream.SentCount():] {\n\t\t\t\tres.Populate(action.Ctx, record)\n\t\t\t\tstream.Send(sse.Event{ID: record.PagingToken(), Data: res})\n\t\t\t}\n\t\t},\n\t)\n}","func (si ServeIndex) Index(w http.ResponseWriter, r *http.Request) {\n\tpara := params.NewParams()\n\tdata, _, err := Updates(r, para)\n\tif err != nil {\n\t\tif _, ok := err.(params.RenamedConstError); ok {\n\t\t\thttp.Redirect(w, r, err.Error(), http.StatusFound)\n\t\t\treturn\n\t\t}\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tdata[\"Distrib\"] = si.StaticData.Distrib\n\tdata[\"Exporting\"] = exportingCopy() // from ./ws.go\n\tdata[\"OstentUpgrade\"] = OstentUpgrade.Get()\n\tdata[\"OstentVersion\"] = si.StaticData.OstentVersion\n\tdata[\"TAGGEDbin\"] = si.StaticData.TAGGEDbin\n\n\tsi.IndexTemplate.Apply(w, struct{ Data IndexData }{Data: data})\n}","func (sw ServeWS) IndexWS(w http.ResponseWriter, req *http.Request) {\n\t// Upgrader.Upgrade() has Origin check if .CheckOrigin is nil\n\tupgrader := &websocket.Upgrader{HandshakeTimeout: 5 * time.Second}\n\twsconn, err := upgrader.Upgrade(w, req, nil)\n\tif err != nil { // Upgrade() does http.Error() to the client\n\t\treturn\n\t}\n\n\tc := &conn{\n\t\tlogger: sw.logger,\n\t\tConn: wsconn,\n\n\t\tinitialRequest: req,\n\t\tlogRequests: sw.logRequests,\n\n\t\tpara: params.NewParams(),\n\t}\n\tconnections.reg(c)\n\tdefer func() {\n\t\tconnections.unreg(c)\n\t\tc.Conn.Close()\n\t}()\n\tfor {\n\t\trd := new(received)\n\t\tif err := c.Conn.ReadJSON(&rd); err != nil || !c.Process(rd, nil) {\n\t\t\treturn\n\t\t}\n\t}\n}","func (action *AccountShowAction) SSE(stream sse.Stream) {\n\taction.Do(\n\t\taction.LoadQuery,\n\t\taction.LoadRecord,\n\t\taction.LoadResource,\n\t\tfunc() {\n\t\t\tstream.SetLimit(10)\n\t\t\tstream.Send(sse.Event{Data: action.Resource})\n\t\t},\n\t)\n}","func (esHandler *ESHandler) Index(verses []Verse) error {\n\tctx := context.Background()\n\tserivce, err := esHandler.Client.BulkProcessor().Name(\"ScriptureProcessor\").Workers(2).BulkActions(1000).Do(ctx)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Error initializing BulkProcessor\")\n\t}\n\tdefer serivce.Close()\n\n\tfor _, v := range verses {\n\t\tid := v.GetID()\n\t\tr := elastic.NewBulkIndexRequest().Index(esHandler.ESIndex).Type(\"Verse\").Id(id).Doc(v)\n\t\tserivce.Add(r)\n\t}\n\treturn nil\n}","func (h *SubscribeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tvar index, err = strconv.Atoi(r.Header.Get(\"Last-Event-ID\"))\n\tif r.Header.Get(\"Last-Event-ID\") != \"\" {\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\tindex += 1\n\t}\n\n\t// Create a channel for subscribing to database updates.\n\tch := h.db.Subscribe(index)\n\tcloseNotifier := w.(http.CloseNotifier).CloseNotify()\n\n\t// Mark this as an SSE event stream.\n\tw.Header().Set(\"Content-Type\", \"text/event-stream\")\n\n\t// Continually stream updates as they come.\nloop:\n\tfor {\n\t\tselect {\n\t\tcase <-closeNotifier:\n\t\t\tbreak loop\n\n\t\tcase row := <-ch:\n\t\t\t// Encode row as JSON.\n\t\t\tb, err := json.Marshal(row)\n\t\t\tif err != nil {\n\t\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\t\tbreak loop\n\t\t\t}\n\n\t\t\t// Send row as server-sent event.\n\t\t\tfmt.Fprintf(w, \"id: %d\\n\", row.Index())\n\t\t\tfmt.Fprintf(w, \"data: %s\\n\\n\", b)\n\t\t\tw.(http.Flusher).Flush()\n\t\t}\n\t}\n\n\t// Unsubscribe from the database when the connection is lost.\n\th.db.Unsubscribe(ch)\n}","func HandleSSE(handler func(http.ResponseWriter, *http.Request, *MessageFlusher, <-chan bool)) func(http.ResponseWriter, *http.Request) {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tflusher, ok := makeNewMessageFlusher(w)\n\t\tif !ok {\n\t\t\thttp.Error(w, \"Streaming unsupported.\", http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Content-Type\", \"text/event-stream\")\n\t\tw.Header().Set(\"Cache-Control\", \"no-cache\")\n\t\tw.Header().Set(\"Connection\", \"keep-alive\")\n\t\tfmt.Println(\"opening connection\")\n\t\tcn, ok := w.(http.CloseNotifier)\n\t\tif !ok {\n\t\t\thttp.Error(w, \"Closing not supported\", http.StatusNotImplemented)\n\t\t\treturn\n\t\t}\n\t\tclose := cn.CloseNotify()\n\t\thandler(w, r, flusher, close)\n\t}\n}","func (es *EventSource) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tvar startID int\n\tif start := r.Header.Get(\"Last-Event-ID\"); start != \"\" {\n\t\tif _, err := fmt.Sscanf(start, \"%d\", &startID); err != nil {\n\t\t\thttp.Error(w, \"bad Last-Event-ID\", http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\tstartID++\n\t}\n\n\tw.Header().Set(\"Content-Type\", ContentType)\n\tw.Header().Set(\"Connection\", \"keep-alive\")\n\tw.Header().Set(\"Cache-Control\", \"no-cache\")\n\tw.Header().Set(\"Transfer-Encoding\", \"chunked\")\n\tw.WriteHeader(200)\n\n\tflusher, ok := w.(http.Flusher)\n\tif !ok {\n\t\tpanic(\"esource: ServeHTTP called without a Flusher\")\n\t}\n\n\tlog.Printf(\"esource: [%s] starting stream\", r.RemoteAddr)\n\n\told, events := es.Tee(startID)\n\tfor _, event := range old {\n\t\tif _, err := event.WriteTo(w); err != nil {\n\t\t\tlog.Printf(\"esource: [%s] failed to write backlogged event %+v\", r.RemoteAddr, event)\n\t\t\treturn\n\t\t}\n\t}\n\tflusher.Flush()\n\n\tfor event := range events {\n\t\tif _, err := event.WriteTo(w); err != nil {\n\t\t\tlog.Printf(\"esource: [%s] failed to write event %+v\", r.RemoteAddr, event)\n\t\t\tfmt.Fprintln(w, \"\\nretry: 0\\n\")\n\t\t\treturn\n\t\t}\n\t\tflusher.Flush()\n\t}\n\n\tlog.Printf(\"esource: [%s] complete\", r.RemoteAddr)\n}","func (sse *SSE) ServeHTTP(_ http.ResponseWriter, r *http.Request) {\n\tw := sse.Writer\n\tdata, _, err := Updates(r, sse.Params)\n\tif err != nil {\n\t\tif _, ok := err.(params.RenamedConstError); ok {\n\t\t\thttp.Redirect(w, r, err.Error(), http.StatusFound)\n\t\t\treturn\n\t\t}\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n\ttext, err := json.Marshal(data)\n\tif err != nil {\n\t\tsse.Errord = true\n\t\t// what would http.Error do\n\t\tif sse.SetHeader(\"Content-Type\", \"text/plain; charset=utf-8\") {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t}\n\t\tfmt.Fprintln(w, err.Error())\n\t\treturn\n\t}\n\tsse.SetHeader(\"Content-Type\", \"text/event-stream\")\n\tif _, err := w.Write(append(append([]byte(\"data: \"), text...), []byte(\"\\n\\n\")...)); err != nil {\n\t\tsse.Errord = true\n\t}\n}","func (ms *MusicServer) Index(response http.ResponseWriter, request *http.Request) {\n\t// Always check addressMask. If no define, mask is 0.0.0.0 and nothing is accepted (except localhost)\n\tif !ms.checkRequester(request) {\n\t\treturn\n\t}\n\tif ms.musicFolder != \"\" {\n\t\ttextIndexer := music.IndexArtists(ms.folder)\n\t\tms.indexManager.UpdateIndexer(textIndexer)\n\t}\n}","func Index(w http.ResponseWriter, data *IndexData) {\n\trender(tpIndex, w, data)\n}","func Index(w http.ResponseWriter, data *IndexData) {\n\trender(tpIndex, w, data)\n}","func (s *ChartStreamServer) IndexHandler(c *gin.Context) {\n\tindex, err := s.chartProvider.GetIndexFile()\n\tif err != nil {\n\t\tc.AbortWithError(500, err)\n\t}\n\n\tc.YAML(200, index)\n}","func indexHandler(w http.ResponseWriter, r *http.Request, s *Server) {\n\tif r.Method == \"GET\" {\n\t\t//create the source upload page with available languages and metrics\n\t\tpage := &Page{Config: s.Config, Extensions: s.Analyzer.Extensions(), Metrics: s.Analyzer.Metrics, Languages: s.Analyzer.Languages}\n\n\t\t//display the source upload page\n\t\ts.Template.ExecuteTemplate(w, \"index.html\", page)\n\t}\n}","func (c *Connection) Index(idx []FileInfo) {\n\tc.Lock()\n\tvar msgType int\n\tif c.indexSent == nil {\n\t\t// This is the first time we send an index.\n\t\tmsgType = messageTypeIndex\n\n\t\tc.indexSent = make(map[string]int64)\n\t\tfor _, f := range idx {\n\t\t\tc.indexSent[f.Name] = f.Modified\n\t\t}\n\t} else {\n\t\t// We have sent one full index. Only send updates now.\n\t\tmsgType = messageTypeIndexUpdate\n\t\tvar diff []FileInfo\n\t\tfor _, f := range idx {\n\t\t\tif modified, ok := c.indexSent[f.Name]; !ok || f.Modified != modified {\n\t\t\t\tdiff = append(diff, f)\n\t\t\t\tc.indexSent[f.Name] = f.Modified\n\t\t\t}\n\t\t}\n\t\tidx = diff\n\t}\n\n\tc.mwriter.writeHeader(header{0, c.nextId, msgType})\n\tc.mwriter.writeIndex(idx)\n\terr := c.flush()\n\tc.nextId = (c.nextId + 1) & 0xfff\n\tc.hasSentIndex = true\n\tc.Unlock()\n\n\tif err != nil {\n\t\tc.Close(err)\n\t\treturn\n\t} else if c.mwriter.err != nil {\n\t\tc.Close(c.mwriter.err)\n\t\treturn\n\t}\n}","func (siw *SindexWatcher) refresh(o *Observer, infoKeys []string, rawMetrics map[string]string, ch chan<- prometheus.Metric) error {\n\tif config.Aerospike.DisableSindexMetrics {\n\t\t// disabled\n\t\treturn nil\n\t}\n\n\tif siw.sindexMetrics == nil {\n\t\tsiw.sindexMetrics = make(map[string]AerospikeStat)\n\t}\n\n\tfor _, sindex := range infoKeys {\n\t\tsindexInfoKey := strings.ReplaceAll(sindex, \"sindex/\", \"\")\n\t\tsindexInfoKeySplit := strings.Split(sindexInfoKey, \"/\")\n\t\tnsName := sindexInfoKeySplit[0]\n\t\tsindexName := sindexInfoKeySplit[1]\n\t\tlog.Tracef(\"sindex-stats:%s:%s:%s\", nsName, sindexName, rawMetrics[sindex])\n\n\t\tstats := parseStats(rawMetrics[sindex], \";\")\n\t\tfor stat, value := range stats {\n\t\t\tpv, err := tryConvert(value)\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tasMetric, exists := siw.sindexMetrics[stat]\n\n\t\t\tif !exists {\n\t\t\t\tasMetric = newAerospikeStat(CTX_SINDEX, stat)\n\t\t\t\tsiw.sindexMetrics[stat] = asMetric\n\t\t\t}\n\t\t\t// handle any panic from prometheus, this may occur when prom encounters a config/stat with special characters\n\t\t\tdefer func() {\n\t\t\t\tif r := recover(); r != nil {\n\t\t\t\t\tlog.Tracef(\"sindex-stats: recovered from panic while handling stat %s in %s\", stat, sindexName)\n\t\t\t\t}\n\t\t\t}()\n\n\t\t\tif asMetric.isAllowed {\n\t\t\t\tdesc, valueType := asMetric.makePromMetric(METRIC_LABEL_CLUSTER_NAME, METRIC_LABEL_SERVICE, METRIC_LABEL_NS, METRIC_LABEL_SINDEX)\n\t\t\t\tch <- prometheus.MustNewConstMetric(desc, valueType, pv, rawMetrics[ikClusterName], rawMetrics[ikService], nsName, sindexName)\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\treturn nil\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\n\tfmt.Fprintln(w, \"Steve and Kyle Podcast: #api\")\n\tfmt.Fprintln(w, \"Number of episodes in database:\", EpCount())\n\tfmt.Fprintln(w, \"Created by Derek Slenk\")\n\tfmt.Println(\"Endpoint Hit: Index\")\n}","func Index(w http.ResponseWriter, data interface{}) {\n\trender(tpIndex, w, data)\n}","func (c *rawConnection) Index(repo string, idx []FileInfo) {\n\tc.imut.Lock()\n\tvar msgType int\n\tif c.indexSent[repo] == nil {\n\t\t// This is the first time we send an index.\n\t\tmsgType = messageTypeIndex\n\n\t\tc.indexSent[repo] = make(map[string][2]int64)\n\t\tfor _, f := range idx {\n\t\t\tc.indexSent[repo][f.Name] = [2]int64{f.Modified, int64(f.Version)}\n\t\t}\n\t} else {\n\t\t// We have sent one full index. Only send updates now.\n\t\tmsgType = messageTypeIndexUpdate\n\t\tvar diff []FileInfo\n\t\tfor _, f := range idx {\n\t\t\tif vs, ok := c.indexSent[repo][f.Name]; !ok || f.Modified != vs[0] || int64(f.Version) != vs[1] {\n\t\t\t\tdiff = append(diff, f)\n\t\t\t\tc.indexSent[repo][f.Name] = [2]int64{f.Modified, int64(f.Version)}\n\t\t\t}\n\t\t}\n\t\tidx = diff\n\t}\n\tc.imut.Unlock()\n\n\tc.send(header{0, -1, msgType}, IndexMessage{repo, idx})\n}","func Index(c *gin.Context) {\n\n\tw := c.Writer\n\tr := c.Request\n\tw.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n\tp, lastMod, err := tools.ReadFileIfModified(time.Time{})\n\tif err != nil {\n\t\tp = []byte(err.Error())\n\t\tlastMod = time.Unix(0, 0)\n\t}\n\tvar v = struct {\n\t\tHost string\n\t\tData string\n\t\tLastMod string\n\t}{\n\t\tr.Host,\n\t\tstring(p),\n\t\tstrconv.FormatInt(lastMod.UnixNano(), 16),\n\t}\n\tindexTempl.Execute(w, &v)\n}","func (handler StormWatchHandler) Index(c *gin.Context) {\n\tstormWatchs := []m.StormWatch{}\t\n\tvar query = handler.db\n\n\tstartParam,startParamExist := c.GetQuery(\"start\")\n\tlimitParam,limitParamExist := c.GetQuery(\"limit\")\n\n\t//start param exist\n\tif startParamExist {\n\t\tstart,_ := strconv.Atoi(startParam)\n\t\tif start != 0 {\n\t\t\tquery = query.Offset(start).Order(\"created_at asc\")\t\t\n\t\t} else {\n\t\t\tquery = query.Offset(0).Order(\"created_at desc\")\n\t\t}\n\t} \n\n\t//limit param exist\n\tif limitParamExist {\n\t\tlimit,_ := strconv.Atoi(limitParam)\n\t\tquery = query.Limit(limit)\n\t} else {\n\t\tquery = query.Limit(10)\n\t}\n\n\tquery.Order(\"created_at desc\").Find(&stormWatchs)\n\tc.JSON(http.StatusOK, stormWatchs)\n\treturn\n}","func index(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {\n\terr := tpl.ExecuteTemplate(w, \"index.html\", nil)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\tlog.Fatalln(err)\n\t}\n\tfmt.Println(\"HERE INDEX\")\n}","func indexHandler(w http.ResponseWriter, req *http.Request) {\n\tlayout, err := template.ParseFile(PATH_PUBLIC + TEMPLATE_LAYOUT)\n\tif err != nil {\n\t\thttp.Error(w, ERROR_TEMPLATE_NOT_FOUND, http.StatusNotFound)\n\t\treturn\n\t}\n\tindex, err := template.ParseFile(PATH_PUBLIC + TEMPLATE_INDEX)\n\t//artical, err := template.ParseFile(PATH_PUBLIC + TEMPLATE_ARTICAL)\n\tif err != nil {\n\t\thttp.Error(w, ERROR_TEMPLATE_NOT_FOUND, http.StatusNotFound)\n\t\treturn\n\t}\n\tmapOutput := map[string]interface{}{\"Title\": \"炫酷的网站技术\" + TITLE, \"Keyword\": KEYWORD, \"Description\": DESCRIPTION, \"Base\": BASE_URL, \"Url\": BASE_URL, \"Carousel\": getAddition(PREFIX_INDEX), \"Script\": getAddition(PREFIX_SCRIPT), \"Items\": leveldb.GetRandomContents(20, &Filter{})}\n\tcontent := []byte(index.RenderInLayout(layout, mapOutput))\n\tw.Write(content)\n\tgo cacheFile(\"index\", content)\n}","func indexHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"indexHandler is called\")\n\n\tw.WriteHeader(http.StatusOK)\n}","func indexHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"indexHandler is called\")\n\n\tw.WriteHeader(http.StatusOK)\n}","func handleIndex(w http.ResponseWriter, r *http.Request) {\n\n\tif r.URL.Path != \"/\" {\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\n\tc := appengine.NewContext(r)\n\tlog.Infof(c, \"Serving main page.\")\n\n\ttmpl, _ := template.ParseFiles(\"web/tmpl/index.tmpl\")\n\n\ttmpl.Execute(w, time.Since(initTime))\n}","func indexHandler(c *fiber.Ctx) error {\n\treturn common.HandleTemplate(c, \"index\",\n\t\t\"me\", nil, 200)\n}","func indexHandler(w http.ResponseWriter, r *http.Request) {\r\n t, _ := template.New(\"webpage\").Parse(indexPage) // parse embeded index page\r\n t.Execute(w, pd) // serve the index page (html template)\r\n}","func (s *Server) Index(w http.ResponseWriter, r *http.Request) {\n\tsession := s.getSessionFromCookie(r)\n\n\tif session.IsNew {\n\t\ts.newRandomInbox(session, w, r)\n\t\treturn\n\t}\n\n\ts.getInbox(session, w, r)\n}","func index(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprint(w, \"index de uma função\")\n}","func index(w http.ResponseWriter, req *http.Request, ctx httputil.Context) (e *httputil.Error) {\n\tif req.URL.Path != \"/\" {\n\t\tnotFound(w, req)\n\t\treturn\n\t}\n\tm := newManager(ctx)\n\n\tres, err := m.Index()\n\tif err != nil {\n\t\te = httputil.Errorf(err, \"couldn't query for test results\")\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"text/html\")\n\tif err := T(\"index/index.html\").Execute(w, res); err != nil {\n\t\te = httputil.Errorf(err, \"error executing index template\")\n\t}\n\treturn\n}","func (db *DB) Index(ctx context.Context, i services.Consumable) error {\n\tvar (\n\t\terr error\n\t\tjob = db.stream.NewJob(\"index\")\n\t\tsess = db.db.NewSession(job)\n\t)\n\tjob.KeyValue(\"id\", i.ID())\n\tjob.KeyValue(\"chain_id\", i.ChainID())\n\n\tdefer func() {\n\t\tif err != nil {\n\t\t\tjob.CompleteKv(health.Error, health.Kvs{\"err\": err.Error()})\n\t\t\treturn\n\t\t}\n\t\tjob.Complete(health.Success)\n\t}()\n\n\t// Create db tx\n\tvar dbTx *dbr.Tx\n\tdbTx, err = sess.Begin()\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer dbTx.RollbackUnlessCommitted()\n\n\t// Ingest the tx and commit\n\terr = db.ingestTx(services.NewConsumerContext(ctx, job, dbTx, i.Timestamp()), i.Body())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = dbTx.Commit()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprint(w, \"s-senpai, please don't hurt me ;_;\\n\")\n}","func (s *Server) IndexHandler(w http.ResponseWriter, r *http.Request) {\n\tworkouts, err := storage.GetWorkouts(s.DataRepository)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), 500)\n\t\treturn\n\t}\n\n\tout, err := json.Marshal(workouts)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), 500)\n\t\treturn\n\t}\n\n\tfmt.Fprintf(w, string(out))\n}","func (s *Server) indexHandler(w http.ResponseWriter, r *http.Request) {\n\tb, _ := s.static.Find(\"index.html\")\n\tw.Write(b)\n}","func Index(data []byte){\n\n api.Domain = \"localhost\"\n fmt.Println(\"Entered inside elasticgo file...lets do this\")\n response, _ := core.Index(\"scalegray_sample\", \"first_sampleset\", \"3\", nil, data)\n fmt.Println(response)\n fmt.Println(\"Done pushing the data into elastic search..woohoo!\")\n}","func Serve(ctx context.Context, serveAddr string, db idb.IndexerDb, fetcherError error, log *log.Logger, options ExtraOptions) {\n\te := echo.New()\n\te.HideBanner = true\n\n\tif options.MetricsEndpoint {\n\t\tp := echo_contrib.NewPrometheus(\"indexer\", nil, nil)\n\t\tif options.MetricsEndpointVerbose {\n\t\t\tp.RequestCounterURLLabelMappingFunc = middlewares.PrometheusPathMapperVerbose\n\t\t} else {\n\t\t\tp.RequestCounterURLLabelMappingFunc = middlewares.PrometheusPathMapper404Sink\n\t\t}\n\t\t// This call installs the prometheus metrics collection middleware and\n\t\t// the \"/metrics\" handler.\n\t\tp.Use(e)\n\t}\n\n\te.Use(middlewares.MakeLogger(log))\n\te.Use(middleware.CORS())\n\n\tmiddleware := make([]echo.MiddlewareFunc, 0)\n\n\tmiddleware = append(middleware, middlewares.MakeMigrationMiddleware(db))\n\n\tif len(options.Tokens) > 0 {\n\t\tmiddleware = append(middleware, middlewares.MakeAuth(\"X-Indexer-API-Token\", options.Tokens))\n\t}\n\n\tapi := ServerImplementation{\n\t\tEnableAddressSearchRoundRewind: options.DeveloperMode,\n\t\tdb: db,\n\t\tfetcher: fetcherError,\n\t}\n\n\tgenerated.RegisterHandlers(e, &api, middleware...)\n\tcommon.RegisterHandlers(e, &api)\n\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\tgetctx := func(l net.Listener) context.Context {\n\t\treturn ctx\n\t}\n\ts := &http.Server{\n\t\tAddr: serveAddr,\n\t\tReadTimeout: 10 * time.Second,\n\t\tWriteTimeout: 10 * time.Second,\n\t\tMaxHeaderBytes: 1 << 20,\n\t\tBaseContext: getctx,\n\t}\n\n\tlog.Fatal(e.StartServer(s))\n}","func (app *Application) Index(w http.ResponseWriter, r *http.Request) {\n\tdata := struct {\n\t\tTime int64\n\t}{\n\t\tTime: time.Now().Unix(),\n\t}\n\n\tt, err := template.ParseFiles(\"views/index.tpl\")\n\n\tif err != nil {\n\t\tlog.Println(\"Template.Parse:\", err)\n\t\thttp.Error(w, \"Internal Server Error 0x0178\", http.StatusInternalServerError)\n\t}\n\n\tif err := t.Execute(w, data); err != nil {\n\t\tlog.Println(\"Template.Execute:\", err)\n\t\thttp.Error(w, \"Internal Server Error 0x0183\", http.StatusInternalServerError)\n\t}\n}","func index(w http.ResponseWriter, r *http.Request){\n\terr := templ.ExecuteTemplate(w, \"index\", nil)\n\tif err != nil {\n\t\tfmt.Print(err.Error())\n\t}\n}","func serveIndex(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\terr := serveAssets(w, r, \"index.html\")\n\tcheckError(err)\n}","func indexHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"indexHandler is called\")\n\n\tw.WriteHeader(http.StatusOK)\n\tjson.NewEncoder(w).Encode(indexHandlerResponse{Message: \"OK\"})\n}","func index(c echo.Context) error {\n\tpprof.Index(c.Response().Writer, c.Request())\n\treturn nil\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\tif err := json.NewEncoder(w).Encode(ResultIndex{Connect: true}); err != nil {\n\t\tpanic(err)\n\t}\n}","func subscribeSSE(transport *HTTPTransport, statuschan chan ServerStatus, errorchan chan error, untilNextOnly bool) error {\n\tctx, cancel := context.WithCancel(context.Background())\n\n\tevents := make(chan *sseclient.Event)\n\tcancelled := false\n\tgo func() {\n\t\tfor {\n\t\t\te := <-events\n\t\t\tif e == nil || e.Type == \"open\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tstatus := ServerStatus(strings.Trim(string(e.Data), `\"`))\n\t\t\tstatuschan <- status\n\t\t\tif untilNextOnly || status.Finished() {\n\t\t\t\terrorchan <- nil\n\t\t\t\tcancelled = true\n\t\t\t\tcancel()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n\n\terr := sseclient.Notify(ctx, transport.Server+\"statusevents\", true, events)\n\t// When sse was cancelled, an error is expected to be returned. The channels are already closed then.\n\tif cancelled {\n\t\treturn nil\n\t}\n\tclose(events)\n\treturn err\n}","func Index(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {\n\tio.WriteString(w, \"Hello\")\n}","func IndexHandeler(w http.ResponseWriter, r *http.Request) {\n\trespond.OK(w, map[string]interface{}{\n\t\t\"name\": \"hotstar-schedular\",\n\t\t\"version\": 1,\n\t})\n}","func indexHandler(w http.ResponseWriter, r *http.Request) {\n\tw.WriteHeader(http.StatusOK)\n}","func showIndex(res http.ResponseWriter, req *http.Request, params httprouter.Params) {\n\tServeTemplateWithParams(res, req, \"index.html\", nil)\n}","func HandleIndex(w http.ResponseWriter, r *http.Request) {\n\tresponse := info()\n\n\terr := utils.Respond(w, response)\n\tif err != nil {\n\t\tlog.Printf(\"ERROR: Failed to encode info response, %s\", err)\n\t}\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"Hola, este es el inicio\")\n}","func (s *RefreshService) Index(index ...string) *RefreshService {\n\ts.index = append(s.index, index...)\n\treturn s\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\tc := flight.Context(w, r)\n\n\titems, _, err := summary.All(c.DB)\n\tif err != nil {\n\t\tc.FlashErrorGeneric(err)\n\t\titems = []summary.Item{}\n\t}\n\tdefaultFormat := \"Mon, 02-Jan-2006\"\n\n\tfor i := 0; i < len(items); i++ {\n\t\titems[i].SnapshotDate_Formatted = items[i].SnapshotDate.Time.Format(defaultFormat)\n\t\t//items[i].Details_Split = strings.Split(items[i].Details, \"|\")\n\t\titems[i].Cash_String = utilities.DisplayPrettyNullFloat64(items[i].Cash)\n\t\titems[i].Loads_String = utilities.DisplayPrettyNullFloat64(items[i].Loads)\n\t\titems[i].SmartMoney_String = utilities.DisplayPrettyNullFloat64(items[i].SmartMoney)\n\t\titems[i].Codes_String = utilities.DisplayPrettyNullFloat64(items[i].Codes)\n\t\titems[i].Total_String = utilities.DisplayPrettyNullFloat64(items[i].Total)\n\t}\n\n\tdaily_earnings, _, _ := summary.DailyEarnings(c.DB, \"7\")\n\n\tm := make(map[string]float64)\n\tn := make(map[string]float64)\n\n\tfor i := 0; i < len(daily_earnings); i++ {\n\t\tdaily_earnings[i].Trans_Datetime_Formatted = daily_earnings[i].Trans_Datetime.Time.Format(defaultFormat)\n\t\tdaily_earnings[i].Amount_String = utilities.DisplayPrettyNullFloat64(daily_earnings[i].Amount)\n\n\t\tm[daily_earnings[i].Trans_Datetime.Time.Format(\"2006-01-02\")] = m[daily_earnings[i].Trans_Datetime.Time.Format(\"2006-01-02\")] + daily_earnings[i].Amount.Float64\n\t\tn[daily_earnings[i].Trans_code] = n[daily_earnings[i].Trans_code] + daily_earnings[i].Amount.Float64\n\t}\n\n\t//fmt.Println(m)\n\n\t//prettysum := utilities.DisplayPrettyFloat(sum)\n\n\tpie := chart.PieChart{\n\t\tTitle: \"Summary\",\n\t\tWidth: 512,\n\t\tHeight: 512,\n\t\tValues: []chart.Value{\n\t\t\t{Value: items[0].Cash.Float64, Label: \"Cash\"},\n\t\t\t{Value: items[0].Loads.Float64, Label: \"Loads\"},\n\t\t\t{Value: items[0].SmartMoney.Float64, Label: \"SmartMoney\"},\n\t\t\t{Value: items[0].Codes.Float64, Label: \"Codes\"},\n\t\t},\n\t}\n\n\toutputfile := \"./asset/static/outputfile.png\"\n\n\tpie2 := chart.PieChart{\n\t\tTitle: \"Summary\",\n\t\tWidth: 512,\n\t\tHeight: 512,\n\t\tValues: []chart.Value{},\n\t}\n\n\t//outputfile := \"./asset/static/outputfile.png\"\n\n\t//buffer := []byte{}\n\n\tf, _ := os.Create(outputfile)\n\n\twriter := bufio.NewWriter(f)\n\n\tdefer f.Close()\n\n\t_ = pie.Render(chart.PNG, writer)\n\n\twriter.Flush()\n\n\tsbc := chart.BarChart{\n\t\tTitle: \"Daily Total Earnings\",\n\t\tTitleStyle: chart.StyleShow(),\n\t\tBackground: chart.Style{\n\t\t\tPadding: chart.Box{\n\t\t\t\tTop: 40,\n\t\t\t},\n\t\t},\n\t\tHeight: 512,\n\t\tBarWidth: 60,\n\t\tXAxis: chart.Style{\n\t\t\tShow: true,\n\t\t},\n\t\tYAxis: chart.YAxis{\n\t\t\tStyle: chart.Style{\n\t\t\t\tShow: true,\n\t\t\t},\n\t\t},\n\t\tBars: []chart.Value{},\n\t}\n\n\t//vBars := sbc.Bars\n\tidx := 0\n\t// fmt.Println(\"Length of m:\", len(m))\n\tslice := make([]chart.Value, len(m))\n\n\tslice1 := make([]summary.Earning, len(m))\n\t//fmt.Println(\"Arr:\", slice)\n\tfor k, v := range m {\n\n\t\t//\t\tfmt.Println(k, v)\n\t\t//fmt.Printf(\"type: %T\\n\", sbc.Bars)\n\t\tslice[idx].Label = k\n\t\tslice[idx].Value = v\n\n\t\tslice1[idx].Trans_Datetime_Formatted = k\n\t\tslice1[idx].Amount_String = utilities.DisplayPrettyFloat64(v)\n\n\t\tidx++\n\t}\n\n\tsort.Slice(slice, func(i, j int) bool { return slice[i].Label < slice[j].Label })\n\n\tsbc.Bars = slice\n\n\toutputfile2 := \"./asset/static/outputfile2.png\"\n\n\t//buffer := []byte{}\n\n\tf2, _ := os.Create(outputfile2)\n\n\twriter2 := bufio.NewWriter(f2)\n\n\tdefer f2.Close()\n\n\t_ = sbc.Render(chart.PNG, writer2)\n\n\twriter2.Flush()\n\n\tidx2 := 0\n\n\tslice2 := make([]chart.Value, len(n))\n\n\t//make([]summary.Earning, len(n))\n\n\tslice3 := make([]summary.Earning, len(n))\n\t//fmt.Println(\"Arr:\", slice)\n\tfor k, v := range n {\n\t\t//sbc.Bars[idx].Label = k\n\t\t//sbc.Bars[idx].Value = v\n\n\t\t//\t\tfmt.Println(k, v)\n\t\t//fmt.Printf(\"type: %T\\n\", sbc.Bars)\n\t\tslice2[idx2].Label = k\n\t\tslice2[idx2].Value = v\n\n\t\tslice3[idx2].Trans_code = k\n\t\tslice3[idx2].Amount_String = utilities.DisplayPrettyFloat64(v)\n\n\t\tidx2++\n\t}\n\n\tpie2.Values = slice2\n\n\toutputfile3 := \"./asset/static/outputfile3.png\"\n\n\tf3, _ := os.Create(outputfile3)\n\n\twriter3 := bufio.NewWriter(f3)\n\n\tdefer f3.Close()\n\n\t_ = pie2.Render(chart.PNG, writer3)\n\n\twriter3.Flush()\n\n\t//fmt.Println(n)\n\n\t//\tfmt.Println(daily_earnings)\n\t//\tfmt.Println(slice3)\n\n\tcurrentTime := time.Now()\n\n\tv := c.View.New(\"summary/index\")\n\tv.Vars[\"items\"] = items\n\tv.Vars[\"today\"] = currentTime.Format(defaultFormat)\n\t//fmt.Println(daily_earnings)\n\t//v.Vars[\"buf\"] = outputfile\n\t//v.Vars[\"daily_earnings\"] = daily_earnings\n\tv.Vars[\"daily_earnings\"] = slice1\n\tv.Vars[\"earnings_by_transcode\"] = slice3\n\tv.Render(w, r)\n}","func IndexHandler() gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\tpprof.Index(c.Writer, c.Request)\n\t}\n}","func indexHandler(res http.ResponseWriter, req *http.Request) {\n\n\t// Execute the template and respond with the index page.\n\ttemplates.ExecuteTemplate(res, \"index\", nil)\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\tc := flight.Context(w, r)\n\n\titems, sum, cnt, _, err := code.All(c.DB)\n\tif err != nil {\n\t\tc.FlashErrorGeneric(err)\n\t\titems = []code.Item{}\n\t}\n\n\tdefaultFormat := \"Mon, 02-Jan-2006\"\n\n\tfor i := 0; i < len(items); i++ {\n\t\titems[i].Trans_Datetime_Formatted = items[i].Trans_Datetime.Time.Format(defaultFormat)\n\t\titems[i].Details_Split = strings.Split(items[i].Details, \"|\")\n\t\titems[i].Amount_String = u.DisplayPrettyNullFloat64(items[i].Amount)\n\t}\n\n\tprettysum := u.DisplayPrettyFloat(sum)\n\tprettycnt := u.DisplayPrettyFloat(cnt)\n\n\tv := c.View.New(\"code/index\")\n\tv.Vars[\"items\"] = items\n\tv.Vars[\"sum\"] = prettysum\n\tv.Vars[\"cnt\"] = prettycnt\n\tv.Render(w, r)\n}","func IndexHandler(w http.ResponseWriter, r *http.Request) {\n\thttp.Redirect(w, r, \"http://sjsafranek.github.io/gospatial/\", 200)\n\treturn\n}","func indexHandler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprint(w, \"Whoa, Nice!\")\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\tenv.Output.WriteChDebug(\"(ApiEngine::Index)\")\n\thttp.Redirect(w, r, \"/api/node\", http.StatusFound)\n}","func index(ctx *gin.Context) {\n\tctx.Header(\"Content-Type\", \"text/html\")\n\tctx.String(\n\t\thttp.StatusOK,\n\t\t\"

Rasse Server

Wel come to the api server.

%v

\",nil)\n}","func (ns *EsIndexer) Start(grpcClient types.AergoRPCServiceClient, reindex bool) error {\n\turl := ns.esURL\n\tif !strings.HasPrefix(url, \"http\") {\n\t\turl = fmt.Sprintf(\"http://%s\", url)\n\t}\n\ttr := &http.Transport{\n\t\tTLSClientConfig: &tls.Config{InsecureSkipVerify: true},\n\t}\n\thttpClient := &http.Client{Transport: tr}\n\tclient, err := elastic.NewClient(\n\t\telastic.SetHttpClient(httpClient),\n\t\telastic.SetURL(url),\n\t\telastic.SetHealthcheckTimeoutStartup(30*time.Second),\n\t\telastic.SetSniff(false),\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\tns.client = client\n\tns.grpcClient = grpcClient\n\n\tif reindex {\n\t\tns.log.Warn().Msg(\"Reindexing database. Will sync from scratch and replace index aliases when caught up\")\n\t\tns.reindexing = true\n\t}\n\n\tns.CreateIndexIfNotExists(\"tx\")\n\tns.CreateIndexIfNotExists(\"block\")\n\tns.CreateIndexIfNotExists(\"name\")\n\tns.UpdateLastBlockHeightFromDb()\n\tns.log.Info().Uint64(\"lastBlockHeight\", ns.lastBlockHeight).Msg(\"Started Elasticsearch Indexer\")\n\n\tgo ns.CheckConsistency()\n\n\treturn ns.StartStream()\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"%v\", \"Hello world\")\n}","func IndexHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tif pusher, ok := w.(http.Pusher); ok {\n\t\tif err := pusher.Push(\"./web/css/app.css\", nil); err != nil {\n\t\t\tlog.Printf(\"Failed to push %v\\n\", err)\n\t\t}\n\t}\n\tt, err := template.ParseFiles(\"./web/html/index.html\")\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tt.Execute(w, nil)\n}","func main() {\n\tapp := iris.New()\n\ts := sse.New()\n\t/*\n\t\tThis creates a new stream inside of the scheduler.\n\t\tSeeing as there are no consumers, publishing a message\n\t\tto this channel will do nothing.\n\t\tClients can connect to this stream once the iris handler is started\n\t\tby specifying stream as a url parameter, like so:\n\t\thttp://localhost:8080/events?stream=messages\n\t*/\n\ts.CreateStream(\"messages\")\n\n\tapp.Any(\"/events\", iris.FromStd(s))\n\n\tgo func() {\n\t\t// You design when to send messages to the client,\n\t\t// here we just wait 5 seconds to send the first message\n\t\t// in order to give u time to open a browser window...\n\t\ttime.Sleep(5 * time.Second)\n\t\t// Publish a payload to the stream.\n\t\ts.Publish(\"messages\", &sse.Event{\n\t\t\tData: []byte(\"ping\"),\n\t\t})\n\n\t\ttime.Sleep(3 * time.Second)\n\t\ts.Publish(\"messages\", &sse.Event{\n\t\t\tData: []byte(\"second message\"),\n\t\t})\n\t\ttime.Sleep(2 * time.Second)\n\t\ts.Publish(\"messages\", &sse.Event{\n\t\t\tData: []byte(\"third message\"),\n\t\t})\n\t}() // ...\n\n\tapp.Listen(\":8080\")\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"Hello from our index page\")\n}","func run() {\n\tfor {\n\t\tselect {\n\t\tcase at, more := <-pump:\n\t\t\tlog.WithField(ctx, \"time\", at).Debug(\"sse pump\")\n\n\t\t\tprev := nextTick\n\t\t\tnextTick = make(chan struct{})\n\t\t\t// trigger all listeners by closing the nextTick channel\n\t\t\tclose(prev)\n\n\t\t\tif !more {\n\t\t\t\treturn\n\t\t\t}\n\t\tcase <-ctx.Done():\n\t\t\tpump = nil\n\t\t\treturn\n\t\t}\n\t}\n}","func (s *Server) Index(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"[INDEX]: \", r.URL.Path[1:])\n\tu, ok := s.m[r.URL.Path[1:]]\n\tif !ok {\n\t\tw.WriteHeader(http.StatusNotFound)\n\t\tfmt.Fprintf(w, \"not found\\n\")\n\t\treturn\n\t}\n\thttp.Redirect(w, r, u, http.StatusMovedPermanently)\n}","func (c *Client) IndexUpdate(update io.Reader, opts IndexUpdateOptions) error {\n\tpopts := PostMultipartOptions{\n\t\tFiles: map[string]io.Reader{\n\t\t\t\"update\": update,\n\t\t},\n\t\tProgress: opts.Progress,\n\t}\n\n\treturn c.PostMultipart(\"/index/update\", popts, nil)\n}","func (s *Service) HandleIndex(w http.ResponseWriter, r *http.Request) {\n\tpag, err := s.parsePagination(r)\n\tif err != nil {\n\t\ts.writer.Error(w, \"error during pagination parse\", err, http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif err = pag.Valid(); err != nil {\n\t\ts.writer.Error(w, \"invalid pagination\", err, http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tsubs, subsPag, err := s.subscriptionRepository.FindAll(\n\t\tr.Context(), pag, s.getResourceID(r),\n\t)\n\tif err != nil {\n\t\ts.writer.Error(w, \"error during subscriptions search\", err, http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\ts.writer.Response(w, &response{\n\t\tSubscriptions: transformSubscriptions(subs),\n\t\tPagination: transformPagination(subsPag),\n\t}, http.StatusOK, nil)\n}","func (i *Index) Index(docs []index.Document, opts interface{}) error {\n blk := i.conn.Bulk()\n\tfor _, doc := range docs {\n //fmt.Println(\"indexing \", doc.Id)\n\t\treq := elastic.NewBulkIndexRequest().Index(i.name).Type(\"doc\").Id(doc.Id).Doc(doc.Properties)\n\t\tblk.Add(req)\n\t\t/*_, err := i.conn.Index().Index(i.name).Type(\"doc\").Id(doc.Id).BodyJson(doc.Properties).Do()\n if err != nil {\n // Handle error\n panic(err)\n }*/\n //fmt.Printf(\"Indexed tweet %s to index %s, type %s\\n\", put2.Id, put2.Index, put2.Type)\n\t}\n\t//_, err := blk.Refresh(true).Do()\n\t_, err := blk.Refresh(false).Do()\n if err != nil {\n panic(err)\n fmt.Println(\"Get Error during indexing\", err)\n }\n\treturn err\n\t//return nil\n}","func indexHandler(w http.ResponseWriter, r *http.Request) {\n\tdata := &Index{\n\t\tTitle: \"Image gallery\",\n\t\tBody: \"Welcome to the image gallery.\",\n\t}\n\tfor name, img := range images {\n\t\tdata.Links = append(data.Links, Link{\n\t\t\tURL: \"/image/\" + name,\n\t\t\tTitle: img.Title,\n\t\t})\n\t}\n\tif err := indexTemplate.Execute(w, data); err != nil {\n\t\tlog.Println(err)\n\t}\n}","func (s *FieldStatsService) Index(index ...string) *FieldStatsService {\n\ts.index = append(s.index, index...)\n\treturn s\n}","func HandleIndex(w http.ResponseWriter, r *http.Request, p httprouter.Params) {\n\tname := p.ByName(\"name\")\n\tresponse := snakes[name].Info\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\terr := json.NewEncoder(w).Encode(response)\n\tif err != nil {\n\t\tfmt.Println(\"ERROR: response write: \" + err.Error())\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tfmt.Println(\"Index: \" + name)\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\tmessage := \"Welcome to Recipe Book!\"\n\tindexT.Execute(w, message)\n}","func (tc *TransactionsController) Index(c *gin.Context, size, page, offset int) {\n\ttxs, count, err := tc.App.GetStore().Transactions(offset, size)\n\tptxs := make([]presenters.Tx, len(txs))\n\tfor i, tx := range txs {\n\t\tptxs[i] = presenters.NewTx(&tx)\n\t}\n\tpaginatedResponse(c, \"Transactions\", size, page, ptxs, count, err)\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\tw.WriteHeader(http.StatusOK)\n\tw.Write([]byte(\"Hello World!\"))\n}","func BenchmarkIndexHandler(b *testing.B) {\n\tc, _ := loadTestYaml()\n\tcontext := &Context{Config: c}\n\tappHandler := &CtxWrapper{context, IndexHandler}\n\thandler := http.Handler(appHandler)\n\treq, _ := http.NewRequest(\"GET\", \"/z\", nil)\n\treq.Host = \"g\"\n\trr := httptest.NewRecorder()\n\tfor n := 0; n < b.N; n++ {\n\t\thandler.ServeHTTP(rr, req)\n\t}\n}","func TestIndexHandler(t *testing.T) {\n\tslist := []Subscription{\n\t\tSubscription{\n\t\t\tEventType: \"test_type\",\n\t\t\tContext: \"test_context\",\n\t\t},\n\t}\n\n\th := Handler{\n\t\tdb: MockDatabase{slist: slist},\n\t}\n\treq, w := newReqParams(\"GET\")\n\n\th.Index(w, req, httprouter.Params{})\n\n\tcases := []struct {\n\t\tlabel, actual, expected interface{}\n\t}{\n\t\t{\"Response code\", w.Code, 200},\n\t\t{\"Response body contains context\", strings.Contains(w.Body.String(), slist[0].Context), true},\n\t\t{\"Response body contains event type\", strings.Contains(w.Body.String(), slist[0].EventType), true},\n\t}\n\n\ttestCases(t, cases)\n}","func (s *IndicesStatsService) Index(indices ...string) *IndicesStatsService {\n\ts.index = append(s.index, indices...)\n\treturn s\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\ta := \"hello from index router\"\n\tfmt.Fprintln(w, a)\n}","func (s *service) indexCore(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\treq := &indexRequest{\n\t\tindex: s.index,\n\t\tlog: s.logger,\n\t\tr: r,\n\t\tstore: s.store,\n\t}\n\treq.init()\n\treq.read()\n\treq.readCore()\n\tif req.req.IncludeExecutable {\n\t\treq.readExecutable()\n\t} else {\n\t\treq.computeExecutableSize()\n\t}\n\treq.indexCore()\n\treq.close()\n\n\tif req.err != nil {\n\t\ts.logger.Error(\"indexing\", \"uid\", req.uid, \"err\", req.err)\n\t\twriteError(w, http.StatusInternalServerError, req.err)\n\t\treturn\n\t}\n\n\ts.received.With(prometheus.Labels{\n\t\t\"hostname\": req.coredump.Hostname,\n\t\t\"executable\": req.coredump.Executable,\n\t}).Inc()\n\n\ts.receivedSizes.With(prometheus.Labels{\n\t\t\"hostname\": req.coredump.Hostname,\n\t\t\"executable\": req.coredump.Executable,\n\t}).Observe(datasize.ByteSize(req.coredump.Size).MBytes())\n\n\ts.analysisQueue <- req.coredump\n\n\twrite(w, http.StatusOK, map[string]interface{}{\"acknowledged\": true})\n}","func (req MinRequest) Index(index interface{}) MinRequest {\n\treq.index = index\n\treturn req\n}","func indexHandler() func(http.ResponseWriter, *http.Request) {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tt, err := template.New(\"index\").Parse(indexHTMLTemplate)\n\t\tif err != nil {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\tfmt.Fprintf(w, \"parsing the HTML template failed: %+v\", err)\n\t\t}\n\n\t\tinfo := struct {\n\t\t\tPrefix string\n\t\t}{\n\t\t\tPrefix: rootPrefix,\n\t\t}\n\n\t\terr = t.Execute(w, info)\n\t\tif err != nil {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\tfmt.Fprintf(w, \"error writting index template: %+v\", err)\n\t\t}\n\t}\n}","func HandlerIndex(res http.ResponseWriter, req *http.Request) {\n\thttp.ServeFile(res, req, \"./static/index.html\")\n}","func (h *handler) Serve() {\n\tdefer close(h.stopDone)\n\th.logger.Info(\"Running\")\n\th.updateChan <- addStreamUpdate{streamID: h.streamID}\n\tfor {\n\t\tselect {\n\t\tcase parsedBlock := <-h.ingressChan:\n\t\t\th.updateChan <- h.generator.Generate(h.streamID, false, parsedBlock)\n\t\tcase parsedBlock := <-h.egressChan:\n\t\t\th.updateChan <- h.generator.Generate(h.streamID, true, parsedBlock)\n\t\tcase <-h.stop:\n\t\t\th.logger.Info(\"Stopping...\")\n\t\t\th.updateChan <- removeStreamUpdate{streamID: h.streamID}\n\t\t\treturn\n\t\t}\n\t}\n}","func (s *server) handleIndex(FSS fs.FS) http.HandlerFunc {\n\ttype AppConfig struct {\n\t\tAvatarService string\n\t\tToastTimeout int\n\t\tAllowGuests bool\n\t\tAllowRegistration bool\n\t\tDefaultLocale string\n\t\tAuthMethod string\n\t\tAppVersion string\n\t\tCookieName string\n\t\tPathPrefix string\n\t\tAPIEnabled bool\n\t\tCleanupGuestsDaysOld int\n\t\tCleanupStoryboardsDaysOld int\n\t\tShowActiveCountries bool\n\t}\n\ttype UIConfig struct {\n\t\tAnalyticsEnabled bool\n\t\tAnalyticsID string\n\t\tAppConfig AppConfig\n\t\tActiveAlerts []interface{}\n\t}\n\n\ttmpl := s.getIndexTemplate(FSS)\n\n\tappConfig := AppConfig{\n\t\tAvatarService: viper.GetString(\"config.avatar_service\"),\n\t\tToastTimeout: viper.GetInt(\"config.toast_timeout\"),\n\t\tAllowGuests: viper.GetBool(\"config.allow_guests\"),\n\t\tAllowRegistration: viper.GetBool(\"config.allow_registration\") && viper.GetString(\"auth.method\") == \"normal\",\n\t\tDefaultLocale: viper.GetString(\"config.default_locale\"),\n\t\tAuthMethod: viper.GetString(\"auth.method\"),\n\t\tAPIEnabled: viper.GetBool(\"config.allow_external_api\"),\n\t\tAppVersion: s.config.Version,\n\t\tCookieName: s.config.FrontendCookieName,\n\t\tPathPrefix: s.config.PathPrefix,\n\t\tCleanupGuestsDaysOld: viper.GetInt(\"config.cleanup_guests_days_old\"),\n\t\tCleanupStoryboardsDaysOld: viper.GetInt(\"config.cleanup_storyboards_days_old\"),\n\t\tShowActiveCountries: viper.GetBool(\"config.show_active_countries\"),\n\t}\n\n\tActiveAlerts = s.database.GetActiveAlerts()\n\n\tdata := UIConfig{\n\t\tAnalyticsEnabled: s.config.AnalyticsEnabled,\n\t\tAnalyticsID: s.config.AnalyticsID,\n\t\tAppConfig: appConfig,\n\t}\n\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tdata.ActiveAlerts = ActiveAlerts // get latest alerts from memory\n\n\t\tif embedUseOS {\n\t\t\ttmpl = s.getIndexTemplate(FSS)\n\t\t}\n\n\t\ttmpl.Execute(w, data)\n\t}\n}","func (h *MovieHandler) index(w http.ResponseWriter, r *http.Request) {\n\t// Call GetMovies to retrieve all movies from the database.\n\tif movies, err := h.MovieService.GetMovies(); err != nil {\n\t\t// Render an error response and set status code.\n\t\thttp.Error(w, \"Internal Server Error\", http.StatusInternalServerError)\n\t\tlog.Println(\"Error:\", err)\n\t} else {\n\t\t// Render a HTML response and set status code.\n\t\trender.HTML(w, http.StatusOK, \"movie/index.html\", movies)\n\t}\n}","func Index(w http.ResponseWriter, req *http.Request) {\n\tfmt.Fprint(w, \"El servidor esta funcionando\")\n\n\tmatriz := pedidosAnuales.BuscarNodo(2017).meses.searchByContent(04).data\n\tfmt.Println(matriz)\n\tmatriz.lst_h.print()\n\tmatriz.lst_v.print()\n\tfmt.Println(matriz.getGraphviz())\n}","func serveWs(w http.ResponseWriter, r *http.Request) {\n\tconn, err := upgrader.Upgrade(w, r, nil)\n\tif err != nil {\n\t\tlog.Print(err)\n\t\treturn\n\t}\n\tdefer conn.Close()\n\n\t_, p, err := conn.ReadMessage()\n\tif err != nil {\n\t\tlog.Print(err)\n\t\treturn\n\t}\n\turi := string(p)\n\tarticleInfo := articleInfoFromUrl(uri)\n\tif articleInfo == nil {\n\t\tfmt.Printf(\"serveWs: didn't find article for uri %s\\n\", uri)\n\t\treturn\n\t}\n\n\tarticle := articleInfo.this\n\tfmt.Printf(\"serveWs: started watching %s for uri %s\\n\", article.Path, uri)\n\n\tc := AddWatch(article.Path)\n\tdefer RemoveWatch(c)\n\tdone := make(chan struct{})\n\n\tgo func() {\n\t\tfor {\n\t\t\t_, _, err := conn.ReadMessage()\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"serveWs: closing for %s\\n\", uri)\n\t\t\t\tclose(done)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}()\n\nloop:\n\tfor {\n\t\tselect {\n\t\tcase <-c:\n\t\t\treloadArticle(article)\n\t\t\terr := conn.WriteMessage(websocket.TextMessage, nil)\n\t\t\tif err != nil {\n\t\t\t\tlog.Print(err)\n\t\t\t\tbreak loop\n\t\t\t}\n\t\tcase <-done:\n\t\t\tbreak loop\n\t\t}\n\t}\n}","func indexer() {\n\tfor {\n\t\tselect {\n\t\tcase file := <-feedCh:\n\t\t\treadFeed(file)\n\t\t}\n\t}\n}","func Index(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintln(w, \"Welcome to the DEM service!\")\n}","func (e Manager) Send(envelope sunduq.Envelope) {\n\te.index.send(envelope)\n}","func indexHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"indexHandler is called\")\n\n\tw.WriteHeader(http.StatusOK)\n\tjson.NewEncoder(w).Encode(appResponse{Message: \"OK\"})\n}","func (req *MinRequest) Index(index interface{}) *MinRequest {\n\treq.index = index\n\treturn req\n}","func ReadIndex(output http.ResponseWriter, reader *http.Request) {\n\tfmt.Fprintln(output, \"ImageManagerAPI v1.0\")\n\tLog(\"info\", \"Endpoint Hit: ReadIndex\")\n}","func Index(_ core.StorageClient) gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\tc.String(http.StatusOK, \"Hello World!\")\n\t}\n}","func indexHandler(w http.ResponseWriter, r *http.Request) {\n\tswitch r.Method {\n\tcase \"GET\":\n\t\tmovies, err := service.GetMoviesData()\n\t\tif err != nil {\n\t\t\tlog.Printf(\"getMoviesData: %v\", err)\n\t\t\thttp.Error(w, \"Internal Server Error\", http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tjs, err := json.Marshal(movies)\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.Write(js)\n\n\tdefault:\n\t\thttp.Error(w, fmt.Sprintf(\"HTTP Method %s Not Allowed\", r.Method), http.StatusMethodNotAllowed)\n\t}\n}","func (s *IndicesSyncedFlushService) Index(indices ...string) *IndicesSyncedFlushService {\n\ts.index = append(s.index, indices...)\n\treturn s\n}","func TestIndexHandler(t *testing.T) {\n\telist := []Event{testEvent}\n\n\th := Handler{\n\t\tdb: MockDatabase{elist: elist},\n\t}\n\treq, w := newReqParams(\"GET\")\n\n\th.Index(w, req, httprouter.Params{})\n\n\tcases := []struct {\n\t\tlabel, actual, expected interface{}\n\t}{\n\t\t{\"Response code\", w.Code, 200},\n\t\t{\"Response body contains context\", strings.Contains(w.Body.String(), testEvent.Context), true},\n\t\t{\"Response body contains event type\", strings.Contains(w.Body.String(), testEvent.EventType), true},\n\t\t{\"Response body contains data\", strings.Contains(w.Body.String(), testEvent.Data), true},\n\t\t{\"Response body contains id\", strings.Contains(w.Body.String(), testEvent.ID.String()), true},\n\t\t{\"Response body contains account id\", strings.Contains(w.Body.String(), testEvent.OriginalAccountID.String()), true},\n\t}\n\n\ttestCases(t, cases)\n}"],"string":"[\n \"func (action *LedgerIndexAction) SSE(stream sse.Stream) {\\n\\taction.LoadRecords()\\n\\n\\tif action.Err != nil {\\n\\t\\tstream.Err(action.Err)\\n\\t\\treturn\\n\\t}\\n\\n\\trecords := action.Records[stream.SentCount():]\\n\\n\\tfor _, record := range records {\\n\\t\\tstream.Send(sse.Event{\\n\\t\\t\\tID: record.PagingToken(),\\n\\t\\t\\tData: NewLedgerResource(record),\\n\\t\\t})\\n\\t}\\n\\n\\tif stream.SentCount() >= int(action.Query.Limit) {\\n\\t\\tstream.Done()\\n\\t}\\n}\",\n \"func (action *TransactionIndexAction) SSE(stream sse.Stream) {\\n\\taction.Setup(\\n\\t\\taction.EnsureHistoryFreshness,\\n\\t\\taction.loadParams,\\n\\t\\taction.checkAllowed,\\n\\t\\taction.ValidateCursorWithinHistory,\\n\\t)\\n\\taction.Do(\\n\\t\\tfunc() {\\n\\t\\t\\t// we will reuse this variable in sse, so re-initializing is required\\n\\t\\t\\taction.Records = []history.Transaction{}\\n\\t\\t},\\n\\t\\taction.loadRecords,\\n\\t\\tfunc() {\\n\\t\\t\\trecords := action.Records[:]\\n\\n\\t\\t\\tfor _, record := range records {\\n\\t\\t\\t\\tres := resource.PopulateTransaction(record)\\n\\t\\t\\t\\tstream.Send(sse.Event{\\n\\t\\t\\t\\t\\tID: res.PagingToken(),\\n\\t\\t\\t\\t\\tData: res,\\n\\t\\t\\t\\t})\\n\\t\\t\\t\\taction.PagingParams.Cursor = res.PagingToken()\\n\\t\\t\\t}\\n\\t\\t},\\n\\t)\\n}\",\n \"func (action *AccountIndexAction) SSE(stream sse.Stream) {\\n\\taction.Setup(action.LoadQuery)\\n\\taction.Do(\\n\\t\\taction.LoadRecords,\\n\\t\\tfunc() {\\n\\t\\t\\tstream.SetLimit(int(action.Query.Limit))\\n\\t\\t\\tvar res resource.HistoryAccount\\n\\t\\t\\tfor _, record := range action.Records[stream.SentCount():] {\\n\\t\\t\\t\\tres.Populate(action.Ctx, record)\\n\\t\\t\\t\\tstream.Send(sse.Event{ID: record.PagingToken(), Data: res})\\n\\t\\t\\t}\\n\\t\\t},\\n\\t)\\n}\",\n \"func (si ServeIndex) Index(w http.ResponseWriter, r *http.Request) {\\n\\tpara := params.NewParams()\\n\\tdata, _, err := Updates(r, para)\\n\\tif err != nil {\\n\\t\\tif _, ok := err.(params.RenamedConstError); ok {\\n\\t\\t\\thttp.Redirect(w, r, err.Error(), http.StatusFound)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\thttp.Error(w, err.Error(), http.StatusInternalServerError)\\n\\t\\treturn\\n\\t}\\n\\n\\tdata[\\\"Distrib\\\"] = si.StaticData.Distrib\\n\\tdata[\\\"Exporting\\\"] = exportingCopy() // from ./ws.go\\n\\tdata[\\\"OstentUpgrade\\\"] = OstentUpgrade.Get()\\n\\tdata[\\\"OstentVersion\\\"] = si.StaticData.OstentVersion\\n\\tdata[\\\"TAGGEDbin\\\"] = si.StaticData.TAGGEDbin\\n\\n\\tsi.IndexTemplate.Apply(w, struct{ Data IndexData }{Data: data})\\n}\",\n \"func (sw ServeWS) IndexWS(w http.ResponseWriter, req *http.Request) {\\n\\t// Upgrader.Upgrade() has Origin check if .CheckOrigin is nil\\n\\tupgrader := &websocket.Upgrader{HandshakeTimeout: 5 * time.Second}\\n\\twsconn, err := upgrader.Upgrade(w, req, nil)\\n\\tif err != nil { // Upgrade() does http.Error() to the client\\n\\t\\treturn\\n\\t}\\n\\n\\tc := &conn{\\n\\t\\tlogger: sw.logger,\\n\\t\\tConn: wsconn,\\n\\n\\t\\tinitialRequest: req,\\n\\t\\tlogRequests: sw.logRequests,\\n\\n\\t\\tpara: params.NewParams(),\\n\\t}\\n\\tconnections.reg(c)\\n\\tdefer func() {\\n\\t\\tconnections.unreg(c)\\n\\t\\tc.Conn.Close()\\n\\t}()\\n\\tfor {\\n\\t\\trd := new(received)\\n\\t\\tif err := c.Conn.ReadJSON(&rd); err != nil || !c.Process(rd, nil) {\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t}\\n}\",\n \"func (action *AccountShowAction) SSE(stream sse.Stream) {\\n\\taction.Do(\\n\\t\\taction.LoadQuery,\\n\\t\\taction.LoadRecord,\\n\\t\\taction.LoadResource,\\n\\t\\tfunc() {\\n\\t\\t\\tstream.SetLimit(10)\\n\\t\\t\\tstream.Send(sse.Event{Data: action.Resource})\\n\\t\\t},\\n\\t)\\n}\",\n \"func (esHandler *ESHandler) Index(verses []Verse) error {\\n\\tctx := context.Background()\\n\\tserivce, err := esHandler.Client.BulkProcessor().Name(\\\"ScriptureProcessor\\\").Workers(2).BulkActions(1000).Do(ctx)\\n\\tif err != nil {\\n\\t\\treturn errors.Wrap(err, \\\"Error initializing BulkProcessor\\\")\\n\\t}\\n\\tdefer serivce.Close()\\n\\n\\tfor _, v := range verses {\\n\\t\\tid := v.GetID()\\n\\t\\tr := elastic.NewBulkIndexRequest().Index(esHandler.ESIndex).Type(\\\"Verse\\\").Id(id).Doc(v)\\n\\t\\tserivce.Add(r)\\n\\t}\\n\\treturn nil\\n}\",\n \"func (h *SubscribeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tvar index, err = strconv.Atoi(r.Header.Get(\\\"Last-Event-ID\\\"))\\n\\tif r.Header.Get(\\\"Last-Event-ID\\\") != \\\"\\\" {\\n\\t\\tif err != nil {\\n\\t\\t\\thttp.Error(w, err.Error(), http.StatusBadRequest)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tindex += 1\\n\\t}\\n\\n\\t// Create a channel for subscribing to database updates.\\n\\tch := h.db.Subscribe(index)\\n\\tcloseNotifier := w.(http.CloseNotifier).CloseNotify()\\n\\n\\t// Mark this as an SSE event stream.\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"text/event-stream\\\")\\n\\n\\t// Continually stream updates as they come.\\nloop:\\n\\tfor {\\n\\t\\tselect {\\n\\t\\tcase <-closeNotifier:\\n\\t\\t\\tbreak loop\\n\\n\\t\\tcase row := <-ch:\\n\\t\\t\\t// Encode row as JSON.\\n\\t\\t\\tb, err := json.Marshal(row)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\thttp.Error(w, err.Error(), http.StatusInternalServerError)\\n\\t\\t\\t\\tbreak loop\\n\\t\\t\\t}\\n\\n\\t\\t\\t// Send row as server-sent event.\\n\\t\\t\\tfmt.Fprintf(w, \\\"id: %d\\\\n\\\", row.Index())\\n\\t\\t\\tfmt.Fprintf(w, \\\"data: %s\\\\n\\\\n\\\", b)\\n\\t\\t\\tw.(http.Flusher).Flush()\\n\\t\\t}\\n\\t}\\n\\n\\t// Unsubscribe from the database when the connection is lost.\\n\\th.db.Unsubscribe(ch)\\n}\",\n \"func HandleSSE(handler func(http.ResponseWriter, *http.Request, *MessageFlusher, <-chan bool)) func(http.ResponseWriter, *http.Request) {\\n\\treturn func(w http.ResponseWriter, r *http.Request) {\\n\\t\\tflusher, ok := makeNewMessageFlusher(w)\\n\\t\\tif !ok {\\n\\t\\t\\thttp.Error(w, \\\"Streaming unsupported.\\\", http.StatusInternalServerError)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tw.Header().Set(\\\"Content-Type\\\", \\\"text/event-stream\\\")\\n\\t\\tw.Header().Set(\\\"Cache-Control\\\", \\\"no-cache\\\")\\n\\t\\tw.Header().Set(\\\"Connection\\\", \\\"keep-alive\\\")\\n\\t\\tfmt.Println(\\\"opening connection\\\")\\n\\t\\tcn, ok := w.(http.CloseNotifier)\\n\\t\\tif !ok {\\n\\t\\t\\thttp.Error(w, \\\"Closing not supported\\\", http.StatusNotImplemented)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tclose := cn.CloseNotify()\\n\\t\\thandler(w, r, flusher, close)\\n\\t}\\n}\",\n \"func (es *EventSource) ServeHTTP(w http.ResponseWriter, r *http.Request) {\\n\\tvar startID int\\n\\tif start := r.Header.Get(\\\"Last-Event-ID\\\"); start != \\\"\\\" {\\n\\t\\tif _, err := fmt.Sscanf(start, \\\"%d\\\", &startID); err != nil {\\n\\t\\t\\thttp.Error(w, \\\"bad Last-Event-ID\\\", http.StatusBadRequest)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tstartID++\\n\\t}\\n\\n\\tw.Header().Set(\\\"Content-Type\\\", ContentType)\\n\\tw.Header().Set(\\\"Connection\\\", \\\"keep-alive\\\")\\n\\tw.Header().Set(\\\"Cache-Control\\\", \\\"no-cache\\\")\\n\\tw.Header().Set(\\\"Transfer-Encoding\\\", \\\"chunked\\\")\\n\\tw.WriteHeader(200)\\n\\n\\tflusher, ok := w.(http.Flusher)\\n\\tif !ok {\\n\\t\\tpanic(\\\"esource: ServeHTTP called without a Flusher\\\")\\n\\t}\\n\\n\\tlog.Printf(\\\"esource: [%s] starting stream\\\", r.RemoteAddr)\\n\\n\\told, events := es.Tee(startID)\\n\\tfor _, event := range old {\\n\\t\\tif _, err := event.WriteTo(w); err != nil {\\n\\t\\t\\tlog.Printf(\\\"esource: [%s] failed to write backlogged event %+v\\\", r.RemoteAddr, event)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t}\\n\\tflusher.Flush()\\n\\n\\tfor event := range events {\\n\\t\\tif _, err := event.WriteTo(w); err != nil {\\n\\t\\t\\tlog.Printf(\\\"esource: [%s] failed to write event %+v\\\", r.RemoteAddr, event)\\n\\t\\t\\tfmt.Fprintln(w, \\\"\\\\nretry: 0\\\\n\\\")\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tflusher.Flush()\\n\\t}\\n\\n\\tlog.Printf(\\\"esource: [%s] complete\\\", r.RemoteAddr)\\n}\",\n \"func (sse *SSE) ServeHTTP(_ http.ResponseWriter, r *http.Request) {\\n\\tw := sse.Writer\\n\\tdata, _, err := Updates(r, sse.Params)\\n\\tif err != nil {\\n\\t\\tif _, ok := err.(params.RenamedConstError); ok {\\n\\t\\t\\thttp.Redirect(w, r, err.Error(), http.StatusFound)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\thttp.Error(w, err.Error(), http.StatusInternalServerError)\\n\\t}\\n\\ttext, err := json.Marshal(data)\\n\\tif err != nil {\\n\\t\\tsse.Errord = true\\n\\t\\t// what would http.Error do\\n\\t\\tif sse.SetHeader(\\\"Content-Type\\\", \\\"text/plain; charset=utf-8\\\") {\\n\\t\\t\\tw.WriteHeader(http.StatusInternalServerError)\\n\\t\\t}\\n\\t\\tfmt.Fprintln(w, err.Error())\\n\\t\\treturn\\n\\t}\\n\\tsse.SetHeader(\\\"Content-Type\\\", \\\"text/event-stream\\\")\\n\\tif _, err := w.Write(append(append([]byte(\\\"data: \\\"), text...), []byte(\\\"\\\\n\\\\n\\\")...)); err != nil {\\n\\t\\tsse.Errord = true\\n\\t}\\n}\",\n \"func (ms *MusicServer) Index(response http.ResponseWriter, request *http.Request) {\\n\\t// Always check addressMask. If no define, mask is 0.0.0.0 and nothing is accepted (except localhost)\\n\\tif !ms.checkRequester(request) {\\n\\t\\treturn\\n\\t}\\n\\tif ms.musicFolder != \\\"\\\" {\\n\\t\\ttextIndexer := music.IndexArtists(ms.folder)\\n\\t\\tms.indexManager.UpdateIndexer(textIndexer)\\n\\t}\\n}\",\n \"func Index(w http.ResponseWriter, data *IndexData) {\\n\\trender(tpIndex, w, data)\\n}\",\n \"func Index(w http.ResponseWriter, data *IndexData) {\\n\\trender(tpIndex, w, data)\\n}\",\n \"func (s *ChartStreamServer) IndexHandler(c *gin.Context) {\\n\\tindex, err := s.chartProvider.GetIndexFile()\\n\\tif err != nil {\\n\\t\\tc.AbortWithError(500, err)\\n\\t}\\n\\n\\tc.YAML(200, index)\\n}\",\n \"func indexHandler(w http.ResponseWriter, r *http.Request, s *Server) {\\n\\tif r.Method == \\\"GET\\\" {\\n\\t\\t//create the source upload page with available languages and metrics\\n\\t\\tpage := &Page{Config: s.Config, Extensions: s.Analyzer.Extensions(), Metrics: s.Analyzer.Metrics, Languages: s.Analyzer.Languages}\\n\\n\\t\\t//display the source upload page\\n\\t\\ts.Template.ExecuteTemplate(w, \\\"index.html\\\", page)\\n\\t}\\n}\",\n \"func (c *Connection) Index(idx []FileInfo) {\\n\\tc.Lock()\\n\\tvar msgType int\\n\\tif c.indexSent == nil {\\n\\t\\t// This is the first time we send an index.\\n\\t\\tmsgType = messageTypeIndex\\n\\n\\t\\tc.indexSent = make(map[string]int64)\\n\\t\\tfor _, f := range idx {\\n\\t\\t\\tc.indexSent[f.Name] = f.Modified\\n\\t\\t}\\n\\t} else {\\n\\t\\t// We have sent one full index. Only send updates now.\\n\\t\\tmsgType = messageTypeIndexUpdate\\n\\t\\tvar diff []FileInfo\\n\\t\\tfor _, f := range idx {\\n\\t\\t\\tif modified, ok := c.indexSent[f.Name]; !ok || f.Modified != modified {\\n\\t\\t\\t\\tdiff = append(diff, f)\\n\\t\\t\\t\\tc.indexSent[f.Name] = f.Modified\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tidx = diff\\n\\t}\\n\\n\\tc.mwriter.writeHeader(header{0, c.nextId, msgType})\\n\\tc.mwriter.writeIndex(idx)\\n\\terr := c.flush()\\n\\tc.nextId = (c.nextId + 1) & 0xfff\\n\\tc.hasSentIndex = true\\n\\tc.Unlock()\\n\\n\\tif err != nil {\\n\\t\\tc.Close(err)\\n\\t\\treturn\\n\\t} else if c.mwriter.err != nil {\\n\\t\\tc.Close(c.mwriter.err)\\n\\t\\treturn\\n\\t}\\n}\",\n \"func (siw *SindexWatcher) refresh(o *Observer, infoKeys []string, rawMetrics map[string]string, ch chan<- prometheus.Metric) error {\\n\\tif config.Aerospike.DisableSindexMetrics {\\n\\t\\t// disabled\\n\\t\\treturn nil\\n\\t}\\n\\n\\tif siw.sindexMetrics == nil {\\n\\t\\tsiw.sindexMetrics = make(map[string]AerospikeStat)\\n\\t}\\n\\n\\tfor _, sindex := range infoKeys {\\n\\t\\tsindexInfoKey := strings.ReplaceAll(sindex, \\\"sindex/\\\", \\\"\\\")\\n\\t\\tsindexInfoKeySplit := strings.Split(sindexInfoKey, \\\"/\\\")\\n\\t\\tnsName := sindexInfoKeySplit[0]\\n\\t\\tsindexName := sindexInfoKeySplit[1]\\n\\t\\tlog.Tracef(\\\"sindex-stats:%s:%s:%s\\\", nsName, sindexName, rawMetrics[sindex])\\n\\n\\t\\tstats := parseStats(rawMetrics[sindex], \\\";\\\")\\n\\t\\tfor stat, value := range stats {\\n\\t\\t\\tpv, err := tryConvert(value)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\n\\t\\t\\tasMetric, exists := siw.sindexMetrics[stat]\\n\\n\\t\\t\\tif !exists {\\n\\t\\t\\t\\tasMetric = newAerospikeStat(CTX_SINDEX, stat)\\n\\t\\t\\t\\tsiw.sindexMetrics[stat] = asMetric\\n\\t\\t\\t}\\n\\t\\t\\t// handle any panic from prometheus, this may occur when prom encounters a config/stat with special characters\\n\\t\\t\\tdefer func() {\\n\\t\\t\\t\\tif r := recover(); r != nil {\\n\\t\\t\\t\\t\\tlog.Tracef(\\\"sindex-stats: recovered from panic while handling stat %s in %s\\\", stat, sindexName)\\n\\t\\t\\t\\t}\\n\\t\\t\\t}()\\n\\n\\t\\t\\tif asMetric.isAllowed {\\n\\t\\t\\t\\tdesc, valueType := asMetric.makePromMetric(METRIC_LABEL_CLUSTER_NAME, METRIC_LABEL_SERVICE, METRIC_LABEL_NS, METRIC_LABEL_SINDEX)\\n\\t\\t\\t\\tch <- prometheus.MustNewConstMetric(desc, valueType, pv, rawMetrics[ikClusterName], rawMetrics[ikService], nsName, sindexName)\\n\\t\\t\\t}\\n\\n\\t\\t}\\n\\n\\t}\\n\\n\\treturn nil\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\n\\tfmt.Fprintln(w, \\\"Steve and Kyle Podcast: #api\\\")\\n\\tfmt.Fprintln(w, \\\"Number of episodes in database:\\\", EpCount())\\n\\tfmt.Fprintln(w, \\\"Created by Derek Slenk\\\")\\n\\tfmt.Println(\\\"Endpoint Hit: Index\\\")\\n}\",\n \"func Index(w http.ResponseWriter, data interface{}) {\\n\\trender(tpIndex, w, data)\\n}\",\n \"func (c *rawConnection) Index(repo string, idx []FileInfo) {\\n\\tc.imut.Lock()\\n\\tvar msgType int\\n\\tif c.indexSent[repo] == nil {\\n\\t\\t// This is the first time we send an index.\\n\\t\\tmsgType = messageTypeIndex\\n\\n\\t\\tc.indexSent[repo] = make(map[string][2]int64)\\n\\t\\tfor _, f := range idx {\\n\\t\\t\\tc.indexSent[repo][f.Name] = [2]int64{f.Modified, int64(f.Version)}\\n\\t\\t}\\n\\t} else {\\n\\t\\t// We have sent one full index. Only send updates now.\\n\\t\\tmsgType = messageTypeIndexUpdate\\n\\t\\tvar diff []FileInfo\\n\\t\\tfor _, f := range idx {\\n\\t\\t\\tif vs, ok := c.indexSent[repo][f.Name]; !ok || f.Modified != vs[0] || int64(f.Version) != vs[1] {\\n\\t\\t\\t\\tdiff = append(diff, f)\\n\\t\\t\\t\\tc.indexSent[repo][f.Name] = [2]int64{f.Modified, int64(f.Version)}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tidx = diff\\n\\t}\\n\\tc.imut.Unlock()\\n\\n\\tc.send(header{0, -1, msgType}, IndexMessage{repo, idx})\\n}\",\n \"func Index(c *gin.Context) {\\n\\n\\tw := c.Writer\\n\\tr := c.Request\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"text/html; charset=utf-8\\\")\\n\\tp, lastMod, err := tools.ReadFileIfModified(time.Time{})\\n\\tif err != nil {\\n\\t\\tp = []byte(err.Error())\\n\\t\\tlastMod = time.Unix(0, 0)\\n\\t}\\n\\tvar v = struct {\\n\\t\\tHost string\\n\\t\\tData string\\n\\t\\tLastMod string\\n\\t}{\\n\\t\\tr.Host,\\n\\t\\tstring(p),\\n\\t\\tstrconv.FormatInt(lastMod.UnixNano(), 16),\\n\\t}\\n\\tindexTempl.Execute(w, &v)\\n}\",\n \"func (handler StormWatchHandler) Index(c *gin.Context) {\\n\\tstormWatchs := []m.StormWatch{}\\t\\n\\tvar query = handler.db\\n\\n\\tstartParam,startParamExist := c.GetQuery(\\\"start\\\")\\n\\tlimitParam,limitParamExist := c.GetQuery(\\\"limit\\\")\\n\\n\\t//start param exist\\n\\tif startParamExist {\\n\\t\\tstart,_ := strconv.Atoi(startParam)\\n\\t\\tif start != 0 {\\n\\t\\t\\tquery = query.Offset(start).Order(\\\"created_at asc\\\")\\t\\t\\n\\t\\t} else {\\n\\t\\t\\tquery = query.Offset(0).Order(\\\"created_at desc\\\")\\n\\t\\t}\\n\\t} \\n\\n\\t//limit param exist\\n\\tif limitParamExist {\\n\\t\\tlimit,_ := strconv.Atoi(limitParam)\\n\\t\\tquery = query.Limit(limit)\\n\\t} else {\\n\\t\\tquery = query.Limit(10)\\n\\t}\\n\\n\\tquery.Order(\\\"created_at desc\\\").Find(&stormWatchs)\\n\\tc.JSON(http.StatusOK, stormWatchs)\\n\\treturn\\n}\",\n \"func index(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {\\n\\terr := tpl.ExecuteTemplate(w, \\\"index.html\\\", nil)\\n\\tif err != nil {\\n\\t\\thttp.Error(w, err.Error(), http.StatusInternalServerError)\\n\\t\\tlog.Fatalln(err)\\n\\t}\\n\\tfmt.Println(\\\"HERE INDEX\\\")\\n}\",\n \"func indexHandler(w http.ResponseWriter, req *http.Request) {\\n\\tlayout, err := template.ParseFile(PATH_PUBLIC + TEMPLATE_LAYOUT)\\n\\tif err != nil {\\n\\t\\thttp.Error(w, ERROR_TEMPLATE_NOT_FOUND, http.StatusNotFound)\\n\\t\\treturn\\n\\t}\\n\\tindex, err := template.ParseFile(PATH_PUBLIC + TEMPLATE_INDEX)\\n\\t//artical, err := template.ParseFile(PATH_PUBLIC + TEMPLATE_ARTICAL)\\n\\tif err != nil {\\n\\t\\thttp.Error(w, ERROR_TEMPLATE_NOT_FOUND, http.StatusNotFound)\\n\\t\\treturn\\n\\t}\\n\\tmapOutput := map[string]interface{}{\\\"Title\\\": \\\"炫酷的网站技术\\\" + TITLE, \\\"Keyword\\\": KEYWORD, \\\"Description\\\": DESCRIPTION, \\\"Base\\\": BASE_URL, \\\"Url\\\": BASE_URL, \\\"Carousel\\\": getAddition(PREFIX_INDEX), \\\"Script\\\": getAddition(PREFIX_SCRIPT), \\\"Items\\\": leveldb.GetRandomContents(20, &Filter{})}\\n\\tcontent := []byte(index.RenderInLayout(layout, mapOutput))\\n\\tw.Write(content)\\n\\tgo cacheFile(\\\"index\\\", content)\\n}\",\n \"func indexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tlog.Println(\\\"indexHandler is called\\\")\\n\\n\\tw.WriteHeader(http.StatusOK)\\n}\",\n \"func indexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tlog.Println(\\\"indexHandler is called\\\")\\n\\n\\tw.WriteHeader(http.StatusOK)\\n}\",\n \"func handleIndex(w http.ResponseWriter, r *http.Request) {\\n\\n\\tif r.URL.Path != \\\"/\\\" {\\n\\t\\thttp.NotFound(w, r)\\n\\t\\treturn\\n\\t}\\n\\n\\tc := appengine.NewContext(r)\\n\\tlog.Infof(c, \\\"Serving main page.\\\")\\n\\n\\ttmpl, _ := template.ParseFiles(\\\"web/tmpl/index.tmpl\\\")\\n\\n\\ttmpl.Execute(w, time.Since(initTime))\\n}\",\n \"func indexHandler(c *fiber.Ctx) error {\\n\\treturn common.HandleTemplate(c, \\\"index\\\",\\n\\t\\t\\\"me\\\", nil, 200)\\n}\",\n \"func indexHandler(w http.ResponseWriter, r *http.Request) {\\r\\n t, _ := template.New(\\\"webpage\\\").Parse(indexPage) // parse embeded index page\\r\\n t.Execute(w, pd) // serve the index page (html template)\\r\\n}\",\n \"func (s *Server) Index(w http.ResponseWriter, r *http.Request) {\\n\\tsession := s.getSessionFromCookie(r)\\n\\n\\tif session.IsNew {\\n\\t\\ts.newRandomInbox(session, w, r)\\n\\t\\treturn\\n\\t}\\n\\n\\ts.getInbox(session, w, r)\\n}\",\n \"func index(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprint(w, \\\"index de uma função\\\")\\n}\",\n \"func index(w http.ResponseWriter, req *http.Request, ctx httputil.Context) (e *httputil.Error) {\\n\\tif req.URL.Path != \\\"/\\\" {\\n\\t\\tnotFound(w, req)\\n\\t\\treturn\\n\\t}\\n\\tm := newManager(ctx)\\n\\n\\tres, err := m.Index()\\n\\tif err != nil {\\n\\t\\te = httputil.Errorf(err, \\\"couldn't query for test results\\\")\\n\\t\\treturn\\n\\t}\\n\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"text/html\\\")\\n\\tif err := T(\\\"index/index.html\\\").Execute(w, res); err != nil {\\n\\t\\te = httputil.Errorf(err, \\\"error executing index template\\\")\\n\\t}\\n\\treturn\\n}\",\n \"func (db *DB) Index(ctx context.Context, i services.Consumable) error {\\n\\tvar (\\n\\t\\terr error\\n\\t\\tjob = db.stream.NewJob(\\\"index\\\")\\n\\t\\tsess = db.db.NewSession(job)\\n\\t)\\n\\tjob.KeyValue(\\\"id\\\", i.ID())\\n\\tjob.KeyValue(\\\"chain_id\\\", i.ChainID())\\n\\n\\tdefer func() {\\n\\t\\tif err != nil {\\n\\t\\t\\tjob.CompleteKv(health.Error, health.Kvs{\\\"err\\\": err.Error()})\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tjob.Complete(health.Success)\\n\\t}()\\n\\n\\t// Create db tx\\n\\tvar dbTx *dbr.Tx\\n\\tdbTx, err = sess.Begin()\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\tdefer dbTx.RollbackUnlessCommitted()\\n\\n\\t// Ingest the tx and commit\\n\\terr = db.ingestTx(services.NewConsumerContext(ctx, job, dbTx, i.Timestamp()), i.Body())\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\n\\terr = dbTx.Commit()\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\n\\treturn nil\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprint(w, \\\"s-senpai, please don't hurt me ;_;\\\\n\\\")\\n}\",\n \"func (s *Server) IndexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tworkouts, err := storage.GetWorkouts(s.DataRepository)\\n\\tif err != nil {\\n\\t\\thttp.Error(w, err.Error(), 500)\\n\\t\\treturn\\n\\t}\\n\\n\\tout, err := json.Marshal(workouts)\\n\\tif err != nil {\\n\\t\\thttp.Error(w, err.Error(), 500)\\n\\t\\treturn\\n\\t}\\n\\n\\tfmt.Fprintf(w, string(out))\\n}\",\n \"func (s *Server) indexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tb, _ := s.static.Find(\\\"index.html\\\")\\n\\tw.Write(b)\\n}\",\n \"func Index(data []byte){\\n\\n api.Domain = \\\"localhost\\\"\\n fmt.Println(\\\"Entered inside elasticgo file...lets do this\\\")\\n response, _ := core.Index(\\\"scalegray_sample\\\", \\\"first_sampleset\\\", \\\"3\\\", nil, data)\\n fmt.Println(response)\\n fmt.Println(\\\"Done pushing the data into elastic search..woohoo!\\\")\\n}\",\n \"func Serve(ctx context.Context, serveAddr string, db idb.IndexerDb, fetcherError error, log *log.Logger, options ExtraOptions) {\\n\\te := echo.New()\\n\\te.HideBanner = true\\n\\n\\tif options.MetricsEndpoint {\\n\\t\\tp := echo_contrib.NewPrometheus(\\\"indexer\\\", nil, nil)\\n\\t\\tif options.MetricsEndpointVerbose {\\n\\t\\t\\tp.RequestCounterURLLabelMappingFunc = middlewares.PrometheusPathMapperVerbose\\n\\t\\t} else {\\n\\t\\t\\tp.RequestCounterURLLabelMappingFunc = middlewares.PrometheusPathMapper404Sink\\n\\t\\t}\\n\\t\\t// This call installs the prometheus metrics collection middleware and\\n\\t\\t// the \\\"/metrics\\\" handler.\\n\\t\\tp.Use(e)\\n\\t}\\n\\n\\te.Use(middlewares.MakeLogger(log))\\n\\te.Use(middleware.CORS())\\n\\n\\tmiddleware := make([]echo.MiddlewareFunc, 0)\\n\\n\\tmiddleware = append(middleware, middlewares.MakeMigrationMiddleware(db))\\n\\n\\tif len(options.Tokens) > 0 {\\n\\t\\tmiddleware = append(middleware, middlewares.MakeAuth(\\\"X-Indexer-API-Token\\\", options.Tokens))\\n\\t}\\n\\n\\tapi := ServerImplementation{\\n\\t\\tEnableAddressSearchRoundRewind: options.DeveloperMode,\\n\\t\\tdb: db,\\n\\t\\tfetcher: fetcherError,\\n\\t}\\n\\n\\tgenerated.RegisterHandlers(e, &api, middleware...)\\n\\tcommon.RegisterHandlers(e, &api)\\n\\n\\tif ctx == nil {\\n\\t\\tctx = context.Background()\\n\\t}\\n\\tgetctx := func(l net.Listener) context.Context {\\n\\t\\treturn ctx\\n\\t}\\n\\ts := &http.Server{\\n\\t\\tAddr: serveAddr,\\n\\t\\tReadTimeout: 10 * time.Second,\\n\\t\\tWriteTimeout: 10 * time.Second,\\n\\t\\tMaxHeaderBytes: 1 << 20,\\n\\t\\tBaseContext: getctx,\\n\\t}\\n\\n\\tlog.Fatal(e.StartServer(s))\\n}\",\n \"func (app *Application) Index(w http.ResponseWriter, r *http.Request) {\\n\\tdata := struct {\\n\\t\\tTime int64\\n\\t}{\\n\\t\\tTime: time.Now().Unix(),\\n\\t}\\n\\n\\tt, err := template.ParseFiles(\\\"views/index.tpl\\\")\\n\\n\\tif err != nil {\\n\\t\\tlog.Println(\\\"Template.Parse:\\\", err)\\n\\t\\thttp.Error(w, \\\"Internal Server Error 0x0178\\\", http.StatusInternalServerError)\\n\\t}\\n\\n\\tif err := t.Execute(w, data); err != nil {\\n\\t\\tlog.Println(\\\"Template.Execute:\\\", err)\\n\\t\\thttp.Error(w, \\\"Internal Server Error 0x0183\\\", http.StatusInternalServerError)\\n\\t}\\n}\",\n \"func index(w http.ResponseWriter, r *http.Request){\\n\\terr := templ.ExecuteTemplate(w, \\\"index\\\", nil)\\n\\tif err != nil {\\n\\t\\tfmt.Print(err.Error())\\n\\t}\\n}\",\n \"func serveIndex(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\\n\\terr := serveAssets(w, r, \\\"index.html\\\")\\n\\tcheckError(err)\\n}\",\n \"func indexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tlog.Println(\\\"indexHandler is called\\\")\\n\\n\\tw.WriteHeader(http.StatusOK)\\n\\tjson.NewEncoder(w).Encode(indexHandlerResponse{Message: \\\"OK\\\"})\\n}\",\n \"func index(c echo.Context) error {\\n\\tpprof.Index(c.Response().Writer, c.Request())\\n\\treturn nil\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tif err := json.NewEncoder(w).Encode(ResultIndex{Connect: true}); err != nil {\\n\\t\\tpanic(err)\\n\\t}\\n}\",\n \"func subscribeSSE(transport *HTTPTransport, statuschan chan ServerStatus, errorchan chan error, untilNextOnly bool) error {\\n\\tctx, cancel := context.WithCancel(context.Background())\\n\\n\\tevents := make(chan *sseclient.Event)\\n\\tcancelled := false\\n\\tgo func() {\\n\\t\\tfor {\\n\\t\\t\\te := <-events\\n\\t\\t\\tif e == nil || e.Type == \\\"open\\\" {\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\n\\t\\t\\tstatus := ServerStatus(strings.Trim(string(e.Data), `\\\"`))\\n\\t\\t\\tstatuschan <- status\\n\\t\\t\\tif untilNextOnly || status.Finished() {\\n\\t\\t\\t\\terrorchan <- nil\\n\\t\\t\\t\\tcancelled = true\\n\\t\\t\\t\\tcancel()\\n\\t\\t\\t\\treturn\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}()\\n\\n\\terr := sseclient.Notify(ctx, transport.Server+\\\"statusevents\\\", true, events)\\n\\t// When sse was cancelled, an error is expected to be returned. The channels are already closed then.\\n\\tif cancelled {\\n\\t\\treturn nil\\n\\t}\\n\\tclose(events)\\n\\treturn err\\n}\",\n \"func Index(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {\\n\\tio.WriteString(w, \\\"Hello\\\")\\n}\",\n \"func IndexHandeler(w http.ResponseWriter, r *http.Request) {\\n\\trespond.OK(w, map[string]interface{}{\\n\\t\\t\\\"name\\\": \\\"hotstar-schedular\\\",\\n\\t\\t\\\"version\\\": 1,\\n\\t})\\n}\",\n \"func indexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tw.WriteHeader(http.StatusOK)\\n}\",\n \"func showIndex(res http.ResponseWriter, req *http.Request, params httprouter.Params) {\\n\\tServeTemplateWithParams(res, req, \\\"index.html\\\", nil)\\n}\",\n \"func HandleIndex(w http.ResponseWriter, r *http.Request) {\\n\\tresponse := info()\\n\\n\\terr := utils.Respond(w, response)\\n\\tif err != nil {\\n\\t\\tlog.Printf(\\\"ERROR: Failed to encode info response, %s\\\", err)\\n\\t}\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprintf(w, \\\"Hola, este es el inicio\\\")\\n}\",\n \"func (s *RefreshService) Index(index ...string) *RefreshService {\\n\\ts.index = append(s.index, index...)\\n\\treturn s\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tc := flight.Context(w, r)\\n\\n\\titems, _, err := summary.All(c.DB)\\n\\tif err != nil {\\n\\t\\tc.FlashErrorGeneric(err)\\n\\t\\titems = []summary.Item{}\\n\\t}\\n\\tdefaultFormat := \\\"Mon, 02-Jan-2006\\\"\\n\\n\\tfor i := 0; i < len(items); i++ {\\n\\t\\titems[i].SnapshotDate_Formatted = items[i].SnapshotDate.Time.Format(defaultFormat)\\n\\t\\t//items[i].Details_Split = strings.Split(items[i].Details, \\\"|\\\")\\n\\t\\titems[i].Cash_String = utilities.DisplayPrettyNullFloat64(items[i].Cash)\\n\\t\\titems[i].Loads_String = utilities.DisplayPrettyNullFloat64(items[i].Loads)\\n\\t\\titems[i].SmartMoney_String = utilities.DisplayPrettyNullFloat64(items[i].SmartMoney)\\n\\t\\titems[i].Codes_String = utilities.DisplayPrettyNullFloat64(items[i].Codes)\\n\\t\\titems[i].Total_String = utilities.DisplayPrettyNullFloat64(items[i].Total)\\n\\t}\\n\\n\\tdaily_earnings, _, _ := summary.DailyEarnings(c.DB, \\\"7\\\")\\n\\n\\tm := make(map[string]float64)\\n\\tn := make(map[string]float64)\\n\\n\\tfor i := 0; i < len(daily_earnings); i++ {\\n\\t\\tdaily_earnings[i].Trans_Datetime_Formatted = daily_earnings[i].Trans_Datetime.Time.Format(defaultFormat)\\n\\t\\tdaily_earnings[i].Amount_String = utilities.DisplayPrettyNullFloat64(daily_earnings[i].Amount)\\n\\n\\t\\tm[daily_earnings[i].Trans_Datetime.Time.Format(\\\"2006-01-02\\\")] = m[daily_earnings[i].Trans_Datetime.Time.Format(\\\"2006-01-02\\\")] + daily_earnings[i].Amount.Float64\\n\\t\\tn[daily_earnings[i].Trans_code] = n[daily_earnings[i].Trans_code] + daily_earnings[i].Amount.Float64\\n\\t}\\n\\n\\t//fmt.Println(m)\\n\\n\\t//prettysum := utilities.DisplayPrettyFloat(sum)\\n\\n\\tpie := chart.PieChart{\\n\\t\\tTitle: \\\"Summary\\\",\\n\\t\\tWidth: 512,\\n\\t\\tHeight: 512,\\n\\t\\tValues: []chart.Value{\\n\\t\\t\\t{Value: items[0].Cash.Float64, Label: \\\"Cash\\\"},\\n\\t\\t\\t{Value: items[0].Loads.Float64, Label: \\\"Loads\\\"},\\n\\t\\t\\t{Value: items[0].SmartMoney.Float64, Label: \\\"SmartMoney\\\"},\\n\\t\\t\\t{Value: items[0].Codes.Float64, Label: \\\"Codes\\\"},\\n\\t\\t},\\n\\t}\\n\\n\\toutputfile := \\\"./asset/static/outputfile.png\\\"\\n\\n\\tpie2 := chart.PieChart{\\n\\t\\tTitle: \\\"Summary\\\",\\n\\t\\tWidth: 512,\\n\\t\\tHeight: 512,\\n\\t\\tValues: []chart.Value{},\\n\\t}\\n\\n\\t//outputfile := \\\"./asset/static/outputfile.png\\\"\\n\\n\\t//buffer := []byte{}\\n\\n\\tf, _ := os.Create(outputfile)\\n\\n\\twriter := bufio.NewWriter(f)\\n\\n\\tdefer f.Close()\\n\\n\\t_ = pie.Render(chart.PNG, writer)\\n\\n\\twriter.Flush()\\n\\n\\tsbc := chart.BarChart{\\n\\t\\tTitle: \\\"Daily Total Earnings\\\",\\n\\t\\tTitleStyle: chart.StyleShow(),\\n\\t\\tBackground: chart.Style{\\n\\t\\t\\tPadding: chart.Box{\\n\\t\\t\\t\\tTop: 40,\\n\\t\\t\\t},\\n\\t\\t},\\n\\t\\tHeight: 512,\\n\\t\\tBarWidth: 60,\\n\\t\\tXAxis: chart.Style{\\n\\t\\t\\tShow: true,\\n\\t\\t},\\n\\t\\tYAxis: chart.YAxis{\\n\\t\\t\\tStyle: chart.Style{\\n\\t\\t\\t\\tShow: true,\\n\\t\\t\\t},\\n\\t\\t},\\n\\t\\tBars: []chart.Value{},\\n\\t}\\n\\n\\t//vBars := sbc.Bars\\n\\tidx := 0\\n\\t// fmt.Println(\\\"Length of m:\\\", len(m))\\n\\tslice := make([]chart.Value, len(m))\\n\\n\\tslice1 := make([]summary.Earning, len(m))\\n\\t//fmt.Println(\\\"Arr:\\\", slice)\\n\\tfor k, v := range m {\\n\\n\\t\\t//\\t\\tfmt.Println(k, v)\\n\\t\\t//fmt.Printf(\\\"type: %T\\\\n\\\", sbc.Bars)\\n\\t\\tslice[idx].Label = k\\n\\t\\tslice[idx].Value = v\\n\\n\\t\\tslice1[idx].Trans_Datetime_Formatted = k\\n\\t\\tslice1[idx].Amount_String = utilities.DisplayPrettyFloat64(v)\\n\\n\\t\\tidx++\\n\\t}\\n\\n\\tsort.Slice(slice, func(i, j int) bool { return slice[i].Label < slice[j].Label })\\n\\n\\tsbc.Bars = slice\\n\\n\\toutputfile2 := \\\"./asset/static/outputfile2.png\\\"\\n\\n\\t//buffer := []byte{}\\n\\n\\tf2, _ := os.Create(outputfile2)\\n\\n\\twriter2 := bufio.NewWriter(f2)\\n\\n\\tdefer f2.Close()\\n\\n\\t_ = sbc.Render(chart.PNG, writer2)\\n\\n\\twriter2.Flush()\\n\\n\\tidx2 := 0\\n\\n\\tslice2 := make([]chart.Value, len(n))\\n\\n\\t//make([]summary.Earning, len(n))\\n\\n\\tslice3 := make([]summary.Earning, len(n))\\n\\t//fmt.Println(\\\"Arr:\\\", slice)\\n\\tfor k, v := range n {\\n\\t\\t//sbc.Bars[idx].Label = k\\n\\t\\t//sbc.Bars[idx].Value = v\\n\\n\\t\\t//\\t\\tfmt.Println(k, v)\\n\\t\\t//fmt.Printf(\\\"type: %T\\\\n\\\", sbc.Bars)\\n\\t\\tslice2[idx2].Label = k\\n\\t\\tslice2[idx2].Value = v\\n\\n\\t\\tslice3[idx2].Trans_code = k\\n\\t\\tslice3[idx2].Amount_String = utilities.DisplayPrettyFloat64(v)\\n\\n\\t\\tidx2++\\n\\t}\\n\\n\\tpie2.Values = slice2\\n\\n\\toutputfile3 := \\\"./asset/static/outputfile3.png\\\"\\n\\n\\tf3, _ := os.Create(outputfile3)\\n\\n\\twriter3 := bufio.NewWriter(f3)\\n\\n\\tdefer f3.Close()\\n\\n\\t_ = pie2.Render(chart.PNG, writer3)\\n\\n\\twriter3.Flush()\\n\\n\\t//fmt.Println(n)\\n\\n\\t//\\tfmt.Println(daily_earnings)\\n\\t//\\tfmt.Println(slice3)\\n\\n\\tcurrentTime := time.Now()\\n\\n\\tv := c.View.New(\\\"summary/index\\\")\\n\\tv.Vars[\\\"items\\\"] = items\\n\\tv.Vars[\\\"today\\\"] = currentTime.Format(defaultFormat)\\n\\t//fmt.Println(daily_earnings)\\n\\t//v.Vars[\\\"buf\\\"] = outputfile\\n\\t//v.Vars[\\\"daily_earnings\\\"] = daily_earnings\\n\\tv.Vars[\\\"daily_earnings\\\"] = slice1\\n\\tv.Vars[\\\"earnings_by_transcode\\\"] = slice3\\n\\tv.Render(w, r)\\n}\",\n \"func IndexHandler() gin.HandlerFunc {\\n\\treturn func(c *gin.Context) {\\n\\t\\tpprof.Index(c.Writer, c.Request)\\n\\t}\\n}\",\n \"func indexHandler(res http.ResponseWriter, req *http.Request) {\\n\\n\\t// Execute the template and respond with the index page.\\n\\ttemplates.ExecuteTemplate(res, \\\"index\\\", nil)\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tc := flight.Context(w, r)\\n\\n\\titems, sum, cnt, _, err := code.All(c.DB)\\n\\tif err != nil {\\n\\t\\tc.FlashErrorGeneric(err)\\n\\t\\titems = []code.Item{}\\n\\t}\\n\\n\\tdefaultFormat := \\\"Mon, 02-Jan-2006\\\"\\n\\n\\tfor i := 0; i < len(items); i++ {\\n\\t\\titems[i].Trans_Datetime_Formatted = items[i].Trans_Datetime.Time.Format(defaultFormat)\\n\\t\\titems[i].Details_Split = strings.Split(items[i].Details, \\\"|\\\")\\n\\t\\titems[i].Amount_String = u.DisplayPrettyNullFloat64(items[i].Amount)\\n\\t}\\n\\n\\tprettysum := u.DisplayPrettyFloat(sum)\\n\\tprettycnt := u.DisplayPrettyFloat(cnt)\\n\\n\\tv := c.View.New(\\\"code/index\\\")\\n\\tv.Vars[\\\"items\\\"] = items\\n\\tv.Vars[\\\"sum\\\"] = prettysum\\n\\tv.Vars[\\\"cnt\\\"] = prettycnt\\n\\tv.Render(w, r)\\n}\",\n \"func IndexHandler(w http.ResponseWriter, r *http.Request) {\\n\\thttp.Redirect(w, r, \\\"http://sjsafranek.github.io/gospatial/\\\", 200)\\n\\treturn\\n}\",\n \"func indexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprint(w, \\\"Whoa, Nice!\\\")\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tenv.Output.WriteChDebug(\\\"(ApiEngine::Index)\\\")\\n\\thttp.Redirect(w, r, \\\"/api/node\\\", http.StatusFound)\\n}\",\n \"func index(ctx *gin.Context) {\\n\\tctx.Header(\\\"Content-Type\\\", \\\"text/html\\\")\\n\\tctx.String(\\n\\t\\thttp.StatusOK,\\n\\t\\t\\\"

Rasse Server

Wel come to the api server.

%v

\\\",nil)\\n}\",\n \"func (ns *EsIndexer) Start(grpcClient types.AergoRPCServiceClient, reindex bool) error {\\n\\turl := ns.esURL\\n\\tif !strings.HasPrefix(url, \\\"http\\\") {\\n\\t\\turl = fmt.Sprintf(\\\"http://%s\\\", url)\\n\\t}\\n\\ttr := &http.Transport{\\n\\t\\tTLSClientConfig: &tls.Config{InsecureSkipVerify: true},\\n\\t}\\n\\thttpClient := &http.Client{Transport: tr}\\n\\tclient, err := elastic.NewClient(\\n\\t\\telastic.SetHttpClient(httpClient),\\n\\t\\telastic.SetURL(url),\\n\\t\\telastic.SetHealthcheckTimeoutStartup(30*time.Second),\\n\\t\\telastic.SetSniff(false),\\n\\t)\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\tns.client = client\\n\\tns.grpcClient = grpcClient\\n\\n\\tif reindex {\\n\\t\\tns.log.Warn().Msg(\\\"Reindexing database. Will sync from scratch and replace index aliases when caught up\\\")\\n\\t\\tns.reindexing = true\\n\\t}\\n\\n\\tns.CreateIndexIfNotExists(\\\"tx\\\")\\n\\tns.CreateIndexIfNotExists(\\\"block\\\")\\n\\tns.CreateIndexIfNotExists(\\\"name\\\")\\n\\tns.UpdateLastBlockHeightFromDb()\\n\\tns.log.Info().Uint64(\\\"lastBlockHeight\\\", ns.lastBlockHeight).Msg(\\\"Started Elasticsearch Indexer\\\")\\n\\n\\tgo ns.CheckConsistency()\\n\\n\\treturn ns.StartStream()\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprintf(w, \\\"%v\\\", \\\"Hello world\\\")\\n}\",\n \"func IndexHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\\n\\tif pusher, ok := w.(http.Pusher); ok {\\n\\t\\tif err := pusher.Push(\\\"./web/css/app.css\\\", nil); err != nil {\\n\\t\\t\\tlog.Printf(\\\"Failed to push %v\\\\n\\\", err)\\n\\t\\t}\\n\\t}\\n\\tt, err := template.ParseFiles(\\\"./web/html/index.html\\\")\\n\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n\\n\\tt.Execute(w, nil)\\n}\",\n \"func main() {\\n\\tapp := iris.New()\\n\\ts := sse.New()\\n\\t/*\\n\\t\\tThis creates a new stream inside of the scheduler.\\n\\t\\tSeeing as there are no consumers, publishing a message\\n\\t\\tto this channel will do nothing.\\n\\t\\tClients can connect to this stream once the iris handler is started\\n\\t\\tby specifying stream as a url parameter, like so:\\n\\t\\thttp://localhost:8080/events?stream=messages\\n\\t*/\\n\\ts.CreateStream(\\\"messages\\\")\\n\\n\\tapp.Any(\\\"/events\\\", iris.FromStd(s))\\n\\n\\tgo func() {\\n\\t\\t// You design when to send messages to the client,\\n\\t\\t// here we just wait 5 seconds to send the first message\\n\\t\\t// in order to give u time to open a browser window...\\n\\t\\ttime.Sleep(5 * time.Second)\\n\\t\\t// Publish a payload to the stream.\\n\\t\\ts.Publish(\\\"messages\\\", &sse.Event{\\n\\t\\t\\tData: []byte(\\\"ping\\\"),\\n\\t\\t})\\n\\n\\t\\ttime.Sleep(3 * time.Second)\\n\\t\\ts.Publish(\\\"messages\\\", &sse.Event{\\n\\t\\t\\tData: []byte(\\\"second message\\\"),\\n\\t\\t})\\n\\t\\ttime.Sleep(2 * time.Second)\\n\\t\\ts.Publish(\\\"messages\\\", &sse.Event{\\n\\t\\t\\tData: []byte(\\\"third message\\\"),\\n\\t\\t})\\n\\t}() // ...\\n\\n\\tapp.Listen(\\\":8080\\\")\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprintf(w, \\\"Hello from our index page\\\")\\n}\",\n \"func run() {\\n\\tfor {\\n\\t\\tselect {\\n\\t\\tcase at, more := <-pump:\\n\\t\\t\\tlog.WithField(ctx, \\\"time\\\", at).Debug(\\\"sse pump\\\")\\n\\n\\t\\t\\tprev := nextTick\\n\\t\\t\\tnextTick = make(chan struct{})\\n\\t\\t\\t// trigger all listeners by closing the nextTick channel\\n\\t\\t\\tclose(prev)\\n\\n\\t\\t\\tif !more {\\n\\t\\t\\t\\treturn\\n\\t\\t\\t}\\n\\t\\tcase <-ctx.Done():\\n\\t\\t\\tpump = nil\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t}\\n}\",\n \"func (s *Server) Index(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Println(\\\"[INDEX]: \\\", r.URL.Path[1:])\\n\\tu, ok := s.m[r.URL.Path[1:]]\\n\\tif !ok {\\n\\t\\tw.WriteHeader(http.StatusNotFound)\\n\\t\\tfmt.Fprintf(w, \\\"not found\\\\n\\\")\\n\\t\\treturn\\n\\t}\\n\\thttp.Redirect(w, r, u, http.StatusMovedPermanently)\\n}\",\n \"func (c *Client) IndexUpdate(update io.Reader, opts IndexUpdateOptions) error {\\n\\tpopts := PostMultipartOptions{\\n\\t\\tFiles: map[string]io.Reader{\\n\\t\\t\\t\\\"update\\\": update,\\n\\t\\t},\\n\\t\\tProgress: opts.Progress,\\n\\t}\\n\\n\\treturn c.PostMultipart(\\\"/index/update\\\", popts, nil)\\n}\",\n \"func (s *Service) HandleIndex(w http.ResponseWriter, r *http.Request) {\\n\\tpag, err := s.parsePagination(r)\\n\\tif err != nil {\\n\\t\\ts.writer.Error(w, \\\"error during pagination parse\\\", err, http.StatusBadRequest)\\n\\t\\treturn\\n\\t}\\n\\n\\tif err = pag.Valid(); err != nil {\\n\\t\\ts.writer.Error(w, \\\"invalid pagination\\\", err, http.StatusBadRequest)\\n\\t\\treturn\\n\\t}\\n\\n\\tsubs, subsPag, err := s.subscriptionRepository.FindAll(\\n\\t\\tr.Context(), pag, s.getResourceID(r),\\n\\t)\\n\\tif err != nil {\\n\\t\\ts.writer.Error(w, \\\"error during subscriptions search\\\", err, http.StatusInternalServerError)\\n\\t\\treturn\\n\\t}\\n\\n\\ts.writer.Response(w, &response{\\n\\t\\tSubscriptions: transformSubscriptions(subs),\\n\\t\\tPagination: transformPagination(subsPag),\\n\\t}, http.StatusOK, nil)\\n}\",\n \"func (i *Index) Index(docs []index.Document, opts interface{}) error {\\n blk := i.conn.Bulk()\\n\\tfor _, doc := range docs {\\n //fmt.Println(\\\"indexing \\\", doc.Id)\\n\\t\\treq := elastic.NewBulkIndexRequest().Index(i.name).Type(\\\"doc\\\").Id(doc.Id).Doc(doc.Properties)\\n\\t\\tblk.Add(req)\\n\\t\\t/*_, err := i.conn.Index().Index(i.name).Type(\\\"doc\\\").Id(doc.Id).BodyJson(doc.Properties).Do()\\n if err != nil {\\n // Handle error\\n panic(err)\\n }*/\\n //fmt.Printf(\\\"Indexed tweet %s to index %s, type %s\\\\n\\\", put2.Id, put2.Index, put2.Type)\\n\\t}\\n\\t//_, err := blk.Refresh(true).Do()\\n\\t_, err := blk.Refresh(false).Do()\\n if err != nil {\\n panic(err)\\n fmt.Println(\\\"Get Error during indexing\\\", err)\\n }\\n\\treturn err\\n\\t//return nil\\n}\",\n \"func indexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tdata := &Index{\\n\\t\\tTitle: \\\"Image gallery\\\",\\n\\t\\tBody: \\\"Welcome to the image gallery.\\\",\\n\\t}\\n\\tfor name, img := range images {\\n\\t\\tdata.Links = append(data.Links, Link{\\n\\t\\t\\tURL: \\\"/image/\\\" + name,\\n\\t\\t\\tTitle: img.Title,\\n\\t\\t})\\n\\t}\\n\\tif err := indexTemplate.Execute(w, data); err != nil {\\n\\t\\tlog.Println(err)\\n\\t}\\n}\",\n \"func (s *FieldStatsService) Index(index ...string) *FieldStatsService {\\n\\ts.index = append(s.index, index...)\\n\\treturn s\\n}\",\n \"func HandleIndex(w http.ResponseWriter, r *http.Request, p httprouter.Params) {\\n\\tname := p.ByName(\\\"name\\\")\\n\\tresponse := snakes[name].Info\\n\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"application/json\\\")\\n\\terr := json.NewEncoder(w).Encode(response)\\n\\tif err != nil {\\n\\t\\tfmt.Println(\\\"ERROR: response write: \\\" + err.Error())\\n\\t\\tw.WriteHeader(http.StatusBadRequest)\\n\\t\\treturn\\n\\t}\\n\\n\\tfmt.Println(\\\"Index: \\\" + name)\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tmessage := \\\"Welcome to Recipe Book!\\\"\\n\\tindexT.Execute(w, message)\\n}\",\n \"func (tc *TransactionsController) Index(c *gin.Context, size, page, offset int) {\\n\\ttxs, count, err := tc.App.GetStore().Transactions(offset, size)\\n\\tptxs := make([]presenters.Tx, len(txs))\\n\\tfor i, tx := range txs {\\n\\t\\tptxs[i] = presenters.NewTx(&tx)\\n\\t}\\n\\tpaginatedResponse(c, \\\"Transactions\\\", size, page, ptxs, count, err)\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tw.WriteHeader(http.StatusOK)\\n\\tw.Write([]byte(\\\"Hello World!\\\"))\\n}\",\n \"func BenchmarkIndexHandler(b *testing.B) {\\n\\tc, _ := loadTestYaml()\\n\\tcontext := &Context{Config: c}\\n\\tappHandler := &CtxWrapper{context, IndexHandler}\\n\\thandler := http.Handler(appHandler)\\n\\treq, _ := http.NewRequest(\\\"GET\\\", \\\"/z\\\", nil)\\n\\treq.Host = \\\"g\\\"\\n\\trr := httptest.NewRecorder()\\n\\tfor n := 0; n < b.N; n++ {\\n\\t\\thandler.ServeHTTP(rr, req)\\n\\t}\\n}\",\n \"func TestIndexHandler(t *testing.T) {\\n\\tslist := []Subscription{\\n\\t\\tSubscription{\\n\\t\\t\\tEventType: \\\"test_type\\\",\\n\\t\\t\\tContext: \\\"test_context\\\",\\n\\t\\t},\\n\\t}\\n\\n\\th := Handler{\\n\\t\\tdb: MockDatabase{slist: slist},\\n\\t}\\n\\treq, w := newReqParams(\\\"GET\\\")\\n\\n\\th.Index(w, req, httprouter.Params{})\\n\\n\\tcases := []struct {\\n\\t\\tlabel, actual, expected interface{}\\n\\t}{\\n\\t\\t{\\\"Response code\\\", w.Code, 200},\\n\\t\\t{\\\"Response body contains context\\\", strings.Contains(w.Body.String(), slist[0].Context), true},\\n\\t\\t{\\\"Response body contains event type\\\", strings.Contains(w.Body.String(), slist[0].EventType), true},\\n\\t}\\n\\n\\ttestCases(t, cases)\\n}\",\n \"func (s *IndicesStatsService) Index(indices ...string) *IndicesStatsService {\\n\\ts.index = append(s.index, indices...)\\n\\treturn s\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\ta := \\\"hello from index router\\\"\\n\\tfmt.Fprintln(w, a)\\n}\",\n \"func (s *service) indexCore(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\\n\\treq := &indexRequest{\\n\\t\\tindex: s.index,\\n\\t\\tlog: s.logger,\\n\\t\\tr: r,\\n\\t\\tstore: s.store,\\n\\t}\\n\\treq.init()\\n\\treq.read()\\n\\treq.readCore()\\n\\tif req.req.IncludeExecutable {\\n\\t\\treq.readExecutable()\\n\\t} else {\\n\\t\\treq.computeExecutableSize()\\n\\t}\\n\\treq.indexCore()\\n\\treq.close()\\n\\n\\tif req.err != nil {\\n\\t\\ts.logger.Error(\\\"indexing\\\", \\\"uid\\\", req.uid, \\\"err\\\", req.err)\\n\\t\\twriteError(w, http.StatusInternalServerError, req.err)\\n\\t\\treturn\\n\\t}\\n\\n\\ts.received.With(prometheus.Labels{\\n\\t\\t\\\"hostname\\\": req.coredump.Hostname,\\n\\t\\t\\\"executable\\\": req.coredump.Executable,\\n\\t}).Inc()\\n\\n\\ts.receivedSizes.With(prometheus.Labels{\\n\\t\\t\\\"hostname\\\": req.coredump.Hostname,\\n\\t\\t\\\"executable\\\": req.coredump.Executable,\\n\\t}).Observe(datasize.ByteSize(req.coredump.Size).MBytes())\\n\\n\\ts.analysisQueue <- req.coredump\\n\\n\\twrite(w, http.StatusOK, map[string]interface{}{\\\"acknowledged\\\": true})\\n}\",\n \"func (req MinRequest) Index(index interface{}) MinRequest {\\n\\treq.index = index\\n\\treturn req\\n}\",\n \"func indexHandler() func(http.ResponseWriter, *http.Request) {\\n\\treturn func(w http.ResponseWriter, r *http.Request) {\\n\\t\\tt, err := template.New(\\\"index\\\").Parse(indexHTMLTemplate)\\n\\t\\tif err != nil {\\n\\t\\t\\tw.WriteHeader(http.StatusInternalServerError)\\n\\t\\t\\tfmt.Fprintf(w, \\\"parsing the HTML template failed: %+v\\\", err)\\n\\t\\t}\\n\\n\\t\\tinfo := struct {\\n\\t\\t\\tPrefix string\\n\\t\\t}{\\n\\t\\t\\tPrefix: rootPrefix,\\n\\t\\t}\\n\\n\\t\\terr = t.Execute(w, info)\\n\\t\\tif err != nil {\\n\\t\\t\\tw.WriteHeader(http.StatusInternalServerError)\\n\\t\\t\\tfmt.Fprintf(w, \\\"error writting index template: %+v\\\", err)\\n\\t\\t}\\n\\t}\\n}\",\n \"func HandlerIndex(res http.ResponseWriter, req *http.Request) {\\n\\thttp.ServeFile(res, req, \\\"./static/index.html\\\")\\n}\",\n \"func (h *handler) Serve() {\\n\\tdefer close(h.stopDone)\\n\\th.logger.Info(\\\"Running\\\")\\n\\th.updateChan <- addStreamUpdate{streamID: h.streamID}\\n\\tfor {\\n\\t\\tselect {\\n\\t\\tcase parsedBlock := <-h.ingressChan:\\n\\t\\t\\th.updateChan <- h.generator.Generate(h.streamID, false, parsedBlock)\\n\\t\\tcase parsedBlock := <-h.egressChan:\\n\\t\\t\\th.updateChan <- h.generator.Generate(h.streamID, true, parsedBlock)\\n\\t\\tcase <-h.stop:\\n\\t\\t\\th.logger.Info(\\\"Stopping...\\\")\\n\\t\\t\\th.updateChan <- removeStreamUpdate{streamID: h.streamID}\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t}\\n}\",\n \"func (s *server) handleIndex(FSS fs.FS) http.HandlerFunc {\\n\\ttype AppConfig struct {\\n\\t\\tAvatarService string\\n\\t\\tToastTimeout int\\n\\t\\tAllowGuests bool\\n\\t\\tAllowRegistration bool\\n\\t\\tDefaultLocale string\\n\\t\\tAuthMethod string\\n\\t\\tAppVersion string\\n\\t\\tCookieName string\\n\\t\\tPathPrefix string\\n\\t\\tAPIEnabled bool\\n\\t\\tCleanupGuestsDaysOld int\\n\\t\\tCleanupStoryboardsDaysOld int\\n\\t\\tShowActiveCountries bool\\n\\t}\\n\\ttype UIConfig struct {\\n\\t\\tAnalyticsEnabled bool\\n\\t\\tAnalyticsID string\\n\\t\\tAppConfig AppConfig\\n\\t\\tActiveAlerts []interface{}\\n\\t}\\n\\n\\ttmpl := s.getIndexTemplate(FSS)\\n\\n\\tappConfig := AppConfig{\\n\\t\\tAvatarService: viper.GetString(\\\"config.avatar_service\\\"),\\n\\t\\tToastTimeout: viper.GetInt(\\\"config.toast_timeout\\\"),\\n\\t\\tAllowGuests: viper.GetBool(\\\"config.allow_guests\\\"),\\n\\t\\tAllowRegistration: viper.GetBool(\\\"config.allow_registration\\\") && viper.GetString(\\\"auth.method\\\") == \\\"normal\\\",\\n\\t\\tDefaultLocale: viper.GetString(\\\"config.default_locale\\\"),\\n\\t\\tAuthMethod: viper.GetString(\\\"auth.method\\\"),\\n\\t\\tAPIEnabled: viper.GetBool(\\\"config.allow_external_api\\\"),\\n\\t\\tAppVersion: s.config.Version,\\n\\t\\tCookieName: s.config.FrontendCookieName,\\n\\t\\tPathPrefix: s.config.PathPrefix,\\n\\t\\tCleanupGuestsDaysOld: viper.GetInt(\\\"config.cleanup_guests_days_old\\\"),\\n\\t\\tCleanupStoryboardsDaysOld: viper.GetInt(\\\"config.cleanup_storyboards_days_old\\\"),\\n\\t\\tShowActiveCountries: viper.GetBool(\\\"config.show_active_countries\\\"),\\n\\t}\\n\\n\\tActiveAlerts = s.database.GetActiveAlerts()\\n\\n\\tdata := UIConfig{\\n\\t\\tAnalyticsEnabled: s.config.AnalyticsEnabled,\\n\\t\\tAnalyticsID: s.config.AnalyticsID,\\n\\t\\tAppConfig: appConfig,\\n\\t}\\n\\n\\treturn func(w http.ResponseWriter, r *http.Request) {\\n\\t\\tdata.ActiveAlerts = ActiveAlerts // get latest alerts from memory\\n\\n\\t\\tif embedUseOS {\\n\\t\\t\\ttmpl = s.getIndexTemplate(FSS)\\n\\t\\t}\\n\\n\\t\\ttmpl.Execute(w, data)\\n\\t}\\n}\",\n \"func (h *MovieHandler) index(w http.ResponseWriter, r *http.Request) {\\n\\t// Call GetMovies to retrieve all movies from the database.\\n\\tif movies, err := h.MovieService.GetMovies(); err != nil {\\n\\t\\t// Render an error response and set status code.\\n\\t\\thttp.Error(w, \\\"Internal Server Error\\\", http.StatusInternalServerError)\\n\\t\\tlog.Println(\\\"Error:\\\", err)\\n\\t} else {\\n\\t\\t// Render a HTML response and set status code.\\n\\t\\trender.HTML(w, http.StatusOK, \\\"movie/index.html\\\", movies)\\n\\t}\\n}\",\n \"func Index(w http.ResponseWriter, req *http.Request) {\\n\\tfmt.Fprint(w, \\\"El servidor esta funcionando\\\")\\n\\n\\tmatriz := pedidosAnuales.BuscarNodo(2017).meses.searchByContent(04).data\\n\\tfmt.Println(matriz)\\n\\tmatriz.lst_h.print()\\n\\tmatriz.lst_v.print()\\n\\tfmt.Println(matriz.getGraphviz())\\n}\",\n \"func serveWs(w http.ResponseWriter, r *http.Request) {\\n\\tconn, err := upgrader.Upgrade(w, r, nil)\\n\\tif err != nil {\\n\\t\\tlog.Print(err)\\n\\t\\treturn\\n\\t}\\n\\tdefer conn.Close()\\n\\n\\t_, p, err := conn.ReadMessage()\\n\\tif err != nil {\\n\\t\\tlog.Print(err)\\n\\t\\treturn\\n\\t}\\n\\turi := string(p)\\n\\tarticleInfo := articleInfoFromUrl(uri)\\n\\tif articleInfo == nil {\\n\\t\\tfmt.Printf(\\\"serveWs: didn't find article for uri %s\\\\n\\\", uri)\\n\\t\\treturn\\n\\t}\\n\\n\\tarticle := articleInfo.this\\n\\tfmt.Printf(\\\"serveWs: started watching %s for uri %s\\\\n\\\", article.Path, uri)\\n\\n\\tc := AddWatch(article.Path)\\n\\tdefer RemoveWatch(c)\\n\\tdone := make(chan struct{})\\n\\n\\tgo func() {\\n\\t\\tfor {\\n\\t\\t\\t_, _, err := conn.ReadMessage()\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tfmt.Printf(\\\"serveWs: closing for %s\\\\n\\\", uri)\\n\\t\\t\\t\\tclose(done)\\n\\t\\t\\t\\tbreak\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}()\\n\\nloop:\\n\\tfor {\\n\\t\\tselect {\\n\\t\\tcase <-c:\\n\\t\\t\\treloadArticle(article)\\n\\t\\t\\terr := conn.WriteMessage(websocket.TextMessage, nil)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tlog.Print(err)\\n\\t\\t\\t\\tbreak loop\\n\\t\\t\\t}\\n\\t\\tcase <-done:\\n\\t\\t\\tbreak loop\\n\\t\\t}\\n\\t}\\n}\",\n \"func indexer() {\\n\\tfor {\\n\\t\\tselect {\\n\\t\\tcase file := <-feedCh:\\n\\t\\t\\treadFeed(file)\\n\\t\\t}\\n\\t}\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprintln(w, \\\"Welcome to the DEM service!\\\")\\n}\",\n \"func (e Manager) Send(envelope sunduq.Envelope) {\\n\\te.index.send(envelope)\\n}\",\n \"func indexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tlog.Println(\\\"indexHandler is called\\\")\\n\\n\\tw.WriteHeader(http.StatusOK)\\n\\tjson.NewEncoder(w).Encode(appResponse{Message: \\\"OK\\\"})\\n}\",\n \"func (req *MinRequest) Index(index interface{}) *MinRequest {\\n\\treq.index = index\\n\\treturn req\\n}\",\n \"func ReadIndex(output http.ResponseWriter, reader *http.Request) {\\n\\tfmt.Fprintln(output, \\\"ImageManagerAPI v1.0\\\")\\n\\tLog(\\\"info\\\", \\\"Endpoint Hit: ReadIndex\\\")\\n}\",\n \"func Index(_ core.StorageClient) gin.HandlerFunc {\\n\\treturn func(c *gin.Context) {\\n\\t\\tc.String(http.StatusOK, \\\"Hello World!\\\")\\n\\t}\\n}\",\n \"func indexHandler(w http.ResponseWriter, r *http.Request) {\\n\\tswitch r.Method {\\n\\tcase \\\"GET\\\":\\n\\t\\tmovies, err := service.GetMoviesData()\\n\\t\\tif err != nil {\\n\\t\\t\\tlog.Printf(\\\"getMoviesData: %v\\\", err)\\n\\t\\t\\thttp.Error(w, \\\"Internal Server Error\\\", http.StatusInternalServerError)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\n\\t\\tjs, err := json.Marshal(movies)\\n\\t\\tif err != nil {\\n\\t\\t\\thttp.Error(w, err.Error(), http.StatusInternalServerError)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tw.Header().Set(\\\"Content-Type\\\", \\\"application/json\\\")\\n\\t\\tw.Write(js)\\n\\n\\tdefault:\\n\\t\\thttp.Error(w, fmt.Sprintf(\\\"HTTP Method %s Not Allowed\\\", r.Method), http.StatusMethodNotAllowed)\\n\\t}\\n}\",\n \"func (s *IndicesSyncedFlushService) Index(indices ...string) *IndicesSyncedFlushService {\\n\\ts.index = append(s.index, indices...)\\n\\treturn s\\n}\",\n \"func TestIndexHandler(t *testing.T) {\\n\\telist := []Event{testEvent}\\n\\n\\th := Handler{\\n\\t\\tdb: MockDatabase{elist: elist},\\n\\t}\\n\\treq, w := newReqParams(\\\"GET\\\")\\n\\n\\th.Index(w, req, httprouter.Params{})\\n\\n\\tcases := []struct {\\n\\t\\tlabel, actual, expected interface{}\\n\\t}{\\n\\t\\t{\\\"Response code\\\", w.Code, 200},\\n\\t\\t{\\\"Response body contains context\\\", strings.Contains(w.Body.String(), testEvent.Context), true},\\n\\t\\t{\\\"Response body contains event type\\\", strings.Contains(w.Body.String(), testEvent.EventType), true},\\n\\t\\t{\\\"Response body contains data\\\", strings.Contains(w.Body.String(), testEvent.Data), true},\\n\\t\\t{\\\"Response body contains id\\\", strings.Contains(w.Body.String(), testEvent.ID.String()), true},\\n\\t\\t{\\\"Response body contains account id\\\", strings.Contains(w.Body.String(), testEvent.OriginalAccountID.String()), true},\\n\\t}\\n\\n\\ttestCases(t, cases)\\n}\"\n]"},"negative_scores":{"kind":"list like","value":["0.64418113","0.6440549","0.6064773","0.59902114","0.5585452","0.5555484","0.55490744","0.5497935","0.5477929","0.54218686","0.53964406","0.5335342","0.52755517","0.52755517","0.5224524","0.52050734","0.52000564","0.51795226","0.51668257","0.5147979","0.5136852","0.5081622","0.50739896","0.50573564","0.5041458","0.49915555","0.49915555","0.49341318","0.48991054","0.4890557","0.4887498","0.4886702","0.48864636","0.48817533","0.48815873","0.4880548","0.48498708","0.4849382","0.48401156","0.48353982","0.483534","0.4826761","0.4816217","0.48150557","0.4805371","0.48008314","0.47822547","0.47801274","0.47744912","0.47602138","0.47396624","0.47385553","0.47255158","0.47233823","0.47223297","0.4721904","0.47204095","0.47072744","0.47061688","0.4696188","0.46949178","0.4692428","0.46922588","0.46909094","0.468459","0.4683208","0.46810037","0.46728665","0.46692872","0.466899","0.46652973","0.4663862","0.465334","0.46508166","0.46455795","0.46452323","0.46441534","0.46437255","0.46377167","0.46337038","0.46257535","0.46239504","0.460884","0.45916626","0.458753","0.45866403","0.458661","0.4584211","0.45800608","0.45796612","0.4569796","0.4561945","0.45533648","0.453393","0.45302603","0.45275682","0.4522599","0.45197058","0.4518554","0.45172453"],"string":"[\n \"0.64418113\",\n \"0.6440549\",\n \"0.6064773\",\n \"0.59902114\",\n \"0.5585452\",\n \"0.5555484\",\n \"0.55490744\",\n \"0.5497935\",\n \"0.5477929\",\n \"0.54218686\",\n \"0.53964406\",\n \"0.5335342\",\n \"0.52755517\",\n \"0.52755517\",\n \"0.5224524\",\n \"0.52050734\",\n \"0.52000564\",\n \"0.51795226\",\n \"0.51668257\",\n \"0.5147979\",\n \"0.5136852\",\n \"0.5081622\",\n \"0.50739896\",\n \"0.50573564\",\n \"0.5041458\",\n \"0.49915555\",\n \"0.49915555\",\n \"0.49341318\",\n \"0.48991054\",\n \"0.4890557\",\n \"0.4887498\",\n \"0.4886702\",\n \"0.48864636\",\n \"0.48817533\",\n \"0.48815873\",\n \"0.4880548\",\n \"0.48498708\",\n \"0.4849382\",\n \"0.48401156\",\n \"0.48353982\",\n \"0.483534\",\n \"0.4826761\",\n \"0.4816217\",\n \"0.48150557\",\n \"0.4805371\",\n \"0.48008314\",\n \"0.47822547\",\n \"0.47801274\",\n \"0.47744912\",\n \"0.47602138\",\n \"0.47396624\",\n \"0.47385553\",\n \"0.47255158\",\n \"0.47233823\",\n \"0.47223297\",\n \"0.4721904\",\n \"0.47204095\",\n \"0.47072744\",\n \"0.47061688\",\n \"0.4696188\",\n \"0.46949178\",\n \"0.4692428\",\n \"0.46922588\",\n \"0.46909094\",\n \"0.468459\",\n \"0.4683208\",\n \"0.46810037\",\n \"0.46728665\",\n \"0.46692872\",\n \"0.466899\",\n \"0.46652973\",\n \"0.4663862\",\n \"0.465334\",\n \"0.46508166\",\n \"0.46455795\",\n \"0.46452323\",\n \"0.46441534\",\n \"0.46437255\",\n \"0.46377167\",\n \"0.46337038\",\n \"0.46257535\",\n \"0.46239504\",\n \"0.460884\",\n \"0.45916626\",\n \"0.458753\",\n \"0.45866403\",\n \"0.458661\",\n \"0.4584211\",\n \"0.45800608\",\n \"0.45796612\",\n \"0.4569796\",\n \"0.4561945\",\n \"0.45533648\",\n \"0.453393\",\n \"0.45302603\",\n \"0.45275682\",\n \"0.4522599\",\n \"0.45197058\",\n \"0.4518554\",\n \"0.45172453\"\n]"},"document_score":{"kind":"string","value":"0.812101"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":105053,"cells":{"query":{"kind":"string","value":"problem statement : given a story generate html to show the story"},"document":{"kind":"string","value":"func main() {\n\tstories, err := reader.ReadJsonStory(\"./static/story/default.json\")\n\tif err != nil {\n\t\tlog.Panicln(err)\n\t}\n\n\tweb.Start(stories)\n}"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["func story(Memories int) string {\n\tGamePlot := \"story.txt\"\n\tif len(plot) <= 0 {\n\t\tstory, err := os.Open(GamePlot)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"either incorrect format or associated with %s please rewrite.\\n\", err)\n\t\t} else {\n\t\t\tStoryReader := bio.NewScanner(story)\n\t\t\tStoryReader.Split(bio.ScanLines)\n\t\t\tdefer story.Close()\n\t\t\tfor StoryReader.Scan() {\n\t\t\t\tplot = append(plot, StoryReader.Text())\n\t\t\t}\n\t\t}\n\t}\n\treturn plot[Memories]\n}","func getStory(w http.ResponseWriter, r *http.Request) {\n\t// read the id\n\tid := mux.Vars(r)[\"id\"]\n\t// format the url\n\tstoryURL := fmtURL(id)\n\t// Make request and get response body\n\tdata := fmtRes(storyURL)\n\tfmt.Println(\"data:\", data)\n\tw.Write([]byte(data))\n}","func Source_() HTML {\n return Source(nil)\n}","func (page *storyPage) playStoryMethod() {\n\tfor page != nil {\n\t\tfmt.Println(page.text)\n\t\tpage = page.nextPage\n\t}\n}","func Embed_() HTML {\n return Embed(nil)\n}","func getHTML(str string) template.HTML {\n\tmarkdown := string(blackfriday.Run([]byte(str)))\n\treturn template.HTML(markdown)\n}","func (t toc) toHTMLStr() (htmlStr string) {\n\thtmlStr = `\n\n\n\nRedis in Action: Table Of Content\n\n\n

Redis in Action

\n`\n\n\thtmlStr += \"
\\n
    \\n\"\n\tcurrentLevel := 1\n\tfor _, v := range t {\n\t\tif v.level > currentLevel {\n\t\t\thtmlStr += \"
      \\n\"\n\t\t\tcurrentLevel = v.level\n\t\t} else if v.level < currentLevel {\n\t\t\tfor i := v.level; i < currentLevel; i++ {\n\t\t\t\thtmlStr += \"
    \\n\"\n\t\t\t}\n\t\t\tcurrentLevel = v.level\n\t\t}\n\n\t\thtmlStr += fmt.Sprintf(\"
  • %s
  • \\n\", v.value, v.title)\n\t}\n\thtmlStr += \"
\\n
\\n\\n\"\n\treturn htmlStr\n}","func playHtmlHandle(w http.ResponseWriter, r *http.Request) {\n\tplayTempl.Execute(w, Params)\n}","func toHtml(fname string) string {\n\treturn strings.Replace(fname, \".md\", \".html\", -1)\n}","func pagemain(w http.ResponseWriter, r *http.Request){\n w.Write([]byte( `\n \n Ciao\n

Come stai

\n \n `))\n }","func work(reader io.Reader, app_data AppData) string {\n content_markdown := ReaderToString(reader)\n content_title := \"\"\n \n //look for an H1 title, break it out for use in the HTML title tag\n first_newline := strings.Index(content_markdown, \"\\n\")\n if first_newline > -1{\n if strings.HasPrefix(content_markdown[0:first_newline], \"# \") {\n content_title = content_markdown[2:first_newline]\n content_markdown = content_markdown[first_newline:]\n }\n }\n\n //get the content\n var content_html string\n if app_data.Markdown {\n content_html = MarkdownToHTML(content_markdown)\n } else {\n content_html = content_markdown\n }\n\n //set up reporting time/date\n now := time.Now()\n formated_date := now.Format(\"2006-01-02 03:04 PM\")\n\n //expose data to template\n data := TemplateData{\n Title: content_title,\n Content: content_html,\n Date: formated_date,\n }\n \n //get template file\n template_file_path := FindTemplate(app_data.Template, app_data.Limit)\n var template_content string\n if template_file_path == \"\" {\n template_content = FILE_TEMPLATE\n } else {\n template_content = readFile(template_file_path)\n }\n \n return render(template_content, data)\n}","func (server Server) Create_Open_Html() {\n\tlayernames := []string{}\n\tfor _,i := range server.Mbtiles {\n\t\tlayernames = append(layernames,Get_Vector_Layers(i)...)\n\t}\n\tfor _,i := range server.Geobufs {\n\t\tlayernames = append(layernames,i.Config_Dynamic.LayerName)\n\t}\n\n\tlayer_parts := []string{}\n\tfor _,layername := range layernames {\n\t\tlayer_parts = append(layer_parts,Get_Part_Layer(layername))\n\t}\n\tmiddle := strings.Join(layer_parts,\"\\n\")\n\tstart,end := Start_End()\n\n\ttotal := start + \"\\n\" + middle + \"\\n\" + end\n\n\tioutil.WriteFile(\"index.html\",[]byte(total),0677)\n\n\texec.Command(\"open\",\"index.html\").Run()\n\n}","func TestHTML(t *testing.T) {\n\tm := MarkHub{}\n\terr := m.ParseString(\"# title 1\")\n\tif err != nil {\n\t\tt.Errorf(\"TestHTML(): got -> %v, want: nil\", err)\n\t}\n\thtml := m.HTML()\n\tif len(html) == 0 {\n\t\tt.Errorf(\"TestHTML(): got -> %v, want: length > 0\", len(html))\n\t}\n}","func HTML(s string) got.HTML {\n\treturn got.HTML(s)\n}","func execToHTML(_ int, p *gop.Context) {\n\targs := p.GetArgs(3)\n\tdoc.ToHTML(args[0].(io.Writer), args[1].(string), args[2].(map[string]string))\n}","func (llp *LogLineParsed) HTML(vp viewerProvider) string {\n\tseconds := llp.StampSeconds\n\thour := seconds / (60 * 60)\n\tseconds -= hour * 60 * 60\n\tminute := seconds / 60\n\tseconds -= minute * 60\n\n\tcatStr := llp.Cat.FriendlyName()\n\tif llp.Msg == nil {\n\t\treturn fmt.Sprintf(ChatLogFormatHTML,\n\t\t\tcatStr,\n\t\t\thour, minute, seconds,\n\t\t\tllp.Body)\n\t}\n\n\tmsgContent := llp.Msg.Emotes.Replace(llp.Msg.Content)\n\n\t// Multiple Badges\n\tbadgeHTML := \"\"\n\n\t// Get Viewer Data\n\tv, err := vp.GetData(llp.Msg.UserID)\n\tif err != nil {\n\t\treturn fmt.Sprintf(ChatLogFormatMsgHTML,\n\t\t\tcatStr,\n\t\t\thour, minute, seconds,\n\t\t\tllp.Msg.UserID,\n\t\t\tbadgeHTML,\n\t\t\tllp.Msg.Nick,\n\t\t\tmsgContent)\n\t}\n\n\t// View Lock\n\tif v.Follower != nil {\n\t\tcatStr += \" follow\"\n\t}\n\n\tchatColor := \"#DDD\"\n\tif v.Chatter != nil {\n\t\tchatColor = v.Chatter.Color\n\n\t\tfor badgeID, ver := range v.Chatter.Badges {\n\t\t\tbadgeHTML += vp.Client().Badges.BadgeHTML(badgeID, ver)\n\t\t}\n\n\t\treturn llp.Body\n\t}\n\t//\n\n\treturn fmt.Sprintf(ChatLogFormatMsgExtraHTML,\n\t\tcatStr,\n\t\tchatColor,\n\t\thour, minute, seconds,\n\t\tllp.Msg.UserID,\n\t\tbadgeHTML,\n\t\tllp.Msg.Nick,\n\t\tmsgContent)\n}","func _html(ns Nodes, outer bool) string {\n\tif len(ns) == 0 {\n\t\treturn \"\"\n\t}\n\twr := w{}\n\tif outer {\n\t\thtml.Render(&wr, ns[0].Node)\n\t} else {\n\t\tfor _, v := range ns[0].Node.Child {\n\t\t\thtml.Render(&wr, v)\n\t\t}\n\t}\n\treturn wr.s\n}","func (o *OutputHandler) createBeautifulHTML() error {\n\terr := o.importFile()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\to.markdownToHTML()\n\n\terr = o.createFile()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}","func templateHTML(releases []models.HelmRelease, w io.Writer) error {\n\n\tsum := internalSummery{\n\t\tOutdatedReleases: make(map[string][]uiHelmRelease),\n\t\tDeprecatedReleases: make(map[string][]uiHelmRelease),\n\t\tGoodReleases: make(map[string][]uiHelmRelease),\n\t}\n\n\tfor _, c := range releases {\n\t\tuiC := uiHelmRelease{\n\t\t\tName: c.Name,\n\t\t\tNamespace: c.Namespace,\n\t\t\tDeprecated: c.Deprecated,\n\t\t\tInstalledVersion: c.InstalledVersion,\n\t\t\tLatestVersion: c.LatestVersion,\n\t\t\tOutdated: c.InstalledVersion != c.LatestVersion,\n\t\t}\n\n\t\tif uiC.Deprecated {\n\t\t\tsum.DeprecatedReleases[uiC.Namespace] = append(sum.DeprecatedReleases[uiC.Namespace], uiC)\n\t\t} else if uiC.Outdated {\n\t\t\tsum.OutdatedReleases[uiC.Namespace] = append(sum.OutdatedReleases[uiC.Namespace], uiC)\n\t\t} else {\n\t\t\tsum.GoodReleases[uiC.Namespace] = append(sum.GoodReleases[uiC.Namespace], uiC)\n\t\t}\n\t}\n\n\tfor i, v := range sum.DeprecatedReleases {\n\t\tsort.Sort(ByName(v))\n\t\tsum.DeprecatedReleases[i] = v\n\t}\n\n\tfor i, v := range sum.OutdatedReleases {\n\t\tsort.Sort(ByName(v))\n\t\tsum.OutdatedReleases[i] = v\n\t}\n\n\tfor i, v := range sum.GoodReleases {\n\t\tsort.Sort(ByName(v))\n\t\tsum.GoodReleases[i] = v\n\t}\n\n\tt := template.Must(template.New(\"index.html\").Funcs(getFunctions()).ParseFS(views, \"views/*\"))\n\terr := t.Execute(w, sum)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}","func (r *Template) Html() pulumi.StringOutput {\n\treturn (pulumi.StringOutput)(r.s.State[\"html\"])\n}","func page(content string) string {\n\treturn \"\\n\" + content + \"\\n\"\n}","func (e *explorer) outputGoHTML(goSource, funcName string, lines [][2]int, step int, subStep string) error {\n\t// Get Chroma Go lexer.\n\tlexer := lexers.Get(\"go\")\n\tif lexer == nil {\n\t\tlexer = lexers.Fallback\n\t}\n\t//lexer = chroma.Coalesce(lexer)\n\t// Get Chrome style.\n\tstyle := styles.Get(e.style)\n\tif style == nil {\n\t\tstyle = styles.Fallback\n\t}\n\t// Get Chroma HTML formatter.\n\tformatter := html.New(\n\t\thtml.TabWidth(3),\n\t\thtml.WithLineNumbers(),\n\t\thtml.WithClasses(),\n\t\thtml.LineNumbersInTable(),\n\t\t//html.HighlightLines(lines),\n\t)\n\t// Generate syntax highlighted Go code.\n\titerator, err := lexer.Tokenise(nil, goSource)\n\tif err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\tgoCode := &bytes.Buffer{}\n\tif err := formatter.Format(goCode, style, iterator); err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\t// Generate Go HTML page.\n\thtmlContent := &bytes.Buffer{}\n\tdata := map[string]interface{}{\n\t\t\"FuncName\": funcName,\n\t\t\"Style\": e.style,\n\t\t\"GoCode\": template.HTML(goCode.String()),\n\t}\n\tif err := e.goTmpl.Execute(htmlContent, data); err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\thtmlName := fmt.Sprintf(\"%s_step_%04d%s_go.html\", funcName, step, subStep)\n\thtmlPath := filepath.Join(e.outputDir, htmlName)\n\tdbg.Printf(\"creating file %q\", htmlPath)\n\tif err := ioutil.WriteFile(htmlPath, htmlContent.Bytes(), 0644); err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\treturn nil\n}","func getStories(w http.ResponseWriter, r *http.Request) {\n\t// get all of the story id\n\tids := getNewsItems()\n\t// filter out anything that isn't a story\n\t// Not sure this is going to be a necessary step\n\tstories := filterStories(ids)\n\n\tvar s []map[string]interface{}\n\n\tfor i := 0; i < len(stories); i++ {\n\t\ts = append(s, stories[i])\n\t\t// fmt.Println(\"stories\", byt)\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\tw.WriteHeader(http.StatusCreated)\n\t// json.NewEncoder(w).Encode(s)\n\tbyt, err := json.Marshal(s)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tw.Write(byt)\n}","func viewPage(response http.ResponseWriter, request *http.Request) {\n\ttitle := request.URL.Path[len(\"/\"):]\n\tpage, err := loadPage(title)\n\tif err != nil {\n\t\thttp.Error(response, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tfmt.Fprintf(response, \"

%s

%s

\", page.Title, page.Body)\n}","func Html(url string) ([]byte, error) {\n\trsp, err := http.Get(url)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not make request: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tbody, err := ioutil.ReadAll(rsp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not read response body: %w\", err)\n\t}\n\treturn body, nil\n}","func (as *Action) HTML(u string, args ...interface{}) *httptest.Request {\n\treturn httptest.New(as.App).HTML(u, args...)\n}","func main() {\n\t// We place each set of stories in a new buffer\n\thnStories := newHnStories()\n\tredditStories := newRedditStories()\n\t// And we need a buffer to contain all stories\n\tvar stories []Story\n\n\t// Now we check that each source actually did return some stories\n\tif hnStories != nil {\n\t\t// If so, we'll append those to the list\n\t\tstories = append(stories, hnStories...)\n\t}\n\tif redditStories != nil {\n\t\tstories = append(stories, redditStories...)\n\t}\n\n\t// Now let's write these stories to a file, stories.txt\n\t// First we open the file\n\tfile, err := os.Create(\"stories.txt\")\n\t// If there's a problem opening the file, abort\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tos.Exit(1)\n\t}\n\t// And we'll defer closing the file\n\tdefer file.Close()\n\t// Now we'll write the stories out to the file\n\tfor _, s := range stories {\n\t\tfmt.Fprintf(file, \"%s: %s\\nby %s on %s\\n\\n\", s.title, s.url, s.author, s.source)\n\t}\n\n\t// Finally, we'll print out all the stories we received\n\tfor _, s := range stories {\n\t\tfmt.Printf(\"%s: %s\\nby %s on %s\\n\\n\", s.title, s.url, s.author, s.source)\n\t}\n}","func createHTMLNote(htmlFileName, mdFileName string) error {\n\tvar result error\n\tlog.Print(\"Generating HTML release note...\")\n\tcssFileName := \"/tmp/release_note_cssfile\"\n\tcssFile, err := os.Create(cssFileName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create css file %s: %v\", cssFileName, err)\n\t}\n\n\tcssFile.WriteString(\"\")\n\t// Here we manually close the css file instead of defer the close function,\n\t// because we need to use the css file for pandoc command below.\n\t// Writing to css file is a clear small logic so we don't separate it into\n\t// another function.\n\tif err = cssFile.Close(); err != nil {\n\t\treturn fmt.Errorf(\"failed to close file %s, %v\", cssFileName, err)\n\t}\n\n\thtmlStr, err := u.Shell(\"pandoc\", \"-H\", cssFileName, \"--from\", \"markdown_github\", \"--to\", \"html\", mdFileName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to generate html content: %v\", err)\n\t}\n\n\thtmlFile, err := os.Create(htmlFileName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create html file: %v\", err)\n\t}\n\tdefer func() {\n\t\tif err = htmlFile.Close(); err != nil {\n\t\t\tresult = fmt.Errorf(\"failed to close file %s, %v\", htmlFileName, err)\n\t\t}\n\t}()\n\n\thtmlFile.WriteString(htmlStr)\n\treturn result\n}","func (e *explorer) outputLLVMHTML(f *ir.Func, lines [][2]int, step int) error {\n\t// Get Chroma LLVM IR lexer.\n\tlexer := lexers.Get(\"llvm\")\n\tif lexer == nil {\n\t\tlexer = lexers.Fallback\n\t}\n\t//lexer = chroma.Coalesce(lexer)\n\t// Get Chrome style.\n\tstyle := styles.Get(e.style)\n\tif style == nil {\n\t\tstyle = styles.Fallback\n\t}\n\t// Get Chroma HTML formatter.\n\tformatter := html.New(\n\t\thtml.TabWidth(3),\n\t\thtml.WithLineNumbers(),\n\t\thtml.WithClasses(),\n\t\thtml.LineNumbersInTable(),\n\t\thtml.HighlightLines(lines),\n\t)\n\t// Generate syntax highlighted LLVM IR assembly.\n\tllvmSource := f.LLString()\n\titerator, err := lexer.Tokenise(nil, llvmSource)\n\tif err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\tllvmCode := &bytes.Buffer{}\n\tif err := formatter.Format(llvmCode, style, iterator); err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\t// Generate LLVM IR HTML page.\n\thtmlContent := &bytes.Buffer{}\n\tfuncName := f.Name()\n\tdata := map[string]interface{}{\n\t\t\"FuncName\": funcName,\n\t\t\"Style\": e.style,\n\t\t\"LLVMCode\": template.HTML(llvmCode.String()),\n\t}\n\tif err := e.llvmTmpl.Execute(htmlContent, data); err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\thtmlName := fmt.Sprintf(\"%s_step_%04d_llvm.html\", funcName, step)\n\thtmlPath := filepath.Join(e.outputDir, htmlName)\n\tdbg.Printf(\"creating file %q\", htmlPath)\n\tif err := ioutil.WriteFile(htmlPath, htmlContent.Bytes(), 0644); err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\treturn nil\n}","func Track_() HTML {\n return Track(nil)\n}","func HTML(c *slurp.C, data interface{}) slurp.Stage {\n\treturn func(in <-chan slurp.File, out chan<- slurp.File) {\n\n\t\ttemplates := html.New(\"\")\n\n\t\tvar wg sync.WaitGroup\n\t\tdefer wg.Wait() //Wait before all templates are executed.\n\n\t\tfor f := range in {\n\n\t\t\tbuf := new(bytes.Buffer)\n\t\t\t_, err := buf.ReadFrom(f.Reader)\n\t\t\tf.Close()\n\t\t\tif err != nil {\n\t\t\t\tc.Println(err)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\ttemplate, err := templates.New(f.Stat.Name()).Parse(buf.String())\n\t\t\tif err != nil {\n\t\t\t\tc.Println(err)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tf.Reader = NewTemplateReadCloser(c, wg, template, data)\n\n\t\t\tout <- f\n\t\t}\n\t}\n}","func Start(story map[string]storyBuilder.Arc) {\n\tconst tpl = `\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t{{.Title}}\n\t\t\t\n\t\t\t\n\t\t\t

{{.Title}}

\n\t\t\t{{range .Paragraphs}}\n\t\t\t\t

{{.}}

\n\t\t\t{{end}}\n\t\t\t\t{{range .Options}}\n\t\t\t\t\t

\n\t\t\t\t\t\t{{.Text}}\n\t\t\t\t\t

\n\t\t\t\t{{end}}\n\t\t\t\n\t\t`\n\n\ttemplate, err := template.New(\"story\").Parse(tpl)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\thandler := func(w http.ResponseWriter, req *http.Request) {\n\t\turl := strings.Replace(req.URL.Path, \"/\", \"\", 1)\n\t\tcurrentStory, found := story[url]\n\t\tif found {\n\t\t\ttemplate.Execute(w, currentStory)\n\t\t} else {\n\t\t\ttemplate.Execute(w, story[\"intro\"])\n\t\t}\n\n\t}\n\n\thttp.HandleFunc(\"/\", handler)\n\tfmt.Println(\"Server is listening on port 8080\")\n\tlog.Fatal(http.ListenAndServe(\":8080\", nil))\n}","func generateURLIssue(h string) string {\n\tconst (\n\t\ttitle = \"Move your ass\"\n\t\turlFormat = \"https://github.com/sjeandeaux/nexus-cli/issues/new?title=%s&body=%s\"\n\t\tbodyFormat = \"Could you add the hash %q lazy man?\\n%s\"\n\t)\n\tescapedTitle := url.QueryEscape(title)\n\tbody := fmt.Sprintf(bodyFormat, h, information.Print())\n\tescapedBody := url.QueryEscape(body)\n\turlIssue := fmt.Sprintf(urlFormat, escapedTitle, escapedBody)\n\treturn urlIssue\n}","func viewHandler(w http.ResponseWriter, r *http.Request, title string) {\n\t// Special case for the root page.\n\tif title == rootTitle {\n\t\trootHandler(w, r, title)\n\t\treturn\n\t}\n\n\tp, err := loadPage(title)\n\tif err != nil {\n\t\thttp.Redirect(w, r, \"/edit/\"+title, http.StatusFound)\n\t\treturn\n\t}\n\n\tp.Ingredients = template.HTML(blackfriday.MarkdownCommon([]byte(p.Ingredients)))\n\tp.Instructions = template.HTML(blackfriday.MarkdownCommon([]byte(p.Instructions)))\n\tp.Ingredients = template.HTML(convertWikiMarkup([]byte(p.Ingredients)))\n\tp.Instructions = template.HTML(convertWikiMarkup([]byte(p.Instructions)))\n\trenderTemplate(w, \"view\", p)\n}","func generateHTML(writer http.ResponseWriter, data interface{}, filenames ...string) {\n\n\tvar t *template.Template\n\tvar files []string\n\tfor _, file := range filenames {\n\t\tfiles = append(files, fmt.Sprintf(\"web/ui/template/HTMLLayouts/%s.html\", file))\n\t}\n\tt = template.Must(template.ParseFiles(files...))\n\tt.ExecuteTemplate(writer, \"layout\", data)\n}","func (thread *Thread) HTML() string {\n\tif thread.html != \"\" {\n\t\treturn thread.html\n\t}\n\n\tthread.html = markdown.Render(thread.Text)\n\treturn thread.html\n}","func (c *StoryController) Get() mvc.Result {\n\tstories, err := c.StoryUsecase.GetAll()\n\tif err != nil {\n\t\treturn mvc.View{\n\t\t\tName: \"index.html\",\n\t\t\tData: iris.Map{\"Title\": \"Stories\"},\n\t\t}\n\t}\n\n\treturn mvc.View{\n\t\tName: \"index.html\",\n\t\tData: iris.Map{\"Title\": \"Stories\", \"Stories\": stories},\n\t}\n}","func main() {\n\tstory := flag.String(\"story\", \"\", \"select the story to play.\")\n\tflag.Parse()\n\n\troot := flag.Arg(0)\n\tif !stories.Select(*story) || root == \"\" {\n\t\tfmt.Println(\"Expected a story and a directory of files to serve.\")\n\t\tfmt.Println(\"ex. webapp -story sushi .\")\n\t\tfmt.Println(\"The following example stories are available:\")\n\t\tfor _, nick := range stories.List() {\n\t\t\tfmt.Println(\" \", nick)\n\t\t}\n\t} else {\n\t\tfmt.Println(\"listening on http://localhost:8080\")\n\t\thandler := support.NewServeMux()\n\t\thandler.HandleFunc(\"/game/\", net.HandleResource(ess.GameResource(mem.NewSessions())))\n\t\thandler.HandleFilePatterns(root,\n\t\t\tsupport.Dir(\"/app/\"),\n\t\t\tsupport.Dir(\"/bower_components/\"),\n\t\t\tsupport.Dir(\"/media/\"))\n\t\tgo support.OpenBrowser(\"http://localhost:8080/app/\")\n\t\tlog.Fatal(http.ListenAndServe(\":8080\", handler))\n\t}\n}","func publishShareInstructions(url string) {\n\tlog.Println(\"\\n\" + GrayStyle.Render(\" Share your GIF with Markdown:\"))\n\tlog.Println(CommandStyle.Render(\" ![Made with VHS]\") + URLStyle.Render(\"(\"+url+\")\"))\n\tlog.Println(GrayStyle.Render(\"\\n Or HTML (with badge):\"))\n\tlog.Println(CommandStyle.Render(\" \")\"))\n\tlog.Println(CommandStyle.Render(\" \"))\n\tlog.Println(CommandStyle.Render(\" \"))\n\tlog.Println(CommandStyle.Render(\" \"))\n\tlog.Println(GrayStyle.Render(\"\\n Or link to it:\"))\n}","func CreateArticelePage(w http.ResponseWriter, r *http.Request) {\n\n\tvars := mux.Vars(r)\n\n\tmtitle := vars[\"mtitle\"]\n\n\tmongoDBDialInfo := &mgo.DialInfo{\n\n\t\tAddrs: []string{\"mymongo-controller\"},\n\t\tTimeout: 60 * time.Second,\n\t\tDatabase: \"admin\",\n\t\tUsername: mongodbuser,\n\t\tPassword: mongodbpass,\n\t\tMechanism: \"SCRAM-SHA-1\",\n\t}\n\n\tdbsession, err := mgo.DialWithInfo(mongoDBDialInfo)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer dbsession.Close()\n\n\tif mtitle == \"\" {\n\n\t\tlog.Println(\"no mtitle\")\n\n\t\tarticles := dbhandler.GetAllForStatic(*dbsession, \"kaukotyo.eu\")\n\t\tjson.NewEncoder(w).Encode(articles)\n\n\t} else {\n\n\t\tarticle := dbhandler.GetOneArticle(*dbsession, mtitle)\n\n\t\tjson.NewEncoder(w).Encode(article)\n\n\t}\n}","func HTMLString(data interface{}, viewName string) string {\n\tvar html bytes.Buffer\n\ttemplateName := viewName\n\tt, err := Jet.GetTemplate(templateName)\n\tif err != nil {\n\t\tlog.Println(\"Failed to get tempalte \")\n\t}\n\tvars := make(jet.VarMap)\n\tif err = t.Execute(&html, vars, data); err != nil {\n\t\tlog.Println(\"Failed to execute view tepmlate \")\n\t}\n\treturn html.String()\n}","func generateHTML(domain, pkg, source string) ([]byte, error) {\n\tvar (\n\t\tdir, file, redirect string\n\t\tb bytes.Buffer\n\t)\n\n\tif pkg != \"\" {\n\t\tredirect = \"https://pkg.go.dev/\" + domain + \"/\" + pkg\n\n\t\t// Add the URL scheme if not already present\n\t\tif !strings.HasPrefix(source, \"http\") {\n\t\t\tsource = \"https://\" + source\n\t\t}\n\n\t\t// Deduce go-source paths for the hosting\n\t\tswitch path := urlMustParse(source); path.Host {\n\t\tcase \"github.com\":\n\t\t\tdir = source + \"/tree/master/{dir}\"\n\t\t\tfile = source + \"/blob/master/{dir}/{file}#L{line}\"\n\t\tcase \"gitlab.com\":\n\t\t\tdir = source + \"/-/tree/master/{dir}\"\n\t\t\tfile = source + \"/-/blob/master/{dir}/{file}#L{line}\"\n\t\t}\n\t} else {\n\t\tredirect = \"https://\" + domain\n\t}\n\n\tt := template.Must(template.New(\"package\").Parse(templString))\n\terr := t.Execute(&b, &templValue{redirect, domain, pkg, source, dir, file})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn b.Bytes(), nil\n}","func htmlPageHandler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, `\n\n\t\n\t\n`)\n\n}","func main() {\n\twebview.Open(\"GoNotes\", \"file:///home/ubuntu/go/src/github.com/mattackard/project-0/cmd/GoNotesClient/client.html\", 600, 700, true)\n}","func (bt *Hackerbeat) fetchStory(stories chan<- story, storyID uint) {\n\tstory := story{\n\t\tID: storyID,\n\t}\n\n\t// Generate getStoryURL from getItemURL and storyID\n\tgetStoryURL := strings.Replace(getItemURL, storyIDToken, strconv.FormatUint(uint64(storyID), 10), -1)\n\n\t// Get story from HackerNews API\n\tresp, err := bt.httpClient.Get(getStoryURL)\n\tif err != nil {\n\t\tbt.logger.Errorw(\n\t\t\t\"Failed to get story\",\n\t\t\t\"error\", err,\n\t\t)\n\t\treturn\n\t}\n\n\t// Read all bytes from response body\n\tstoryInfos, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tbt.logger.Errorw(\n\t\t\t\"Failed to parse story\",\n\t\t\t\"error\", err,\n\t\t)\n\t\treturn\n\t}\n\n\t// Unmarshal response body into our story data structure\n\terr = json.Unmarshal(storyInfos, &story)\n\tif err != nil {\n\t\tbt.logger.Errorw(\n\t\t\t\"Failed to unmarshal story\",\n\t\t\t\"error\", err,\n\t\t)\n\t\treturn\n\t}\n\n\t// Send story back to the main thread\n\tstories <- story\n}","func RenderHTMLWithMetadata(actual string, settings ...configuration.Setting) (string, types.Metadata, error) {\n\tallSettings := append([]configuration.Setting{configuration.WithFilename(\"test.adoc\"), configuration.WithBackEnd(\"html5\")}, settings...)\n\tconfig := configuration.NewConfiguration(allSettings...)\n\tcontentReader := strings.NewReader(actual)\n\tresultWriter := bytes.NewBuffer(nil)\n\tmetadata, err := libasciidoc.Convert(contentReader, resultWriter, config)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn \"\", types.Metadata{}, err\n\t}\n\tif log.IsLevelEnabled(log.DebugLevel) {\n\t\tlog.Debug(resultWriter.String())\n\t}\n\treturn resultWriter.String(), metadata, nil\n}","func getHTMLContent(articleContent *goquery.Selection) string {\n\thtml, err := articleContent.Html()\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\n\thtml = ghtml.UnescapeString(html)\n\thtml = rxComments.ReplaceAllString(html, \"\")\n\thtml = rxKillBreaks.ReplaceAllString(html, \"
\")\n\thtml = rxSpaces.ReplaceAllString(html, \" \")\n\treturn html\n}","func (r renderer) BlockHtml(out *bytes.Buffer, text []byte) {}","func HTMLFromResults(script *Script, serverConfigs map[string]ServerConfig, scriptResults map[string]*ScriptResults) string {\n\t// sorted ID list\n\tvar sortedIDs []string\n\tfor id := range serverConfigs {\n\t\tsortedIDs = append(sortedIDs, id)\n\t}\n\tsort.Strings(sortedIDs)\n\n\t// tab buttons\n\tvar tabs string\n\tfor _, id := range sortedIDs {\n\t\ttabs += fmt.Sprintf(tabText, id, serverConfigs[id].DisplayName)\n\t}\n\n\t// css\n\tvar css string\n\thue := 150\n\tfor id := range script.Clients {\n\t\t// + 5 for ' <- ' or similar\n\t\tcss += fmt.Sprintf(cssPreTemplate, id, len(id)+5, hue)\n\t\thue += 40\n\t}\n\n\t// construct JSON blob used by the page\n\tblob := htmlJSONBlob{\n\t\tDefaultServer: sortedIDs[0],\n\t\tServerNames: make(map[string]string),\n\t\tServerLogs: make(map[string]serverBlob),\n\t}\n\tfor id, info := range serverConfigs {\n\t\tblob.ServerNames[id] = info.DisplayName\n\t}\n\tfor id, sr := range scriptResults {\n\t\tvar sBlob serverBlob\n\n\t\tvar actionIndex int\n\t\tfor _, srl := range sr.Lines {\n\t\t\tswitch srl.Type {\n\t\t\tcase ResultIRCMessage:\n\t\t\t\t// raw line\n\t\t\t\tlineRaw := lineBlob{\n\t\t\t\t\tClient: srl.Client,\n\t\t\t\t\tSentBy: \"s\",\n\t\t\t\t\tLine: strings.TrimSuffix(srl.RawLine, \"\\r\\n\"),\n\t\t\t\t}\n\t\t\t\tsBlob.Raw = append(sBlob.Raw, lineRaw)\n\n\t\t\t\t// sanitised line\n\t\t\t\tsanitisedLine := srl.RawLine\n\t\t\t\tfor orig, new := range serverConfigs[id].SanitisedReplacements {\n\t\t\t\t\tsanitisedLine = strings.Replace(sanitisedLine, orig, new, -1)\n\t\t\t\t}\n\t\t\t\tlineSanitised := lineBlob{\n\t\t\t\t\tClient: srl.Client,\n\t\t\t\t\tSentBy: \"s\",\n\t\t\t\t\tLine: strings.TrimSuffix(sanitisedLine, \"\\r\\n\"),\n\t\t\t\t}\n\t\t\t\tsBlob.Sanitised = append(sBlob.Sanitised, lineSanitised)\n\t\t\tcase ResultActionSync:\n\t\t\t\tthisAction := script.Actions[actionIndex]\n\t\t\t\tif thisAction.LineToSend != \"\" {\n\t\t\t\t\t// sent line always stays the same\n\t\t\t\t\tline := lineBlob{\n\t\t\t\t\t\tClient: thisAction.Client,\n\t\t\t\t\t\tSentBy: \"c\",\n\t\t\t\t\t\tLine: strings.TrimSuffix(thisAction.LineToSend, \"\\r\\n\"),\n\t\t\t\t\t}\n\t\t\t\t\tsBlob.Raw = append(sBlob.Raw, line)\n\t\t\t\t\tsBlob.Sanitised = append(sBlob.Sanitised, line)\n\t\t\t\t}\n\t\t\t\tactionIndex++\n\t\t\tcase ResultDisconnected:\n\t\t\t\tline := lineBlob{\n\t\t\t\t\tClient: srl.Client,\n\t\t\t\t\tError: fmt.Sprintf(\"%s was disconnected unexpectedly\", srl.Client),\n\t\t\t\t}\n\t\t\t\tsBlob.Raw = append(sBlob.Raw, line)\n\t\t\t\tsBlob.Sanitised = append(sBlob.Sanitised, line)\n\t\t\tcase ResultDisconnectedExpected:\n\t\t\t\tline := lineBlob{\n\t\t\t\t\tClient: srl.Client,\n\t\t\t\t\tError: fmt.Sprintf(\"%s was disconnected\", srl.Client),\n\t\t\t\t}\n\t\t\t\tsBlob.Raw = append(sBlob.Raw, line)\n\t\t\t\tsBlob.Sanitised = append(sBlob.Sanitised, line)\n\t\t\t}\n\t\t}\n\n\t\tblob.ServerLogs[id] = sBlob\n\t}\n\n\t// marshall json blob\n\tblobBytes, err := json.Marshal(blob)\n\tblobString := \"{'error': 1}\"\n\tif err == nil {\n\t\tblobString = string(blobBytes)\n\t}\n\n\t// assemble template\n\treturn fmt.Sprintf(htmlTemplate, script.Name, script.ShortDescription, tabs, blobString, css)\n}","func (VS *Server) manuals(c *gin.Context) {\n\trender(c, gin.H{}, \"presentation-manuals.html\")\n}","func (this *Asset) buildHTML() template.HTML {\n\tvar tag_fn func(string) template.HTML\n\tswitch this.assetType {\n\tcase ASSET_JAVASCRIPT:\n\t\ttag_fn = js_tag\n\tcase ASSET_STYLESHEET:\n\t\ttag_fn = css_tag\n\tdefault:\n\t\tError(\"Unknown asset type\")\n\t\treturn \"\"\n\t}\n\tvar result template.HTML\n\tfor _, assetFile := range this.result {\n\t\tresult += tag_fn(\"/\" + assetFile.Path)\n\t}\n\treturn result\n}","func (service *StoriesService) getStories(codes []int, limit int64) ([]*handler.Story, error) {\n\n\t// concurrency is cool, but needs to be limited\n\tsemaphore := make(chan struct{}, 10)\n\n\t// how we know when all our goroutines are done\n\twg := sync.WaitGroup{}\n\n\t// somewhere to store all the stories when we're done\n\tstories := make([]*handler.Story, 0)\n\n\t// go over all the stories\n\tfor _, code := range codes {\n\n\t\t// stop when we have 30 stories\n\t\tif int64(len(stories)) >= limit {\n\t\t\tbreak\n\t\t}\n\n\t\t// in a goroutine with the story key\n\t\tgo func(code int) {\n\n\t\t\t// add one to the wait group\n\t\t\twg.Add(1)\n\n\t\t\t// add one to the semaphore\n\t\t\tsemaphore <- struct{}{}\n\n\t\t\t// make sure this gets fired\n\t\t\tdefer func() {\n\n\t\t\t\t// remove one from the wait group\n\t\t\t\twg.Done()\n\n\t\t\t\t// remove one from the semaphore\n\t\t\t\t<-semaphore\n\t\t\t}()\n\n\t\t\tp, err := service.hn.GetPost(code)\n\t\t\tif err != nil {\n\t\t\t\tlog.WithError(err).Error(\"error get stories\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// parse the url\n\t\t\tu, err := url.Parse(p.Url)\n\t\t\tif err != nil {\n\t\t\t\tlog.WithError(err).Error(\"error get stories\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// get the hostname from the url\n\t\t\th := u.Hostname()\n\n\t\t\t// check if it's from github or gitlab before adding to stories\n\t\t\tif strings.Contains(h, \"github\") || strings.Contains(h, \"gitlab\") {\n\t\t\t\tlog.Debugf(\"found url (%s)\", p.Url)\n\n\t\t\t\ts := &handler.Story{\n\t\t\t\t\tScore: p.Score,\n\t\t\t\t\tTitle: p.Title,\n\t\t\t\t\tUrl: p.Url,\n\t\t\t\t}\n\n\t\t\t\tif strings.Contains(h, \"github\") {\n\t\t\t\t\tvar err error\n\t\t\t\t\ts.Langauges, err = service.gh.GetDataBy(p.Url)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.WithError(err).Error(\"error get stories\")\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ts.DomainName = h\n\t\t\t\tstories = append(stories, s)\n\t\t\t}\n\n\t\t}(code)\n\t}\n\n\t// wait for all the goroutines\n\twg.Wait()\n\n\treturn stories, nil\n}","func Html(resp http.ResponseWriter, content string, code int) error {\n\tresp.Header().Add(\"Content-Type\", \"text/html\")\n\tresp.WriteHeader(code)\n\t_, err := resp.Write([]byte(content))\n\treturn maskAny(err)\n}","func (dt *Slick) HTMLTemplate() string {\n\treturn htmlTemplate\n}","func (p *TestPager) GeneratePagerHtml() (string, error) {\n p.FixData()\n\n var buffer bytes.Buffer\n left := p.Total\n i := 1\n for left > 0 {\n // generate spliter before\n if i > 1 {\n buffer.WriteString(d_spliter)\n }\n\n // main page nubmer\n if p.PageItems*(i-1) < p.Current && p.Current <= p.PageItems*i {\n buffer.WriteString(d_curr1)\n buffer.WriteString(strconv.Itoa(i))\n buffer.WriteString(d_curr2)\n } else {\n buffer.WriteString(d_pagenumber1)\n buffer.WriteString(strconv.Itoa(i))\n buffer.WriteString(d_pagenumber2)\n }\n // prepare next loop\n i += 1\n left -= p.PageItems\n }\n\n return buffer.String(), nil\n}","func render(src string, dst string) {\n\tdefer wg.Done()\n\tmd, err := ioutil.ReadFile(src)\n\tif err != nil {\n\t\tprintErr(err)\n\t\treturn\n\t}\n\thtml := renderHtml(md)\n\tif stylefile != \"\" {\n\t\thtml = addStyle(html, stylecont)\n\t} else {\n\t\thtml = addStyle(html, CSS)\n\t}\n\n\terr = ioutil.WriteFile(dst, []byte(html), 0644)\n\tif err != nil {\n\t\tprintErr(err)\n\t}\n}","func TestToHTML(timestamp string, results [][]string) string {\n\tvar ti testResults\n\n\t// for each line in the test results\n\tfor i := 0; i < len(results); i++ {\n\t\t// transform line to HTML\n\t\tfor _, v := range results[i] {\n\t\t\tparseTestLine(v, &ti)\n\t\t}\n\t}\n\n\t// return the body as a string\n\treturn statHeader(ti.pass, ti.fail, timestamp) + strings.Join(ti.html, \"\")\n}","func (c *Client) ReportStory(ctx context.Context, request *ReportStoryRequest) error {\n\tvar ok Ok\n\n\tif err := c.rpc.Invoke(ctx, request, &ok); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}","func writeHTML(domain, pkg, source, filename string) error {\n\tdata, err := generateHTML(domain, pkg, source)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = os.MkdirAll(filepath.Dir(filename), 0755)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn ioutil.WriteFile(filename, data, 0666)\n}","func Article_(children ...HTML) HTML {\n return Article(nil, children...)\n}","func outHTML(config *MainConfig, fileFunc FileResultFunc) {\n\n\tindexPath := filepath.Join(config.Outpath, FILE_NAME_HTML_INDEX)\n\terr := SFFileManager.WirteFilepath(indexPath, []byte(assets.HTML_INDEX))\n\n\tif nil != err {\n\t\tfileFunc(indexPath, ResultFileOutFail, err)\n\t} else {\n\t\tfileFunc(indexPath, ResultFileSuccess, nil)\n\t}\n\n\tsrcPath := filepath.Join(config.Outpath, FILE_NAME_HTML_SRC)\n\terr = SFFileManager.WirteFilepath(srcPath, []byte(assets.HTML_SRC))\n\n\tif nil != err {\n\t\tfileFunc(srcPath, ResultFileOutFail, err)\n\t} else {\n\t\tfileFunc(srcPath, ResultFileSuccess, nil)\n\t}\n\n}","func (account *Account) Stories() *StoryMedia {\r\n\tmedia := &StoryMedia{}\r\n\tmedia.uid = account.ID\r\n\tmedia.inst = account.inst\r\n\tmedia.endpoint = urlUserStories\r\n\treturn media\r\n}","func (self templateEngine) genBoard(prefix, frontend, newsgroup, outdir string, db Database) {\n // get the board model\n board := self.obtainBoard(prefix, frontend, newsgroup, db)\n // update the entire board model\n board = board.UpdateAll(db)\n // save the model\n self.groups[newsgroup] = board\n updateLinkCache()\n \n pages := len(board)\n for page := 0 ; page < pages ; page ++ {\n outfile := filepath.Join(outdir, fmt.Sprintf(\"%s-%d.html\", newsgroup, page))\n wr, err := OpenFileWriter(outfile)\n if err == nil {\n board[page].RenderTo(wr)\n wr.Close()\n log.Println(\"wrote file\", outfile)\n } else {\n log.Println(\"error generating board page\", page, \"for\", newsgroup, err)\n }\n }\n}","func (is *infosec) html(page *Page, els element) {\n\tis.Map.html(page, nil)\n\tels.setMeta(\"isInfosec\", true)\n\n\t// not in an infobox{}\n\t// FIXME: do not produce this warning if infosec{} is in a variable\n\tif is.parentBlock().blockType() != \"infobox\" {\n\t\tis.warn(is.openPosition(), \"infosec{} outside of infobox{} does nothing\")\n\t\treturn\n\t}\n\n\t// inject the title\n\tif is.blockName() != \"\" {\n\t\tis.mapList = append([]*mapListEntry{{\n\t\t\tkey: \"_infosec_title_\",\n\t\t\tmetas: map[string]bool{\"isTitle\": true},\n\t\t\tvalue: page.Fmt(is.blockName(), is.openPosition()),\n\t\t}}, is.mapList...)\n\t}\n\n\tinfoTableAddRows(is, els, page, is.mapList)\n}","func toHTML(s string) template.HTML {\n\treturn template.HTML(s)\n}","func HTML(opts ...ServerOption) {\n\tsrv, err := initServer(opts...)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\thttp.HandleFunc(\"/\", renderTemplate(srv))\n\n\tlog.Println(\"Listening on :3000...\")\n\terr = http.ListenAndServe(\":3000\", nil)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}","func (h *Home) SetHtmlFromPosts(html []byte, summ []byte, posts Posts) {\n var summaries []byte\n\n // Sort the Posts\n sort.Sort(posts)\n\n // Loop through Post collection\n for _, post := range posts {\n html := summ\n\n // Replace summary template variables\n html = bytes.Replace(html, []byte(\"{{ path }}\"), []byte(post.path), -1)\n html = bytes.Replace(html, []byte(\"{{ name }}\"), []byte(post.name), -1)\n\n summaries = append(summaries, html...)\n }\n\n // Replace base template variables\n html = bytes.Replace(html, []byte(\"{{ posts }}\"), summaries, -1)\n\n h.html = html\n}","func (g *Generator) GenerateHTML(data *scraper.ScrapedData) error {\n\treturn g.template.ExecuteTemplate(g.writer, \"profile\", data)\n}","func RenderHTMLFromFile(filename string, settings ...configuration.Setting) (string, types.Metadata, error) {\n\tinfo, err := os.Stat(filename)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn \"\", types.Metadata{}, err\n\t}\n\n\tallSettings := append([]configuration.Setting{\n\t\tconfiguration.WithLastUpdated(info.ModTime()),\n\t\tconfiguration.WithFilename(filename),\n\t\tconfiguration.WithBackEnd(\"html5\")},\n\t\tsettings...)\n\tconfig := configuration.NewConfiguration(allSettings...)\n\tf, err := os.Open(filename)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn \"\", types.Metadata{}, err\n\t}\n\tdefer func() { f.Close() }()\n\tresultWriter := bytes.NewBuffer(nil)\n\tmetadata, err := libasciidoc.Convert(f, resultWriter, config)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn \"\", types.Metadata{}, err\n\t}\n\tif log.IsLevelEnabled(log.DebugLevel) {\n\t\tlog.Debug(resultWriter.String())\n\t}\n\treturn resultWriter.String(), metadata, nil\n}","func (r *Recipe) parseHTML() (rerr error) {\n\tif r == nil {\n\t\tr = &Recipe{}\n\t}\n\tif r.FileContent == \"\" || r.FileName == \"\" {\n\t\trerr = fmt.Errorf(\"no file loaded\")\n\t\treturn\n\t}\n\n\tr.Lines, rerr = getIngredientLinesInHTML(r.FileContent)\n\treturn r.parseRecipe()\n\n}","func (h *ImageProxyHandler) imagesHTML(w http.ResponseWriter, dataURLChan <-chan *dataurl.DataURL) {\n\tw.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n\tw.WriteHeader(http.StatusOK)\n\n\tif err := imagesPageTmpl.Execute(w, dataURLChan); err != nil {\n\t\th.logger.Println(\"writing html response error:\", err)\n\t}\n}","func (t *GoatsTemplate) genRenderContent(output io.Writer) string {\n\tvar headProcessor processors.Processor = processors.NewHeadProcessor()\n\n\tvar argProcessor processors.Processor = processors.NewArgProcessor(t.Args)\n\theadProcessor.SetNext(argProcessor)\n\n\tt.buildProcessorChain(argProcessor, t.RootNode)\n\n\tctx := processors.NewTagContext(t.Parser.PkgMgr, t.pkgRefs, t.Parser.Settings.OutputFormat)\n\tif t.NeedsDocType {\n\t\tdocTypeProcessor := processors.NewDocTypeProcessor(t.Parser.DocTypeTag, t.Parser.DocTypeAttrs)\n\t\tdocTypeProcessor.SetNext(headProcessor)\n\t\theadProcessor = docTypeProcessor\n\t}\n\n\tvar renderBuffer bytes.Buffer\n\theadProcessor.Process(&renderBuffer, ctx)\n\treturn renderBuffer.String()\n}","func viewHandler(w http.ResponseWriter, r *http.Request) {\n\ttitle := r.URL.Path[len(\"/view/\"):]\n\tp, err := loadPage(title)\n\tif err != nil {\n\t\thttp.Redirect(w, r, \"/edit/\"+title, http.StatusFound)// if there does not exist page:title, make a new page.\n\t\treturn\t\t\n\t}\n\trenderTemplate(w, \"view\", p)\n\t// t, _ := template.ParseFiles(\"view.html\")// return *template.Template, error\n\t// t.Execute(w,p)\n\t// fmt.Fprintf(w, \"

%s

%s
\", p.Title, p.Body)\n}","func newHnStories() []Story {\n\t// First we need a buffer to hold stories\n\tvar stories []Story\n\t// We can use the GetChanges function to get all the most recent objects\n\t// from HackerNews. These will just be integer IDs, and we'll need to make requests\n\t// for each one.\n\tchanges, err := hackerNewsClient.GetChanges()\n\t// In case of an error, we'll print it and return nil\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn nil\n\t}\n\n\t// Now, we can loop over the IDs we got back and make a request for each one.\n\tfor _, id := range changes.Items {\n\t\t// The GetStory method will return a Story struct, or an error if the requested object wasn't\n\t\t// as story.\n\t\tstory, err := hackerNewsClient.GetStory(id)\n\t\t// In case it wasn't a story, just move on.\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\t// Now we can construct a Story struct and put it in the list\n\t\tnewStory := Story{\n\t\t\ttitle: story.Title,\n\t\t\turl: story.URL,\n\t\t\tauthor: story.By,\n\t\t\tsource: \"HackerNews\",\n\t\t}\n\t\tstories = append(stories, newStory)\n\t}\n\n\t// Finally, after the loop completes, we'll just return the stories\n\treturn stories\n}","func (i Novel) HTMLContent(ctx context.Context, renderer ContentRenderer) (string, error) {\n\tif renderer == nil {\n\t\trenderer = SimpleContentRenderer{EmbeddedImages: i.EmbeddedImages}\n\t}\n\treturn HTMLContent(ctx, renderer, i.Content)\n}","func (c *rstConverter) getRstContent(src []byte, ctx converter.DocumentContext) []byte {\n\tlogger := c.cfg.Logger\n\tpath := getRstExecPath()\n\n\tif path == \"\" {\n\t\tlogger.Println(\"rst2html / rst2html.py not found in $PATH: Please install.\\n\",\n\t\t\t\" Leaving reStructuredText content unrendered.\")\n\t\treturn src\n\t}\n\n\tlogger.Infoln(\"Rendering\", ctx.DocumentName, \"with\", path, \"...\")\n\n\tvar result []byte\n\t// certain *nix based OSs wrap executables in scripted launchers\n\t// invoking binaries on these OSs via python interpreter causes SyntaxError\n\t// invoke directly so that shebangs work as expected\n\t// handle Windows manually because it doesn't do shebangs\n\tif runtime.GOOS == \"windows\" {\n\t\tpython := internal.GetPythonExecPath()\n\t\targs := []string{path, \"--leave-comments\", \"--initial-header-level=2\"}\n\t\tresult = internal.ExternallyRenderContent(c.cfg, ctx, src, python, args)\n\t} else {\n\t\targs := []string{\"--leave-comments\", \"--initial-header-level=2\"}\n\t\tresult = internal.ExternallyRenderContent(c.cfg, ctx, src, path, args)\n\t}\n\t// TODO(bep) check if rst2html has a body only option.\n\tbodyStart := bytes.Index(result, []byte(\"\\n\"))\n\tif bodyStart < 0 {\n\t\tbodyStart = -7 // compensate for length\n\t}\n\n\tbodyEnd := bytes.Index(result, []byte(\"\\n\"))\n\tif bodyEnd < 0 || bodyEnd >= len(result) {\n\t\tbodyEnd = len(result) - 1\n\t\tif bodyEnd < 0 {\n\t\t\tbodyEnd = 0\n\t\t}\n\t}\n\n\treturn result[bodyStart+7 : bodyEnd]\n}","func main() {\n\tp1 := &gowiki.Page{Title: \"TestPage\", Body: []byte(\"This is a sample Page.\")}\n\tp1.Save()\n\tp2, _ := gowiki.LoadPage(\"TestPage\")\n\tfmt.Println(string(p2.Body))\n}","func ForHTMLTemplate(ts ...*template.Template) func(io.Writer) frameless.Presenter {\n\treturn (func(io.Writer) frameless.Presenter)(func(w io.Writer) frameless.Presenter {\n\t\treturn frameless.PresenterFunc(func(data interface{}) error {\n\n\t\t\tmostInnerTemplate := ts[len(ts)-1]\n\t\t\ttContent := bytes.NewBuffer([]byte{})\n\n\t\t\tif err := mostInnerTemplate.Execute(tContent, data); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\trest := ts[:len(ts)-1]\n\t\t\tcurrentContent := tContent.String()\n\n\t\t\tfor i := len(rest) - 1; i >= 0; i-- {\n\t\t\t\tt := rest[i]\n\t\t\t\tb := bytes.NewBuffer([]byte{})\n\n\t\t\t\tif err := t.Execute(b, template.HTML(currentContent)); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tcurrentContent = b.String()\n\t\t\t}\n\n\t\t\tw.Write([]byte(currentContent))\n\n\t\t\treturn nil\n\n\t\t})\n\t})\n}","func BuildPage(htmlTemplate string, bingoBoard BingoBoard) *bytes.Buffer {\n\tvar bodyBuffer bytes.Buffer\n\tt := template.New(\"template\")\n\tvar templates = template.Must(t.Parse(htmlTemplate))\n\ttemplates.Execute(&bodyBuffer, bingoBoard)\n\treturn &bodyBuffer\n}","func (VS *Server) design(c *gin.Context) {\n\trender(c, gin.H{}, \"presentation-design.html\")\n}","func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n p, _ := loadPage(\"/src/github.com/mrgirlyman/watcher/frontman/build/index.html\")\n\n fmt.Fprintf(w, string(p.Body))\n // log.Fatal(err)\n\n // if (err != nil) {\n // fmt.Fprintf(w, string(p.Body))\n // } else {\n // fmt.Fprintf(w, \"Error reading index.html\")\n // }\n}","func TestPutSlidesDocumentFromHtmlInvalidhtml(t *testing.T) {\n request := createPutSlidesDocumentFromHtmlRequest()\n request.html = invalidizeTestParamValue(request.html, \"html\", \"string\").(string)\n e := initializeTest(\"PutSlidesDocumentFromHtml\", \"html\", request.html)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesDocumentFromHtml(request)\n assertError(t, \"PutSlidesDocumentFromHtml\", \"html\", r.Code, e)\n}","func markdownToHTML(s string) string {\n\ts = strings.Replace(s, \"_blank\", \"________\", -1)\n\ts = strings.Replace(s, \"\\\\kh\", \"( )\", -1)\n\ts = strings.Replace(s, \"~\", \" \", -1)\n\tresult := \"\"\n\troot := Parse(s)\n\tfor node := root.FirstChild; node != nil; node = node.NextSibling {\n\t\tif node.Type == NodePara {\n\t\t\tresult += fmt.Sprintf(\"

%s

\", node.Data)\n\t\t} else if node.Type == NodeImag {\n\t\t\tresult += fmt.Sprintf(\"

\", node.Data, node.Attr)\n\t\t} else if node.Type == NodeOl {\n\t\t\tresult += \"
    \"\n\t\t\tfor linode := node.FirstChild; linode != nil; linode = linode.NextSibling {\n\t\t\t\tresult += fmt.Sprintf(\"
  1. \\n\", linode.Attr)\n\t\t\t\tfor p := linode.FirstChild; p != nil; p = p.NextSibling {\n\t\t\t\t\tif p.Type == NodePara {\n\t\t\t\t\t\tresult += fmt.Sprintf(\"

    %s

    \", p.Data)\n\t\t\t\t\t} else if p.Type == NodeImag {\n\t\t\t\t\t\tresult += fmt.Sprintf(\"

    \", p.Data, p.Attr)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tresult += fmt.Sprintf(\"
  2. \\n\")\n\t\t\t}\n\t\t\tresult += \"
\"\n\t\t}\n\t}\n\treturn result\n}","func htmlHandler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprint(w, \"

Whoa, Nice!

\")\n\tfmt.Fprint(w, \"

Nice Go

\")\n\tfmt.Fprint(w, \"

This is a paragraph

\")\n\t// Note Fprintf for formatting\n\tfmt.Fprintf(w, \"

You %s even add %s

\", \"can\", \"variables\")\n\t// Multiline print\n\tfmt.Fprintf(w, `

Hi!

\n

This is also Go

\n

Multiline

`)\n\n}","func generateHTMLReport(c *gin.Context,scrapeID string){\n\tjsonFile, err := os.Open(\"data/\" + scrapeID + \"_report.json\")\n\tif err!=nil{\n\t\tc.HTML(\n\t\t\thttp.StatusBadRequest,\n\t\t\t\"error.tmpl\",\n\t\t\tgin.H{\n\t\t\t\t\"err\": \"no report found!\",\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\n\tdefer jsonFile.Close()\n\treportInBytes, err := ioutil.ReadAll(jsonFile)\n\tif err!=nil{\n\t\tc.HTML(\n\t\t\thttp.StatusBadRequest,\n\t\t\t\"error.tmpl\",\n\t\t\tgin.H{\n\t\t\t\t\"err\": \"Error while reading report\",\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\n\tvar finalReport scraper.Report\n\t_ = json.Unmarshal(reportInBytes, &finalReport)\n\n\tc.HTML(\n\t\thttp.StatusOK,\n\t\t\"index.tmpl\",\n\t\tgin.H{\n\t\t\t\"scrape_id\": finalReport.ScrapeID,\n\t\t\t\"project_id\":finalReport.ProjectID,\n\t\t\t\"folder_threshold\":finalReport.FolderThreshold,\n\t\t\t\"folder_examples_count\":finalReport.FolderExamplesCount,\n\t\t\t\"patterns\":finalReport.Patterns,\n\t\t\t\"details\": finalReport.DetailedReport,\n\t\t},\n\t)\n\treturn\n\n}","func testTemplate(w http.ResponseWriter, r *http.Request) {\n\ttestpage := Page{\n\t\tID: \"urn:cts:tests:test1.test1:1\",\n\t\tText: template.HTML(\"This is a testing of the template\")}\n\n\trenderTemplate(w, \"view\", testpage)\n}","func how(w http.ResponseWriter, req *http.Request, ctx httputil.Context) (e *httputil.Error) {\n\tw.Header().Set(\"Content-Type\", \"text/html\")\n\n\tif err := T(\"how/how.html\").Execute(w, nil); err != nil {\n\t\te = httputil.Errorf(err, \"error executing index template\")\n\t}\n\treturn\n}","func PrettyPrints(print int) {\r\n\t/*this section is going to define all my big pretty printing and follow with a simple switch that chooses the particular graphic by its integer number associated with it.\r\n\tthe images come out distorted without modifying them here piece by piece so they look weird here but they look great in use.*/\r\n\r\n\t//this graphic and a few other presented weird so adjustments were made to achieve correct appearance\r\n\tvar pridePic string = `\r\n\t _____ _____ _____ _____\r\n\t| | | __| _ | | __|___ _____ ___ ___\r\n\t| | | |__ | | | | | .'| | -_|_ -|\r\n\t|_|___|_____|__|__| |_____|__,|_|_|_|___|___|\r\n\t _____ _\r\n\t\t| _ |___ ___ ___ ___ ___| |_ ___\r\n\t\t| __| _| -_|_ -| -_| | _|_ -|\r\n\t\t|__| |_| |___|___|___|_|_|_| |___|\r\n`\r\n\tvar titlePic string = `\r\n\t _____ _ _\r\n\t| _ |___ ___ |_|___ ___| |_\r\n\t| __| _| . | | | -_| _| _|\r\n\t|__| |_| |___|_| |___|___|_|\r\n\t\t |___|\r\n\t \t _ _\r\n\t\t _| | |_ ___\r\n\t |_ _| |_ |\r\n\t\t |_ _| | _|\r\n\t\t |_|_| |___|\r\n`\r\n\r\n\tvar spellPic string = `\r\n /\\\r\n / \\\r\n | |\r\n --:'''':--\r\n :'_' :\r\n _:\"\":\\___\r\n ' ' ____.' ::: '._\r\n . *=====<<=) \\ :\r\n . ' '-'-'\\_ /'._.'\r\n \\====:_ \"\"\r\n .' \\\\\r\n : :\r\n / : \\\r\n : . '.\r\n ,. _ : : : :\r\n '-' ). :__:-:__.;--'\r\n ( ' ) '-' '-'\r\n ( - .00. - _\r\n( .' O ) )\r\n'- ()_.\\,\\, -\r\n`\r\n\t//\r\n\tvar swordPic string = `\r\n /\r\nO===[====================-\r\n \\\r\n`\r\n\r\n\tvar shieldPic string = `\r\n\t\\_ _/\r\n\t] --__________-- [\r\n\t| || |\r\n\t\\ || /\r\n\t [ || ]\r\n\t |______||______|\r\n\t |------..------|\r\n\t ] || [\r\n\t \\ || /\r\n\t [ || ]\r\n\t \\ || /\r\n\t [ || ]\r\n\t \\__||__/\r\n\t --\r\n\t`\r\n\tvar winPic string = `\r\n\t __ __ _ _ _ __\r\n\t| | |___ _ _ | | | |___ ___| |\r\n\t|_ _| . | | | | | | | . | |__|\r\n\t |_| |___|___| |_____|___|_|_|__|\r\n\t`\r\n\r\n\tvar losePic string = `\r\n\t __ __ ____ _ _\r\n\t| | |___ _ _ | \\|_|___ _| |\r\n\t|_ _| . | | | | | | | -_| . |\r\n\t |_| |___|___| |____/|_|___|___|\r\n\t`\r\n\tvar tiePic string = `\r\n\t _____ _\r\n\t|_ _|_|___\r\n\t | | | | -_|\r\n\t |_| |_|___|\r\n\t`\r\n\tvar sssPic string = `\r\n\t _____ _\r\n\t| __|_ _ _ ___ ___ _| |\r\n\t|__ | | | | . | _| . |\r\n\t|_____|_____|___|_| |___|\r\n\t _____ _ _ _ _\r\n\t| __| |_|_|___| |_| |\r\n\t|__ | | | -_| | . |\r\n\t|_____|_|_|_|___|_|___|\r\n\t _____ _ _\r\n\t| __|___ ___| | |\r\n\t|__ | . | -_| | |\r\n\t|_____| _|___|_|_|\r\n\t\t|_|\r\n\t`\r\n\tswitch print {\r\n\tcase 1:\r\n\t\tfmt.Printf(\"%s\\n\", pridePic)\r\n\tcase 2:\r\n\t\tfmt.Printf(\"%s\\n\", titlePic)\r\n\tcase 3:\r\n\t\tfmt.Printf(\"%s\\n\", spellPic)\r\n\tcase 4:\r\n\t\tfmt.Printf(\"%s\\n\", swordPic)\r\n\tcase 5:\r\n\t\tfmt.Printf(\"%s\\n\", shieldPic)\r\n\tcase 6:\r\n\t\tfmt.Printf(\"%s\\n\", winPic)\r\n\tcase 7:\r\n\t\tfmt.Printf(\"%s\\n\", losePic)\r\n\tcase 8:\r\n\t\tfmt.Printf(\"%s\\n\", sssPic)\r\n\tcase 9:\r\n\t\tfmt.Printf(\"%s\\n\", tiePic)\r\n\r\n\t}\r\n}","func main() {\n\tdomTarget := dom.GetWindow().Document().GetElementByID(\"app\")\n\n\tr.Render(container.Container(), domTarget)\n}","func FullStory(ctx context.Context, client streamexp.ReadMyStoryServiceClient) error {\n\n}","func getOneStory(id int, c hn.Client, channel chan item, counter int) {\r\n\t// defer wg.Done()\r\n\tvar i item\r\n\t// fmt.Printf(\"getting item %d inside getOneStory number %d\\n\", id, counter)\r\n\thnItem, err := c.GetItem(id)\r\n\tif err != nil {\r\n\t\tfmt.Println(err)\r\n\t\treturn\r\n\t}\r\n\tfmt.Printf(\"parsing item %d\\n\", id)\r\n\ti = parseHNItem(hnItem)\r\n\tif !isStoryLink(i) {\r\n\t\tgoroutine--\r\n\t\t// fmt.Printf(\"returning because item %d is not a story.\\n\", id)\r\n\t\treturn\r\n\t}\r\n\t// fmt.Printf(\"Adding item %d to channel.\\n\", id)\r\n\tchannel <- i\r\n}","func helpHtmlHandle(w http.ResponseWriter, r *http.Request) {\n\thelpTempl.Execute(w, Params)\n}","func descriptionContents(shuffledData *ClipJSON) string {\n\tcontents := `\\n\\n` // Start with new line to seperate message at top\n\tcurrentTime := 0\n\n\tfor _, clip := range shuffledData.Clips {\n\t\tcontents += fmt.Sprintf(\"Title: %s\\nVod: %s\\nTime: %s\\n\\n\", clip.Title, clip.Vod.URL, youtubeTimify(currentTime))\n\t\t// Convert clip.Duration to milliseconds, then round in to the nearest millisecond\n\t\tcurrentTime += int(math.Floor(clip.Duration + 0.5))\n\t}\n\n\treturn contents\n}","func GenerateHTMLReport(totalTestTime, testDate string, testSummary []TestOverview, testSuiteDetails map[string]TestSuiteDetails) {\n\ttotalPassedTests := 0\n\ttotalFailedTests := 0\n\ttotalSkippedTests := 0\n\ttemplates := make([]template.HTML, 0)\n\tfor _, testSuite := range testSuiteDetails {\n\t\ttotalPassedTests = totalPassedTests + testSuite.PassedTests\n\t\ttotalFailedTests = totalFailedTests + testSuite.FailedTests\n\t\ttotalSkippedTests = totalSkippedTests + testSuite.SkippedTests\n\t\t// display testSuiteName\n\t\thtmlString := template.HTML(\"
\\n\")\n\t\tpackageInfoTemplateString := template.HTML(\"\")\n\n\t\tpackageInfoTemplateString = \"
{{.testsuiteName}}
\" + \"\\n\" + \"
Run Time: {{.elapsedTime}}m
\" + \"\\n\"\n\t\tpackageInfoTemplate, err := template.New(\"packageInfoTemplate\").Parse(string(packageInfoTemplateString))\n\t\tif err != nil {\n\t\t\tlog.Println(\"error parsing package info template\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\tvar processedPackageTemplate bytes.Buffer\n\t\terr = packageInfoTemplate.Execute(&processedPackageTemplate, map[string]string{\n\t\t\t\"testsuiteName\": testSuite.TestSuiteName + \"_\" + OS,\n\t\t\t\"elapsedTime\": fmt.Sprintf(\"%.2f\", testSuite.ElapsedTime),\n\t\t})\n\t\tif err != nil {\n\t\t\tlog.Println(\"error applying package info template: \", err)\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\tif testSuite.Status == \"pass\" {\n\t\t\tpackageInfoTemplateString = \"
\" +\n\t\t\t\ttemplate.HTML(processedPackageTemplate.Bytes()) + \"
\"\n\t\t} else if testSuite.Status == \"fail\" {\n\t\t\tpackageInfoTemplateString = \"
\" +\n\t\t\t\ttemplate.HTML(processedPackageTemplate.Bytes()) + \"
\"\n\t\t} else {\n\t\t\tpackageInfoTemplateString = \"
\" +\n\t\t\t\ttemplate.HTML(processedPackageTemplate.Bytes()) + \"
\"\n\t\t}\n\n\t\thtmlString = htmlString + \"\\n\" + packageInfoTemplateString\n\t\ttestInfoTemplateString := template.HTML(\"\")\n\n\t\t// display testCases\n\t\tfor _, pt := range testSummary {\n\t\t\ttestHTMLTemplateString := template.HTML(\"\")\n\t\t\tif len(pt.TestCases) == 0 {\n\t\t\t\tlog.Println(\"Test run failed for \", pt.TestSuiteName, \"no testcases were executed\")\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif pt.TestSuiteName == testSuite.TestSuiteName {\n\t\t\t\tif testSuite.FailedTests == 0 {\n\t\t\t\t\ttestHTMLTemplateString = \"
\" +\n\t\t\t\t\t\t\"\\n\" + \"
\" +\n\t\t\t\t\t\t\"
+ {{.testName}}
\" + \"\\n\" + \"
{{.elapsedTime}}
\" + \"\\n\" +\n\t\t\t\t\t\t\"
\" + \"\\n\" +\n\t\t\t\t\t\t\"
\"\n\t\t\t\t} else if testSuite.FailedTests > 0 {\n\t\t\t\t\ttestHTMLTemplateString = \"
\" +\n\t\t\t\t\t\t\"\\n\" + \"
\" +\n\t\t\t\t\t\t\"
+ {{.testName}}
\" + \"\\n\" + \"
{{.elapsedTime}}
\" + \"\\n\" +\n\t\t\t\t\t\t\"
\" + \"\\n\" +\n\t\t\t\t\t\t\"
\"\n\t\t\t\t} else if testSuite.SkippedTests > 0 {\n\t\t\t\t\ttestHTMLTemplateString = \"
\" +\n\t\t\t\t\t\t\"\\n\" + \"
\" +\n\t\t\t\t\t\t\"
+ {{.testName}}
\" + \"\\n\" + \"
{{.elapsedTime}}
\" + \"\\n\" +\n\t\t\t\t\t\t\"
\" + \"\\n\" +\n\t\t\t\t\t\t\"
\"\n\t\t\t\t}\n\t\t\t\ttestTemplate, err := template.New(\"Test\").Parse(string(testHTMLTemplateString))\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Println(\"error parsing tests template: \", err)\n\t\t\t\t\tos.Exit(1)\n\t\t\t\t}\n\t\t\t\tvar processedTestTemplate bytes.Buffer\n\t\t\t\terr = testTemplate.Execute(&processedTestTemplate, map[string]string{\n\t\t\t\t\t\"testName\": \"TestCases\",\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Println(\"error applying test template: \", err)\n\t\t\t\t\tos.Exit(1)\n\t\t\t\t}\n\n\t\t\t\ttestHTMLTemplateString = template.HTML(processedTestTemplate.Bytes())\n\t\t\t\ttestCaseHTMLTemplateString := template.HTML(\"\")\n\n\t\t\t\tfor _, tC := range pt.TestCases {\n\t\t\t\t\ttestCaseHTMLTemplateString = \"
{{.testName}}
\" + \"\\n\" + \"
{{.elapsedTime}}m
\"\n\t\t\t\t\ttestCaseTemplate, err := template.New(\"testCase\").Parse(string(testCaseHTMLTemplateString))\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Println(\"error parsing test case template: \", err)\n\t\t\t\t\t\tos.Exit(1)\n\t\t\t\t\t}\n\n\t\t\t\t\tvar processedTestCaseTemplate bytes.Buffer\n\t\t\t\t\terr = testCaseTemplate.Execute(&processedTestCaseTemplate, map[string]string{\n\t\t\t\t\t\t\"testName\": tC.TestCaseName,\n\t\t\t\t\t\t\"elapsedTime\": fmt.Sprintf(\"%f\", tC.ElapsedTime),\n\t\t\t\t\t})\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Println(\"error applying test case template: \", err)\n\t\t\t\t\t\tos.Exit(1)\n\t\t\t\t\t}\n\n\t\t\t\t\tif tC.Status == \"passed\" {\n\t\t\t\t\t\ttestCaseHTMLTemplateString = \"
\" + template.HTML(processedTestCaseTemplate.Bytes()) + \"
\"\n\n\t\t\t\t\t} else if tC.Status == \"failed\" {\n\t\t\t\t\t\ttestCaseHTMLTemplateString = \"
\" + template.HTML(processedTestCaseTemplate.Bytes()) + \"
\"\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttestCaseHTMLTemplateString = \"
\" + template.HTML(processedTestCaseTemplate.Bytes()) + \"
\"\n\t\t\t\t\t}\n\t\t\t\t\ttestHTMLTemplateString = testHTMLTemplateString + \"\\n\" + testCaseHTMLTemplateString\n\t\t\t\t}\n\t\t\t\ttestHTMLTemplateString = testHTMLTemplateString + \"\\n\" + \"
\" + \"\\n\" + \"
\"\n\t\t\t\ttestInfoTemplateString = testInfoTemplateString + \"\\n\" + testHTMLTemplateString\n\t\t\t}\n\t\t}\n\t\thtmlString = htmlString + \"\\n\" + \"
\\n\" + testInfoTemplateString + \"\\n\" + \"
\"\n\t\thtmlString = htmlString + \"\\n\" + \"
\"\n\t\ttemplates = append(templates, htmlString)\n\t}\n\treportTemplate := template.New(\"report-template.html\")\n\treportTemplateData, err := Asset(\"report-template.html\")\n\tif err != nil {\n\t\tlog.Println(\"error retrieving report-template.html: \", err)\n\t\tos.Exit(1)\n\t}\n\n\treport, err := reportTemplate.Parse(string(reportTemplateData))\n\tif err != nil {\n\t\tlog.Println(\"error parsing report-template.html: \", err)\n\t\tos.Exit(1)\n\t}\n\n\tvar processedTemplate bytes.Buffer\n\ttype templateData struct {\n\t\tHTMLElements []template.HTML\n\t\tFailedTests int\n\t\tPassedTests int\n\t\tSkippedTests int\n\t\tTotalTestTime string\n\t\tTestDate string\n\t}\n\n\terr = report.Execute(&processedTemplate,\n\t\t&templateData{\n\t\t\tHTMLElements: templates,\n\t\t\tFailedTests: totalFailedTests,\n\t\t\tPassedTests: totalPassedTests,\n\t\t\tSkippedTests: totalSkippedTests,\n\t\t\tTotalTestTime: totalTestTime,\n\t\t\tTestDate: testDate,\n\t\t},\n\t)\n\tif err != nil {\n\t\tlog.Println(\"error applying report-template.html: \", err)\n\t\tos.Exit(1)\n\t}\n\thtmlReport = strings.Split(fileName, \".\")[0] + \"_results.html\"\n\tbucketName = strings.Split(htmlReport, \"_\")[0] + \"-results\"\n\tfmt.Println(bucketName)\n\terr = ioutil.WriteFile(htmlReport, processedTemplate.Bytes(), 0644)\n\tif err != nil {\n\t\tlog.Println(\"error writing report.html file: \", err)\n\t\tos.Exit(1)\n\t}\n}","func outputHTML(w http.ResponseWriter, r *http.Request, filepath string) {\n\tfile, err := os.Open(filepath)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tdefer file.Close()\n\n\thttp.ServeContent(w, r, file.Name(), time.Now(), file)\n}","func generate(p *models.Project) string {\n\tvar builder strings.Builder\n\tbuilder.WriteString(fmt.Sprintf(\"# %s\\n\", p.Name))\n\tplugins := []Plugin{description}\n\tif len(p.Badges) > 0 {\n\t\tplugins = append(plugins, addBadges)\n\t\tfor _, plugin := range plugins {\n\t\t\tplugin(&builder, p)\n\t\t}\n\t}\n\tbuilder.WriteString(fmt.Sprintf(\"### Author\\n\"))\n\tbuilder.WriteString(fmt.Sprintf(\"%s\\n\", p.Author))\n\tbuilder.WriteString(fmt.Sprintf(\"### LICENCE\\n\"))\n\treturn builder.String()\n}","func handlerPreview(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n\tvar v = struct {\n\t\tHost string\n\t\tData string\n\t}{\n\t\tr.Host,\n\t\t\"Go ahead, save that markdown file.\",\n\t}\n\n\ttmpl.Execute(w, &v)\n}","func Idea() string {\n\tresp, err := http.Get(\"http://itsthisforthat.com/api.php?json\")\n\tif err != nil {\n\t\treturn \"I had a problem...\"\n\t}\n\tdefer resp.Body.Close()\n\n\tbodyBytes, err := ioutil.ReadAll(resp.Body)\n\n\tvar concept idea\n\tjson.Unmarshal([]byte(bodyBytes), &concept)\n\treturn \"you should create \" + concept.This + \" for \" + concept.That\n}","func handlerView(w http.ResponseWriter, r *http.Request, title string) {\r\n\tp2, err := loadPage(title)\r\n\tif err != nil {\r\n\t\t//thiswill redirect the cliebt to the edit page so the content may be created\r\n\t\t//the http.redirect fucntion adds an HTTP status code\r\n\t\t//of fttp.statusFound(302) and a location header to the http response\r\n\t\thttp.Redirect(w, r, \"/edit/\"+title, http.StatusFound)\r\n\t\tfmt.Println(err.Error())\r\n\t\tos.Exit(1)\r\n\t}\r\n\tfetchHTML(w, \"view\", p2)\r\n}","func TestHandler_OEmbed(t *testing.T) {\n\th := NewTestHandler()\n\tdefer h.Close()\n\n\t// Create the gist in the database.\n\th.DB.Update(func(tx *gist.Tx) error {\n\t\treturn tx.SaveGist(&gist.Gist{ID: \"abc123\", UserID: 1000, Description: \"My Gist\"})\n\t})\n\n\t// Retrieve oEmbed.\n\tu, _ := url.Parse(h.Server.URL + \"/oembed.json\")\n\tu.RawQuery = (&url.Values{\"url\": {\"https://gist.exposed/benbjohnson/abc123\"}}).Encode()\n\tresp, err := http.Get(u.String())\n\tok(t, err)\n\tequals(t, 200, resp.StatusCode)\n\n\thtml, _ := json.Marshal(`
`)\n\tequals(t, `{\"version\":\"1.0\",\"type\":\"rich\",\"html\":`+string(html)+`,\"height\":300,\"title\":\"My Gist\",\"provider_name\":\"Gist Exposed!\",\"provider_url\":\"https://gist.exposed\"}`+\"\\n\", readall(resp.Body))\n}"],"string":"[\n \"func story(Memories int) string {\\n\\tGamePlot := \\\"story.txt\\\"\\n\\tif len(plot) <= 0 {\\n\\t\\tstory, err := os.Open(GamePlot)\\n\\t\\tif err != nil {\\n\\t\\t\\tlog.Fatalf(\\\"either incorrect format or associated with %s please rewrite.\\\\n\\\", err)\\n\\t\\t} else {\\n\\t\\t\\tStoryReader := bio.NewScanner(story)\\n\\t\\t\\tStoryReader.Split(bio.ScanLines)\\n\\t\\t\\tdefer story.Close()\\n\\t\\t\\tfor StoryReader.Scan() {\\n\\t\\t\\t\\tplot = append(plot, StoryReader.Text())\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\treturn plot[Memories]\\n}\",\n \"func getStory(w http.ResponseWriter, r *http.Request) {\\n\\t// read the id\\n\\tid := mux.Vars(r)[\\\"id\\\"]\\n\\t// format the url\\n\\tstoryURL := fmtURL(id)\\n\\t// Make request and get response body\\n\\tdata := fmtRes(storyURL)\\n\\tfmt.Println(\\\"data:\\\", data)\\n\\tw.Write([]byte(data))\\n}\",\n \"func Source_() HTML {\\n return Source(nil)\\n}\",\n \"func (page *storyPage) playStoryMethod() {\\n\\tfor page != nil {\\n\\t\\tfmt.Println(page.text)\\n\\t\\tpage = page.nextPage\\n\\t}\\n}\",\n \"func Embed_() HTML {\\n return Embed(nil)\\n}\",\n \"func getHTML(str string) template.HTML {\\n\\tmarkdown := string(blackfriday.Run([]byte(str)))\\n\\treturn template.HTML(markdown)\\n}\",\n \"func (t toc) toHTMLStr() (htmlStr string) {\\n\\thtmlStr = `\\n\\n\\n\\nRedis in Action: Table Of Content\\n\\n\\n

Redis in Action

\\n`\\n\\n\\thtmlStr += \\\"
\\\\n
    \\\\n\\\"\\n\\tcurrentLevel := 1\\n\\tfor _, v := range t {\\n\\t\\tif v.level > currentLevel {\\n\\t\\t\\thtmlStr += \\\"
      \\\\n\\\"\\n\\t\\t\\tcurrentLevel = v.level\\n\\t\\t} else if v.level < currentLevel {\\n\\t\\t\\tfor i := v.level; i < currentLevel; i++ {\\n\\t\\t\\t\\thtmlStr += \\\"
    \\\\n\\\"\\n\\t\\t\\t}\\n\\t\\t\\tcurrentLevel = v.level\\n\\t\\t}\\n\\n\\t\\thtmlStr += fmt.Sprintf(\\\"
  • %s
  • \\\\n\\\", v.value, v.title)\\n\\t}\\n\\thtmlStr += \\\"
\\\\n
\\\\n\\\\n\\\"\\n\\treturn htmlStr\\n}\",\n \"func playHtmlHandle(w http.ResponseWriter, r *http.Request) {\\n\\tplayTempl.Execute(w, Params)\\n}\",\n \"func toHtml(fname string) string {\\n\\treturn strings.Replace(fname, \\\".md\\\", \\\".html\\\", -1)\\n}\",\n \"func pagemain(w http.ResponseWriter, r *http.Request){\\n w.Write([]byte( `\\n \\n Ciao\\n

Come stai

\\n \\n `))\\n }\",\n \"func work(reader io.Reader, app_data AppData) string {\\n content_markdown := ReaderToString(reader)\\n content_title := \\\"\\\"\\n \\n //look for an H1 title, break it out for use in the HTML title tag\\n first_newline := strings.Index(content_markdown, \\\"\\\\n\\\")\\n if first_newline > -1{\\n if strings.HasPrefix(content_markdown[0:first_newline], \\\"# \\\") {\\n content_title = content_markdown[2:first_newline]\\n content_markdown = content_markdown[first_newline:]\\n }\\n }\\n\\n //get the content\\n var content_html string\\n if app_data.Markdown {\\n content_html = MarkdownToHTML(content_markdown)\\n } else {\\n content_html = content_markdown\\n }\\n\\n //set up reporting time/date\\n now := time.Now()\\n formated_date := now.Format(\\\"2006-01-02 03:04 PM\\\")\\n\\n //expose data to template\\n data := TemplateData{\\n Title: content_title,\\n Content: content_html,\\n Date: formated_date,\\n }\\n \\n //get template file\\n template_file_path := FindTemplate(app_data.Template, app_data.Limit)\\n var template_content string\\n if template_file_path == \\\"\\\" {\\n template_content = FILE_TEMPLATE\\n } else {\\n template_content = readFile(template_file_path)\\n }\\n \\n return render(template_content, data)\\n}\",\n \"func (server Server) Create_Open_Html() {\\n\\tlayernames := []string{}\\n\\tfor _,i := range server.Mbtiles {\\n\\t\\tlayernames = append(layernames,Get_Vector_Layers(i)...)\\n\\t}\\n\\tfor _,i := range server.Geobufs {\\n\\t\\tlayernames = append(layernames,i.Config_Dynamic.LayerName)\\n\\t}\\n\\n\\tlayer_parts := []string{}\\n\\tfor _,layername := range layernames {\\n\\t\\tlayer_parts = append(layer_parts,Get_Part_Layer(layername))\\n\\t}\\n\\tmiddle := strings.Join(layer_parts,\\\"\\\\n\\\")\\n\\tstart,end := Start_End()\\n\\n\\ttotal := start + \\\"\\\\n\\\" + middle + \\\"\\\\n\\\" + end\\n\\n\\tioutil.WriteFile(\\\"index.html\\\",[]byte(total),0677)\\n\\n\\texec.Command(\\\"open\\\",\\\"index.html\\\").Run()\\n\\n}\",\n \"func TestHTML(t *testing.T) {\\n\\tm := MarkHub{}\\n\\terr := m.ParseString(\\\"# title 1\\\")\\n\\tif err != nil {\\n\\t\\tt.Errorf(\\\"TestHTML(): got -> %v, want: nil\\\", err)\\n\\t}\\n\\thtml := m.HTML()\\n\\tif len(html) == 0 {\\n\\t\\tt.Errorf(\\\"TestHTML(): got -> %v, want: length > 0\\\", len(html))\\n\\t}\\n}\",\n \"func HTML(s string) got.HTML {\\n\\treturn got.HTML(s)\\n}\",\n \"func execToHTML(_ int, p *gop.Context) {\\n\\targs := p.GetArgs(3)\\n\\tdoc.ToHTML(args[0].(io.Writer), args[1].(string), args[2].(map[string]string))\\n}\",\n \"func (llp *LogLineParsed) HTML(vp viewerProvider) string {\\n\\tseconds := llp.StampSeconds\\n\\thour := seconds / (60 * 60)\\n\\tseconds -= hour * 60 * 60\\n\\tminute := seconds / 60\\n\\tseconds -= minute * 60\\n\\n\\tcatStr := llp.Cat.FriendlyName()\\n\\tif llp.Msg == nil {\\n\\t\\treturn fmt.Sprintf(ChatLogFormatHTML,\\n\\t\\t\\tcatStr,\\n\\t\\t\\thour, minute, seconds,\\n\\t\\t\\tllp.Body)\\n\\t}\\n\\n\\tmsgContent := llp.Msg.Emotes.Replace(llp.Msg.Content)\\n\\n\\t// Multiple Badges\\n\\tbadgeHTML := \\\"\\\"\\n\\n\\t// Get Viewer Data\\n\\tv, err := vp.GetData(llp.Msg.UserID)\\n\\tif err != nil {\\n\\t\\treturn fmt.Sprintf(ChatLogFormatMsgHTML,\\n\\t\\t\\tcatStr,\\n\\t\\t\\thour, minute, seconds,\\n\\t\\t\\tllp.Msg.UserID,\\n\\t\\t\\tbadgeHTML,\\n\\t\\t\\tllp.Msg.Nick,\\n\\t\\t\\tmsgContent)\\n\\t}\\n\\n\\t// View Lock\\n\\tif v.Follower != nil {\\n\\t\\tcatStr += \\\" follow\\\"\\n\\t}\\n\\n\\tchatColor := \\\"#DDD\\\"\\n\\tif v.Chatter != nil {\\n\\t\\tchatColor = v.Chatter.Color\\n\\n\\t\\tfor badgeID, ver := range v.Chatter.Badges {\\n\\t\\t\\tbadgeHTML += vp.Client().Badges.BadgeHTML(badgeID, ver)\\n\\t\\t}\\n\\n\\t\\treturn llp.Body\\n\\t}\\n\\t//\\n\\n\\treturn fmt.Sprintf(ChatLogFormatMsgExtraHTML,\\n\\t\\tcatStr,\\n\\t\\tchatColor,\\n\\t\\thour, minute, seconds,\\n\\t\\tllp.Msg.UserID,\\n\\t\\tbadgeHTML,\\n\\t\\tllp.Msg.Nick,\\n\\t\\tmsgContent)\\n}\",\n \"func _html(ns Nodes, outer bool) string {\\n\\tif len(ns) == 0 {\\n\\t\\treturn \\\"\\\"\\n\\t}\\n\\twr := w{}\\n\\tif outer {\\n\\t\\thtml.Render(&wr, ns[0].Node)\\n\\t} else {\\n\\t\\tfor _, v := range ns[0].Node.Child {\\n\\t\\t\\thtml.Render(&wr, v)\\n\\t\\t}\\n\\t}\\n\\treturn wr.s\\n}\",\n \"func (o *OutputHandler) createBeautifulHTML() error {\\n\\terr := o.importFile()\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\n\\to.markdownToHTML()\\n\\n\\terr = o.createFile()\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\n\\treturn nil\\n}\",\n \"func templateHTML(releases []models.HelmRelease, w io.Writer) error {\\n\\n\\tsum := internalSummery{\\n\\t\\tOutdatedReleases: make(map[string][]uiHelmRelease),\\n\\t\\tDeprecatedReleases: make(map[string][]uiHelmRelease),\\n\\t\\tGoodReleases: make(map[string][]uiHelmRelease),\\n\\t}\\n\\n\\tfor _, c := range releases {\\n\\t\\tuiC := uiHelmRelease{\\n\\t\\t\\tName: c.Name,\\n\\t\\t\\tNamespace: c.Namespace,\\n\\t\\t\\tDeprecated: c.Deprecated,\\n\\t\\t\\tInstalledVersion: c.InstalledVersion,\\n\\t\\t\\tLatestVersion: c.LatestVersion,\\n\\t\\t\\tOutdated: c.InstalledVersion != c.LatestVersion,\\n\\t\\t}\\n\\n\\t\\tif uiC.Deprecated {\\n\\t\\t\\tsum.DeprecatedReleases[uiC.Namespace] = append(sum.DeprecatedReleases[uiC.Namespace], uiC)\\n\\t\\t} else if uiC.Outdated {\\n\\t\\t\\tsum.OutdatedReleases[uiC.Namespace] = append(sum.OutdatedReleases[uiC.Namespace], uiC)\\n\\t\\t} else {\\n\\t\\t\\tsum.GoodReleases[uiC.Namespace] = append(sum.GoodReleases[uiC.Namespace], uiC)\\n\\t\\t}\\n\\t}\\n\\n\\tfor i, v := range sum.DeprecatedReleases {\\n\\t\\tsort.Sort(ByName(v))\\n\\t\\tsum.DeprecatedReleases[i] = v\\n\\t}\\n\\n\\tfor i, v := range sum.OutdatedReleases {\\n\\t\\tsort.Sort(ByName(v))\\n\\t\\tsum.OutdatedReleases[i] = v\\n\\t}\\n\\n\\tfor i, v := range sum.GoodReleases {\\n\\t\\tsort.Sort(ByName(v))\\n\\t\\tsum.GoodReleases[i] = v\\n\\t}\\n\\n\\tt := template.Must(template.New(\\\"index.html\\\").Funcs(getFunctions()).ParseFS(views, \\\"views/*\\\"))\\n\\terr := t.Execute(w, sum)\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\treturn nil\\n}\",\n \"func (r *Template) Html() pulumi.StringOutput {\\n\\treturn (pulumi.StringOutput)(r.s.State[\\\"html\\\"])\\n}\",\n \"func page(content string) string {\\n\\treturn \\\"\\\\n\\\" + content + \\\"\\\\n\\\"\\n}\",\n \"func (e *explorer) outputGoHTML(goSource, funcName string, lines [][2]int, step int, subStep string) error {\\n\\t// Get Chroma Go lexer.\\n\\tlexer := lexers.Get(\\\"go\\\")\\n\\tif lexer == nil {\\n\\t\\tlexer = lexers.Fallback\\n\\t}\\n\\t//lexer = chroma.Coalesce(lexer)\\n\\t// Get Chrome style.\\n\\tstyle := styles.Get(e.style)\\n\\tif style == nil {\\n\\t\\tstyle = styles.Fallback\\n\\t}\\n\\t// Get Chroma HTML formatter.\\n\\tformatter := html.New(\\n\\t\\thtml.TabWidth(3),\\n\\t\\thtml.WithLineNumbers(),\\n\\t\\thtml.WithClasses(),\\n\\t\\thtml.LineNumbersInTable(),\\n\\t\\t//html.HighlightLines(lines),\\n\\t)\\n\\t// Generate syntax highlighted Go code.\\n\\titerator, err := lexer.Tokenise(nil, goSource)\\n\\tif err != nil {\\n\\t\\treturn errors.WithStack(err)\\n\\t}\\n\\tgoCode := &bytes.Buffer{}\\n\\tif err := formatter.Format(goCode, style, iterator); err != nil {\\n\\t\\treturn errors.WithStack(err)\\n\\t}\\n\\t// Generate Go HTML page.\\n\\thtmlContent := &bytes.Buffer{}\\n\\tdata := map[string]interface{}{\\n\\t\\t\\\"FuncName\\\": funcName,\\n\\t\\t\\\"Style\\\": e.style,\\n\\t\\t\\\"GoCode\\\": template.HTML(goCode.String()),\\n\\t}\\n\\tif err := e.goTmpl.Execute(htmlContent, data); err != nil {\\n\\t\\treturn errors.WithStack(err)\\n\\t}\\n\\thtmlName := fmt.Sprintf(\\\"%s_step_%04d%s_go.html\\\", funcName, step, subStep)\\n\\thtmlPath := filepath.Join(e.outputDir, htmlName)\\n\\tdbg.Printf(\\\"creating file %q\\\", htmlPath)\\n\\tif err := ioutil.WriteFile(htmlPath, htmlContent.Bytes(), 0644); err != nil {\\n\\t\\treturn errors.WithStack(err)\\n\\t}\\n\\treturn nil\\n}\",\n \"func getStories(w http.ResponseWriter, r *http.Request) {\\n\\t// get all of the story id\\n\\tids := getNewsItems()\\n\\t// filter out anything that isn't a story\\n\\t// Not sure this is going to be a necessary step\\n\\tstories := filterStories(ids)\\n\\n\\tvar s []map[string]interface{}\\n\\n\\tfor i := 0; i < len(stories); i++ {\\n\\t\\ts = append(s, stories[i])\\n\\t\\t// fmt.Println(\\\"stories\\\", byt)\\n\\t}\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"application/x-www-form-urlencoded\\\")\\n\\tw.WriteHeader(http.StatusCreated)\\n\\t// json.NewEncoder(w).Encode(s)\\n\\tbyt, err := json.Marshal(s)\\n\\tif err != nil {\\n\\t\\tpanic(err)\\n\\t}\\n\\tw.Write(byt)\\n}\",\n \"func viewPage(response http.ResponseWriter, request *http.Request) {\\n\\ttitle := request.URL.Path[len(\\\"/\\\"):]\\n\\tpage, err := loadPage(title)\\n\\tif err != nil {\\n\\t\\thttp.Error(response, err.Error(), http.StatusInternalServerError)\\n\\t\\treturn\\n\\t}\\n\\tfmt.Fprintf(response, \\\"

%s

%s

\\\", page.Title, page.Body)\\n}\",\n \"func Html(url string) ([]byte, error) {\\n\\trsp, err := http.Get(url)\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"could not make request: %w\\\", err)\\n\\t}\\n\\tdefer rsp.Body.Close()\\n\\tbody, err := ioutil.ReadAll(rsp.Body)\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"could not read response body: %w\\\", err)\\n\\t}\\n\\treturn body, nil\\n}\",\n \"func (as *Action) HTML(u string, args ...interface{}) *httptest.Request {\\n\\treturn httptest.New(as.App).HTML(u, args...)\\n}\",\n \"func main() {\\n\\t// We place each set of stories in a new buffer\\n\\thnStories := newHnStories()\\n\\tredditStories := newRedditStories()\\n\\t// And we need a buffer to contain all stories\\n\\tvar stories []Story\\n\\n\\t// Now we check that each source actually did return some stories\\n\\tif hnStories != nil {\\n\\t\\t// If so, we'll append those to the list\\n\\t\\tstories = append(stories, hnStories...)\\n\\t}\\n\\tif redditStories != nil {\\n\\t\\tstories = append(stories, redditStories...)\\n\\t}\\n\\n\\t// Now let's write these stories to a file, stories.txt\\n\\t// First we open the file\\n\\tfile, err := os.Create(\\\"stories.txt\\\")\\n\\t// If there's a problem opening the file, abort\\n\\tif err != nil {\\n\\t\\tfmt.Println(err)\\n\\t\\tos.Exit(1)\\n\\t}\\n\\t// And we'll defer closing the file\\n\\tdefer file.Close()\\n\\t// Now we'll write the stories out to the file\\n\\tfor _, s := range stories {\\n\\t\\tfmt.Fprintf(file, \\\"%s: %s\\\\nby %s on %s\\\\n\\\\n\\\", s.title, s.url, s.author, s.source)\\n\\t}\\n\\n\\t// Finally, we'll print out all the stories we received\\n\\tfor _, s := range stories {\\n\\t\\tfmt.Printf(\\\"%s: %s\\\\nby %s on %s\\\\n\\\\n\\\", s.title, s.url, s.author, s.source)\\n\\t}\\n}\",\n \"func createHTMLNote(htmlFileName, mdFileName string) error {\\n\\tvar result error\\n\\tlog.Print(\\\"Generating HTML release note...\\\")\\n\\tcssFileName := \\\"/tmp/release_note_cssfile\\\"\\n\\tcssFile, err := os.Create(cssFileName)\\n\\tif err != nil {\\n\\t\\treturn fmt.Errorf(\\\"failed to create css file %s: %v\\\", cssFileName, err)\\n\\t}\\n\\n\\tcssFile.WriteString(\\\"\\\")\\n\\t// Here we manually close the css file instead of defer the close function,\\n\\t// because we need to use the css file for pandoc command below.\\n\\t// Writing to css file is a clear small logic so we don't separate it into\\n\\t// another function.\\n\\tif err = cssFile.Close(); err != nil {\\n\\t\\treturn fmt.Errorf(\\\"failed to close file %s, %v\\\", cssFileName, err)\\n\\t}\\n\\n\\thtmlStr, err := u.Shell(\\\"pandoc\\\", \\\"-H\\\", cssFileName, \\\"--from\\\", \\\"markdown_github\\\", \\\"--to\\\", \\\"html\\\", mdFileName)\\n\\tif err != nil {\\n\\t\\treturn fmt.Errorf(\\\"failed to generate html content: %v\\\", err)\\n\\t}\\n\\n\\thtmlFile, err := os.Create(htmlFileName)\\n\\tif err != nil {\\n\\t\\treturn fmt.Errorf(\\\"failed to create html file: %v\\\", err)\\n\\t}\\n\\tdefer func() {\\n\\t\\tif err = htmlFile.Close(); err != nil {\\n\\t\\t\\tresult = fmt.Errorf(\\\"failed to close file %s, %v\\\", htmlFileName, err)\\n\\t\\t}\\n\\t}()\\n\\n\\thtmlFile.WriteString(htmlStr)\\n\\treturn result\\n}\",\n \"func (e *explorer) outputLLVMHTML(f *ir.Func, lines [][2]int, step int) error {\\n\\t// Get Chroma LLVM IR lexer.\\n\\tlexer := lexers.Get(\\\"llvm\\\")\\n\\tif lexer == nil {\\n\\t\\tlexer = lexers.Fallback\\n\\t}\\n\\t//lexer = chroma.Coalesce(lexer)\\n\\t// Get Chrome style.\\n\\tstyle := styles.Get(e.style)\\n\\tif style == nil {\\n\\t\\tstyle = styles.Fallback\\n\\t}\\n\\t// Get Chroma HTML formatter.\\n\\tformatter := html.New(\\n\\t\\thtml.TabWidth(3),\\n\\t\\thtml.WithLineNumbers(),\\n\\t\\thtml.WithClasses(),\\n\\t\\thtml.LineNumbersInTable(),\\n\\t\\thtml.HighlightLines(lines),\\n\\t)\\n\\t// Generate syntax highlighted LLVM IR assembly.\\n\\tllvmSource := f.LLString()\\n\\titerator, err := lexer.Tokenise(nil, llvmSource)\\n\\tif err != nil {\\n\\t\\treturn errors.WithStack(err)\\n\\t}\\n\\tllvmCode := &bytes.Buffer{}\\n\\tif err := formatter.Format(llvmCode, style, iterator); err != nil {\\n\\t\\treturn errors.WithStack(err)\\n\\t}\\n\\t// Generate LLVM IR HTML page.\\n\\thtmlContent := &bytes.Buffer{}\\n\\tfuncName := f.Name()\\n\\tdata := map[string]interface{}{\\n\\t\\t\\\"FuncName\\\": funcName,\\n\\t\\t\\\"Style\\\": e.style,\\n\\t\\t\\\"LLVMCode\\\": template.HTML(llvmCode.String()),\\n\\t}\\n\\tif err := e.llvmTmpl.Execute(htmlContent, data); err != nil {\\n\\t\\treturn errors.WithStack(err)\\n\\t}\\n\\thtmlName := fmt.Sprintf(\\\"%s_step_%04d_llvm.html\\\", funcName, step)\\n\\thtmlPath := filepath.Join(e.outputDir, htmlName)\\n\\tdbg.Printf(\\\"creating file %q\\\", htmlPath)\\n\\tif err := ioutil.WriteFile(htmlPath, htmlContent.Bytes(), 0644); err != nil {\\n\\t\\treturn errors.WithStack(err)\\n\\t}\\n\\treturn nil\\n}\",\n \"func Track_() HTML {\\n return Track(nil)\\n}\",\n \"func HTML(c *slurp.C, data interface{}) slurp.Stage {\\n\\treturn func(in <-chan slurp.File, out chan<- slurp.File) {\\n\\n\\t\\ttemplates := html.New(\\\"\\\")\\n\\n\\t\\tvar wg sync.WaitGroup\\n\\t\\tdefer wg.Wait() //Wait before all templates are executed.\\n\\n\\t\\tfor f := range in {\\n\\n\\t\\t\\tbuf := new(bytes.Buffer)\\n\\t\\t\\t_, err := buf.ReadFrom(f.Reader)\\n\\t\\t\\tf.Close()\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tc.Println(err)\\n\\t\\t\\t\\tbreak\\n\\t\\t\\t}\\n\\n\\t\\t\\ttemplate, err := templates.New(f.Stat.Name()).Parse(buf.String())\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tc.Println(err)\\n\\t\\t\\t\\tbreak\\n\\t\\t\\t}\\n\\n\\t\\t\\tf.Reader = NewTemplateReadCloser(c, wg, template, data)\\n\\n\\t\\t\\tout <- f\\n\\t\\t}\\n\\t}\\n}\",\n \"func Start(story map[string]storyBuilder.Arc) {\\n\\tconst tpl = `\\n\\t\\t\\n\\t\\t\\n\\t\\t\\t\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t{{.Title}}\\n\\t\\t\\t\\n\\t\\t\\t\\n\\t\\t\\t

{{.Title}}

\\n\\t\\t\\t{{range .Paragraphs}}\\n\\t\\t\\t\\t

{{.}}

\\n\\t\\t\\t{{end}}\\n\\t\\t\\t\\t{{range .Options}}\\n\\t\\t\\t\\t\\t

\\n\\t\\t\\t\\t\\t\\t{{.Text}}\\n\\t\\t\\t\\t\\t

\\n\\t\\t\\t\\t{{end}}\\n\\t\\t\\t\\n\\t\\t`\\n\\n\\ttemplate, err := template.New(\\\"story\\\").Parse(tpl)\\n\\n\\tif err != nil {\\n\\t\\tpanic(err)\\n\\t}\\n\\n\\thandler := func(w http.ResponseWriter, req *http.Request) {\\n\\t\\turl := strings.Replace(req.URL.Path, \\\"/\\\", \\\"\\\", 1)\\n\\t\\tcurrentStory, found := story[url]\\n\\t\\tif found {\\n\\t\\t\\ttemplate.Execute(w, currentStory)\\n\\t\\t} else {\\n\\t\\t\\ttemplate.Execute(w, story[\\\"intro\\\"])\\n\\t\\t}\\n\\n\\t}\\n\\n\\thttp.HandleFunc(\\\"/\\\", handler)\\n\\tfmt.Println(\\\"Server is listening on port 8080\\\")\\n\\tlog.Fatal(http.ListenAndServe(\\\":8080\\\", nil))\\n}\",\n \"func generateURLIssue(h string) string {\\n\\tconst (\\n\\t\\ttitle = \\\"Move your ass\\\"\\n\\t\\turlFormat = \\\"https://github.com/sjeandeaux/nexus-cli/issues/new?title=%s&body=%s\\\"\\n\\t\\tbodyFormat = \\\"Could you add the hash %q lazy man?\\\\n%s\\\"\\n\\t)\\n\\tescapedTitle := url.QueryEscape(title)\\n\\tbody := fmt.Sprintf(bodyFormat, h, information.Print())\\n\\tescapedBody := url.QueryEscape(body)\\n\\turlIssue := fmt.Sprintf(urlFormat, escapedTitle, escapedBody)\\n\\treturn urlIssue\\n}\",\n \"func viewHandler(w http.ResponseWriter, r *http.Request, title string) {\\n\\t// Special case for the root page.\\n\\tif title == rootTitle {\\n\\t\\trootHandler(w, r, title)\\n\\t\\treturn\\n\\t}\\n\\n\\tp, err := loadPage(title)\\n\\tif err != nil {\\n\\t\\thttp.Redirect(w, r, \\\"/edit/\\\"+title, http.StatusFound)\\n\\t\\treturn\\n\\t}\\n\\n\\tp.Ingredients = template.HTML(blackfriday.MarkdownCommon([]byte(p.Ingredients)))\\n\\tp.Instructions = template.HTML(blackfriday.MarkdownCommon([]byte(p.Instructions)))\\n\\tp.Ingredients = template.HTML(convertWikiMarkup([]byte(p.Ingredients)))\\n\\tp.Instructions = template.HTML(convertWikiMarkup([]byte(p.Instructions)))\\n\\trenderTemplate(w, \\\"view\\\", p)\\n}\",\n \"func generateHTML(writer http.ResponseWriter, data interface{}, filenames ...string) {\\n\\n\\tvar t *template.Template\\n\\tvar files []string\\n\\tfor _, file := range filenames {\\n\\t\\tfiles = append(files, fmt.Sprintf(\\\"web/ui/template/HTMLLayouts/%s.html\\\", file))\\n\\t}\\n\\tt = template.Must(template.ParseFiles(files...))\\n\\tt.ExecuteTemplate(writer, \\\"layout\\\", data)\\n}\",\n \"func (thread *Thread) HTML() string {\\n\\tif thread.html != \\\"\\\" {\\n\\t\\treturn thread.html\\n\\t}\\n\\n\\tthread.html = markdown.Render(thread.Text)\\n\\treturn thread.html\\n}\",\n \"func (c *StoryController) Get() mvc.Result {\\n\\tstories, err := c.StoryUsecase.GetAll()\\n\\tif err != nil {\\n\\t\\treturn mvc.View{\\n\\t\\t\\tName: \\\"index.html\\\",\\n\\t\\t\\tData: iris.Map{\\\"Title\\\": \\\"Stories\\\"},\\n\\t\\t}\\n\\t}\\n\\n\\treturn mvc.View{\\n\\t\\tName: \\\"index.html\\\",\\n\\t\\tData: iris.Map{\\\"Title\\\": \\\"Stories\\\", \\\"Stories\\\": stories},\\n\\t}\\n}\",\n \"func main() {\\n\\tstory := flag.String(\\\"story\\\", \\\"\\\", \\\"select the story to play.\\\")\\n\\tflag.Parse()\\n\\n\\troot := flag.Arg(0)\\n\\tif !stories.Select(*story) || root == \\\"\\\" {\\n\\t\\tfmt.Println(\\\"Expected a story and a directory of files to serve.\\\")\\n\\t\\tfmt.Println(\\\"ex. webapp -story sushi .\\\")\\n\\t\\tfmt.Println(\\\"The following example stories are available:\\\")\\n\\t\\tfor _, nick := range stories.List() {\\n\\t\\t\\tfmt.Println(\\\" \\\", nick)\\n\\t\\t}\\n\\t} else {\\n\\t\\tfmt.Println(\\\"listening on http://localhost:8080\\\")\\n\\t\\thandler := support.NewServeMux()\\n\\t\\thandler.HandleFunc(\\\"/game/\\\", net.HandleResource(ess.GameResource(mem.NewSessions())))\\n\\t\\thandler.HandleFilePatterns(root,\\n\\t\\t\\tsupport.Dir(\\\"/app/\\\"),\\n\\t\\t\\tsupport.Dir(\\\"/bower_components/\\\"),\\n\\t\\t\\tsupport.Dir(\\\"/media/\\\"))\\n\\t\\tgo support.OpenBrowser(\\\"http://localhost:8080/app/\\\")\\n\\t\\tlog.Fatal(http.ListenAndServe(\\\":8080\\\", handler))\\n\\t}\\n}\",\n \"func publishShareInstructions(url string) {\\n\\tlog.Println(\\\"\\\\n\\\" + GrayStyle.Render(\\\" Share your GIF with Markdown:\\\"))\\n\\tlog.Println(CommandStyle.Render(\\\" ![Made with VHS]\\\") + URLStyle.Render(\\\"(\\\"+url+\\\")\\\"))\\n\\tlog.Println(GrayStyle.Render(\\\"\\\\n Or HTML (with badge):\\\"))\\n\\tlog.Println(CommandStyle.Render(\\\" \\\")\\\"))\\n\\tlog.Println(CommandStyle.Render(\\\" \\\"))\\n\\tlog.Println(CommandStyle.Render(\\\" \\\"))\\n\\tlog.Println(CommandStyle.Render(\\\" \\\"))\\n\\tlog.Println(GrayStyle.Render(\\\"\\\\n Or link to it:\\\"))\\n}\",\n \"func CreateArticelePage(w http.ResponseWriter, r *http.Request) {\\n\\n\\tvars := mux.Vars(r)\\n\\n\\tmtitle := vars[\\\"mtitle\\\"]\\n\\n\\tmongoDBDialInfo := &mgo.DialInfo{\\n\\n\\t\\tAddrs: []string{\\\"mymongo-controller\\\"},\\n\\t\\tTimeout: 60 * time.Second,\\n\\t\\tDatabase: \\\"admin\\\",\\n\\t\\tUsername: mongodbuser,\\n\\t\\tPassword: mongodbpass,\\n\\t\\tMechanism: \\\"SCRAM-SHA-1\\\",\\n\\t}\\n\\n\\tdbsession, err := mgo.DialWithInfo(mongoDBDialInfo)\\n\\n\\tif err != nil {\\n\\t\\tpanic(err)\\n\\t}\\n\\tdefer dbsession.Close()\\n\\n\\tif mtitle == \\\"\\\" {\\n\\n\\t\\tlog.Println(\\\"no mtitle\\\")\\n\\n\\t\\tarticles := dbhandler.GetAllForStatic(*dbsession, \\\"kaukotyo.eu\\\")\\n\\t\\tjson.NewEncoder(w).Encode(articles)\\n\\n\\t} else {\\n\\n\\t\\tarticle := dbhandler.GetOneArticle(*dbsession, mtitle)\\n\\n\\t\\tjson.NewEncoder(w).Encode(article)\\n\\n\\t}\\n}\",\n \"func HTMLString(data interface{}, viewName string) string {\\n\\tvar html bytes.Buffer\\n\\ttemplateName := viewName\\n\\tt, err := Jet.GetTemplate(templateName)\\n\\tif err != nil {\\n\\t\\tlog.Println(\\\"Failed to get tempalte \\\")\\n\\t}\\n\\tvars := make(jet.VarMap)\\n\\tif err = t.Execute(&html, vars, data); err != nil {\\n\\t\\tlog.Println(\\\"Failed to execute view tepmlate \\\")\\n\\t}\\n\\treturn html.String()\\n}\",\n \"func generateHTML(domain, pkg, source string) ([]byte, error) {\\n\\tvar (\\n\\t\\tdir, file, redirect string\\n\\t\\tb bytes.Buffer\\n\\t)\\n\\n\\tif pkg != \\\"\\\" {\\n\\t\\tredirect = \\\"https://pkg.go.dev/\\\" + domain + \\\"/\\\" + pkg\\n\\n\\t\\t// Add the URL scheme if not already present\\n\\t\\tif !strings.HasPrefix(source, \\\"http\\\") {\\n\\t\\t\\tsource = \\\"https://\\\" + source\\n\\t\\t}\\n\\n\\t\\t// Deduce go-source paths for the hosting\\n\\t\\tswitch path := urlMustParse(source); path.Host {\\n\\t\\tcase \\\"github.com\\\":\\n\\t\\t\\tdir = source + \\\"/tree/master/{dir}\\\"\\n\\t\\t\\tfile = source + \\\"/blob/master/{dir}/{file}#L{line}\\\"\\n\\t\\tcase \\\"gitlab.com\\\":\\n\\t\\t\\tdir = source + \\\"/-/tree/master/{dir}\\\"\\n\\t\\t\\tfile = source + \\\"/-/blob/master/{dir}/{file}#L{line}\\\"\\n\\t\\t}\\n\\t} else {\\n\\t\\tredirect = \\\"https://\\\" + domain\\n\\t}\\n\\n\\tt := template.Must(template.New(\\\"package\\\").Parse(templString))\\n\\terr := t.Execute(&b, &templValue{redirect, domain, pkg, source, dir, file})\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\treturn b.Bytes(), nil\\n}\",\n \"func htmlPageHandler(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprintf(w, `\\n\\n\\t\\n\\t\\n`)\\n\\n}\",\n \"func main() {\\n\\twebview.Open(\\\"GoNotes\\\", \\\"file:///home/ubuntu/go/src/github.com/mattackard/project-0/cmd/GoNotesClient/client.html\\\", 600, 700, true)\\n}\",\n \"func (bt *Hackerbeat) fetchStory(stories chan<- story, storyID uint) {\\n\\tstory := story{\\n\\t\\tID: storyID,\\n\\t}\\n\\n\\t// Generate getStoryURL from getItemURL and storyID\\n\\tgetStoryURL := strings.Replace(getItemURL, storyIDToken, strconv.FormatUint(uint64(storyID), 10), -1)\\n\\n\\t// Get story from HackerNews API\\n\\tresp, err := bt.httpClient.Get(getStoryURL)\\n\\tif err != nil {\\n\\t\\tbt.logger.Errorw(\\n\\t\\t\\t\\\"Failed to get story\\\",\\n\\t\\t\\t\\\"error\\\", err,\\n\\t\\t)\\n\\t\\treturn\\n\\t}\\n\\n\\t// Read all bytes from response body\\n\\tstoryInfos, err := ioutil.ReadAll(resp.Body)\\n\\tif err != nil {\\n\\t\\tbt.logger.Errorw(\\n\\t\\t\\t\\\"Failed to parse story\\\",\\n\\t\\t\\t\\\"error\\\", err,\\n\\t\\t)\\n\\t\\treturn\\n\\t}\\n\\n\\t// Unmarshal response body into our story data structure\\n\\terr = json.Unmarshal(storyInfos, &story)\\n\\tif err != nil {\\n\\t\\tbt.logger.Errorw(\\n\\t\\t\\t\\\"Failed to unmarshal story\\\",\\n\\t\\t\\t\\\"error\\\", err,\\n\\t\\t)\\n\\t\\treturn\\n\\t}\\n\\n\\t// Send story back to the main thread\\n\\tstories <- story\\n}\",\n \"func RenderHTMLWithMetadata(actual string, settings ...configuration.Setting) (string, types.Metadata, error) {\\n\\tallSettings := append([]configuration.Setting{configuration.WithFilename(\\\"test.adoc\\\"), configuration.WithBackEnd(\\\"html5\\\")}, settings...)\\n\\tconfig := configuration.NewConfiguration(allSettings...)\\n\\tcontentReader := strings.NewReader(actual)\\n\\tresultWriter := bytes.NewBuffer(nil)\\n\\tmetadata, err := libasciidoc.Convert(contentReader, resultWriter, config)\\n\\tif err != nil {\\n\\t\\tlog.Error(err)\\n\\t\\treturn \\\"\\\", types.Metadata{}, err\\n\\t}\\n\\tif log.IsLevelEnabled(log.DebugLevel) {\\n\\t\\tlog.Debug(resultWriter.String())\\n\\t}\\n\\treturn resultWriter.String(), metadata, nil\\n}\",\n \"func getHTMLContent(articleContent *goquery.Selection) string {\\n\\thtml, err := articleContent.Html()\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\"\\n\\t}\\n\\n\\thtml = ghtml.UnescapeString(html)\\n\\thtml = rxComments.ReplaceAllString(html, \\\"\\\")\\n\\thtml = rxKillBreaks.ReplaceAllString(html, \\\"
\\\")\\n\\thtml = rxSpaces.ReplaceAllString(html, \\\" \\\")\\n\\treturn html\\n}\",\n \"func (r renderer) BlockHtml(out *bytes.Buffer, text []byte) {}\",\n \"func HTMLFromResults(script *Script, serverConfigs map[string]ServerConfig, scriptResults map[string]*ScriptResults) string {\\n\\t// sorted ID list\\n\\tvar sortedIDs []string\\n\\tfor id := range serverConfigs {\\n\\t\\tsortedIDs = append(sortedIDs, id)\\n\\t}\\n\\tsort.Strings(sortedIDs)\\n\\n\\t// tab buttons\\n\\tvar tabs string\\n\\tfor _, id := range sortedIDs {\\n\\t\\ttabs += fmt.Sprintf(tabText, id, serverConfigs[id].DisplayName)\\n\\t}\\n\\n\\t// css\\n\\tvar css string\\n\\thue := 150\\n\\tfor id := range script.Clients {\\n\\t\\t// + 5 for ' <- ' or similar\\n\\t\\tcss += fmt.Sprintf(cssPreTemplate, id, len(id)+5, hue)\\n\\t\\thue += 40\\n\\t}\\n\\n\\t// construct JSON blob used by the page\\n\\tblob := htmlJSONBlob{\\n\\t\\tDefaultServer: sortedIDs[0],\\n\\t\\tServerNames: make(map[string]string),\\n\\t\\tServerLogs: make(map[string]serverBlob),\\n\\t}\\n\\tfor id, info := range serverConfigs {\\n\\t\\tblob.ServerNames[id] = info.DisplayName\\n\\t}\\n\\tfor id, sr := range scriptResults {\\n\\t\\tvar sBlob serverBlob\\n\\n\\t\\tvar actionIndex int\\n\\t\\tfor _, srl := range sr.Lines {\\n\\t\\t\\tswitch srl.Type {\\n\\t\\t\\tcase ResultIRCMessage:\\n\\t\\t\\t\\t// raw line\\n\\t\\t\\t\\tlineRaw := lineBlob{\\n\\t\\t\\t\\t\\tClient: srl.Client,\\n\\t\\t\\t\\t\\tSentBy: \\\"s\\\",\\n\\t\\t\\t\\t\\tLine: strings.TrimSuffix(srl.RawLine, \\\"\\\\r\\\\n\\\"),\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tsBlob.Raw = append(sBlob.Raw, lineRaw)\\n\\n\\t\\t\\t\\t// sanitised line\\n\\t\\t\\t\\tsanitisedLine := srl.RawLine\\n\\t\\t\\t\\tfor orig, new := range serverConfigs[id].SanitisedReplacements {\\n\\t\\t\\t\\t\\tsanitisedLine = strings.Replace(sanitisedLine, orig, new, -1)\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tlineSanitised := lineBlob{\\n\\t\\t\\t\\t\\tClient: srl.Client,\\n\\t\\t\\t\\t\\tSentBy: \\\"s\\\",\\n\\t\\t\\t\\t\\tLine: strings.TrimSuffix(sanitisedLine, \\\"\\\\r\\\\n\\\"),\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tsBlob.Sanitised = append(sBlob.Sanitised, lineSanitised)\\n\\t\\t\\tcase ResultActionSync:\\n\\t\\t\\t\\tthisAction := script.Actions[actionIndex]\\n\\t\\t\\t\\tif thisAction.LineToSend != \\\"\\\" {\\n\\t\\t\\t\\t\\t// sent line always stays the same\\n\\t\\t\\t\\t\\tline := lineBlob{\\n\\t\\t\\t\\t\\t\\tClient: thisAction.Client,\\n\\t\\t\\t\\t\\t\\tSentBy: \\\"c\\\",\\n\\t\\t\\t\\t\\t\\tLine: strings.TrimSuffix(thisAction.LineToSend, \\\"\\\\r\\\\n\\\"),\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tsBlob.Raw = append(sBlob.Raw, line)\\n\\t\\t\\t\\t\\tsBlob.Sanitised = append(sBlob.Sanitised, line)\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tactionIndex++\\n\\t\\t\\tcase ResultDisconnected:\\n\\t\\t\\t\\tline := lineBlob{\\n\\t\\t\\t\\t\\tClient: srl.Client,\\n\\t\\t\\t\\t\\tError: fmt.Sprintf(\\\"%s was disconnected unexpectedly\\\", srl.Client),\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tsBlob.Raw = append(sBlob.Raw, line)\\n\\t\\t\\t\\tsBlob.Sanitised = append(sBlob.Sanitised, line)\\n\\t\\t\\tcase ResultDisconnectedExpected:\\n\\t\\t\\t\\tline := lineBlob{\\n\\t\\t\\t\\t\\tClient: srl.Client,\\n\\t\\t\\t\\t\\tError: fmt.Sprintf(\\\"%s was disconnected\\\", srl.Client),\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tsBlob.Raw = append(sBlob.Raw, line)\\n\\t\\t\\t\\tsBlob.Sanitised = append(sBlob.Sanitised, line)\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\tblob.ServerLogs[id] = sBlob\\n\\t}\\n\\n\\t// marshall json blob\\n\\tblobBytes, err := json.Marshal(blob)\\n\\tblobString := \\\"{'error': 1}\\\"\\n\\tif err == nil {\\n\\t\\tblobString = string(blobBytes)\\n\\t}\\n\\n\\t// assemble template\\n\\treturn fmt.Sprintf(htmlTemplate, script.Name, script.ShortDescription, tabs, blobString, css)\\n}\",\n \"func (VS *Server) manuals(c *gin.Context) {\\n\\trender(c, gin.H{}, \\\"presentation-manuals.html\\\")\\n}\",\n \"func (this *Asset) buildHTML() template.HTML {\\n\\tvar tag_fn func(string) template.HTML\\n\\tswitch this.assetType {\\n\\tcase ASSET_JAVASCRIPT:\\n\\t\\ttag_fn = js_tag\\n\\tcase ASSET_STYLESHEET:\\n\\t\\ttag_fn = css_tag\\n\\tdefault:\\n\\t\\tError(\\\"Unknown asset type\\\")\\n\\t\\treturn \\\"\\\"\\n\\t}\\n\\tvar result template.HTML\\n\\tfor _, assetFile := range this.result {\\n\\t\\tresult += tag_fn(\\\"/\\\" + assetFile.Path)\\n\\t}\\n\\treturn result\\n}\",\n \"func (service *StoriesService) getStories(codes []int, limit int64) ([]*handler.Story, error) {\\n\\n\\t// concurrency is cool, but needs to be limited\\n\\tsemaphore := make(chan struct{}, 10)\\n\\n\\t// how we know when all our goroutines are done\\n\\twg := sync.WaitGroup{}\\n\\n\\t// somewhere to store all the stories when we're done\\n\\tstories := make([]*handler.Story, 0)\\n\\n\\t// go over all the stories\\n\\tfor _, code := range codes {\\n\\n\\t\\t// stop when we have 30 stories\\n\\t\\tif int64(len(stories)) >= limit {\\n\\t\\t\\tbreak\\n\\t\\t}\\n\\n\\t\\t// in a goroutine with the story key\\n\\t\\tgo func(code int) {\\n\\n\\t\\t\\t// add one to the wait group\\n\\t\\t\\twg.Add(1)\\n\\n\\t\\t\\t// add one to the semaphore\\n\\t\\t\\tsemaphore <- struct{}{}\\n\\n\\t\\t\\t// make sure this gets fired\\n\\t\\t\\tdefer func() {\\n\\n\\t\\t\\t\\t// remove one from the wait group\\n\\t\\t\\t\\twg.Done()\\n\\n\\t\\t\\t\\t// remove one from the semaphore\\n\\t\\t\\t\\t<-semaphore\\n\\t\\t\\t}()\\n\\n\\t\\t\\tp, err := service.hn.GetPost(code)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tlog.WithError(err).Error(\\\"error get stories\\\")\\n\\t\\t\\t\\treturn\\n\\t\\t\\t}\\n\\n\\t\\t\\t// parse the url\\n\\t\\t\\tu, err := url.Parse(p.Url)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tlog.WithError(err).Error(\\\"error get stories\\\")\\n\\t\\t\\t\\treturn\\n\\t\\t\\t}\\n\\n\\t\\t\\t// get the hostname from the url\\n\\t\\t\\th := u.Hostname()\\n\\n\\t\\t\\t// check if it's from github or gitlab before adding to stories\\n\\t\\t\\tif strings.Contains(h, \\\"github\\\") || strings.Contains(h, \\\"gitlab\\\") {\\n\\t\\t\\t\\tlog.Debugf(\\\"found url (%s)\\\", p.Url)\\n\\n\\t\\t\\t\\ts := &handler.Story{\\n\\t\\t\\t\\t\\tScore: p.Score,\\n\\t\\t\\t\\t\\tTitle: p.Title,\\n\\t\\t\\t\\t\\tUrl: p.Url,\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\tif strings.Contains(h, \\\"github\\\") {\\n\\t\\t\\t\\t\\tvar err error\\n\\t\\t\\t\\t\\ts.Langauges, err = service.gh.GetDataBy(p.Url)\\n\\t\\t\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t\\t\\tlog.WithError(err).Error(\\\"error get stories\\\")\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\ts.DomainName = h\\n\\t\\t\\t\\tstories = append(stories, s)\\n\\t\\t\\t}\\n\\n\\t\\t}(code)\\n\\t}\\n\\n\\t// wait for all the goroutines\\n\\twg.Wait()\\n\\n\\treturn stories, nil\\n}\",\n \"func Html(resp http.ResponseWriter, content string, code int) error {\\n\\tresp.Header().Add(\\\"Content-Type\\\", \\\"text/html\\\")\\n\\tresp.WriteHeader(code)\\n\\t_, err := resp.Write([]byte(content))\\n\\treturn maskAny(err)\\n}\",\n \"func (dt *Slick) HTMLTemplate() string {\\n\\treturn htmlTemplate\\n}\",\n \"func (p *TestPager) GeneratePagerHtml() (string, error) {\\n p.FixData()\\n\\n var buffer bytes.Buffer\\n left := p.Total\\n i := 1\\n for left > 0 {\\n // generate spliter before\\n if i > 1 {\\n buffer.WriteString(d_spliter)\\n }\\n\\n // main page nubmer\\n if p.PageItems*(i-1) < p.Current && p.Current <= p.PageItems*i {\\n buffer.WriteString(d_curr1)\\n buffer.WriteString(strconv.Itoa(i))\\n buffer.WriteString(d_curr2)\\n } else {\\n buffer.WriteString(d_pagenumber1)\\n buffer.WriteString(strconv.Itoa(i))\\n buffer.WriteString(d_pagenumber2)\\n }\\n // prepare next loop\\n i += 1\\n left -= p.PageItems\\n }\\n\\n return buffer.String(), nil\\n}\",\n \"func render(src string, dst string) {\\n\\tdefer wg.Done()\\n\\tmd, err := ioutil.ReadFile(src)\\n\\tif err != nil {\\n\\t\\tprintErr(err)\\n\\t\\treturn\\n\\t}\\n\\thtml := renderHtml(md)\\n\\tif stylefile != \\\"\\\" {\\n\\t\\thtml = addStyle(html, stylecont)\\n\\t} else {\\n\\t\\thtml = addStyle(html, CSS)\\n\\t}\\n\\n\\terr = ioutil.WriteFile(dst, []byte(html), 0644)\\n\\tif err != nil {\\n\\t\\tprintErr(err)\\n\\t}\\n}\",\n \"func TestToHTML(timestamp string, results [][]string) string {\\n\\tvar ti testResults\\n\\n\\t// for each line in the test results\\n\\tfor i := 0; i < len(results); i++ {\\n\\t\\t// transform line to HTML\\n\\t\\tfor _, v := range results[i] {\\n\\t\\t\\tparseTestLine(v, &ti)\\n\\t\\t}\\n\\t}\\n\\n\\t// return the body as a string\\n\\treturn statHeader(ti.pass, ti.fail, timestamp) + strings.Join(ti.html, \\\"\\\")\\n}\",\n \"func (c *Client) ReportStory(ctx context.Context, request *ReportStoryRequest) error {\\n\\tvar ok Ok\\n\\n\\tif err := c.rpc.Invoke(ctx, request, &ok); err != nil {\\n\\t\\treturn err\\n\\t}\\n\\treturn nil\\n}\",\n \"func writeHTML(domain, pkg, source, filename string) error {\\n\\tdata, err := generateHTML(domain, pkg, source)\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\n\\terr = os.MkdirAll(filepath.Dir(filename), 0755)\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\n\\treturn ioutil.WriteFile(filename, data, 0666)\\n}\",\n \"func Article_(children ...HTML) HTML {\\n return Article(nil, children...)\\n}\",\n \"func outHTML(config *MainConfig, fileFunc FileResultFunc) {\\n\\n\\tindexPath := filepath.Join(config.Outpath, FILE_NAME_HTML_INDEX)\\n\\terr := SFFileManager.WirteFilepath(indexPath, []byte(assets.HTML_INDEX))\\n\\n\\tif nil != err {\\n\\t\\tfileFunc(indexPath, ResultFileOutFail, err)\\n\\t} else {\\n\\t\\tfileFunc(indexPath, ResultFileSuccess, nil)\\n\\t}\\n\\n\\tsrcPath := filepath.Join(config.Outpath, FILE_NAME_HTML_SRC)\\n\\terr = SFFileManager.WirteFilepath(srcPath, []byte(assets.HTML_SRC))\\n\\n\\tif nil != err {\\n\\t\\tfileFunc(srcPath, ResultFileOutFail, err)\\n\\t} else {\\n\\t\\tfileFunc(srcPath, ResultFileSuccess, nil)\\n\\t}\\n\\n}\",\n \"func (account *Account) Stories() *StoryMedia {\\r\\n\\tmedia := &StoryMedia{}\\r\\n\\tmedia.uid = account.ID\\r\\n\\tmedia.inst = account.inst\\r\\n\\tmedia.endpoint = urlUserStories\\r\\n\\treturn media\\r\\n}\",\n \"func (self templateEngine) genBoard(prefix, frontend, newsgroup, outdir string, db Database) {\\n // get the board model\\n board := self.obtainBoard(prefix, frontend, newsgroup, db)\\n // update the entire board model\\n board = board.UpdateAll(db)\\n // save the model\\n self.groups[newsgroup] = board\\n updateLinkCache()\\n \\n pages := len(board)\\n for page := 0 ; page < pages ; page ++ {\\n outfile := filepath.Join(outdir, fmt.Sprintf(\\\"%s-%d.html\\\", newsgroup, page))\\n wr, err := OpenFileWriter(outfile)\\n if err == nil {\\n board[page].RenderTo(wr)\\n wr.Close()\\n log.Println(\\\"wrote file\\\", outfile)\\n } else {\\n log.Println(\\\"error generating board page\\\", page, \\\"for\\\", newsgroup, err)\\n }\\n }\\n}\",\n \"func (is *infosec) html(page *Page, els element) {\\n\\tis.Map.html(page, nil)\\n\\tels.setMeta(\\\"isInfosec\\\", true)\\n\\n\\t// not in an infobox{}\\n\\t// FIXME: do not produce this warning if infosec{} is in a variable\\n\\tif is.parentBlock().blockType() != \\\"infobox\\\" {\\n\\t\\tis.warn(is.openPosition(), \\\"infosec{} outside of infobox{} does nothing\\\")\\n\\t\\treturn\\n\\t}\\n\\n\\t// inject the title\\n\\tif is.blockName() != \\\"\\\" {\\n\\t\\tis.mapList = append([]*mapListEntry{{\\n\\t\\t\\tkey: \\\"_infosec_title_\\\",\\n\\t\\t\\tmetas: map[string]bool{\\\"isTitle\\\": true},\\n\\t\\t\\tvalue: page.Fmt(is.blockName(), is.openPosition()),\\n\\t\\t}}, is.mapList...)\\n\\t}\\n\\n\\tinfoTableAddRows(is, els, page, is.mapList)\\n}\",\n \"func toHTML(s string) template.HTML {\\n\\treturn template.HTML(s)\\n}\",\n \"func HTML(opts ...ServerOption) {\\n\\tsrv, err := initServer(opts...)\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n\\n\\thttp.HandleFunc(\\\"/\\\", renderTemplate(srv))\\n\\n\\tlog.Println(\\\"Listening on :3000...\\\")\\n\\terr = http.ListenAndServe(\\\":3000\\\", nil)\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n}\",\n \"func (h *Home) SetHtmlFromPosts(html []byte, summ []byte, posts Posts) {\\n var summaries []byte\\n\\n // Sort the Posts\\n sort.Sort(posts)\\n\\n // Loop through Post collection\\n for _, post := range posts {\\n html := summ\\n\\n // Replace summary template variables\\n html = bytes.Replace(html, []byte(\\\"{{ path }}\\\"), []byte(post.path), -1)\\n html = bytes.Replace(html, []byte(\\\"{{ name }}\\\"), []byte(post.name), -1)\\n\\n summaries = append(summaries, html...)\\n }\\n\\n // Replace base template variables\\n html = bytes.Replace(html, []byte(\\\"{{ posts }}\\\"), summaries, -1)\\n\\n h.html = html\\n}\",\n \"func (g *Generator) GenerateHTML(data *scraper.ScrapedData) error {\\n\\treturn g.template.ExecuteTemplate(g.writer, \\\"profile\\\", data)\\n}\",\n \"func RenderHTMLFromFile(filename string, settings ...configuration.Setting) (string, types.Metadata, error) {\\n\\tinfo, err := os.Stat(filename)\\n\\tif err != nil {\\n\\t\\tlog.Error(err)\\n\\t\\treturn \\\"\\\", types.Metadata{}, err\\n\\t}\\n\\n\\tallSettings := append([]configuration.Setting{\\n\\t\\tconfiguration.WithLastUpdated(info.ModTime()),\\n\\t\\tconfiguration.WithFilename(filename),\\n\\t\\tconfiguration.WithBackEnd(\\\"html5\\\")},\\n\\t\\tsettings...)\\n\\tconfig := configuration.NewConfiguration(allSettings...)\\n\\tf, err := os.Open(filename)\\n\\tif err != nil {\\n\\t\\tlog.Error(err)\\n\\t\\treturn \\\"\\\", types.Metadata{}, err\\n\\t}\\n\\tdefer func() { f.Close() }()\\n\\tresultWriter := bytes.NewBuffer(nil)\\n\\tmetadata, err := libasciidoc.Convert(f, resultWriter, config)\\n\\tif err != nil {\\n\\t\\tlog.Error(err)\\n\\t\\treturn \\\"\\\", types.Metadata{}, err\\n\\t}\\n\\tif log.IsLevelEnabled(log.DebugLevel) {\\n\\t\\tlog.Debug(resultWriter.String())\\n\\t}\\n\\treturn resultWriter.String(), metadata, nil\\n}\",\n \"func (r *Recipe) parseHTML() (rerr error) {\\n\\tif r == nil {\\n\\t\\tr = &Recipe{}\\n\\t}\\n\\tif r.FileContent == \\\"\\\" || r.FileName == \\\"\\\" {\\n\\t\\trerr = fmt.Errorf(\\\"no file loaded\\\")\\n\\t\\treturn\\n\\t}\\n\\n\\tr.Lines, rerr = getIngredientLinesInHTML(r.FileContent)\\n\\treturn r.parseRecipe()\\n\\n}\",\n \"func (h *ImageProxyHandler) imagesHTML(w http.ResponseWriter, dataURLChan <-chan *dataurl.DataURL) {\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"text/html; charset=utf-8\\\")\\n\\tw.WriteHeader(http.StatusOK)\\n\\n\\tif err := imagesPageTmpl.Execute(w, dataURLChan); err != nil {\\n\\t\\th.logger.Println(\\\"writing html response error:\\\", err)\\n\\t}\\n}\",\n \"func (t *GoatsTemplate) genRenderContent(output io.Writer) string {\\n\\tvar headProcessor processors.Processor = processors.NewHeadProcessor()\\n\\n\\tvar argProcessor processors.Processor = processors.NewArgProcessor(t.Args)\\n\\theadProcessor.SetNext(argProcessor)\\n\\n\\tt.buildProcessorChain(argProcessor, t.RootNode)\\n\\n\\tctx := processors.NewTagContext(t.Parser.PkgMgr, t.pkgRefs, t.Parser.Settings.OutputFormat)\\n\\tif t.NeedsDocType {\\n\\t\\tdocTypeProcessor := processors.NewDocTypeProcessor(t.Parser.DocTypeTag, t.Parser.DocTypeAttrs)\\n\\t\\tdocTypeProcessor.SetNext(headProcessor)\\n\\t\\theadProcessor = docTypeProcessor\\n\\t}\\n\\n\\tvar renderBuffer bytes.Buffer\\n\\theadProcessor.Process(&renderBuffer, ctx)\\n\\treturn renderBuffer.String()\\n}\",\n \"func viewHandler(w http.ResponseWriter, r *http.Request) {\\n\\ttitle := r.URL.Path[len(\\\"/view/\\\"):]\\n\\tp, err := loadPage(title)\\n\\tif err != nil {\\n\\t\\thttp.Redirect(w, r, \\\"/edit/\\\"+title, http.StatusFound)// if there does not exist page:title, make a new page.\\n\\t\\treturn\\t\\t\\n\\t}\\n\\trenderTemplate(w, \\\"view\\\", p)\\n\\t// t, _ := template.ParseFiles(\\\"view.html\\\")// return *template.Template, error\\n\\t// t.Execute(w,p)\\n\\t// fmt.Fprintf(w, \\\"

%s

%s
\\\", p.Title, p.Body)\\n}\",\n \"func newHnStories() []Story {\\n\\t// First we need a buffer to hold stories\\n\\tvar stories []Story\\n\\t// We can use the GetChanges function to get all the most recent objects\\n\\t// from HackerNews. These will just be integer IDs, and we'll need to make requests\\n\\t// for each one.\\n\\tchanges, err := hackerNewsClient.GetChanges()\\n\\t// In case of an error, we'll print it and return nil\\n\\tif err != nil {\\n\\t\\tfmt.Println(err)\\n\\t\\treturn nil\\n\\t}\\n\\n\\t// Now, we can loop over the IDs we got back and make a request for each one.\\n\\tfor _, id := range changes.Items {\\n\\t\\t// The GetStory method will return a Story struct, or an error if the requested object wasn't\\n\\t\\t// as story.\\n\\t\\tstory, err := hackerNewsClient.GetStory(id)\\n\\t\\t// In case it wasn't a story, just move on.\\n\\t\\tif err != nil {\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\t\\t// Now we can construct a Story struct and put it in the list\\n\\t\\tnewStory := Story{\\n\\t\\t\\ttitle: story.Title,\\n\\t\\t\\turl: story.URL,\\n\\t\\t\\tauthor: story.By,\\n\\t\\t\\tsource: \\\"HackerNews\\\",\\n\\t\\t}\\n\\t\\tstories = append(stories, newStory)\\n\\t}\\n\\n\\t// Finally, after the loop completes, we'll just return the stories\\n\\treturn stories\\n}\",\n \"func (i Novel) HTMLContent(ctx context.Context, renderer ContentRenderer) (string, error) {\\n\\tif renderer == nil {\\n\\t\\trenderer = SimpleContentRenderer{EmbeddedImages: i.EmbeddedImages}\\n\\t}\\n\\treturn HTMLContent(ctx, renderer, i.Content)\\n}\",\n \"func (c *rstConverter) getRstContent(src []byte, ctx converter.DocumentContext) []byte {\\n\\tlogger := c.cfg.Logger\\n\\tpath := getRstExecPath()\\n\\n\\tif path == \\\"\\\" {\\n\\t\\tlogger.Println(\\\"rst2html / rst2html.py not found in $PATH: Please install.\\\\n\\\",\\n\\t\\t\\t\\\" Leaving reStructuredText content unrendered.\\\")\\n\\t\\treturn src\\n\\t}\\n\\n\\tlogger.Infoln(\\\"Rendering\\\", ctx.DocumentName, \\\"with\\\", path, \\\"...\\\")\\n\\n\\tvar result []byte\\n\\t// certain *nix based OSs wrap executables in scripted launchers\\n\\t// invoking binaries on these OSs via python interpreter causes SyntaxError\\n\\t// invoke directly so that shebangs work as expected\\n\\t// handle Windows manually because it doesn't do shebangs\\n\\tif runtime.GOOS == \\\"windows\\\" {\\n\\t\\tpython := internal.GetPythonExecPath()\\n\\t\\targs := []string{path, \\\"--leave-comments\\\", \\\"--initial-header-level=2\\\"}\\n\\t\\tresult = internal.ExternallyRenderContent(c.cfg, ctx, src, python, args)\\n\\t} else {\\n\\t\\targs := []string{\\\"--leave-comments\\\", \\\"--initial-header-level=2\\\"}\\n\\t\\tresult = internal.ExternallyRenderContent(c.cfg, ctx, src, path, args)\\n\\t}\\n\\t// TODO(bep) check if rst2html has a body only option.\\n\\tbodyStart := bytes.Index(result, []byte(\\\"\\\\n\\\"))\\n\\tif bodyStart < 0 {\\n\\t\\tbodyStart = -7 // compensate for length\\n\\t}\\n\\n\\tbodyEnd := bytes.Index(result, []byte(\\\"\\\\n\\\"))\\n\\tif bodyEnd < 0 || bodyEnd >= len(result) {\\n\\t\\tbodyEnd = len(result) - 1\\n\\t\\tif bodyEnd < 0 {\\n\\t\\t\\tbodyEnd = 0\\n\\t\\t}\\n\\t}\\n\\n\\treturn result[bodyStart+7 : bodyEnd]\\n}\",\n \"func main() {\\n\\tp1 := &gowiki.Page{Title: \\\"TestPage\\\", Body: []byte(\\\"This is a sample Page.\\\")}\\n\\tp1.Save()\\n\\tp2, _ := gowiki.LoadPage(\\\"TestPage\\\")\\n\\tfmt.Println(string(p2.Body))\\n}\",\n \"func ForHTMLTemplate(ts ...*template.Template) func(io.Writer) frameless.Presenter {\\n\\treturn (func(io.Writer) frameless.Presenter)(func(w io.Writer) frameless.Presenter {\\n\\t\\treturn frameless.PresenterFunc(func(data interface{}) error {\\n\\n\\t\\t\\tmostInnerTemplate := ts[len(ts)-1]\\n\\t\\t\\ttContent := bytes.NewBuffer([]byte{})\\n\\n\\t\\t\\tif err := mostInnerTemplate.Execute(tContent, data); err != nil {\\n\\t\\t\\t\\treturn err\\n\\t\\t\\t}\\n\\n\\t\\t\\trest := ts[:len(ts)-1]\\n\\t\\t\\tcurrentContent := tContent.String()\\n\\n\\t\\t\\tfor i := len(rest) - 1; i >= 0; i-- {\\n\\t\\t\\t\\tt := rest[i]\\n\\t\\t\\t\\tb := bytes.NewBuffer([]byte{})\\n\\n\\t\\t\\t\\tif err := t.Execute(b, template.HTML(currentContent)); err != nil {\\n\\t\\t\\t\\t\\treturn err\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\tcurrentContent = b.String()\\n\\t\\t\\t}\\n\\n\\t\\t\\tw.Write([]byte(currentContent))\\n\\n\\t\\t\\treturn nil\\n\\n\\t\\t})\\n\\t})\\n}\",\n \"func BuildPage(htmlTemplate string, bingoBoard BingoBoard) *bytes.Buffer {\\n\\tvar bodyBuffer bytes.Buffer\\n\\tt := template.New(\\\"template\\\")\\n\\tvar templates = template.Must(t.Parse(htmlTemplate))\\n\\ttemplates.Execute(&bodyBuffer, bingoBoard)\\n\\treturn &bodyBuffer\\n}\",\n \"func (VS *Server) design(c *gin.Context) {\\n\\trender(c, gin.H{}, \\\"presentation-design.html\\\")\\n}\",\n \"func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\\n p, _ := loadPage(\\\"/src/github.com/mrgirlyman/watcher/frontman/build/index.html\\\")\\n\\n fmt.Fprintf(w, string(p.Body))\\n // log.Fatal(err)\\n\\n // if (err != nil) {\\n // fmt.Fprintf(w, string(p.Body))\\n // } else {\\n // fmt.Fprintf(w, \\\"Error reading index.html\\\")\\n // }\\n}\",\n \"func TestPutSlidesDocumentFromHtmlInvalidhtml(t *testing.T) {\\n request := createPutSlidesDocumentFromHtmlRequest()\\n request.html = invalidizeTestParamValue(request.html, \\\"html\\\", \\\"string\\\").(string)\\n e := initializeTest(\\\"PutSlidesDocumentFromHtml\\\", \\\"html\\\", request.html)\\n if e != nil {\\n t.Errorf(\\\"Error: %v.\\\", e)\\n return\\n }\\n r, _, e := getTestApiClient().DocumentApi.PutSlidesDocumentFromHtml(request)\\n assertError(t, \\\"PutSlidesDocumentFromHtml\\\", \\\"html\\\", r.Code, e)\\n}\",\n \"func markdownToHTML(s string) string {\\n\\ts = strings.Replace(s, \\\"_blank\\\", \\\"________\\\", -1)\\n\\ts = strings.Replace(s, \\\"\\\\\\\\kh\\\", \\\"( )\\\", -1)\\n\\ts = strings.Replace(s, \\\"~\\\", \\\" \\\", -1)\\n\\tresult := \\\"\\\"\\n\\troot := Parse(s)\\n\\tfor node := root.FirstChild; node != nil; node = node.NextSibling {\\n\\t\\tif node.Type == NodePara {\\n\\t\\t\\tresult += fmt.Sprintf(\\\"

%s

\\\", node.Data)\\n\\t\\t} else if node.Type == NodeImag {\\n\\t\\t\\tresult += fmt.Sprintf(\\\"

\\\", node.Data, node.Attr)\\n\\t\\t} else if node.Type == NodeOl {\\n\\t\\t\\tresult += \\\"
    \\\"\\n\\t\\t\\tfor linode := node.FirstChild; linode != nil; linode = linode.NextSibling {\\n\\t\\t\\t\\tresult += fmt.Sprintf(\\\"
  1. \\\\n\\\", linode.Attr)\\n\\t\\t\\t\\tfor p := linode.FirstChild; p != nil; p = p.NextSibling {\\n\\t\\t\\t\\t\\tif p.Type == NodePara {\\n\\t\\t\\t\\t\\t\\tresult += fmt.Sprintf(\\\"

    %s

    \\\", p.Data)\\n\\t\\t\\t\\t\\t} else if p.Type == NodeImag {\\n\\t\\t\\t\\t\\t\\tresult += fmt.Sprintf(\\\"

    \\\", p.Data, p.Attr)\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tresult += fmt.Sprintf(\\\"
  2. \\\\n\\\")\\n\\t\\t\\t}\\n\\t\\t\\tresult += \\\"
\\\"\\n\\t\\t}\\n\\t}\\n\\treturn result\\n}\",\n \"func htmlHandler(w http.ResponseWriter, r *http.Request) {\\n\\tfmt.Fprint(w, \\\"

Whoa, Nice!

\\\")\\n\\tfmt.Fprint(w, \\\"

Nice Go

\\\")\\n\\tfmt.Fprint(w, \\\"

This is a paragraph

\\\")\\n\\t// Note Fprintf for formatting\\n\\tfmt.Fprintf(w, \\\"

You %s even add %s

\\\", \\\"can\\\", \\\"variables\\\")\\n\\t// Multiline print\\n\\tfmt.Fprintf(w, `

Hi!

\\n

This is also Go

\\n

Multiline

`)\\n\\n}\",\n \"func generateHTMLReport(c *gin.Context,scrapeID string){\\n\\tjsonFile, err := os.Open(\\\"data/\\\" + scrapeID + \\\"_report.json\\\")\\n\\tif err!=nil{\\n\\t\\tc.HTML(\\n\\t\\t\\thttp.StatusBadRequest,\\n\\t\\t\\t\\\"error.tmpl\\\",\\n\\t\\t\\tgin.H{\\n\\t\\t\\t\\t\\\"err\\\": \\\"no report found!\\\",\\n\\t\\t\\t},\\n\\t\\t)\\n\\t\\treturn\\n\\t}\\n\\n\\tdefer jsonFile.Close()\\n\\treportInBytes, err := ioutil.ReadAll(jsonFile)\\n\\tif err!=nil{\\n\\t\\tc.HTML(\\n\\t\\t\\thttp.StatusBadRequest,\\n\\t\\t\\t\\\"error.tmpl\\\",\\n\\t\\t\\tgin.H{\\n\\t\\t\\t\\t\\\"err\\\": \\\"Error while reading report\\\",\\n\\t\\t\\t},\\n\\t\\t)\\n\\t\\treturn\\n\\t}\\n\\n\\tvar finalReport scraper.Report\\n\\t_ = json.Unmarshal(reportInBytes, &finalReport)\\n\\n\\tc.HTML(\\n\\t\\thttp.StatusOK,\\n\\t\\t\\\"index.tmpl\\\",\\n\\t\\tgin.H{\\n\\t\\t\\t\\\"scrape_id\\\": finalReport.ScrapeID,\\n\\t\\t\\t\\\"project_id\\\":finalReport.ProjectID,\\n\\t\\t\\t\\\"folder_threshold\\\":finalReport.FolderThreshold,\\n\\t\\t\\t\\\"folder_examples_count\\\":finalReport.FolderExamplesCount,\\n\\t\\t\\t\\\"patterns\\\":finalReport.Patterns,\\n\\t\\t\\t\\\"details\\\": finalReport.DetailedReport,\\n\\t\\t},\\n\\t)\\n\\treturn\\n\\n}\",\n \"func testTemplate(w http.ResponseWriter, r *http.Request) {\\n\\ttestpage := Page{\\n\\t\\tID: \\\"urn:cts:tests:test1.test1:1\\\",\\n\\t\\tText: template.HTML(\\\"This is a testing of the template\\\")}\\n\\n\\trenderTemplate(w, \\\"view\\\", testpage)\\n}\",\n \"func how(w http.ResponseWriter, req *http.Request, ctx httputil.Context) (e *httputil.Error) {\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"text/html\\\")\\n\\n\\tif err := T(\\\"how/how.html\\\").Execute(w, nil); err != nil {\\n\\t\\te = httputil.Errorf(err, \\\"error executing index template\\\")\\n\\t}\\n\\treturn\\n}\",\n \"func PrettyPrints(print int) {\\r\\n\\t/*this section is going to define all my big pretty printing and follow with a simple switch that chooses the particular graphic by its integer number associated with it.\\r\\n\\tthe images come out distorted without modifying them here piece by piece so they look weird here but they look great in use.*/\\r\\n\\r\\n\\t//this graphic and a few other presented weird so adjustments were made to achieve correct appearance\\r\\n\\tvar pridePic string = `\\r\\n\\t _____ _____ _____ _____\\r\\n\\t| | | __| _ | | __|___ _____ ___ ___\\r\\n\\t| | | |__ | | | | | .'| | -_|_ -|\\r\\n\\t|_|___|_____|__|__| |_____|__,|_|_|_|___|___|\\r\\n\\t _____ _\\r\\n\\t\\t| _ |___ ___ ___ ___ ___| |_ ___\\r\\n\\t\\t| __| _| -_|_ -| -_| | _|_ -|\\r\\n\\t\\t|__| |_| |___|___|___|_|_|_| |___|\\r\\n`\\r\\n\\tvar titlePic string = `\\r\\n\\t _____ _ _\\r\\n\\t| _ |___ ___ |_|___ ___| |_\\r\\n\\t| __| _| . | | | -_| _| _|\\r\\n\\t|__| |_| |___|_| |___|___|_|\\r\\n\\t\\t |___|\\r\\n\\t \\t _ _\\r\\n\\t\\t _| | |_ ___\\r\\n\\t |_ _| |_ |\\r\\n\\t\\t |_ _| | _|\\r\\n\\t\\t |_|_| |___|\\r\\n`\\r\\n\\r\\n\\tvar spellPic string = `\\r\\n /\\\\\\r\\n / \\\\\\r\\n | |\\r\\n --:'''':--\\r\\n :'_' :\\r\\n _:\\\"\\\":\\\\___\\r\\n ' ' ____.' ::: '._\\r\\n . *=====<<=) \\\\ :\\r\\n . ' '-'-'\\\\_ /'._.'\\r\\n \\\\====:_ \\\"\\\"\\r\\n .' \\\\\\\\\\r\\n : :\\r\\n / : \\\\\\r\\n : . '.\\r\\n ,. _ : : : :\\r\\n '-' ). :__:-:__.;--'\\r\\n ( ' ) '-' '-'\\r\\n ( - .00. - _\\r\\n( .' O ) )\\r\\n'- ()_.\\\\,\\\\, -\\r\\n`\\r\\n\\t//\\r\\n\\tvar swordPic string = `\\r\\n /\\r\\nO===[====================-\\r\\n \\\\\\r\\n`\\r\\n\\r\\n\\tvar shieldPic string = `\\r\\n\\t\\\\_ _/\\r\\n\\t] --__________-- [\\r\\n\\t| || |\\r\\n\\t\\\\ || /\\r\\n\\t [ || ]\\r\\n\\t |______||______|\\r\\n\\t |------..------|\\r\\n\\t ] || [\\r\\n\\t \\\\ || /\\r\\n\\t [ || ]\\r\\n\\t \\\\ || /\\r\\n\\t [ || ]\\r\\n\\t \\\\__||__/\\r\\n\\t --\\r\\n\\t`\\r\\n\\tvar winPic string = `\\r\\n\\t __ __ _ _ _ __\\r\\n\\t| | |___ _ _ | | | |___ ___| |\\r\\n\\t|_ _| . | | | | | | | . | |__|\\r\\n\\t |_| |___|___| |_____|___|_|_|__|\\r\\n\\t`\\r\\n\\r\\n\\tvar losePic string = `\\r\\n\\t __ __ ____ _ _\\r\\n\\t| | |___ _ _ | \\\\|_|___ _| |\\r\\n\\t|_ _| . | | | | | | | -_| . |\\r\\n\\t |_| |___|___| |____/|_|___|___|\\r\\n\\t`\\r\\n\\tvar tiePic string = `\\r\\n\\t _____ _\\r\\n\\t|_ _|_|___\\r\\n\\t | | | | -_|\\r\\n\\t |_| |_|___|\\r\\n\\t`\\r\\n\\tvar sssPic string = `\\r\\n\\t _____ _\\r\\n\\t| __|_ _ _ ___ ___ _| |\\r\\n\\t|__ | | | | . | _| . |\\r\\n\\t|_____|_____|___|_| |___|\\r\\n\\t _____ _ _ _ _\\r\\n\\t| __| |_|_|___| |_| |\\r\\n\\t|__ | | | -_| | . |\\r\\n\\t|_____|_|_|_|___|_|___|\\r\\n\\t _____ _ _\\r\\n\\t| __|___ ___| | |\\r\\n\\t|__ | . | -_| | |\\r\\n\\t|_____| _|___|_|_|\\r\\n\\t\\t|_|\\r\\n\\t`\\r\\n\\tswitch print {\\r\\n\\tcase 1:\\r\\n\\t\\tfmt.Printf(\\\"%s\\\\n\\\", pridePic)\\r\\n\\tcase 2:\\r\\n\\t\\tfmt.Printf(\\\"%s\\\\n\\\", titlePic)\\r\\n\\tcase 3:\\r\\n\\t\\tfmt.Printf(\\\"%s\\\\n\\\", spellPic)\\r\\n\\tcase 4:\\r\\n\\t\\tfmt.Printf(\\\"%s\\\\n\\\", swordPic)\\r\\n\\tcase 5:\\r\\n\\t\\tfmt.Printf(\\\"%s\\\\n\\\", shieldPic)\\r\\n\\tcase 6:\\r\\n\\t\\tfmt.Printf(\\\"%s\\\\n\\\", winPic)\\r\\n\\tcase 7:\\r\\n\\t\\tfmt.Printf(\\\"%s\\\\n\\\", losePic)\\r\\n\\tcase 8:\\r\\n\\t\\tfmt.Printf(\\\"%s\\\\n\\\", sssPic)\\r\\n\\tcase 9:\\r\\n\\t\\tfmt.Printf(\\\"%s\\\\n\\\", tiePic)\\r\\n\\r\\n\\t}\\r\\n}\",\n \"func main() {\\n\\tdomTarget := dom.GetWindow().Document().GetElementByID(\\\"app\\\")\\n\\n\\tr.Render(container.Container(), domTarget)\\n}\",\n \"func FullStory(ctx context.Context, client streamexp.ReadMyStoryServiceClient) error {\\n\\n}\",\n \"func getOneStory(id int, c hn.Client, channel chan item, counter int) {\\r\\n\\t// defer wg.Done()\\r\\n\\tvar i item\\r\\n\\t// fmt.Printf(\\\"getting item %d inside getOneStory number %d\\\\n\\\", id, counter)\\r\\n\\thnItem, err := c.GetItem(id)\\r\\n\\tif err != nil {\\r\\n\\t\\tfmt.Println(err)\\r\\n\\t\\treturn\\r\\n\\t}\\r\\n\\tfmt.Printf(\\\"parsing item %d\\\\n\\\", id)\\r\\n\\ti = parseHNItem(hnItem)\\r\\n\\tif !isStoryLink(i) {\\r\\n\\t\\tgoroutine--\\r\\n\\t\\t// fmt.Printf(\\\"returning because item %d is not a story.\\\\n\\\", id)\\r\\n\\t\\treturn\\r\\n\\t}\\r\\n\\t// fmt.Printf(\\\"Adding item %d to channel.\\\\n\\\", id)\\r\\n\\tchannel <- i\\r\\n}\",\n \"func helpHtmlHandle(w http.ResponseWriter, r *http.Request) {\\n\\thelpTempl.Execute(w, Params)\\n}\",\n \"func descriptionContents(shuffledData *ClipJSON) string {\\n\\tcontents := `\\\\n\\\\n` // Start with new line to seperate message at top\\n\\tcurrentTime := 0\\n\\n\\tfor _, clip := range shuffledData.Clips {\\n\\t\\tcontents += fmt.Sprintf(\\\"Title: %s\\\\nVod: %s\\\\nTime: %s\\\\n\\\\n\\\", clip.Title, clip.Vod.URL, youtubeTimify(currentTime))\\n\\t\\t// Convert clip.Duration to milliseconds, then round in to the nearest millisecond\\n\\t\\tcurrentTime += int(math.Floor(clip.Duration + 0.5))\\n\\t}\\n\\n\\treturn contents\\n}\",\n \"func GenerateHTMLReport(totalTestTime, testDate string, testSummary []TestOverview, testSuiteDetails map[string]TestSuiteDetails) {\\n\\ttotalPassedTests := 0\\n\\ttotalFailedTests := 0\\n\\ttotalSkippedTests := 0\\n\\ttemplates := make([]template.HTML, 0)\\n\\tfor _, testSuite := range testSuiteDetails {\\n\\t\\ttotalPassedTests = totalPassedTests + testSuite.PassedTests\\n\\t\\ttotalFailedTests = totalFailedTests + testSuite.FailedTests\\n\\t\\ttotalSkippedTests = totalSkippedTests + testSuite.SkippedTests\\n\\t\\t// display testSuiteName\\n\\t\\thtmlString := template.HTML(\\\"
\\\\n\\\")\\n\\t\\tpackageInfoTemplateString := template.HTML(\\\"\\\")\\n\\n\\t\\tpackageInfoTemplateString = \\\"
{{.testsuiteName}}
\\\" + \\\"\\\\n\\\" + \\\"
Run Time: {{.elapsedTime}}m
\\\" + \\\"\\\\n\\\"\\n\\t\\tpackageInfoTemplate, err := template.New(\\\"packageInfoTemplate\\\").Parse(string(packageInfoTemplateString))\\n\\t\\tif err != nil {\\n\\t\\t\\tlog.Println(\\\"error parsing package info template\\\", err)\\n\\t\\t\\tos.Exit(1)\\n\\t\\t}\\n\\n\\t\\tvar processedPackageTemplate bytes.Buffer\\n\\t\\terr = packageInfoTemplate.Execute(&processedPackageTemplate, map[string]string{\\n\\t\\t\\t\\\"testsuiteName\\\": testSuite.TestSuiteName + \\\"_\\\" + OS,\\n\\t\\t\\t\\\"elapsedTime\\\": fmt.Sprintf(\\\"%.2f\\\", testSuite.ElapsedTime),\\n\\t\\t})\\n\\t\\tif err != nil {\\n\\t\\t\\tlog.Println(\\\"error applying package info template: \\\", err)\\n\\t\\t\\tos.Exit(1)\\n\\t\\t}\\n\\n\\t\\tif testSuite.Status == \\\"pass\\\" {\\n\\t\\t\\tpackageInfoTemplateString = \\\"
\\\" +\\n\\t\\t\\t\\ttemplate.HTML(processedPackageTemplate.Bytes()) + \\\"
\\\"\\n\\t\\t} else if testSuite.Status == \\\"fail\\\" {\\n\\t\\t\\tpackageInfoTemplateString = \\\"
\\\" +\\n\\t\\t\\t\\ttemplate.HTML(processedPackageTemplate.Bytes()) + \\\"
\\\"\\n\\t\\t} else {\\n\\t\\t\\tpackageInfoTemplateString = \\\"
\\\" +\\n\\t\\t\\t\\ttemplate.HTML(processedPackageTemplate.Bytes()) + \\\"
\\\"\\n\\t\\t}\\n\\n\\t\\thtmlString = htmlString + \\\"\\\\n\\\" + packageInfoTemplateString\\n\\t\\ttestInfoTemplateString := template.HTML(\\\"\\\")\\n\\n\\t\\t// display testCases\\n\\t\\tfor _, pt := range testSummary {\\n\\t\\t\\ttestHTMLTemplateString := template.HTML(\\\"\\\")\\n\\t\\t\\tif len(pt.TestCases) == 0 {\\n\\t\\t\\t\\tlog.Println(\\\"Test run failed for \\\", pt.TestSuiteName, \\\"no testcases were executed\\\")\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\n\\t\\t\\tif pt.TestSuiteName == testSuite.TestSuiteName {\\n\\t\\t\\t\\tif testSuite.FailedTests == 0 {\\n\\t\\t\\t\\t\\ttestHTMLTemplateString = \\\"
\\\" +\\n\\t\\t\\t\\t\\t\\t\\\"\\\\n\\\" + \\\"
\\\" +\\n\\t\\t\\t\\t\\t\\t\\\"
+ {{.testName}}
\\\" + \\\"\\\\n\\\" + \\\"
{{.elapsedTime}}
\\\" + \\\"\\\\n\\\" +\\n\\t\\t\\t\\t\\t\\t\\\"
\\\" + \\\"\\\\n\\\" +\\n\\t\\t\\t\\t\\t\\t\\\"
\\\"\\n\\t\\t\\t\\t} else if testSuite.FailedTests > 0 {\\n\\t\\t\\t\\t\\ttestHTMLTemplateString = \\\"
\\\" +\\n\\t\\t\\t\\t\\t\\t\\\"\\\\n\\\" + \\\"
\\\" +\\n\\t\\t\\t\\t\\t\\t\\\"
+ {{.testName}}
\\\" + \\\"\\\\n\\\" + \\\"
{{.elapsedTime}}
\\\" + \\\"\\\\n\\\" +\\n\\t\\t\\t\\t\\t\\t\\\"
\\\" + \\\"\\\\n\\\" +\\n\\t\\t\\t\\t\\t\\t\\\"
\\\"\\n\\t\\t\\t\\t} else if testSuite.SkippedTests > 0 {\\n\\t\\t\\t\\t\\ttestHTMLTemplateString = \\\"
\\\" +\\n\\t\\t\\t\\t\\t\\t\\\"\\\\n\\\" + \\\"
\\\" +\\n\\t\\t\\t\\t\\t\\t\\\"
+ {{.testName}}
\\\" + \\\"\\\\n\\\" + \\\"
{{.elapsedTime}}
\\\" + \\\"\\\\n\\\" +\\n\\t\\t\\t\\t\\t\\t\\\"
\\\" + \\\"\\\\n\\\" +\\n\\t\\t\\t\\t\\t\\t\\\"
\\\"\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\ttestTemplate, err := template.New(\\\"Test\\\").Parse(string(testHTMLTemplateString))\\n\\t\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t\\tlog.Println(\\\"error parsing tests template: \\\", err)\\n\\t\\t\\t\\t\\tos.Exit(1)\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tvar processedTestTemplate bytes.Buffer\\n\\t\\t\\t\\terr = testTemplate.Execute(&processedTestTemplate, map[string]string{\\n\\t\\t\\t\\t\\t\\\"testName\\\": \\\"TestCases\\\",\\n\\t\\t\\t\\t})\\n\\t\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t\\tlog.Println(\\\"error applying test template: \\\", err)\\n\\t\\t\\t\\t\\tos.Exit(1)\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\ttestHTMLTemplateString = template.HTML(processedTestTemplate.Bytes())\\n\\t\\t\\t\\ttestCaseHTMLTemplateString := template.HTML(\\\"\\\")\\n\\n\\t\\t\\t\\tfor _, tC := range pt.TestCases {\\n\\t\\t\\t\\t\\ttestCaseHTMLTemplateString = \\\"
{{.testName}}
\\\" + \\\"\\\\n\\\" + \\\"
{{.elapsedTime}}m
\\\"\\n\\t\\t\\t\\t\\ttestCaseTemplate, err := template.New(\\\"testCase\\\").Parse(string(testCaseHTMLTemplateString))\\n\\t\\t\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t\\t\\tlog.Println(\\\"error parsing test case template: \\\", err)\\n\\t\\t\\t\\t\\t\\tos.Exit(1)\\n\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t\\tvar processedTestCaseTemplate bytes.Buffer\\n\\t\\t\\t\\t\\terr = testCaseTemplate.Execute(&processedTestCaseTemplate, map[string]string{\\n\\t\\t\\t\\t\\t\\t\\\"testName\\\": tC.TestCaseName,\\n\\t\\t\\t\\t\\t\\t\\\"elapsedTime\\\": fmt.Sprintf(\\\"%f\\\", tC.ElapsedTime),\\n\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t\\t\\tlog.Println(\\\"error applying test case template: \\\", err)\\n\\t\\t\\t\\t\\t\\tos.Exit(1)\\n\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t\\tif tC.Status == \\\"passed\\\" {\\n\\t\\t\\t\\t\\t\\ttestCaseHTMLTemplateString = \\\"
\\\" + template.HTML(processedTestCaseTemplate.Bytes()) + \\\"
\\\"\\n\\n\\t\\t\\t\\t\\t} else if tC.Status == \\\"failed\\\" {\\n\\t\\t\\t\\t\\t\\ttestCaseHTMLTemplateString = \\\"
\\\" + template.HTML(processedTestCaseTemplate.Bytes()) + \\\"
\\\"\\n\\n\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\ttestCaseHTMLTemplateString = \\\"
\\\" + template.HTML(processedTestCaseTemplate.Bytes()) + \\\"
\\\"\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\ttestHTMLTemplateString = testHTMLTemplateString + \\\"\\\\n\\\" + testCaseHTMLTemplateString\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\ttestHTMLTemplateString = testHTMLTemplateString + \\\"\\\\n\\\" + \\\"
\\\" + \\\"\\\\n\\\" + \\\"
\\\"\\n\\t\\t\\t\\ttestInfoTemplateString = testInfoTemplateString + \\\"\\\\n\\\" + testHTMLTemplateString\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\thtmlString = htmlString + \\\"\\\\n\\\" + \\\"
\\\\n\\\" + testInfoTemplateString + \\\"\\\\n\\\" + \\\"
\\\"\\n\\t\\thtmlString = htmlString + \\\"\\\\n\\\" + \\\"
\\\"\\n\\t\\ttemplates = append(templates, htmlString)\\n\\t}\\n\\treportTemplate := template.New(\\\"report-template.html\\\")\\n\\treportTemplateData, err := Asset(\\\"report-template.html\\\")\\n\\tif err != nil {\\n\\t\\tlog.Println(\\\"error retrieving report-template.html: \\\", err)\\n\\t\\tos.Exit(1)\\n\\t}\\n\\n\\treport, err := reportTemplate.Parse(string(reportTemplateData))\\n\\tif err != nil {\\n\\t\\tlog.Println(\\\"error parsing report-template.html: \\\", err)\\n\\t\\tos.Exit(1)\\n\\t}\\n\\n\\tvar processedTemplate bytes.Buffer\\n\\ttype templateData struct {\\n\\t\\tHTMLElements []template.HTML\\n\\t\\tFailedTests int\\n\\t\\tPassedTests int\\n\\t\\tSkippedTests int\\n\\t\\tTotalTestTime string\\n\\t\\tTestDate string\\n\\t}\\n\\n\\terr = report.Execute(&processedTemplate,\\n\\t\\t&templateData{\\n\\t\\t\\tHTMLElements: templates,\\n\\t\\t\\tFailedTests: totalFailedTests,\\n\\t\\t\\tPassedTests: totalPassedTests,\\n\\t\\t\\tSkippedTests: totalSkippedTests,\\n\\t\\t\\tTotalTestTime: totalTestTime,\\n\\t\\t\\tTestDate: testDate,\\n\\t\\t},\\n\\t)\\n\\tif err != nil {\\n\\t\\tlog.Println(\\\"error applying report-template.html: \\\", err)\\n\\t\\tos.Exit(1)\\n\\t}\\n\\thtmlReport = strings.Split(fileName, \\\".\\\")[0] + \\\"_results.html\\\"\\n\\tbucketName = strings.Split(htmlReport, \\\"_\\\")[0] + \\\"-results\\\"\\n\\tfmt.Println(bucketName)\\n\\terr = ioutil.WriteFile(htmlReport, processedTemplate.Bytes(), 0644)\\n\\tif err != nil {\\n\\t\\tlog.Println(\\\"error writing report.html file: \\\", err)\\n\\t\\tos.Exit(1)\\n\\t}\\n}\",\n \"func outputHTML(w http.ResponseWriter, r *http.Request, filepath string) {\\n\\tfile, err := os.Open(filepath)\\n\\tif err != nil {\\n\\t\\thttp.Error(w, err.Error(), http.StatusInternalServerError)\\n\\t\\treturn\\n\\t}\\n\\tdefer file.Close()\\n\\n\\thttp.ServeContent(w, r, file.Name(), time.Now(), file)\\n}\",\n \"func generate(p *models.Project) string {\\n\\tvar builder strings.Builder\\n\\tbuilder.WriteString(fmt.Sprintf(\\\"# %s\\\\n\\\", p.Name))\\n\\tplugins := []Plugin{description}\\n\\tif len(p.Badges) > 0 {\\n\\t\\tplugins = append(plugins, addBadges)\\n\\t\\tfor _, plugin := range plugins {\\n\\t\\t\\tplugin(&builder, p)\\n\\t\\t}\\n\\t}\\n\\tbuilder.WriteString(fmt.Sprintf(\\\"### Author\\\\n\\\"))\\n\\tbuilder.WriteString(fmt.Sprintf(\\\"%s\\\\n\\\", p.Author))\\n\\tbuilder.WriteString(fmt.Sprintf(\\\"### LICENCE\\\\n\\\"))\\n\\treturn builder.String()\\n}\",\n \"func handlerPreview(w http.ResponseWriter, r *http.Request) {\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"text/html; charset=utf-8\\\")\\n\\tvar v = struct {\\n\\t\\tHost string\\n\\t\\tData string\\n\\t}{\\n\\t\\tr.Host,\\n\\t\\t\\\"Go ahead, save that markdown file.\\\",\\n\\t}\\n\\n\\ttmpl.Execute(w, &v)\\n}\",\n \"func Idea() string {\\n\\tresp, err := http.Get(\\\"http://itsthisforthat.com/api.php?json\\\")\\n\\tif err != nil {\\n\\t\\treturn \\\"I had a problem...\\\"\\n\\t}\\n\\tdefer resp.Body.Close()\\n\\n\\tbodyBytes, err := ioutil.ReadAll(resp.Body)\\n\\n\\tvar concept idea\\n\\tjson.Unmarshal([]byte(bodyBytes), &concept)\\n\\treturn \\\"you should create \\\" + concept.This + \\\" for \\\" + concept.That\\n}\",\n \"func handlerView(w http.ResponseWriter, r *http.Request, title string) {\\r\\n\\tp2, err := loadPage(title)\\r\\n\\tif err != nil {\\r\\n\\t\\t//thiswill redirect the cliebt to the edit page so the content may be created\\r\\n\\t\\t//the http.redirect fucntion adds an HTTP status code\\r\\n\\t\\t//of fttp.statusFound(302) and a location header to the http response\\r\\n\\t\\thttp.Redirect(w, r, \\\"/edit/\\\"+title, http.StatusFound)\\r\\n\\t\\tfmt.Println(err.Error())\\r\\n\\t\\tos.Exit(1)\\r\\n\\t}\\r\\n\\tfetchHTML(w, \\\"view\\\", p2)\\r\\n}\",\n \"func TestHandler_OEmbed(t *testing.T) {\\n\\th := NewTestHandler()\\n\\tdefer h.Close()\\n\\n\\t// Create the gist in the database.\\n\\th.DB.Update(func(tx *gist.Tx) error {\\n\\t\\treturn tx.SaveGist(&gist.Gist{ID: \\\"abc123\\\", UserID: 1000, Description: \\\"My Gist\\\"})\\n\\t})\\n\\n\\t// Retrieve oEmbed.\\n\\tu, _ := url.Parse(h.Server.URL + \\\"/oembed.json\\\")\\n\\tu.RawQuery = (&url.Values{\\\"url\\\": {\\\"https://gist.exposed/benbjohnson/abc123\\\"}}).Encode()\\n\\tresp, err := http.Get(u.String())\\n\\tok(t, err)\\n\\tequals(t, 200, resp.StatusCode)\\n\\n\\thtml, _ := json.Marshal(`
`)\\n\\tequals(t, `{\\\"version\\\":\\\"1.0\\\",\\\"type\\\":\\\"rich\\\",\\\"html\\\":`+string(html)+`,\\\"height\\\":300,\\\"title\\\":\\\"My Gist\\\",\\\"provider_name\\\":\\\"Gist Exposed!\\\",\\\"provider_url\\\":\\\"https://gist.exposed\\\"}`+\\\"\\\\n\\\", readall(resp.Body))\\n}\"\n]"},"negative_scores":{"kind":"list like","value":["0.5904224","0.578877","0.56078124","0.55700314","0.5567403","0.554374","0.5488931","0.53688914","0.5325711","0.532188","0.526886","0.5257439","0.5236609","0.5176298","0.5149505","0.5146099","0.5114756","0.5097406","0.5078993","0.50427485","0.50344986","0.5019498","0.5019177","0.49961522","0.49780497","0.4975862","0.4961908","0.49614975","0.49591345","0.49493757","0.49482626","0.49473584","0.49434146","0.49307263","0.4920825","0.48889476","0.48781717","0.48753387","0.48506093","0.48249647","0.48221233","0.4816635","0.48156294","0.48145634","0.4809513","0.48005748","0.47956198","0.4774784","0.47729695","0.47700685","0.47642386","0.47567058","0.4751701","0.4747277","0.474557","0.47342852","0.47337687","0.47226277","0.4701286","0.46990013","0.46911454","0.4684466","0.4681692","0.46805358","0.46780446","0.46705112","0.46684372","0.46593276","0.46550214","0.463317","0.46255726","0.46148714","0.46144423","0.46049565","0.45956522","0.4586924","0.4575458","0.45742297","0.4574036","0.456465","0.45582435","0.45550835","0.45504823","0.4550298","0.4537013","0.45340636","0.45241225","0.45188797","0.45117643","0.45102054","0.45049828","0.4500267","0.44960213","0.44951433","0.4484383","0.44718808","0.44659087","0.44651255","0.44606313","0.44596946"],"string":"[\n \"0.5904224\",\n \"0.578877\",\n \"0.56078124\",\n \"0.55700314\",\n \"0.5567403\",\n \"0.554374\",\n \"0.5488931\",\n \"0.53688914\",\n \"0.5325711\",\n \"0.532188\",\n \"0.526886\",\n \"0.5257439\",\n \"0.5236609\",\n \"0.5176298\",\n \"0.5149505\",\n \"0.5146099\",\n \"0.5114756\",\n \"0.5097406\",\n \"0.5078993\",\n \"0.50427485\",\n \"0.50344986\",\n \"0.5019498\",\n \"0.5019177\",\n \"0.49961522\",\n \"0.49780497\",\n \"0.4975862\",\n \"0.4961908\",\n \"0.49614975\",\n \"0.49591345\",\n \"0.49493757\",\n \"0.49482626\",\n \"0.49473584\",\n \"0.49434146\",\n \"0.49307263\",\n \"0.4920825\",\n \"0.48889476\",\n \"0.48781717\",\n \"0.48753387\",\n \"0.48506093\",\n \"0.48249647\",\n \"0.48221233\",\n \"0.4816635\",\n \"0.48156294\",\n \"0.48145634\",\n \"0.4809513\",\n \"0.48005748\",\n \"0.47956198\",\n \"0.4774784\",\n \"0.47729695\",\n \"0.47700685\",\n \"0.47642386\",\n \"0.47567058\",\n \"0.4751701\",\n \"0.4747277\",\n \"0.474557\",\n \"0.47342852\",\n \"0.47337687\",\n \"0.47226277\",\n \"0.4701286\",\n \"0.46990013\",\n \"0.46911454\",\n \"0.4684466\",\n \"0.4681692\",\n \"0.46805358\",\n \"0.46780446\",\n \"0.46705112\",\n \"0.46684372\",\n \"0.46593276\",\n \"0.46550214\",\n \"0.463317\",\n \"0.46255726\",\n \"0.46148714\",\n \"0.46144423\",\n \"0.46049565\",\n \"0.45956522\",\n \"0.4586924\",\n \"0.4575458\",\n \"0.45742297\",\n \"0.4574036\",\n \"0.456465\",\n \"0.45582435\",\n \"0.45550835\",\n \"0.45504823\",\n \"0.4550298\",\n \"0.4537013\",\n \"0.45340636\",\n \"0.45241225\",\n \"0.45188797\",\n \"0.45117643\",\n \"0.45102054\",\n \"0.45049828\",\n \"0.4500267\",\n \"0.44960213\",\n \"0.44951433\",\n \"0.4484383\",\n \"0.44718808\",\n \"0.44659087\",\n \"0.44651255\",\n \"0.44606313\",\n \"0.44596946\"\n]"},"document_score":{"kind":"string","value":"0.48855904"},"document_rank":{"kind":"string","value":"36"}}},{"rowIdx":105054,"cells":{"query":{"kind":"string","value":"EvaluateEnv evaluates an env with jsonnet."},"document":{"kind":"string","value":"func EvaluateEnv(a app.App, sourcePath, paramsStr, envName string) (string, error) {\n\tlibPath, err := a.LibPath(envName)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvm := jsonnet.NewVM()\n\n\tvm.JPaths = []string{\n\t\tlibPath,\n\t\tfilepath.Join(a.Root(), \"vendor\"),\n\t}\n\tvm.ExtCode(\"__ksonnet/params\", paramsStr)\n\n\tsnippet, err := afero.ReadFile(a.Fs(), sourcePath)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn vm.EvaluateSnippet(sourcePath, string(snippet))\n}"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["func (r RuleDefinition) EvaluateEnv(e map[string]string) bool {\n\t// Compile if needed\n\tif r.rule == nil {\n\t\tif err := r.Compile(); err != nil {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn r.rule.Env.Evaluate(e)\n}","func (getEnvPropertyValueFn) Eval(params ...interface{}) (interface{}, error) {\n\tif getEnvPropertyValueFnLogger.DebugEnabled() {\n\t\tgetEnvPropertyValueFnLogger.Debugf(\"Entering function getEnvPropertyValue (eval) with param: [%+v]\", params[0])\n\t}\n\n\tinputParamValue := params[0]\n\tinputString := \"\"\n\tvar outputValue interface{}\n\tvar err error\n\n\tinputString, err = coerce.ToString(inputParamValue)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Unable to coerece input value to a string. Value = [%+v].\", inputParamValue)\n\t}\n\n\tif getEnvPropertyValueFnLogger.DebugEnabled() {\n\t\tgetEnvPropertyValueFnLogger.Debugf(\"Input Parameter's string length is [%+v].\", len(inputString))\n\t}\n\n\tif len(inputString) <= 0 {\n\t\tgetEnvPropertyValueFnLogger.Debugf(\"Input Parameter is empty or nil. Returning nil.\")\n\t\treturn nil, nil\n\t}\n\n\toutputValue, exists := os.LookupEnv(inputString)\n\tif !exists {\n\t\tif getEnvPropertyValueFnLogger.DebugEnabled() {\n\t\t\tgetEnvPropertyValueFnLogger.Debugf(\"failed to resolve Env Property: '%s', ensure that property is configured in the application\", inputString)\n\t\t}\n\t\treturn nil, nil\n\t}\n\n\tif getEnvPropertyValueFnLogger.DebugEnabled() {\n\t\tgetEnvPropertyValueFnLogger.Debugf(\"Final output value = [%+v]\", outputValue)\n\t}\n\n\tif getEnvPropertyValueFnLogger.DebugEnabled() {\n\t\tgetEnvPropertyValueFnLogger.Debugf(\"Exiting function getEnvPropertyValue (eval)\")\n\t}\n\n\treturn outputValue, nil\n}","func (rs RuleDefinitions) EvaluateEnv(e map[string]string) bool {\n\tfor _, r := range rs.Rules {\n\t\tif r.EvaluateEnv(e) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}","func EvalEnv(key string) bool {\n\treturn os.Getenv(key) == \"1\" || os.Getenv(key) == \"true\" || os.Getenv(key) == \"TRUE\"\n}","func (gf *genericFramework) Env(key, value string) error {\n\tif gf.adam.Variables == nil {\n\t\tgf.adam.Variables = jsonutil.NewVariableMap(\"\", nil)\n\t}\n\tif _, ok := gf.adam.Variables.Get(key); ok {\n\t\treturn fmt.Errorf(\"%v has been defined\", key)\n\t}\n\tgf.adam.Variables.Set(key, jsonutil.NewStringVariable(key, value))\n\treturn nil\n}","func Eval(input string, env interface{}) (interface{}, error) {\n\tif _, ok := env.(Option); ok {\n\t\treturn nil, fmt.Errorf(\"misused expr.Eval: second argument (env) should be passed without expr.Env\")\n\t}\n\n\ttree, err := parser.Parse(input)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tprogram, err := compiler.Compile(tree, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toutput, err := vm.Run(program, env)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn output, nil\n}","func (c config) EvalContext(env string, props map[string]interface{}) eval.Context {\n\tp, err := json.Marshal(props)\n\tif err != nil {\n\t\tsio.Warnln(\"unable to serialize env properties to JSON:\", err)\n\t}\n\treturn eval.Context{\n\t\tApp: c.App().Name(),\n\t\tTag: c.App().Tag(),\n\t\tEnv: env,\n\t\tEnvPropsJSON: string(p),\n\t\tDefaultNs: c.App().DefaultNamespace(env),\n\t\tVMConfig: c.vmConfig,\n\t\tVerbose: c.Verbosity() > 1,\n\t\tConcurrency: c.EvalConcurrency(),\n\t\tPostProcessFile: c.App().PostProcessor(),\n\t\tCleanMode: c.cleanEvalMode,\n\t}\n}","func (e Env) MarshalJSON() ([]byte, error) {\n\tvar b []byte\n\tvar err error\n\tswitch e.Type {\n\tcase EnvValType:\n\t\tb, err = json.Marshal(UnparseEnvVal(*e.Val))\n\tcase EnvFromType:\n\t\tb, err = json.Marshal(e.From)\n\tdefault:\n\t\treturn []byte{}, util.InvalidInstanceError(e.Type)\n\t}\n\n\tif err != nil {\n\t\treturn nil, util.InvalidInstanceErrorf(e, \"couldn't marshal to JSON: %s\", err.Error())\n\t}\n\n\treturn b, nil\n}","func (s) TestJSONEnvVarSet(t *testing.T) {\n\tconfigJSON := `{\n\t\t\"project_id\": \"fake\"\n\t}`\n\tcleanup, err := createTmpConfigInFileSystem(configJSON)\n\tdefer cleanup()\n\n\tif err != nil {\n\t\tt.Fatalf(\"failed to create config in file system: %v\", err)\n\t}\n\tctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)\n\tdefer cancel()\n\tif err := Start(ctx); err != nil {\n\t\tt.Fatalf(\"error starting observability with valid config through file system: %v\", err)\n\t}\n\tdefer End()\n}","func (e *ChefEnvironment) UpdateFromJSON(jsonEnv map[string]interface{}) util.Gerror {\n\tif e.Name != jsonEnv[\"name\"].(string) {\n\t\terr := util.Errorf(\"Environment name %s and %s from JSON do not match\", e.Name, jsonEnv[\"name\"].(string))\n\t\treturn err\n\t} else if e.Name == \"_default\" {\n\t\terr := util.Errorf(\"The '_default' environment cannot be modified.\")\n\t\terr.SetStatus(http.StatusMethodNotAllowed)\n\t\treturn err\n\t}\n\n\t/* Validations */\n\tvalidElements := []string{\"name\", \"chef_type\", \"json_class\", \"description\", \"default_attributes\", \"override_attributes\", \"cookbook_versions\"}\nValidElem:\n\tfor k := range jsonEnv {\n\t\tfor _, i := range validElements {\n\t\t\tif k == i {\n\t\t\t\tcontinue ValidElem\n\t\t\t}\n\t\t}\n\t\terr := util.Errorf(\"Invalid key %s in request body\", k)\n\t\treturn err\n\t}\n\n\tvar verr util.Gerror\n\n\tattrs := []string{\"default_attributes\", \"override_attributes\"}\n\tfor _, a := range attrs {\n\t\tjsonEnv[a], verr = util.ValidateAttributes(a, jsonEnv[a])\n\t\tif verr != nil {\n\t\t\treturn verr\n\t\t}\n\t}\n\n\tjsonEnv[\"json_class\"], verr = util.ValidateAsFieldString(jsonEnv[\"json_class\"])\n\tif verr != nil {\n\t\tif verr.Error() == \"Field 'name' nil\" {\n\t\t\tjsonEnv[\"json_class\"] = e.JSONClass\n\t\t} else {\n\t\t\treturn verr\n\t\t}\n\t} else {\n\t\tif jsonEnv[\"json_class\"].(string) != \"Chef::Environment\" {\n\t\t\tverr = util.Errorf(\"Field 'json_class' invalid\")\n\t\t\treturn verr\n\t\t}\n\t}\n\n\tjsonEnv[\"chef_type\"], verr = util.ValidateAsFieldString(jsonEnv[\"chef_type\"])\n\tif verr != nil {\n\t\tif verr.Error() == \"Field 'name' nil\" {\n\t\t\tjsonEnv[\"chef_type\"] = e.ChefType\n\t\t} else {\n\t\t\treturn verr\n\t\t}\n\t} else {\n\t\tif jsonEnv[\"chef_type\"].(string) != \"environment\" {\n\t\t\tverr = util.Errorf(\"Field 'chef_type' invalid\")\n\t\t\treturn verr\n\t\t}\n\t}\n\n\tjsonEnv[\"cookbook_versions\"], verr = util.ValidateAttributes(\"cookbook_versions\", jsonEnv[\"cookbook_versions\"])\n\tif verr != nil {\n\t\treturn verr\n\t}\n\tfor k, v := range jsonEnv[\"cookbook_versions\"].(map[string]interface{}) {\n\t\tif !util.ValidateEnvName(k) || k == \"\" {\n\t\t\tmerr := util.Errorf(\"Cookbook name %s invalid\", k)\n\t\t\tmerr.SetStatus(http.StatusBadRequest)\n\t\t\treturn merr\n\t\t}\n\n\t\tif v == nil {\n\t\t\tverr = util.Errorf(\"Invalid version number\")\n\t\t\treturn verr\n\t\t}\n\t\t_, verr = util.ValidateAsConstraint(v)\n\t\tif verr != nil {\n\t\t\t/* try validating as a version */\n\t\t\tv, verr = util.ValidateAsVersion(v)\n\t\t\tif verr != nil {\n\t\t\t\treturn verr\n\t\t\t}\n\t\t}\n\t}\n\n\tjsonEnv[\"description\"], verr = util.ValidateAsString(jsonEnv[\"description\"])\n\tif verr != nil {\n\t\tif verr.Error() == \"Field 'name' missing\" {\n\t\t\tjsonEnv[\"description\"] = \"\"\n\t\t} else {\n\t\t\treturn verr\n\t\t}\n\t}\n\n\te.ChefType = jsonEnv[\"chef_type\"].(string)\n\te.JSONClass = jsonEnv[\"json_class\"].(string)\n\te.Description = jsonEnv[\"description\"].(string)\n\te.Default = jsonEnv[\"default_attributes\"].(map[string]interface{})\n\te.Override = jsonEnv[\"override_attributes\"].(map[string]interface{})\n\t/* clear out, then loop over the cookbook versions */\n\te.CookbookVersions = make(map[string]string, len(jsonEnv[\"cookbook_versions\"].(map[string]interface{})))\n\tfor c, v := range jsonEnv[\"cookbook_versions\"].(map[string]interface{}) {\n\t\te.CookbookVersions[c] = v.(string)\n\t}\n\n\treturn nil\n}","func Test(w http.ResponseWriter, r *http.Request) {\n\tres, err := json.Marshal(EnvVariablesModel{Vars: os.Environ(), A: \"b\", C: 123})\n\tif err != nil {\n\t\tcommon.DisplayAppError(\n\t\t\tw,\n\t\t\terr,\n\t\t\t\"An unexpected error has occurred\",\n\t\t\t500,\n\t\t)\n\t\treturn\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Write(res)\n}","func (t envTemplate) Env(secrets map[string]string, sr tpl.SecretReader) (map[string]string, error) {\n\tresult := make(map[string]string)\n\tfor _, tpls := range t.envVars {\n\t\tkey, err := tpls.key.Evaluate(t.templateVarReader, secretReaderNotAllowed{})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\terr = validation.ValidateEnvarName(key)\n\t\tif err != nil {\n\t\t\treturn nil, templateError(tpls.lineNo, err)\n\t\t}\n\n\t\tvalue, err := tpls.value.Evaluate(t.templateVarReader, sr)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tresult[key] = value\n\t}\n\treturn result, nil\n}","func Env(env string) (value []byte, err error) {\n\tvalue, err = exec.Command(\"go\", \"env\", env).Output()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvalue = bytes.TrimSpace(value)\n\n\tif len(value) == 0 {\n\t\terr = ErrEmptyEnv{env}\n\t}\n\n\treturn\n}","func InitEnv() error {\n\tfile, err := ioutil.ReadFile(envPath)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif errMarsh := codec.DecJson(file, &env); errMarsh != nil {\n\t\treturn fmt.Errorf(\"failed to parse %s. decode error: %v\", string(file), err)\n\t}\n\n\treturn nil\n}","func LoadFromEnv(v interface{}, prefix string) (result []MarshalledEnvironmentVar) {\n\tpointerValue := reflect.ValueOf(v)\n\tstructValue := pointerValue.Elem()\n\tstructType := structValue.Type()\n\n\tfor i := 0; i < structValue.NumField(); i++ {\n\t\tstructField := structType.Field(i)\n\t\tfieldValue := structValue.Field(i)\n\n\t\tif fieldValue.CanSet() {\n\t\t\tenvKey := strings.ToUpper(prefix) + gocase.ToUpperSnake(structField.Name)\n\t\t\tenvVal := os.Getenv(envKey)\n\n\t\t\tif envVal != \"\" {\n\t\t\t\t// create a json blob with the env data\n\t\t\t\tjsonStr := \"\"\n\t\t\t\tif fieldValue.Kind() == reflect.String {\n\t\t\t\t\tjsonStr = fmt.Sprintf(`{\"%s\": \"%s\"}`, structField.Name, envVal)\n\t\t\t\t} else {\n\t\t\t\t\tjsonStr = fmt.Sprintf(`{\"%s\": %s}`, structField.Name, envVal)\n\t\t\t\t}\n\n\t\t\t\terr := json.Unmarshal([]byte(jsonStr), v)\n\t\t\t\tresult = append(result, MarshalledEnvironmentVar{envKey, envVal, structField.Name, err})\n\t\t\t}\n\t\t}\n\t}\n\n\treturn\n}","func (e *Env) UnmarshalJSON(value []byte) error {\n\tvar s string\n\terr := json.Unmarshal(value, &s)\n\tif err == nil {\n\t\tenvVal := ParseEnvVal(s)\n\t\te.SetVal(*envVal)\n\t\treturn nil\n\t}\n\n\tfrom := EnvFrom{}\n\terr = json.Unmarshal(value, &from)\n\tif err == nil {\n\t\te.SetFrom(from)\n\t\treturn nil\n\t}\n\n\treturn util.InvalidInstanceErrorf(e, \"couldn't parse from (%s)\", string(value))\n}","func NewEnvironment(jsonData string) (*Environment, error) {\n\t// initialize env with input data\n\tenv := new(Environment)\n\terr := serialize.CopyFromJSON(jsonData, env)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn env, nil\n}","func (value *Env) Eval(ctx context.Context, env *Env, cont Cont) ReadyCont {\n\treturn cont.Call(value, nil)\n}","func LoadTestEnv() *core.Engine {\n\tengine := new(core.Engine)\n\n\t_, dir, _, _ := runtime.Caller(0)\n\tconfigJSON := filepath.Join(filepath.Dir(dir), \"../..\", \"env\", \"tdd.json\")\n\n\tjsonFile, err := os.Open(configJSON)\n\n\tif err != nil {\n\t\tlog.Fatalln(err, \"can't open the config file\", dir+\"/regularenvs.json\")\n\t}\n\n\tdefer jsonFile.Close()\n\n\tbyteValue, _ := ioutil.ReadAll(jsonFile)\n\n\terr = json.Unmarshal(byteValue, &engine.Env)\n\tif err != nil {\n\t\tlog.Fatalln(err, \"error in unmarshal JSON\")\n\t}\n\n\tif engine.Env.MachineID, err = machineid.ProtectedID(\"SigmaMono\"); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn engine\n}","func NewFromJSON(jsonEnv map[string]interface{}) (*ChefEnvironment, util.Gerror) {\n\tenv, err := New(jsonEnv[\"name\"].(string))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = env.UpdateFromJSON(jsonEnv)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn env, nil\n}","func (cx *Context) Eval(source string, result interface{}) (err error) {\n\tcx.do(func(ptr *C.JSAPIContext) {\n\t\t// alloc C-string\n\t\tcsource := C.CString(source)\n\t\tdefer C.free(unsafe.Pointer(csource))\n\t\tvar jsonData *C.char\n\t\tvar jsonLen C.int\n\t\tfilename := \"eval\"\n\t\tcfilename := C.CString(filename)\n\t\tdefer C.free(unsafe.Pointer(cfilename))\n\t\t// eval\n\t\tif C.JSAPI_EvalJSON(ptr, csource, cfilename, &jsonData, &jsonLen) != C.JSAPI_OK {\n\t\t\terr = cx.getError(filename)\n\t\t\treturn\n\t\t}\n\t\tdefer C.free(unsafe.Pointer(jsonData))\n\t\t// convert to go\n\t\tb := []byte(C.GoStringN(jsonData, jsonLen))\n\t\tif raw, ok := result.(*Raw); ok {\n\t\t\t*raw = Raw(string(b))\n\t\t} else {\n\t\t\terr = json.Unmarshal(b, result)\n\t\t}\n\t})\n\treturn err\n}","func (o BuildRunStatusBuildSpecRuntimeOutput) Env() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v BuildRunStatusBuildSpecRuntime) map[string]string { return v.Env }).(pulumi.StringMapOutput)\n}","func (o BuildSpecRuntimeOutput) Env() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v BuildSpecRuntime) map[string]string { return v.Env }).(pulumi.StringMapOutput)\n}","func ReadEnv(c interface{}) {\r\n\tfor _, value := range os.Environ() {\r\n\t\tif strings.HasPrefix(value, \"ENV_\") {\r\n\t\t\tkv := strings.SplitN(value,\"=\",2)\r\n\t\t\tkv[0] = strings.ToLower(strings.Replace(kv[0],\"_\",\".\",-1))[4:]\r\n\t\t\tSetData(c,strings.Join(kv,\"=\"))\r\n\t\t}\r\n\t}\r\n}","func buildEnvironment(env []string) (map[string]string, error) {\n result := make(map[string]string, len(env))\n for _, s := range env {\n // if value is empty, s is like \"K=\", not \"K\".\n if !strings.Contains(s, \"=\") {\n return result, errors.Errorf(\"unexpected environment %q\", s)\n }\n kv := strings.SplitN(s, \"=\", 2)\n result[kv[0]] = kv[1]\n }\n return result, nil\n}","func (o StorageClusterSpecNodesOutput) Env() StorageClusterSpecNodesEnvArrayOutput {\n\treturn o.ApplyT(func(v StorageClusterSpecNodes) []StorageClusterSpecNodesEnv { return v.Env }).(StorageClusterSpecNodesEnvArrayOutput)\n}","func LoadEnvironment(object interface{}, metaDataKey string) error {\n\tvar values = func(key string) (string, bool) {\n\t\treturn os.LookupEnv(key)\n\t}\n\treturn commonLoad(values, object, metaDataKey)\n}","func (b *taskBuilder) env(key, value string) {\n\tif b.Spec.Environment == nil {\n\t\tb.Spec.Environment = map[string]string{}\n\t}\n\tb.Spec.Environment[key] = value\n}","func GetENV(experimentDetails *experimentTypes.ExperimentDetails) {\n\texperimentDetails.ExperimentName = Getenv(\"EXPERIMENT_NAME\", \"\")\n\texperimentDetails.AppNS = Getenv(\"APP_NS\", \"\")\n\texperimentDetails.TargetContainer = Getenv(\"APP_CONTAINER\", \"\")\n\texperimentDetails.TargetPods = Getenv(\"APP_POD\", \"\")\n\texperimentDetails.AppLabel = Getenv(\"APP_LABEL\", \"\")\n\texperimentDetails.ChaosDuration, _ = strconv.Atoi(Getenv(\"TOTAL_CHAOS_DURATION\", \"30\"))\n\texperimentDetails.ChaosNamespace = Getenv(\"CHAOS_NAMESPACE\", \"litmus\")\n\texperimentDetails.EngineName = Getenv(\"CHAOS_ENGINE\", \"\")\n\texperimentDetails.ChaosUID = clientTypes.UID(Getenv(\"CHAOS_UID\", \"\"))\n\texperimentDetails.ChaosPodName = Getenv(\"POD_NAME\", \"\")\n\texperimentDetails.ContainerRuntime = Getenv(\"CONTAINER_RUNTIME\", \"\")\n\texperimentDetails.NetworkInterface = Getenv(\"NETWORK_INTERFACE\", \"eth0\")\n\texperimentDetails.TargetIPs = Getenv(\"TARGET_IPs\", \"\")\n}","func requireEnv(envVar string) string {\n\tval, _ := getEnv(envVar, true)\n\treturn val\n}","func NewEnv(loader *ScriptLoader, debugging bool) *Env {\n\tenv := &Env{\n\t\tvm: otto.New(),\n\t\tloader: loader,\n\t\tdebugging: debugging,\n\t\tbuiltinModules: make(map[string]otto.Value),\n\t\tbuiltinModuleFactories: make(map[string]BuiltinModuleFactory),\n\t}\n\tenv.vm.Set(\"__getModulePath\", func(call otto.FunctionCall) otto.Value {\n\t\tvm := call.Otto\n\t\tvar cwd, moduleID string\n\t\tvar err error\n\t\tif cwd, err = call.Argument(0).ToString(); err != nil {\n\t\t\tpanic(vm.MakeCustomError(\"__getModulePath error\", err.Error()))\n\t\t}\n\t\tif moduleID, err = call.Argument(1).ToString(); err != nil {\n\t\t\tpanic(vm.MakeCustomError(\"__getModulePath error\", err.Error()))\n\t\t}\n\t\tif _, found := env.builtinModules[moduleID]; found {\n\t\t\tret, _ := otto.ToValue(moduleID)\n\t\t\treturn ret\n\t\t}\n\t\tif _, found := env.builtinModuleFactories[moduleID]; found {\n\t\t\tret, _ := otto.ToValue(moduleID)\n\t\t\treturn ret\n\t\t}\n\t\tif ap, err := env.loader.GetModuleAbs(cwd, moduleID); err != nil {\n\t\t\tpanic(vm.MakeCustomError(\"__getModulePath error\", err.Error()))\n\t\t} else {\n\t\t\tret, _ := otto.ToValue(ap)\n\t\t\treturn ret\n\t\t}\n\t})\n\tvar requireSrc string\n\tif env.debugging {\n\t\trequireSrc = debugRequireSrc\n\t} else {\n\t\trequireSrc = releaseRequireSrc\n\t}\n\tenv.vm.Set(\"__loadSource\", func(call otto.FunctionCall) otto.Value {\n\t\tvar mp string\n\t\tvar err error\n\t\tvm := call.Otto\n\t\t// reading arguments\n\t\tif mp, err = call.Argument(0).ToString(); err != nil {\n\t\t\tpanic(vm.MakeCustomError(\"__loadSource error\", err.Error()))\n\t\t}\n\t\t// finding built builtin modules\n\t\tif mod, found := env.builtinModules[mp]; found {\n\t\t\tretObj, _ := vm.Object(\"({isBuiltin: true})\")\n\t\t\tretObj.Set(\"builtin\", mod)\n\t\t\treturn retObj.Value()\n\t\t}\n\t\t// finding unbuilt builtin modules\n\t\tif mf, found := env.builtinModuleFactories[mp]; found {\n\t\t\tretObj, _ := vm.Object(\"({isBuiltin: true})\")\n\t\t\tmod := mf.CreateModule(vm)\n\t\t\tretObj.Set(\"builtin\", mod)\n\t\t\tenv.builtinModules[mp] = mod\n\t\t\treturn retObj.Value()\n\t\t}\n\t\t// loading module on file system\n\t\tsrc, err := env.loader.LoadScript(mp)\n\t\tif err != nil {\n\t\t\tpanic(vm.MakeCustomError(\"__loadSource error\", err.Error()))\n\t\t}\n\t\tscript, err := vm.Compile(mp, src)\n\t\tif err != nil {\n\t\t\tpanic(vm.MakeCustomError(\"__loadSource error\", err.Error()))\n\t\t}\n\t\tmodValue, err := vm.Run(script)\n\t\tif err != nil {\n\t\t\tpanic(vm.MakeCustomError(\"__loadSource error\", err.Error()))\n\t\t}\n\t\tretObj, _ := vm.Object(\"({})\")\n\t\tretObj.Set(\"src\", modValue)\n\t\tretObj.Set(\"filename\", path.Base(mp))\n\t\tretObj.Set(\"dirname\", path.Dir(mp))\n\t\treturn retObj.Value()\n\t})\n\t_, err := env.vm.Run(requireSrc)\n\tif err != nil {\n\t\tswitch err.(type) {\n\t\tcase *otto.Error:\n\t\t\tpanic(err.(otto.Error).String())\n\t\tdefault:\n\t\t\tpanic(err)\n\t\t}\n\t}\n\treturn env\n}","func (job *Job) DecodeEnv(src io.Reader) error {\n\treturn job.Env.Decode(src)\n}","func SyncEnvVar(env interface{}) {\n\tbs, err := json.Marshal(&env)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tenvVar := map[string]string{}\n\terr = json.Unmarshal(bs, &envVar)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tviper.AutomaticEnv()\n\tfor k := range envVar {\n\t\tval := viper.GetString(k)\n\t\tif val != \"\" {\n\t\t\tenvVar[k] = val\n\t\t}\n\t}\n\n\tbs, err = json.Marshal(envVar)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\terr = json.Unmarshal(bs, &env)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}","func envFun(args ...object.Object) object.Object {\n\n\tenv := os.Environ()\n\tnewHash := make(map[object.HashKey]object.HashPair)\n\n\t//\n\t// If we get a match then the output is an array\n\t// First entry is the match, any additional parts\n\t// are the capture-groups.\n\t//\n\tfor i := 1; i < len(env); i++ {\n\n\t\t// Capture groups start at index 0.\n\t\tk := &object.String{Value: env[i]}\n\t\tv := &object.String{Value: os.Getenv(env[i])}\n\n\t\tnewHashPair := object.HashPair{Key: k, Value: v}\n\t\tnewHash[k.HashKey()] = newHashPair\n\t}\n\n\treturn &object.Hash{Pairs: newHash}\n}","func LookupEnv(key string) (string, bool)","func Env(env Environ) func(*Runner) error {\n\treturn func(r *Runner) error {\n\t\tif env == nil {\n\t\t\tenv, _ = EnvFromList(os.Environ())\n\t\t}\n\t\tr.Env = env\n\t\treturn nil\n\t}\n}","func (e *execution) parseEnvInputs() []apiv1.EnvVar {\n\tvar data []apiv1.EnvVar\n\n\tfor _, val := range e.envInputs {\n\t\ttmp := apiv1.EnvVar{Name: val.Name, Value: val.Value}\n\t\tdata = append(data, tmp)\n\t}\n\n\treturn data\n}","func (o BuildRunStatusBuildSpecRuntimePtrOutput) Env() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *BuildRunStatusBuildSpecRuntime) map[string]string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Env\n\t}).(pulumi.StringMapOutput)\n}","func setEnv(d interface{}) {\n\tVCAP := os.Getenv(\"VCAP_SERVICES\")\n\tif VCAP == \"\" {\n\t\treturn // no environment found so use whatever DBURL is set to\n\t}\n\tb := []byte(VCAP)\n\terr := json.Unmarshal(b, d) \n\tif err != nil {\n\t\tfmt.Printf(\"dbhandler:setEnv:ERROR:%s\", err)\n\t}\n}","func Getenv(key string) string","func Eval(t testing.TestingT, options *EvalOptions, jsonFilePaths []string, resultQuery string) {\n\trequire.NoError(t, EvalE(t, options, jsonFilePaths, resultQuery))\n}","func importEnv(e []string) *phpv.ZHashTable {\n\tzt := phpv.NewHashTable()\n\n\tfor _, s := range e {\n\t\tp := strings.IndexByte(s, '=')\n\t\tif p != -1 {\n\t\t\tzt.SetString(phpv.ZString(s[:p]), phpv.ZString(s[p+1:]).ZVal())\n\t\t}\n\t}\n\n\treturn zt\n}","func (om *OpenMock) ParseEnv() {\n\terr := env.Parse(om)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}","func parseEnv(envs []string) map[string]string {\n\tout := make(map[string]string)\n\tfor _, v := range envs {\n\t\tp := strings.SplitN(v, \"=\", 2)\n\t\tout[p[0]] = p[1]\n\t}\n\treturn out\n}","func RenderWithEnv(s string, ext map[string]string) string {\n\tmatches := regexpEnvironmentVar.FindAllString(s, -1)\n\tfor _, match := range matches {\n\t\tkey := match[1:]\n\t\tval := ext[key]\n\t\tif val == \"\" {\n\t\t\tval = os.Getenv(key)\n\t\t}\n\t\tif val != \"\" {\n\t\t\ts = strings.ReplaceAll(s, match, val)\n\t\t}\n\t}\n\treturn s\n}","func AccessTokensFromEnvJSON(env string) []string {\n\taccessTokens := []string{}\n\tif len(env) == 0 {\n\t\treturn accessTokens\n\t}\n\terr := json.Unmarshal([]byte(env), &accessTokens)\n\tif err != nil {\n\t\tlog.Entry().Infof(\"Token json '%v' has wrong format.\", env)\n\t}\n\treturn accessTokens\n}","func GetEnv(en []map[string]string, key string) string {\n\ts := \"\"\n\tfor _, e := range en {\n\t\tif v, ok := e[key]; ok {\n\t\t\ts = v\n\t\t}\n\t}\n\treturn s\n}","func (hc ApplicationsController) EnvSet(w http.ResponseWriter, r *http.Request) APIErrors {\n\tctx := r.Context()\n\tlog := tracelog.Logger(ctx)\n\n\tparams := httprouter.ParamsFromContext(ctx)\n\torgName := params.ByName(\"org\")\n\tappName := params.ByName(\"app\")\n\n\tlog.Info(\"processing environment variable assignment\",\n\t\t\"org\", orgName, \"app\", appName)\n\n\tcluster, err := kubernetes.GetCluster(ctx)\n\tif err != nil {\n\t\treturn InternalError(err)\n\t}\n\n\texists, err := organizations.Exists(ctx, cluster, orgName)\n\tif err != nil {\n\t\treturn InternalError(err)\n\t}\n\n\tif !exists {\n\t\treturn OrgIsNotKnown(orgName)\n\t}\n\n\tapp := models.NewAppRef(appName, orgName)\n\n\texists, err = application.Exists(ctx, cluster, app)\n\tif err != nil {\n\t\treturn InternalError(err)\n\t}\n\n\tif !exists {\n\t\treturn AppIsNotKnown(appName)\n\t}\n\n\tdefer r.Body.Close()\n\tbodyBytes, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\treturn InternalError(err)\n\t}\n\n\tvar setRequest models.EnvVariableList\n\terr = json.Unmarshal(bodyBytes, &setRequest)\n\tif err != nil {\n\t\treturn BadRequest(err)\n\t}\n\n\terr = application.EnvironmentSet(ctx, cluster, app, setRequest)\n\tif err != nil {\n\t\treturn InternalError(err)\n\t}\n\n\treturn nil\n}","func assertEnv(ctx context.Context, client client.Client, spec corev1.PodSpec, component, container, key, expectedValue string) error {\n\tvalue, err := getEnv(ctx, client, spec, component, container, key)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif value != nil && strings.ToLower(*value) != expectedValue {\n\t\treturn ErrIncompatibleCluster{\n\t\t\terr: fmt.Sprintf(\"%s=%s is not supported\", key, *value),\n\t\t\tcomponent: component,\n\t\t\tfix: fmt.Sprintf(\"remove the %s env var or set it to '%s'\", key, expectedValue),\n\t\t}\n\t}\n\n\treturn nil\n}","func env(key string, fallback string) string {\n\tif v := os.Getenv(key); v != \"\" {\n\t\treturn v\n\t}\n\treturn fallback\n}","func ExpandEnv(env map[string]string, otherEnv map[string]string) map[string]string {\n\tresult := make(map[string]string)\n\n\tfor k, v := range env {\n\t\texpandV := os.Expand(v, func (key string) string { return otherEnv[key] })\n\t\tresult[k] = expandV\n\t}\n\n\treturn result\n}","func Env(def, key string, fallbacks ...string) string {\n\tif val, found := LookupEnv(key, fallbacks...); found {\n\t\treturn val\n\t}\n\treturn def\n}","func TestEnvironmentGet(t *testing.T) {\n\tport := make(chan int, 1)\n\tdefer createTestServer(port, t).Close()\n\taddr := <-port\n\tresp, err := http.Get(fmt.Sprintf(\"http://localhost:%d/env/get\", addr))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer resp.Body.Close()\n\tbodyContent, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif string(bodyContent) != \"Testing env.set function\" {\n\t\tt.Fatalf(\"Wrong env.get value. Expected 'Testing env.set function' but got '%s'\", string(bodyContent))\n\t}\n}","func readEnviromentFile() *ServerEnv {\n\tvar serverEnv ServerEnv\n\tjsonFile, err := os.Open(\"dist/env.json\")\n\tif err != nil {\n\t\tfmt.Printf(\":0 PANIK , enviroment json not attempting local dir found\")\n\t\tjsonFile, err = os.Open(\"env.json\")\n\t\tif err != nil {\n\t\t\tpanic(\":0 PANIK , enviroment json not found\")\n\t\t}\n\t}\n\tbyteValue, _ := ioutil.ReadAll(jsonFile)\n\terr = json.Unmarshal(byteValue, &serverEnv)\n\tif err != nil {\n\t\tpanic(\":0 PANIK , enviroment json could not decode\")\n\t}\n\treturn &serverEnv\n}","func (v LiteralValue) Eval(*Environment) (document.Value, error) {\n\treturn document.Value(v), nil\n}","func getEnvFun(args ...object.Object) object.Object {\n\tif len(args) != 1 {\n\t\treturn newError(\"wrong number of arguments. got=%d, want=1\",\n\t\t\tlen(args))\n\t}\n\tif args[0].Type() != object.STRING_OBJ {\n\t\treturn newError(\"argument must be a string, got=%s\",\n\t\t\targs[0].Type())\n\t}\n\tinput := args[0].(*object.String).Value\n\treturn &object.String{Value: os.Getenv(input)}\n\n}","func assertJSON(e *ptesting.Environment, out string, respObj interface{}) {\n\terr := json.Unmarshal([]byte(out), &respObj)\n\tif err != nil {\n\t\te.Errorf(\"unable to unmarshal %v\", out)\n\t}\n}","func environ(envVars []*apiclient.EnvEntry) []string {\n\tvar environ []string\n\tfor _, item := range envVars {\n\t\tif item != nil && item.Name != \"\" && item.Value != \"\" {\n\t\t\tenviron = append(environ, fmt.Sprintf(\"%s=%s\", item.Name, item.Value))\n\t\t}\n\t}\n\treturn environ\n}","func (ci MrbCallInfo) Env() REnv {\n\treturn REnv{C.mrb_vm_ci_env(ci.p), nil}\n}","func Evaluate(expr string, contextVars map[string]logol.Match) bool {\n\tlogger.Debugf(\"Evaluate expression: %s\", expr)\n\n\tre := regexp.MustCompile(\"[$@#]+\\\\w+\")\n\tres := re.FindAllString(expr, -1)\n\t// msg, _ := json.Marshal(contextVars)\n\t// logger.Errorf(\"CONTEXT: %s\", msg)\n\tparameters := make(map[string]interface{}, 8)\n\tvarIndex := 0\n\tfor _, val := range res {\n\t\tt := strconv.Itoa(varIndex)\n\t\tvarName := \"VAR\" + t\n\t\tr := strings.NewReplacer(val, varName)\n\t\texpr = r.Replace(expr)\n\t\tvarIndex++\n\t\tcValue, cerr := getValueFromExpression(val, contextVars)\n\t\tif cerr {\n\t\t\tlogger.Debugf(\"Failed to get value from expression %s\", val)\n\t\t\treturn false\n\t\t}\n\t\tparameters[varName] = cValue\n\t}\n\tlogger.Debugf(\"New expr: %s with params %v\", expr, parameters)\n\n\texpression, err := govaluate.NewEvaluableExpression(expr)\n\tif err != nil {\n\t\tlogger.Errorf(\"Failed to evaluate expression %s\", expr)\n\t\treturn false\n\t}\n\tresult, _ := expression.Evaluate(parameters)\n\tif result == true {\n\t\treturn true\n\t}\n\treturn false\n}","func (b *Executable) Env(arg, value string) *Executable {\n\tif b.Environment == nil {\n\t\tb.Environment = make(map[string]string)\n\t}\n\tb.Environment[arg] = value\n\treturn b\n}","func parseEnv(name, defval string, parsefn func(string) error) {\n\tif envval := os.Getenv(name); envval != \"\" {\n\t\terr := parsefn(envval)\n\t\tif err == nil {\n\t\t\treturn\n\t\t}\n\t\tlog.Error(\"invalid environment %s=%q: %v, using default %q\", name, envval, err, defval)\n\t}\n\tif err := parsefn(defval); err != nil {\n\t\tlog.Error(\"invalid default %s=%q: %v\", name, defval, err)\n\t}\n}","func evaluateENVBool(envVar string, defaultValue bool) bool {\n\tenvValue, isSet := os.LookupEnv(envVar)\n\n\tif isSet {\n\n\t\tswitch strings.ToLower(envValue) {\n\n\t\tcase \"false\", \"0\", \"no\", \"n\", \"f\":\n\t\t\tlog.Infof(\"%s is %t through environment variable\", envVar, false)\n\t\t\treturn false\n\t\t}\n\t\tlog.Infof(\"%s is %t through environment variable\", envVar, true)\n\t\treturn true\n\t}\n\tlog.Infof(\"%s is %t (defaulted) through environment variable\", envVar, defaultValue)\n\treturn defaultValue\n}","func (c *Cli) ParseEnv() error {\n\tvar (\n\t\terr error\n\t\tu64 uint64\n\t)\n\tfor k, e := range c.env {\n\t\ts := strings.TrimSpace(os.Getenv(k))\n\t\t// NOTE: we only parse the environment if it is not an emprt string\n\t\tif s != \"\" {\n\t\t\tswitch e.Type {\n\t\t\tcase \"bool\":\n\t\t\t\te.BoolValue, err = strconv.ParseBool(s)\n\t\t\tcase \"int\":\n\t\t\t\te.IntValue, err = strconv.Atoi(s)\n\t\t\tcase \"int64\":\n\t\t\t\te.Int64Value, err = strconv.ParseInt(s, 10, 64)\n\t\t\tcase \"uint\":\n\t\t\t\tu64, err = strconv.ParseUint(s, 10, 32)\n\t\t\t\te.UintValue = uint(u64)\n\t\t\tcase \"uint64\":\n\t\t\t\te.Uint64Value, err = strconv.ParseUint(s, 10, 64)\n\t\t\tcase \"float64\":\n\t\t\t\te.Float64Value, err = strconv.ParseFloat(s, 64)\n\t\t\tcase \"time.Duration\":\n\t\t\t\te.DurationValue, err = time.ParseDuration(s)\n\t\t\tdefault:\n\t\t\t\te.StringValue = s\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"%q should be type %q, %s\", e.Name, e.Type, err)\n\t\t\t}\n\t\t}\n\t\tc.env[k] = e\n\t}\n\treturn err\n}","func addEnv(s *scope, arg pyObject, target *core.BuildTarget) {\n\tenvPy, ok := asDict(arg)\n\ts.Assert(ok, \"env must be a dict\")\n\n\tenv := make(map[string]string, len(envPy))\n\tfor name, val := range envPy {\n\t\tv, ok := val.(pyString)\n\t\ts.Assert(ok, \"Values of env must be strings, found %v at key %v\", val.Type(), name)\n\t\tenv[name] = string(v)\n\t}\n\n\ttarget.Env = env\n}","func env() error {\n\t// regexp for TF_VAR_ terraform vars\n\ttfVar := regexp.MustCompile(`^TF_VAR_.*$`)\n\n\t// match terraform vars in environment\n\tfor _, e := range os.Environ() {\n\t\t// split on value\n\t\tpair := strings.SplitN(e, \"=\", 2)\n\n\t\t// match on TF_VAR_*\n\t\tif tfVar.MatchString(pair[0]) {\n\t\t\t// pull out the name\n\t\t\tname := strings.Split(pair[0], \"TF_VAR_\")\n\n\t\t\t// lower case the terraform variable\n\t\t\t// to accommodate cicd injection capitalization\n\t\t\terr := os.Setenv(fmt.Sprintf(\"TF_VAR_%s\",\n\t\t\t\tstrings.ToLower(name[1])), pair[1])\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}","func validateEnv(vars []corev1.EnvVar, fldPath *field.Path) field.ErrorList {\n\tallErrs := field.ErrorList{}\n\n\tfor i, ev := range vars {\n\t\tidxPath := fldPath.Index(i)\n\t\tif len(ev.Name) == 0 {\n\t\t\tallErrs = append(allErrs, field.Required(idxPath.Child(\"name\"), \"\"))\n\t\t} else {\n\t\t\tfor _, msg := range validation.IsEnvVarName(ev.Name) {\n\t\t\t\tallErrs = append(allErrs, field.Invalid(idxPath.Child(\"name\"), ev.Name, msg))\n\t\t\t}\n\t\t}\n\t\tallErrs = append(allErrs, validateEnvVarValueFrom(ev, idxPath.Child(\"valueFrom\"))...)\n\t}\n\treturn allErrs\n}","func UnmarshalFromEnv(c interface{}) {\n\ttopType := reflect.TypeOf(c).Elem()\n\ttopValue := reflect.ValueOf(c)\n\tfor i := 0; i < topType.NumField(); i++ {\n\t\tfield := topType.Field(i)\n\t\tif field.Tag.Get(\"env\") != \"\" {\n\t\t\tenvVar := os.Getenv(field.Tag.Get(\"env\"))\n\t\t\tif envVar == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tswitch field.Type.Kind() {\n\t\t\tcase reflect.Bool:\n\t\t\t\tb, err := strconv.ParseBool(envVar)\n\t\t\t\tif err != nil {\n\t\t\t\t\tfmt.Println(\"didn't set from \", field.Tag.Get(\"env\"), \" due to \", err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tf := topValue.Elem().Field(i)\n\t\t\t\tf.SetBool(b)\n\t\t\tcase reflect.Int64:\n\t\t\t\tinteger, err := strconv.ParseInt(envVar, 0, 64)\n\t\t\t\tif err != nil {\n\t\t\t\t\tfmt.Println(\"didn't set from \", field.Tag.Get(\"env\"), \" due to \", err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tf := topValue.Elem().Field(i)\n\t\t\t\tf.SetInt(integer)\n\t\t\tcase reflect.String:\n\t\t\t\tf := topValue.Elem().Field(i)\n\t\t\t\tf.SetString(envVar)\n\t\t\tcase reflect.Float64:\n\t\t\t\tfloat, err := strconv.ParseFloat(envVar, 64)\n\t\t\t\tif err != nil {\n\t\t\t\t\tfmt.Println(\"didn't set from \", field.Tag.Get(\"env\"), \" due to \", err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tf := topValue.Elem().Field(i)\n\t\t\t\tf.SetFloat(float)\n\t\t\t}\n\t\t}\n\t}\n}","func env(key string, defaultValue string) string {\n\tif value, exists := os.LookupEnv(key); exists {\n\t\treturn value\n\t}\n\treturn defaultValue\n}","func NewJsonEnvironment() *JsonEnvironment {\n\tthis := JsonEnvironment{}\n\treturn &this\n}","func RunJSONSerializationTestForHostingEnvironmentProfile(subject HostingEnvironmentProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual HostingEnvironmentProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func MatchEnv(k string) bool {\n\n\tkey := strings.TrimPrefix(k, \"/\")\n\tkeyEnv := strings.Split(key, \"/\")\n\tif len(keyEnv) > 3 {\n\t\tif (keyEnv[2] == os.Getenv(\"VINE_ENV\")) && (keyEnv[3] == \"routes\") {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}","func (p RProc) Env() REnv {\n\tif !p.HasEnv() {\n\t\treturn REnv{nil, p.mrb}\n\t}\n\treturn REnv{C._MRB_PROC_ENV(p.p), p.mrb}\n}","func parseIPEnvironment(envName, envValue string, version int) string {\n\t// To parse the environment (which could be an IP or a CIDR), convert\n\t// to a JSON string and use the UnmarshalJSON method on the IPNet\n\t// struct to parse the value.\n\tip := &cnet.IPNet{}\n\terr := ip.UnmarshalJSON([]byte(\"\\\"\" + envValue + \"\\\"\"))\n\tif err != nil || ip.Version() != version {\n\t\tlog.Warnf(\"Environment does not contain a valid IPv%d address: %s=%s\", version, envName, envValue)\n\t\tutils.Terminate()\n\t}\n\tlog.Infof(\"Using IPv%d address from environment: %s=%s\", ip.Version(), envName, envValue)\n\n\treturn ip.String()\n}","func standardEnv() map[string]interface{} {\r\n env := make(map[string]interface{}, 0)\r\n env[\"false\"] = false\r\n env[\"true\"] = true\r\n env[\"+\"] = func(args []interface{}) interface{} {\r\n\tn, ok1 := args[0].(int)\r\n\tm, ok2 := args[1].(int)\r\n\tif !ok1 || !ok2 {\r\n\t panic(\"+ needs numbers\")\r\n\t}\r\n\treturn n + m\r\n }\r\n return env\r\n}","func (b *builtinValuesJSONSig) evalJSON(_ chunk.Row) (types.BinaryJSON, bool, error) {\n\trow := b.ctx.GetSessionVars().CurrInsertValues\n\tif row.IsEmpty() {\n\t\treturn types.BinaryJSON{}, true, nil\n\t}\n\tif b.offset < row.Len() {\n\t\tif row.IsNull(b.offset) {\n\t\t\treturn types.BinaryJSON{}, true, nil\n\t\t}\n\t\treturn row.GetJSON(b.offset), false, nil\n\t}\n\treturn types.BinaryJSON{}, true, errors.Errorf(\"Session current insert values len %d and column's offset %v don't match\", row.Len(), b.offset)\n}","func MakeEvalEnv() eval.Env {\n\tvar pkgs map[string] eval.Pkg = make(map[string] eval.Pkg)\n\tEvalEnvironment(pkgs)\n\n\tenv := eval.Env {\n\t\tName: \".\",\n\t\tVars: make(map[string] reflect.Value),\n\t\tConsts: make(map[string] reflect.Value),\n\t\tFuncs: make(map[string] reflect.Value),\n\t\tTypes: make(map[string] reflect.Type),\n\t\tPkgs: pkgs,\n\t}\n\treturn env\n}","func (r *CheckedDaemonSet) assertEnv(ctx context.Context, client client.Client, container, key, expectedValue string) error {\n\tif err := assertEnv(ctx, client, r.Spec.Template.Spec, ComponentCalicoNode, container, key, expectedValue); err != nil {\n\t\treturn err\n\t}\n\tr.ignoreEnv(container, key)\n\treturn nil\n}","func CheckEnv(lookupFunc func(key string) (string, bool)) (err error) {\n\tif lookupFunc == nil {\n\t\tlookupFunc = os.LookupEnv\n\t}\n\n\tenvVars := [4]string{\n\t\tEnvHueBridgeAddress,\n\t\tEnvHueBridgeUsername,\n\t\tEnvHueRemoteToken,\n\t\tEnvRedisURL,\n\t}\n\n\tfor _, v := range envVars {\n\t\tif _, ok := lookupFunc(v); !ok {\n\t\t\treturn models.NewMissingEnvError(v)\n\t\t}\n\t}\n\n\treturn nil\n}","func toEnv(spec *engine.Spec, step *engine.Step) []v1.EnvVar {\n\tvar to []v1.EnvVar\n\tfor k, v := range step.Envs {\n\t\tto = append(to, v1.EnvVar{\n\t\t\tName: k,\n\t\t\tValue: v,\n\t\t})\n\t}\n\tto = append(to, v1.EnvVar{\n\t\tName: \"KUBERNETES_NODE\",\n\t\tValueFrom: &v1.EnvVarSource{\n\t\t\tFieldRef: &v1.ObjectFieldSelector{\n\t\t\t\tFieldPath: \"spec.nodeName\",\n\t\t\t},\n\t\t},\n\t})\n\tfor _, secret := range step.Secrets {\n\t\tsec, ok := engine.LookupSecret(spec, secret)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\t\toptional := true\n\t\tto = append(to, v1.EnvVar{\n\t\t\tName: secret.Env,\n\t\t\tValueFrom: &v1.EnvVarSource{\n\t\t\t\tSecretKeyRef: &v1.SecretKeySelector{\n\t\t\t\t\tLocalObjectReference: v1.LocalObjectReference{\n\t\t\t\t\t\tName: sec.Metadata.UID,\n\t\t\t\t\t},\n\t\t\t\t\tKey: sec.Metadata.UID,\n\t\t\t\t\tOptional: &optional,\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t}\n\treturn to\n}","func Eval(node ast.Node, env *object.Environment) object.Object {\n\tswitch node := node.(type) {\n\n\t// Statements\n\tcase *ast.RootNode:\n\t\treturn evalRootNode(node, env)\n\n\tcase *ast.BlockStatement:\n\t\treturn evalBlockStmt(node, env)\n\n\tcase *ast.ExpressionStatement:\n\t\treturn Eval(node.Expression, env)\n\n\tcase *ast.ReturnStatement:\n\t\tval := Eval(node.ReturnValue, env)\n\t\tif isError(val) {\n\t\t\treturn val\n\t\t}\n\t\treturn &object.ReturnValue{Value: val}\n\n\tcase *ast.LetStatement:\n\t\tval := Eval(node.Value, env)\n\t\tif isError(val) {\n\t\t\treturn val\n\t\t}\n\t\tenv.Set(node.Name.Value, val)\n\n\tcase *ast.ConstStatement:\n\t\tval := Eval(node.Value, env)\n\t\tif isError(val) {\n\t\t\treturn val\n\t\t}\n\t\tenv.Set(node.Name.Value, val)\n\n\t// Expressions\n\tcase *ast.IntegerLiteral:\n\t\treturn &object.Integer{Value: node.Value}\n\n\tcase *ast.StringLiteral:\n\t\treturn &object.String{Value: node.Value}\n\n\tcase *ast.Boolean:\n\t\treturn nativeBoolToBooleanObj(node.Value)\n\n\tcase *ast.PrefixExpression:\n\t\tright := Eval(node.Right, env)\n\t\tif isError(right) {\n\t\t\treturn right\n\t\t}\n\t\treturn evalPrefixExpr(node.Operator, right, node.Token.Line)\n\n\tcase *ast.InfixExpression:\n\t\tleft := Eval(node.Left, env)\n\t\tif isError(left) {\n\t\t\treturn left\n\t\t}\n\t\tright := Eval(node.Right, env)\n\t\tif isError(right) {\n\t\t\treturn right\n\t\t}\n\t\treturn evalInfixExpr(node.Operator, left, right, node.Token.Line)\n\n\tcase *ast.PostfixExpression:\n\t\treturn evalPostfixExpr(env, node.Operator, node)\n\n\tcase *ast.IfExpression:\n\t\treturn evalIfExpr(node, env)\n\n\tcase *ast.Identifier:\n\t\treturn evalIdentifier(node, env)\n\n\tcase *ast.FunctionLiteral:\n\t\tparams := node.Parameters\n\t\tbody := node.Body\n\t\treturn &object.Function{\n\t\t\tParameters: params,\n\t\t\tBody: body,\n\t\t\tEnv: env,\n\t\t}\n\n\tcase *ast.CallExpression:\n\t\tfn := Eval(node.Function, env)\n\t\tif isError(fn) {\n\t\t\treturn fn\n\t\t}\n\t\targs := evalExprs(node.Arguments, env)\n\t\tif len(args) == 1 && isError(args[0]) {\n\t\t\treturn args[0]\n\t\t}\n\t\treturn applyFunction(fn, args, node.Token.Line)\n\n\tcase *ast.ArrayLiteral:\n\t\telements := evalExprs(node.Elements, env)\n\t\tif len(elements) == 1 && isError(elements[0]) {\n\t\t\treturn elements[0]\n\t\t}\n\t\treturn &object.Array{Elements: elements}\n\n\tcase *ast.IndexExpression:\n\t\tleft := Eval(node.Left, env)\n\t\tif isError(left) {\n\t\t\treturn left\n\t\t}\n\t\tindex := Eval(node.Index, env)\n\t\tif isError(index) {\n\t\t\treturn index\n\t\t}\n\t\treturn evalIndexExpr(left, index, node.Token.Line)\n\n\tcase *ast.HashLiteral:\n\t\treturn evalHashLiteral(node, env)\n\t}\n\n\treturn nil\n}","func (o BuildSpecRuntimePtrOutput) Env() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *BuildSpecRuntime) map[string]string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Env\n\t}).(pulumi.StringMapOutput)\n}","func ExampleBind() {\n\t// Simple configuration struct\n\ttype config struct {\n\t\tHostName string `env:\"HOSTNAME\"` // default: HOST_NAME\n\t\tUserName string `env:\"USERNAME\"` // default: USER_NAME\n\t\tSSL bool `env:\"USE_SSL\"` // default: SSL\n\t\tPort int // leave as default (PORT)\n\t\tPingInterval time.Duration `env:\"PING\"` // default: PING_INTERVAL\n\t\tOnline bool `env:\"-\"` // ignore this field\n\t}\n\n\t// Set some values in the environment for test purposes\n\t_ = os.Setenv(\"HOSTNAME\", \"api.example.com\")\n\t_ = os.Setenv(\"USERNAME\", \"\") // empty\n\t_ = os.Setenv(\"PORT\", \"443\")\n\t_ = os.Setenv(\"USE_SSL\", \"1\")\n\t_ = os.Setenv(\"PING\", \"5m\")\n\t_ = os.Setenv(\"ONLINE\", \"1\") // will be ignored\n\n\t// Create a config and bind it to the environment\n\tc := &config{}\n\tif err := Bind(c); err != nil {\n\t\t// handle error...\n\t}\n\n\t// config struct now populated from the environment\n\tfmt.Println(c.HostName)\n\tfmt.Println(c.UserName)\n\tfmt.Printf(\"%d\\n\", c.Port)\n\tfmt.Printf(\"%v\\n\", c.SSL)\n\tfmt.Printf(\"%v\\n\", c.Online)\n\tfmt.Printf(\"%v\\n\", c.PingInterval*4) // it's not a string!\n\t// Output:\n\t// api.example.com\n\t//\n\t// 443\n\t// true\n\t// false\n\t// 20m0s\n\n\tos.Clearenv()\n}","func EnvVarTest(resourceName string, sourceType string, envString string) {\n\n\tif sourceType == \"git\" {\n\t\t// checking the values of the env vars pairs in bc\n\t\tenvVars := runCmd(\"oc get bc \" + resourceName + \" -o go-template='{{range .spec.strategy.sourceStrategy.env}}{{.name}}{{.value}}{{end}}'\")\n\t\tExpect(envVars).To(Equal(envString))\n\t}\n\n\t// checking the values of the env vars pairs in dc\n\tenvVars := runCmd(\"oc get dc \" + resourceName + \" -o go-template='{{range .spec.template.spec.containers}}{{range .env}}{{.name}}{{.value}}{{end}}{{end}}'\")\n\tExpect(envVars).To(Equal(envString))\n}","func (c *Env) MarshalJSON() ([]byte, error) {\n\tdata := map[string]interface{}{\n\t\t\"appID\": strconv.FormatUint(c.appID, 10),\n\t\t\"level\": c.level,\n\t\t\"status\": c.Status,\n\t\t\"frictionlessRequests\": c.FrictionlessRequests,\n\t\t\"signedRequest\": c.SignedRequest,\n\t\t\"viewMode\": c.ViewMode,\n\t\t\"init\": c.Init,\n\t}\n\tif c.isEmployee {\n\t\tdata[\"isEmployee\"] = true\n\t}\n\treturn json.Marshal(data)\n}","func Evaluate(thing interface{}, env Environment) (error, Value, Environment) {\n\tswitch thing.(type) {\n\tcase Value:\n\t\treturn EvaluateValue(thing.(Value), env)\n\tcase SExpression:\n\t\tsexp := thing.(SExpression)\n\t\tif isSpecialForm(sexp.FormName.Contained) {\n\t\t\treturn EvaluateSpecialForm(sexp, env)\n\t\t} else {\n\t\t\treturn EvaluateSexp(thing.(SExpression), env)\n\t\t}\n\tdefault:\n\t\treturn errors.New(fmt.Sprintf(\"No way to evaluate %v\\n\", thing)), Value{}, env\n\t}\n}","func (c *Client) EnvUpdate(ctx context.Context, req *EnvUpdateRequest) (*EnvUpdateResponse, error) {\n\tvar resp EnvUpdateResponse\n\tif err := c.client.Do(ctx, \"PATCH\", envURL, req, &resp); err != nil {\n\t\treturn nil, err\n\t}\n\tresp.Normalize()\n\treturn &resp, nil\n}","func (config *Config) Get(key string, v interface{}) error {\n\tvar val interface{}\n\n\tenv, set := os.LookupEnv(key)\n\n\tif set {\n\t\tswitch v.(type) {\n\t\tcase *float64:\n\t\t\tval, err := strconv.ParseFloat(env, 64)\n\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t*v.(*float64) = val\n\t\t\treturn nil\n\t\tcase *int:\n\t\t\tval, err := strconv.ParseInt(env, 10, 64)\n\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t*v.(*int) = int(val)\n\t\t\treturn nil\n\t\tdefault:\n\t\t\tval = env\n\t\t}\n\t} else if config.cache != nil {\n\t\tval = (*config.cache)[key]\n\t}\n\n\t// Cast JSON values\n\tswitch v.(type) {\n\tcase *string:\n\t\tif val == nil {\n\t\t\tval = \"\"\n\t\t}\n\n\t\tif b, ok := val.(bool); ok {\n\t\t\t*v.(*string) = strconv.FormatBool(b)\n\t\t} else if f, ok := val.(float64); ok {\n\t\t\t*v.(*string) = strconv.FormatFloat(f, 'f', -1, 64)\n\t\t} else {\n\t\t\t*v.(*string) = val.(string)\n\t\t}\n\tcase *bool:\n\t\tswitch val {\n\t\tcase nil, 0, false, \"\", \"0\", \"false\":\n\t\t\t// falsey\n\t\t\tval = false\n\t\tdefault:\n\t\t\t// truthy\n\t\t\tval = true\n\t\t}\n\n\t\t*v.(*bool) = val.(bool)\n\tcase *float64:\n\t\tif val == nil {\n\t\t\tval = float64(0)\n\t\t}\n\n\t\tif s, ok := val.(string); ok {\n\t\t\tpf, err := strconv.ParseFloat(s, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t*v.(*float64) = pf\n\t\t} else {\n\t\t\t*v.(*float64) = val.(float64)\n\t\t}\n\tcase *int:\n\t\tif val == nil {\n\t\t\tval = float64(0)\n\t\t}\n\n\t\t*v.(*int) = int(val.(float64))\n\tdefault:\n\t\treturn errors.New(\"Type not supported\")\n\t}\n\n\treturn nil\n}","func (a *Client) ModifyRuntimeEnv(params *ModifyRuntimeEnvParams) (*ModifyRuntimeEnvOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewModifyRuntimeEnvParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"ModifyRuntimeEnv\",\n\t\tMethod: \"PATCH\",\n\t\tPathPattern: \"/v1/runtime_envs\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"http\"},\n\t\tParams: params,\n\t\tReader: &ModifyRuntimeEnvReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*ModifyRuntimeEnvOK), nil\n\n}","func (environment *Environment) String() string {\n\tmarshaledVal, _ := json.MarshalIndent(*environment, \"\", \" \") // Marshal to JSON\n\n\treturn string(marshaledVal) // Return string value\n}","func Getenv(key string, fallbacks ...string) (value string) {\n\tvalue, _ = LookupEnv(key, fallbacks...)\n\treturn\n}","func (e *EnvironmentVariablesMapV0) UnmarshalJSON(data []byte) error {\n\tvar plain []string\n\tif err := json.Unmarshal(data, &plain); err == nil {\n\t\te.RawCPU = []string{}\n\t\te.RawGPU = []string{}\n\t\te.RawCPU = append(e.RawCPU, plain...)\n\t\te.RawGPU = append(e.RawGPU, plain...)\n\t\treturn nil\n\t}\n\ttype DefaultParser EnvironmentVariablesMapV0\n\tvar jsonItems DefaultParser\n\tif err := json.Unmarshal(data, &jsonItems); err != nil {\n\t\treturn errors.Wrapf(err, \"failed to parse runtime items\")\n\t}\n\te.RawCPU = []string{}\n\te.RawGPU = []string{}\n\tif jsonItems.RawCPU != nil {\n\t\te.RawCPU = append(e.RawCPU, jsonItems.RawCPU...)\n\t}\n\tif jsonItems.RawGPU != nil {\n\t\te.RawGPU = append(e.RawGPU, jsonItems.RawGPU...)\n\t}\n\treturn nil\n}","func eval(x interface{}, env map[string]interface{}) interface{} {\r\n if str, ok := isSymbol(x); ok { // variable reference\r\n\treturn env[str]\r\n }\r\n l, ok := isList(x)\r\n if !ok { // constant literal\r\n\treturn x\r\n }\r\n if len(l) == 0 {\r\n\tpanic(\"empty list\")\r\n }\r\n if str, ok := isSymbol(l[0]); ok {\r\n\tswitch (str) {\r\n\tcase \"quote\": // (quote exp)\r\n\t return l[1]\r\n\tcase \"if\": // (if test conseq alt)\r\n\t test := l[1]\r\n\t conseq := l[2]\r\n\t alt := l[3]\r\n\t r := eval(test, env)\r\n\t if b, ok := isFalse(r); ok && !b {\r\n\t\treturn eval(alt, env)\r\n\t } else {\r\n\t\treturn eval(conseq, env)\r\n\t }\r\n\tcase \"define\": // (define var exp)\r\n\t car := l[1]\r\n\t cdr := l[2]\r\n\t if str, ok = isSymbol(car); ok {\r\n\t\tenv[str] = eval(cdr, env)\r\n\t\treturn env[str]\r\n\t } else {\r\n\t\tpanic(\"define needs a symbol\")\r\n\t }\r\n\tdefault: // (proc arg...)\r\n\t car := eval(l[0], env)\r\n\t proc, ok := car.(func([]interface{})interface{})\r\n\t if !ok {\r\n\t\tpanic(\"not a procedure\")\r\n\t }\r\n args := makeArgs(l[1:], env)\r\n return proc(args)\r\n\t}\r\n }\r\n return nil\r\n}","func evaluateAst(program *ast.RootNode) object.Object {\n\tenv := object.NewEnvironment()\n\treturn evaluator.Eval(program, env)\n}","func ExpandEnv(x *X, env *envvar.Vars) {\n\te := env.ToMap()\n\trootEnv := \"${\" + RootEnv + \"}\"\n\tfor k, v := range e {\n\t\tn := strings.Replace(v, rootEnv, x.Root, -1)\n\t\tif n != v {\n\t\t\tenv.Set(k, n)\n\t\t}\n\t}\n}","func (o StorageClusterSpecStorkOutput) Env() StorageClusterSpecStorkEnvArrayOutput {\n\treturn o.ApplyT(func(v StorageClusterSpecStork) []StorageClusterSpecStorkEnv { return v.Env }).(StorageClusterSpecStorkEnvArrayOutput)\n}","func init() {\n\tenvironments = make(map[string]string)\n\n\tfor _, e := range os.Environ() {\n\t\tspl := strings.SplitN(e, \"=\", 2)\n\t\tenvironments[spl[0]] = spl[1]\n\t}\n}","func (session Runtime) evaluate(expression string, contextID int64, async, returnByValue bool) (*devtool.RemoteObject, error) {\n\tp := &devtool.EvaluatesExpression{\n\t\tExpression: expression,\n\t\tIncludeCommandLineAPI: true,\n\t\tContextID: contextID,\n\t\tAwaitPromise: !async,\n\t\tReturnByValue: returnByValue,\n\t}\n\tresult := new(devtool.EvaluatesResult)\n\tif err := session.call(\"Runtime.evaluate\", p, result); err != nil {\n\t\treturn nil, err\n\t}\n\tif result.ExceptionDetails != nil {\n\t\treturn nil, result.ExceptionDetails\n\t}\n\treturn result.Result, nil\n}","func LoadEnv() {\n\tif err := env.Parse(&Env); err != nil {\n\t\tpanic(err.Error())\n\t}\n}","func (config *configuration) getEnvVariables() error {\n\t// method 1: Decode json file\n\tfile, err := os.Open(confFile)\n\tif err != nil {\n\t\tpc, _, _, _ := runtime.Caller(0)\n\t\terrorWebLogger.ClientIP = \"ClientIP is NOT existed.\"\n\t\terrorWebLogger.FatalPrintln(getCurrentRPCmethod(pc), \"Open config file error.\", err)\n\t\treturn err\n\t}\n\tdecoder := json.NewDecoder(file)\n\tdecoderErr := decoder.Decode(&config)\n\tif decoderErr != nil {\n\t\tpc, _, _, _ := runtime.Caller(0)\n\t\terrorWebLogger.ClientIP = \"ClientIP is NOT existed.\"\n\t\terrorWebLogger.FatalPrintln(getCurrentRPCmethod(pc), \"Decode config file error.\", decoderErr)\n\t\treturn decoderErr\n\t}\n\n\t// method 2: Unmarshal json file\n\t// jsonData, err := ioutil.ReadFile(confFile)\n\t// if err != nil {\n\t// \treturn err\n\t// }\n\t// unmarshalErr := json.Unmarshal(jsonData, &config)\n\t// if unmarshalErr != nil {\n\t// \treturn unmarshalErr\n\t// }\n\treturn nil\n}"],"string":"[\n \"func (r RuleDefinition) EvaluateEnv(e map[string]string) bool {\\n\\t// Compile if needed\\n\\tif r.rule == nil {\\n\\t\\tif err := r.Compile(); err != nil {\\n\\t\\t\\treturn false\\n\\t\\t}\\n\\t}\\n\\treturn r.rule.Env.Evaluate(e)\\n}\",\n \"func (getEnvPropertyValueFn) Eval(params ...interface{}) (interface{}, error) {\\n\\tif getEnvPropertyValueFnLogger.DebugEnabled() {\\n\\t\\tgetEnvPropertyValueFnLogger.Debugf(\\\"Entering function getEnvPropertyValue (eval) with param: [%+v]\\\", params[0])\\n\\t}\\n\\n\\tinputParamValue := params[0]\\n\\tinputString := \\\"\\\"\\n\\tvar outputValue interface{}\\n\\tvar err error\\n\\n\\tinputString, err = coerce.ToString(inputParamValue)\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"Unable to coerece input value to a string. Value = [%+v].\\\", inputParamValue)\\n\\t}\\n\\n\\tif getEnvPropertyValueFnLogger.DebugEnabled() {\\n\\t\\tgetEnvPropertyValueFnLogger.Debugf(\\\"Input Parameter's string length is [%+v].\\\", len(inputString))\\n\\t}\\n\\n\\tif len(inputString) <= 0 {\\n\\t\\tgetEnvPropertyValueFnLogger.Debugf(\\\"Input Parameter is empty or nil. Returning nil.\\\")\\n\\t\\treturn nil, nil\\n\\t}\\n\\n\\toutputValue, exists := os.LookupEnv(inputString)\\n\\tif !exists {\\n\\t\\tif getEnvPropertyValueFnLogger.DebugEnabled() {\\n\\t\\t\\tgetEnvPropertyValueFnLogger.Debugf(\\\"failed to resolve Env Property: '%s', ensure that property is configured in the application\\\", inputString)\\n\\t\\t}\\n\\t\\treturn nil, nil\\n\\t}\\n\\n\\tif getEnvPropertyValueFnLogger.DebugEnabled() {\\n\\t\\tgetEnvPropertyValueFnLogger.Debugf(\\\"Final output value = [%+v]\\\", outputValue)\\n\\t}\\n\\n\\tif getEnvPropertyValueFnLogger.DebugEnabled() {\\n\\t\\tgetEnvPropertyValueFnLogger.Debugf(\\\"Exiting function getEnvPropertyValue (eval)\\\")\\n\\t}\\n\\n\\treturn outputValue, nil\\n}\",\n \"func (rs RuleDefinitions) EvaluateEnv(e map[string]string) bool {\\n\\tfor _, r := range rs.Rules {\\n\\t\\tif r.EvaluateEnv(e) {\\n\\t\\t\\treturn true\\n\\t\\t}\\n\\t}\\n\\treturn false\\n}\",\n \"func EvalEnv(key string) bool {\\n\\treturn os.Getenv(key) == \\\"1\\\" || os.Getenv(key) == \\\"true\\\" || os.Getenv(key) == \\\"TRUE\\\"\\n}\",\n \"func (gf *genericFramework) Env(key, value string) error {\\n\\tif gf.adam.Variables == nil {\\n\\t\\tgf.adam.Variables = jsonutil.NewVariableMap(\\\"\\\", nil)\\n\\t}\\n\\tif _, ok := gf.adam.Variables.Get(key); ok {\\n\\t\\treturn fmt.Errorf(\\\"%v has been defined\\\", key)\\n\\t}\\n\\tgf.adam.Variables.Set(key, jsonutil.NewStringVariable(key, value))\\n\\treturn nil\\n}\",\n \"func Eval(input string, env interface{}) (interface{}, error) {\\n\\tif _, ok := env.(Option); ok {\\n\\t\\treturn nil, fmt.Errorf(\\\"misused expr.Eval: second argument (env) should be passed without expr.Env\\\")\\n\\t}\\n\\n\\ttree, err := parser.Parse(input)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tprogram, err := compiler.Compile(tree, nil)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\toutput, err := vm.Run(program, env)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\treturn output, nil\\n}\",\n \"func (c config) EvalContext(env string, props map[string]interface{}) eval.Context {\\n\\tp, err := json.Marshal(props)\\n\\tif err != nil {\\n\\t\\tsio.Warnln(\\\"unable to serialize env properties to JSON:\\\", err)\\n\\t}\\n\\treturn eval.Context{\\n\\t\\tApp: c.App().Name(),\\n\\t\\tTag: c.App().Tag(),\\n\\t\\tEnv: env,\\n\\t\\tEnvPropsJSON: string(p),\\n\\t\\tDefaultNs: c.App().DefaultNamespace(env),\\n\\t\\tVMConfig: c.vmConfig,\\n\\t\\tVerbose: c.Verbosity() > 1,\\n\\t\\tConcurrency: c.EvalConcurrency(),\\n\\t\\tPostProcessFile: c.App().PostProcessor(),\\n\\t\\tCleanMode: c.cleanEvalMode,\\n\\t}\\n}\",\n \"func (e Env) MarshalJSON() ([]byte, error) {\\n\\tvar b []byte\\n\\tvar err error\\n\\tswitch e.Type {\\n\\tcase EnvValType:\\n\\t\\tb, err = json.Marshal(UnparseEnvVal(*e.Val))\\n\\tcase EnvFromType:\\n\\t\\tb, err = json.Marshal(e.From)\\n\\tdefault:\\n\\t\\treturn []byte{}, util.InvalidInstanceError(e.Type)\\n\\t}\\n\\n\\tif err != nil {\\n\\t\\treturn nil, util.InvalidInstanceErrorf(e, \\\"couldn't marshal to JSON: %s\\\", err.Error())\\n\\t}\\n\\n\\treturn b, nil\\n}\",\n \"func (s) TestJSONEnvVarSet(t *testing.T) {\\n\\tconfigJSON := `{\\n\\t\\t\\\"project_id\\\": \\\"fake\\\"\\n\\t}`\\n\\tcleanup, err := createTmpConfigInFileSystem(configJSON)\\n\\tdefer cleanup()\\n\\n\\tif err != nil {\\n\\t\\tt.Fatalf(\\\"failed to create config in file system: %v\\\", err)\\n\\t}\\n\\tctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)\\n\\tdefer cancel()\\n\\tif err := Start(ctx); err != nil {\\n\\t\\tt.Fatalf(\\\"error starting observability with valid config through file system: %v\\\", err)\\n\\t}\\n\\tdefer End()\\n}\",\n \"func (e *ChefEnvironment) UpdateFromJSON(jsonEnv map[string]interface{}) util.Gerror {\\n\\tif e.Name != jsonEnv[\\\"name\\\"].(string) {\\n\\t\\terr := util.Errorf(\\\"Environment name %s and %s from JSON do not match\\\", e.Name, jsonEnv[\\\"name\\\"].(string))\\n\\t\\treturn err\\n\\t} else if e.Name == \\\"_default\\\" {\\n\\t\\terr := util.Errorf(\\\"The '_default' environment cannot be modified.\\\")\\n\\t\\terr.SetStatus(http.StatusMethodNotAllowed)\\n\\t\\treturn err\\n\\t}\\n\\n\\t/* Validations */\\n\\tvalidElements := []string{\\\"name\\\", \\\"chef_type\\\", \\\"json_class\\\", \\\"description\\\", \\\"default_attributes\\\", \\\"override_attributes\\\", \\\"cookbook_versions\\\"}\\nValidElem:\\n\\tfor k := range jsonEnv {\\n\\t\\tfor _, i := range validElements {\\n\\t\\t\\tif k == i {\\n\\t\\t\\t\\tcontinue ValidElem\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\terr := util.Errorf(\\\"Invalid key %s in request body\\\", k)\\n\\t\\treturn err\\n\\t}\\n\\n\\tvar verr util.Gerror\\n\\n\\tattrs := []string{\\\"default_attributes\\\", \\\"override_attributes\\\"}\\n\\tfor _, a := range attrs {\\n\\t\\tjsonEnv[a], verr = util.ValidateAttributes(a, jsonEnv[a])\\n\\t\\tif verr != nil {\\n\\t\\t\\treturn verr\\n\\t\\t}\\n\\t}\\n\\n\\tjsonEnv[\\\"json_class\\\"], verr = util.ValidateAsFieldString(jsonEnv[\\\"json_class\\\"])\\n\\tif verr != nil {\\n\\t\\tif verr.Error() == \\\"Field 'name' nil\\\" {\\n\\t\\t\\tjsonEnv[\\\"json_class\\\"] = e.JSONClass\\n\\t\\t} else {\\n\\t\\t\\treturn verr\\n\\t\\t}\\n\\t} else {\\n\\t\\tif jsonEnv[\\\"json_class\\\"].(string) != \\\"Chef::Environment\\\" {\\n\\t\\t\\tverr = util.Errorf(\\\"Field 'json_class' invalid\\\")\\n\\t\\t\\treturn verr\\n\\t\\t}\\n\\t}\\n\\n\\tjsonEnv[\\\"chef_type\\\"], verr = util.ValidateAsFieldString(jsonEnv[\\\"chef_type\\\"])\\n\\tif verr != nil {\\n\\t\\tif verr.Error() == \\\"Field 'name' nil\\\" {\\n\\t\\t\\tjsonEnv[\\\"chef_type\\\"] = e.ChefType\\n\\t\\t} else {\\n\\t\\t\\treturn verr\\n\\t\\t}\\n\\t} else {\\n\\t\\tif jsonEnv[\\\"chef_type\\\"].(string) != \\\"environment\\\" {\\n\\t\\t\\tverr = util.Errorf(\\\"Field 'chef_type' invalid\\\")\\n\\t\\t\\treturn verr\\n\\t\\t}\\n\\t}\\n\\n\\tjsonEnv[\\\"cookbook_versions\\\"], verr = util.ValidateAttributes(\\\"cookbook_versions\\\", jsonEnv[\\\"cookbook_versions\\\"])\\n\\tif verr != nil {\\n\\t\\treturn verr\\n\\t}\\n\\tfor k, v := range jsonEnv[\\\"cookbook_versions\\\"].(map[string]interface{}) {\\n\\t\\tif !util.ValidateEnvName(k) || k == \\\"\\\" {\\n\\t\\t\\tmerr := util.Errorf(\\\"Cookbook name %s invalid\\\", k)\\n\\t\\t\\tmerr.SetStatus(http.StatusBadRequest)\\n\\t\\t\\treturn merr\\n\\t\\t}\\n\\n\\t\\tif v == nil {\\n\\t\\t\\tverr = util.Errorf(\\\"Invalid version number\\\")\\n\\t\\t\\treturn verr\\n\\t\\t}\\n\\t\\t_, verr = util.ValidateAsConstraint(v)\\n\\t\\tif verr != nil {\\n\\t\\t\\t/* try validating as a version */\\n\\t\\t\\tv, verr = util.ValidateAsVersion(v)\\n\\t\\t\\tif verr != nil {\\n\\t\\t\\t\\treturn verr\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tjsonEnv[\\\"description\\\"], verr = util.ValidateAsString(jsonEnv[\\\"description\\\"])\\n\\tif verr != nil {\\n\\t\\tif verr.Error() == \\\"Field 'name' missing\\\" {\\n\\t\\t\\tjsonEnv[\\\"description\\\"] = \\\"\\\"\\n\\t\\t} else {\\n\\t\\t\\treturn verr\\n\\t\\t}\\n\\t}\\n\\n\\te.ChefType = jsonEnv[\\\"chef_type\\\"].(string)\\n\\te.JSONClass = jsonEnv[\\\"json_class\\\"].(string)\\n\\te.Description = jsonEnv[\\\"description\\\"].(string)\\n\\te.Default = jsonEnv[\\\"default_attributes\\\"].(map[string]interface{})\\n\\te.Override = jsonEnv[\\\"override_attributes\\\"].(map[string]interface{})\\n\\t/* clear out, then loop over the cookbook versions */\\n\\te.CookbookVersions = make(map[string]string, len(jsonEnv[\\\"cookbook_versions\\\"].(map[string]interface{})))\\n\\tfor c, v := range jsonEnv[\\\"cookbook_versions\\\"].(map[string]interface{}) {\\n\\t\\te.CookbookVersions[c] = v.(string)\\n\\t}\\n\\n\\treturn nil\\n}\",\n \"func Test(w http.ResponseWriter, r *http.Request) {\\n\\tres, err := json.Marshal(EnvVariablesModel{Vars: os.Environ(), A: \\\"b\\\", C: 123})\\n\\tif err != nil {\\n\\t\\tcommon.DisplayAppError(\\n\\t\\t\\tw,\\n\\t\\t\\terr,\\n\\t\\t\\t\\\"An unexpected error has occurred\\\",\\n\\t\\t\\t500,\\n\\t\\t)\\n\\t\\treturn\\n\\t}\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"application/json\\\")\\n\\tw.Write(res)\\n}\",\n \"func (t envTemplate) Env(secrets map[string]string, sr tpl.SecretReader) (map[string]string, error) {\\n\\tresult := make(map[string]string)\\n\\tfor _, tpls := range t.envVars {\\n\\t\\tkey, err := tpls.key.Evaluate(t.templateVarReader, secretReaderNotAllowed{})\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\n\\t\\terr = validation.ValidateEnvarName(key)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, templateError(tpls.lineNo, err)\\n\\t\\t}\\n\\n\\t\\tvalue, err := tpls.value.Evaluate(t.templateVarReader, sr)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\n\\t\\tresult[key] = value\\n\\t}\\n\\treturn result, nil\\n}\",\n \"func Env(env string) (value []byte, err error) {\\n\\tvalue, err = exec.Command(\\\"go\\\", \\\"env\\\", env).Output()\\n\\tif err != nil {\\n\\t\\treturn\\n\\t}\\n\\n\\tvalue = bytes.TrimSpace(value)\\n\\n\\tif len(value) == 0 {\\n\\t\\terr = ErrEmptyEnv{env}\\n\\t}\\n\\n\\treturn\\n}\",\n \"func InitEnv() error {\\n\\tfile, err := ioutil.ReadFile(envPath)\\n\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\n\\tif errMarsh := codec.DecJson(file, &env); errMarsh != nil {\\n\\t\\treturn fmt.Errorf(\\\"failed to parse %s. decode error: %v\\\", string(file), err)\\n\\t}\\n\\n\\treturn nil\\n}\",\n \"func LoadFromEnv(v interface{}, prefix string) (result []MarshalledEnvironmentVar) {\\n\\tpointerValue := reflect.ValueOf(v)\\n\\tstructValue := pointerValue.Elem()\\n\\tstructType := structValue.Type()\\n\\n\\tfor i := 0; i < structValue.NumField(); i++ {\\n\\t\\tstructField := structType.Field(i)\\n\\t\\tfieldValue := structValue.Field(i)\\n\\n\\t\\tif fieldValue.CanSet() {\\n\\t\\t\\tenvKey := strings.ToUpper(prefix) + gocase.ToUpperSnake(structField.Name)\\n\\t\\t\\tenvVal := os.Getenv(envKey)\\n\\n\\t\\t\\tif envVal != \\\"\\\" {\\n\\t\\t\\t\\t// create a json blob with the env data\\n\\t\\t\\t\\tjsonStr := \\\"\\\"\\n\\t\\t\\t\\tif fieldValue.Kind() == reflect.String {\\n\\t\\t\\t\\t\\tjsonStr = fmt.Sprintf(`{\\\"%s\\\": \\\"%s\\\"}`, structField.Name, envVal)\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tjsonStr = fmt.Sprintf(`{\\\"%s\\\": %s}`, structField.Name, envVal)\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\terr := json.Unmarshal([]byte(jsonStr), v)\\n\\t\\t\\t\\tresult = append(result, MarshalledEnvironmentVar{envKey, envVal, structField.Name, err})\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\treturn\\n}\",\n \"func (e *Env) UnmarshalJSON(value []byte) error {\\n\\tvar s string\\n\\terr := json.Unmarshal(value, &s)\\n\\tif err == nil {\\n\\t\\tenvVal := ParseEnvVal(s)\\n\\t\\te.SetVal(*envVal)\\n\\t\\treturn nil\\n\\t}\\n\\n\\tfrom := EnvFrom{}\\n\\terr = json.Unmarshal(value, &from)\\n\\tif err == nil {\\n\\t\\te.SetFrom(from)\\n\\t\\treturn nil\\n\\t}\\n\\n\\treturn util.InvalidInstanceErrorf(e, \\\"couldn't parse from (%s)\\\", string(value))\\n}\",\n \"func NewEnvironment(jsonData string) (*Environment, error) {\\n\\t// initialize env with input data\\n\\tenv := new(Environment)\\n\\terr := serialize.CopyFromJSON(jsonData, env)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\treturn env, nil\\n}\",\n \"func (value *Env) Eval(ctx context.Context, env *Env, cont Cont) ReadyCont {\\n\\treturn cont.Call(value, nil)\\n}\",\n \"func LoadTestEnv() *core.Engine {\\n\\tengine := new(core.Engine)\\n\\n\\t_, dir, _, _ := runtime.Caller(0)\\n\\tconfigJSON := filepath.Join(filepath.Dir(dir), \\\"../..\\\", \\\"env\\\", \\\"tdd.json\\\")\\n\\n\\tjsonFile, err := os.Open(configJSON)\\n\\n\\tif err != nil {\\n\\t\\tlog.Fatalln(err, \\\"can't open the config file\\\", dir+\\\"/regularenvs.json\\\")\\n\\t}\\n\\n\\tdefer jsonFile.Close()\\n\\n\\tbyteValue, _ := ioutil.ReadAll(jsonFile)\\n\\n\\terr = json.Unmarshal(byteValue, &engine.Env)\\n\\tif err != nil {\\n\\t\\tlog.Fatalln(err, \\\"error in unmarshal JSON\\\")\\n\\t}\\n\\n\\tif engine.Env.MachineID, err = machineid.ProtectedID(\\\"SigmaMono\\\"); err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n\\n\\treturn engine\\n}\",\n \"func NewFromJSON(jsonEnv map[string]interface{}) (*ChefEnvironment, util.Gerror) {\\n\\tenv, err := New(jsonEnv[\\\"name\\\"].(string))\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\terr = env.UpdateFromJSON(jsonEnv)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn env, nil\\n}\",\n \"func (cx *Context) Eval(source string, result interface{}) (err error) {\\n\\tcx.do(func(ptr *C.JSAPIContext) {\\n\\t\\t// alloc C-string\\n\\t\\tcsource := C.CString(source)\\n\\t\\tdefer C.free(unsafe.Pointer(csource))\\n\\t\\tvar jsonData *C.char\\n\\t\\tvar jsonLen C.int\\n\\t\\tfilename := \\\"eval\\\"\\n\\t\\tcfilename := C.CString(filename)\\n\\t\\tdefer C.free(unsafe.Pointer(cfilename))\\n\\t\\t// eval\\n\\t\\tif C.JSAPI_EvalJSON(ptr, csource, cfilename, &jsonData, &jsonLen) != C.JSAPI_OK {\\n\\t\\t\\terr = cx.getError(filename)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tdefer C.free(unsafe.Pointer(jsonData))\\n\\t\\t// convert to go\\n\\t\\tb := []byte(C.GoStringN(jsonData, jsonLen))\\n\\t\\tif raw, ok := result.(*Raw); ok {\\n\\t\\t\\t*raw = Raw(string(b))\\n\\t\\t} else {\\n\\t\\t\\terr = json.Unmarshal(b, result)\\n\\t\\t}\\n\\t})\\n\\treturn err\\n}\",\n \"func (o BuildRunStatusBuildSpecRuntimeOutput) Env() pulumi.StringMapOutput {\\n\\treturn o.ApplyT(func(v BuildRunStatusBuildSpecRuntime) map[string]string { return v.Env }).(pulumi.StringMapOutput)\\n}\",\n \"func (o BuildSpecRuntimeOutput) Env() pulumi.StringMapOutput {\\n\\treturn o.ApplyT(func(v BuildSpecRuntime) map[string]string { return v.Env }).(pulumi.StringMapOutput)\\n}\",\n \"func ReadEnv(c interface{}) {\\r\\n\\tfor _, value := range os.Environ() {\\r\\n\\t\\tif strings.HasPrefix(value, \\\"ENV_\\\") {\\r\\n\\t\\t\\tkv := strings.SplitN(value,\\\"=\\\",2)\\r\\n\\t\\t\\tkv[0] = strings.ToLower(strings.Replace(kv[0],\\\"_\\\",\\\".\\\",-1))[4:]\\r\\n\\t\\t\\tSetData(c,strings.Join(kv,\\\"=\\\"))\\r\\n\\t\\t}\\r\\n\\t}\\r\\n}\",\n \"func buildEnvironment(env []string) (map[string]string, error) {\\n result := make(map[string]string, len(env))\\n for _, s := range env {\\n // if value is empty, s is like \\\"K=\\\", not \\\"K\\\".\\n if !strings.Contains(s, \\\"=\\\") {\\n return result, errors.Errorf(\\\"unexpected environment %q\\\", s)\\n }\\n kv := strings.SplitN(s, \\\"=\\\", 2)\\n result[kv[0]] = kv[1]\\n }\\n return result, nil\\n}\",\n \"func (o StorageClusterSpecNodesOutput) Env() StorageClusterSpecNodesEnvArrayOutput {\\n\\treturn o.ApplyT(func(v StorageClusterSpecNodes) []StorageClusterSpecNodesEnv { return v.Env }).(StorageClusterSpecNodesEnvArrayOutput)\\n}\",\n \"func LoadEnvironment(object interface{}, metaDataKey string) error {\\n\\tvar values = func(key string) (string, bool) {\\n\\t\\treturn os.LookupEnv(key)\\n\\t}\\n\\treturn commonLoad(values, object, metaDataKey)\\n}\",\n \"func (b *taskBuilder) env(key, value string) {\\n\\tif b.Spec.Environment == nil {\\n\\t\\tb.Spec.Environment = map[string]string{}\\n\\t}\\n\\tb.Spec.Environment[key] = value\\n}\",\n \"func GetENV(experimentDetails *experimentTypes.ExperimentDetails) {\\n\\texperimentDetails.ExperimentName = Getenv(\\\"EXPERIMENT_NAME\\\", \\\"\\\")\\n\\texperimentDetails.AppNS = Getenv(\\\"APP_NS\\\", \\\"\\\")\\n\\texperimentDetails.TargetContainer = Getenv(\\\"APP_CONTAINER\\\", \\\"\\\")\\n\\texperimentDetails.TargetPods = Getenv(\\\"APP_POD\\\", \\\"\\\")\\n\\texperimentDetails.AppLabel = Getenv(\\\"APP_LABEL\\\", \\\"\\\")\\n\\texperimentDetails.ChaosDuration, _ = strconv.Atoi(Getenv(\\\"TOTAL_CHAOS_DURATION\\\", \\\"30\\\"))\\n\\texperimentDetails.ChaosNamespace = Getenv(\\\"CHAOS_NAMESPACE\\\", \\\"litmus\\\")\\n\\texperimentDetails.EngineName = Getenv(\\\"CHAOS_ENGINE\\\", \\\"\\\")\\n\\texperimentDetails.ChaosUID = clientTypes.UID(Getenv(\\\"CHAOS_UID\\\", \\\"\\\"))\\n\\texperimentDetails.ChaosPodName = Getenv(\\\"POD_NAME\\\", \\\"\\\")\\n\\texperimentDetails.ContainerRuntime = Getenv(\\\"CONTAINER_RUNTIME\\\", \\\"\\\")\\n\\texperimentDetails.NetworkInterface = Getenv(\\\"NETWORK_INTERFACE\\\", \\\"eth0\\\")\\n\\texperimentDetails.TargetIPs = Getenv(\\\"TARGET_IPs\\\", \\\"\\\")\\n}\",\n \"func requireEnv(envVar string) string {\\n\\tval, _ := getEnv(envVar, true)\\n\\treturn val\\n}\",\n \"func NewEnv(loader *ScriptLoader, debugging bool) *Env {\\n\\tenv := &Env{\\n\\t\\tvm: otto.New(),\\n\\t\\tloader: loader,\\n\\t\\tdebugging: debugging,\\n\\t\\tbuiltinModules: make(map[string]otto.Value),\\n\\t\\tbuiltinModuleFactories: make(map[string]BuiltinModuleFactory),\\n\\t}\\n\\tenv.vm.Set(\\\"__getModulePath\\\", func(call otto.FunctionCall) otto.Value {\\n\\t\\tvm := call.Otto\\n\\t\\tvar cwd, moduleID string\\n\\t\\tvar err error\\n\\t\\tif cwd, err = call.Argument(0).ToString(); err != nil {\\n\\t\\t\\tpanic(vm.MakeCustomError(\\\"__getModulePath error\\\", err.Error()))\\n\\t\\t}\\n\\t\\tif moduleID, err = call.Argument(1).ToString(); err != nil {\\n\\t\\t\\tpanic(vm.MakeCustomError(\\\"__getModulePath error\\\", err.Error()))\\n\\t\\t}\\n\\t\\tif _, found := env.builtinModules[moduleID]; found {\\n\\t\\t\\tret, _ := otto.ToValue(moduleID)\\n\\t\\t\\treturn ret\\n\\t\\t}\\n\\t\\tif _, found := env.builtinModuleFactories[moduleID]; found {\\n\\t\\t\\tret, _ := otto.ToValue(moduleID)\\n\\t\\t\\treturn ret\\n\\t\\t}\\n\\t\\tif ap, err := env.loader.GetModuleAbs(cwd, moduleID); err != nil {\\n\\t\\t\\tpanic(vm.MakeCustomError(\\\"__getModulePath error\\\", err.Error()))\\n\\t\\t} else {\\n\\t\\t\\tret, _ := otto.ToValue(ap)\\n\\t\\t\\treturn ret\\n\\t\\t}\\n\\t})\\n\\tvar requireSrc string\\n\\tif env.debugging {\\n\\t\\trequireSrc = debugRequireSrc\\n\\t} else {\\n\\t\\trequireSrc = releaseRequireSrc\\n\\t}\\n\\tenv.vm.Set(\\\"__loadSource\\\", func(call otto.FunctionCall) otto.Value {\\n\\t\\tvar mp string\\n\\t\\tvar err error\\n\\t\\tvm := call.Otto\\n\\t\\t// reading arguments\\n\\t\\tif mp, err = call.Argument(0).ToString(); err != nil {\\n\\t\\t\\tpanic(vm.MakeCustomError(\\\"__loadSource error\\\", err.Error()))\\n\\t\\t}\\n\\t\\t// finding built builtin modules\\n\\t\\tif mod, found := env.builtinModules[mp]; found {\\n\\t\\t\\tretObj, _ := vm.Object(\\\"({isBuiltin: true})\\\")\\n\\t\\t\\tretObj.Set(\\\"builtin\\\", mod)\\n\\t\\t\\treturn retObj.Value()\\n\\t\\t}\\n\\t\\t// finding unbuilt builtin modules\\n\\t\\tif mf, found := env.builtinModuleFactories[mp]; found {\\n\\t\\t\\tretObj, _ := vm.Object(\\\"({isBuiltin: true})\\\")\\n\\t\\t\\tmod := mf.CreateModule(vm)\\n\\t\\t\\tretObj.Set(\\\"builtin\\\", mod)\\n\\t\\t\\tenv.builtinModules[mp] = mod\\n\\t\\t\\treturn retObj.Value()\\n\\t\\t}\\n\\t\\t// loading module on file system\\n\\t\\tsrc, err := env.loader.LoadScript(mp)\\n\\t\\tif err != nil {\\n\\t\\t\\tpanic(vm.MakeCustomError(\\\"__loadSource error\\\", err.Error()))\\n\\t\\t}\\n\\t\\tscript, err := vm.Compile(mp, src)\\n\\t\\tif err != nil {\\n\\t\\t\\tpanic(vm.MakeCustomError(\\\"__loadSource error\\\", err.Error()))\\n\\t\\t}\\n\\t\\tmodValue, err := vm.Run(script)\\n\\t\\tif err != nil {\\n\\t\\t\\tpanic(vm.MakeCustomError(\\\"__loadSource error\\\", err.Error()))\\n\\t\\t}\\n\\t\\tretObj, _ := vm.Object(\\\"({})\\\")\\n\\t\\tretObj.Set(\\\"src\\\", modValue)\\n\\t\\tretObj.Set(\\\"filename\\\", path.Base(mp))\\n\\t\\tretObj.Set(\\\"dirname\\\", path.Dir(mp))\\n\\t\\treturn retObj.Value()\\n\\t})\\n\\t_, err := env.vm.Run(requireSrc)\\n\\tif err != nil {\\n\\t\\tswitch err.(type) {\\n\\t\\tcase *otto.Error:\\n\\t\\t\\tpanic(err.(otto.Error).String())\\n\\t\\tdefault:\\n\\t\\t\\tpanic(err)\\n\\t\\t}\\n\\t}\\n\\treturn env\\n}\",\n \"func (job *Job) DecodeEnv(src io.Reader) error {\\n\\treturn job.Env.Decode(src)\\n}\",\n \"func SyncEnvVar(env interface{}) {\\n\\tbs, err := json.Marshal(&env)\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n\\n\\tenvVar := map[string]string{}\\n\\terr = json.Unmarshal(bs, &envVar)\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n\\n\\tviper.AutomaticEnv()\\n\\tfor k := range envVar {\\n\\t\\tval := viper.GetString(k)\\n\\t\\tif val != \\\"\\\" {\\n\\t\\t\\tenvVar[k] = val\\n\\t\\t}\\n\\t}\\n\\n\\tbs, err = json.Marshal(envVar)\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n\\n\\terr = json.Unmarshal(bs, &env)\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n}\",\n \"func envFun(args ...object.Object) object.Object {\\n\\n\\tenv := os.Environ()\\n\\tnewHash := make(map[object.HashKey]object.HashPair)\\n\\n\\t//\\n\\t// If we get a match then the output is an array\\n\\t// First entry is the match, any additional parts\\n\\t// are the capture-groups.\\n\\t//\\n\\tfor i := 1; i < len(env); i++ {\\n\\n\\t\\t// Capture groups start at index 0.\\n\\t\\tk := &object.String{Value: env[i]}\\n\\t\\tv := &object.String{Value: os.Getenv(env[i])}\\n\\n\\t\\tnewHashPair := object.HashPair{Key: k, Value: v}\\n\\t\\tnewHash[k.HashKey()] = newHashPair\\n\\t}\\n\\n\\treturn &object.Hash{Pairs: newHash}\\n}\",\n \"func LookupEnv(key string) (string, bool)\",\n \"func Env(env Environ) func(*Runner) error {\\n\\treturn func(r *Runner) error {\\n\\t\\tif env == nil {\\n\\t\\t\\tenv, _ = EnvFromList(os.Environ())\\n\\t\\t}\\n\\t\\tr.Env = env\\n\\t\\treturn nil\\n\\t}\\n}\",\n \"func (e *execution) parseEnvInputs() []apiv1.EnvVar {\\n\\tvar data []apiv1.EnvVar\\n\\n\\tfor _, val := range e.envInputs {\\n\\t\\ttmp := apiv1.EnvVar{Name: val.Name, Value: val.Value}\\n\\t\\tdata = append(data, tmp)\\n\\t}\\n\\n\\treturn data\\n}\",\n \"func (o BuildRunStatusBuildSpecRuntimePtrOutput) Env() pulumi.StringMapOutput {\\n\\treturn o.ApplyT(func(v *BuildRunStatusBuildSpecRuntime) map[string]string {\\n\\t\\tif v == nil {\\n\\t\\t\\treturn nil\\n\\t\\t}\\n\\t\\treturn v.Env\\n\\t}).(pulumi.StringMapOutput)\\n}\",\n \"func setEnv(d interface{}) {\\n\\tVCAP := os.Getenv(\\\"VCAP_SERVICES\\\")\\n\\tif VCAP == \\\"\\\" {\\n\\t\\treturn // no environment found so use whatever DBURL is set to\\n\\t}\\n\\tb := []byte(VCAP)\\n\\terr := json.Unmarshal(b, d) \\n\\tif err != nil {\\n\\t\\tfmt.Printf(\\\"dbhandler:setEnv:ERROR:%s\\\", err)\\n\\t}\\n}\",\n \"func Getenv(key string) string\",\n \"func Eval(t testing.TestingT, options *EvalOptions, jsonFilePaths []string, resultQuery string) {\\n\\trequire.NoError(t, EvalE(t, options, jsonFilePaths, resultQuery))\\n}\",\n \"func importEnv(e []string) *phpv.ZHashTable {\\n\\tzt := phpv.NewHashTable()\\n\\n\\tfor _, s := range e {\\n\\t\\tp := strings.IndexByte(s, '=')\\n\\t\\tif p != -1 {\\n\\t\\t\\tzt.SetString(phpv.ZString(s[:p]), phpv.ZString(s[p+1:]).ZVal())\\n\\t\\t}\\n\\t}\\n\\n\\treturn zt\\n}\",\n \"func (om *OpenMock) ParseEnv() {\\n\\terr := env.Parse(om)\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n}\",\n \"func parseEnv(envs []string) map[string]string {\\n\\tout := make(map[string]string)\\n\\tfor _, v := range envs {\\n\\t\\tp := strings.SplitN(v, \\\"=\\\", 2)\\n\\t\\tout[p[0]] = p[1]\\n\\t}\\n\\treturn out\\n}\",\n \"func RenderWithEnv(s string, ext map[string]string) string {\\n\\tmatches := regexpEnvironmentVar.FindAllString(s, -1)\\n\\tfor _, match := range matches {\\n\\t\\tkey := match[1:]\\n\\t\\tval := ext[key]\\n\\t\\tif val == \\\"\\\" {\\n\\t\\t\\tval = os.Getenv(key)\\n\\t\\t}\\n\\t\\tif val != \\\"\\\" {\\n\\t\\t\\ts = strings.ReplaceAll(s, match, val)\\n\\t\\t}\\n\\t}\\n\\treturn s\\n}\",\n \"func AccessTokensFromEnvJSON(env string) []string {\\n\\taccessTokens := []string{}\\n\\tif len(env) == 0 {\\n\\t\\treturn accessTokens\\n\\t}\\n\\terr := json.Unmarshal([]byte(env), &accessTokens)\\n\\tif err != nil {\\n\\t\\tlog.Entry().Infof(\\\"Token json '%v' has wrong format.\\\", env)\\n\\t}\\n\\treturn accessTokens\\n}\",\n \"func GetEnv(en []map[string]string, key string) string {\\n\\ts := \\\"\\\"\\n\\tfor _, e := range en {\\n\\t\\tif v, ok := e[key]; ok {\\n\\t\\t\\ts = v\\n\\t\\t}\\n\\t}\\n\\treturn s\\n}\",\n \"func (hc ApplicationsController) EnvSet(w http.ResponseWriter, r *http.Request) APIErrors {\\n\\tctx := r.Context()\\n\\tlog := tracelog.Logger(ctx)\\n\\n\\tparams := httprouter.ParamsFromContext(ctx)\\n\\torgName := params.ByName(\\\"org\\\")\\n\\tappName := params.ByName(\\\"app\\\")\\n\\n\\tlog.Info(\\\"processing environment variable assignment\\\",\\n\\t\\t\\\"org\\\", orgName, \\\"app\\\", appName)\\n\\n\\tcluster, err := kubernetes.GetCluster(ctx)\\n\\tif err != nil {\\n\\t\\treturn InternalError(err)\\n\\t}\\n\\n\\texists, err := organizations.Exists(ctx, cluster, orgName)\\n\\tif err != nil {\\n\\t\\treturn InternalError(err)\\n\\t}\\n\\n\\tif !exists {\\n\\t\\treturn OrgIsNotKnown(orgName)\\n\\t}\\n\\n\\tapp := models.NewAppRef(appName, orgName)\\n\\n\\texists, err = application.Exists(ctx, cluster, app)\\n\\tif err != nil {\\n\\t\\treturn InternalError(err)\\n\\t}\\n\\n\\tif !exists {\\n\\t\\treturn AppIsNotKnown(appName)\\n\\t}\\n\\n\\tdefer r.Body.Close()\\n\\tbodyBytes, err := ioutil.ReadAll(r.Body)\\n\\tif err != nil {\\n\\t\\treturn InternalError(err)\\n\\t}\\n\\n\\tvar setRequest models.EnvVariableList\\n\\terr = json.Unmarshal(bodyBytes, &setRequest)\\n\\tif err != nil {\\n\\t\\treturn BadRequest(err)\\n\\t}\\n\\n\\terr = application.EnvironmentSet(ctx, cluster, app, setRequest)\\n\\tif err != nil {\\n\\t\\treturn InternalError(err)\\n\\t}\\n\\n\\treturn nil\\n}\",\n \"func assertEnv(ctx context.Context, client client.Client, spec corev1.PodSpec, component, container, key, expectedValue string) error {\\n\\tvalue, err := getEnv(ctx, client, spec, component, container, key)\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\n\\tif value != nil && strings.ToLower(*value) != expectedValue {\\n\\t\\treturn ErrIncompatibleCluster{\\n\\t\\t\\terr: fmt.Sprintf(\\\"%s=%s is not supported\\\", key, *value),\\n\\t\\t\\tcomponent: component,\\n\\t\\t\\tfix: fmt.Sprintf(\\\"remove the %s env var or set it to '%s'\\\", key, expectedValue),\\n\\t\\t}\\n\\t}\\n\\n\\treturn nil\\n}\",\n \"func env(key string, fallback string) string {\\n\\tif v := os.Getenv(key); v != \\\"\\\" {\\n\\t\\treturn v\\n\\t}\\n\\treturn fallback\\n}\",\n \"func ExpandEnv(env map[string]string, otherEnv map[string]string) map[string]string {\\n\\tresult := make(map[string]string)\\n\\n\\tfor k, v := range env {\\n\\t\\texpandV := os.Expand(v, func (key string) string { return otherEnv[key] })\\n\\t\\tresult[k] = expandV\\n\\t}\\n\\n\\treturn result\\n}\",\n \"func Env(def, key string, fallbacks ...string) string {\\n\\tif val, found := LookupEnv(key, fallbacks...); found {\\n\\t\\treturn val\\n\\t}\\n\\treturn def\\n}\",\n \"func TestEnvironmentGet(t *testing.T) {\\n\\tport := make(chan int, 1)\\n\\tdefer createTestServer(port, t).Close()\\n\\taddr := <-port\\n\\tresp, err := http.Get(fmt.Sprintf(\\\"http://localhost:%d/env/get\\\", addr))\\n\\tif err != nil {\\n\\t\\tt.Fatal(err)\\n\\t}\\n\\tdefer resp.Body.Close()\\n\\tbodyContent, err := ioutil.ReadAll(resp.Body)\\n\\tif err != nil {\\n\\t\\tt.Fatal(err)\\n\\t}\\n\\tif string(bodyContent) != \\\"Testing env.set function\\\" {\\n\\t\\tt.Fatalf(\\\"Wrong env.get value. Expected 'Testing env.set function' but got '%s'\\\", string(bodyContent))\\n\\t}\\n}\",\n \"func readEnviromentFile() *ServerEnv {\\n\\tvar serverEnv ServerEnv\\n\\tjsonFile, err := os.Open(\\\"dist/env.json\\\")\\n\\tif err != nil {\\n\\t\\tfmt.Printf(\\\":0 PANIK , enviroment json not attempting local dir found\\\")\\n\\t\\tjsonFile, err = os.Open(\\\"env.json\\\")\\n\\t\\tif err != nil {\\n\\t\\t\\tpanic(\\\":0 PANIK , enviroment json not found\\\")\\n\\t\\t}\\n\\t}\\n\\tbyteValue, _ := ioutil.ReadAll(jsonFile)\\n\\terr = json.Unmarshal(byteValue, &serverEnv)\\n\\tif err != nil {\\n\\t\\tpanic(\\\":0 PANIK , enviroment json could not decode\\\")\\n\\t}\\n\\treturn &serverEnv\\n}\",\n \"func (v LiteralValue) Eval(*Environment) (document.Value, error) {\\n\\treturn document.Value(v), nil\\n}\",\n \"func getEnvFun(args ...object.Object) object.Object {\\n\\tif len(args) != 1 {\\n\\t\\treturn newError(\\\"wrong number of arguments. got=%d, want=1\\\",\\n\\t\\t\\tlen(args))\\n\\t}\\n\\tif args[0].Type() != object.STRING_OBJ {\\n\\t\\treturn newError(\\\"argument must be a string, got=%s\\\",\\n\\t\\t\\targs[0].Type())\\n\\t}\\n\\tinput := args[0].(*object.String).Value\\n\\treturn &object.String{Value: os.Getenv(input)}\\n\\n}\",\n \"func assertJSON(e *ptesting.Environment, out string, respObj interface{}) {\\n\\terr := json.Unmarshal([]byte(out), &respObj)\\n\\tif err != nil {\\n\\t\\te.Errorf(\\\"unable to unmarshal %v\\\", out)\\n\\t}\\n}\",\n \"func environ(envVars []*apiclient.EnvEntry) []string {\\n\\tvar environ []string\\n\\tfor _, item := range envVars {\\n\\t\\tif item != nil && item.Name != \\\"\\\" && item.Value != \\\"\\\" {\\n\\t\\t\\tenviron = append(environ, fmt.Sprintf(\\\"%s=%s\\\", item.Name, item.Value))\\n\\t\\t}\\n\\t}\\n\\treturn environ\\n}\",\n \"func (ci MrbCallInfo) Env() REnv {\\n\\treturn REnv{C.mrb_vm_ci_env(ci.p), nil}\\n}\",\n \"func Evaluate(expr string, contextVars map[string]logol.Match) bool {\\n\\tlogger.Debugf(\\\"Evaluate expression: %s\\\", expr)\\n\\n\\tre := regexp.MustCompile(\\\"[$@#]+\\\\\\\\w+\\\")\\n\\tres := re.FindAllString(expr, -1)\\n\\t// msg, _ := json.Marshal(contextVars)\\n\\t// logger.Errorf(\\\"CONTEXT: %s\\\", msg)\\n\\tparameters := make(map[string]interface{}, 8)\\n\\tvarIndex := 0\\n\\tfor _, val := range res {\\n\\t\\tt := strconv.Itoa(varIndex)\\n\\t\\tvarName := \\\"VAR\\\" + t\\n\\t\\tr := strings.NewReplacer(val, varName)\\n\\t\\texpr = r.Replace(expr)\\n\\t\\tvarIndex++\\n\\t\\tcValue, cerr := getValueFromExpression(val, contextVars)\\n\\t\\tif cerr {\\n\\t\\t\\tlogger.Debugf(\\\"Failed to get value from expression %s\\\", val)\\n\\t\\t\\treturn false\\n\\t\\t}\\n\\t\\tparameters[varName] = cValue\\n\\t}\\n\\tlogger.Debugf(\\\"New expr: %s with params %v\\\", expr, parameters)\\n\\n\\texpression, err := govaluate.NewEvaluableExpression(expr)\\n\\tif err != nil {\\n\\t\\tlogger.Errorf(\\\"Failed to evaluate expression %s\\\", expr)\\n\\t\\treturn false\\n\\t}\\n\\tresult, _ := expression.Evaluate(parameters)\\n\\tif result == true {\\n\\t\\treturn true\\n\\t}\\n\\treturn false\\n}\",\n \"func (b *Executable) Env(arg, value string) *Executable {\\n\\tif b.Environment == nil {\\n\\t\\tb.Environment = make(map[string]string)\\n\\t}\\n\\tb.Environment[arg] = value\\n\\treturn b\\n}\",\n \"func parseEnv(name, defval string, parsefn func(string) error) {\\n\\tif envval := os.Getenv(name); envval != \\\"\\\" {\\n\\t\\terr := parsefn(envval)\\n\\t\\tif err == nil {\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tlog.Error(\\\"invalid environment %s=%q: %v, using default %q\\\", name, envval, err, defval)\\n\\t}\\n\\tif err := parsefn(defval); err != nil {\\n\\t\\tlog.Error(\\\"invalid default %s=%q: %v\\\", name, defval, err)\\n\\t}\\n}\",\n \"func evaluateENVBool(envVar string, defaultValue bool) bool {\\n\\tenvValue, isSet := os.LookupEnv(envVar)\\n\\n\\tif isSet {\\n\\n\\t\\tswitch strings.ToLower(envValue) {\\n\\n\\t\\tcase \\\"false\\\", \\\"0\\\", \\\"no\\\", \\\"n\\\", \\\"f\\\":\\n\\t\\t\\tlog.Infof(\\\"%s is %t through environment variable\\\", envVar, false)\\n\\t\\t\\treturn false\\n\\t\\t}\\n\\t\\tlog.Infof(\\\"%s is %t through environment variable\\\", envVar, true)\\n\\t\\treturn true\\n\\t}\\n\\tlog.Infof(\\\"%s is %t (defaulted) through environment variable\\\", envVar, defaultValue)\\n\\treturn defaultValue\\n}\",\n \"func (c *Cli) ParseEnv() error {\\n\\tvar (\\n\\t\\terr error\\n\\t\\tu64 uint64\\n\\t)\\n\\tfor k, e := range c.env {\\n\\t\\ts := strings.TrimSpace(os.Getenv(k))\\n\\t\\t// NOTE: we only parse the environment if it is not an emprt string\\n\\t\\tif s != \\\"\\\" {\\n\\t\\t\\tswitch e.Type {\\n\\t\\t\\tcase \\\"bool\\\":\\n\\t\\t\\t\\te.BoolValue, err = strconv.ParseBool(s)\\n\\t\\t\\tcase \\\"int\\\":\\n\\t\\t\\t\\te.IntValue, err = strconv.Atoi(s)\\n\\t\\t\\tcase \\\"int64\\\":\\n\\t\\t\\t\\te.Int64Value, err = strconv.ParseInt(s, 10, 64)\\n\\t\\t\\tcase \\\"uint\\\":\\n\\t\\t\\t\\tu64, err = strconv.ParseUint(s, 10, 32)\\n\\t\\t\\t\\te.UintValue = uint(u64)\\n\\t\\t\\tcase \\\"uint64\\\":\\n\\t\\t\\t\\te.Uint64Value, err = strconv.ParseUint(s, 10, 64)\\n\\t\\t\\tcase \\\"float64\\\":\\n\\t\\t\\t\\te.Float64Value, err = strconv.ParseFloat(s, 64)\\n\\t\\t\\tcase \\\"time.Duration\\\":\\n\\t\\t\\t\\te.DurationValue, err = time.ParseDuration(s)\\n\\t\\t\\tdefault:\\n\\t\\t\\t\\te.StringValue = s\\n\\t\\t\\t}\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\treturn fmt.Errorf(\\\"%q should be type %q, %s\\\", e.Name, e.Type, err)\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tc.env[k] = e\\n\\t}\\n\\treturn err\\n}\",\n \"func addEnv(s *scope, arg pyObject, target *core.BuildTarget) {\\n\\tenvPy, ok := asDict(arg)\\n\\ts.Assert(ok, \\\"env must be a dict\\\")\\n\\n\\tenv := make(map[string]string, len(envPy))\\n\\tfor name, val := range envPy {\\n\\t\\tv, ok := val.(pyString)\\n\\t\\ts.Assert(ok, \\\"Values of env must be strings, found %v at key %v\\\", val.Type(), name)\\n\\t\\tenv[name] = string(v)\\n\\t}\\n\\n\\ttarget.Env = env\\n}\",\n \"func env() error {\\n\\t// regexp for TF_VAR_ terraform vars\\n\\ttfVar := regexp.MustCompile(`^TF_VAR_.*$`)\\n\\n\\t// match terraform vars in environment\\n\\tfor _, e := range os.Environ() {\\n\\t\\t// split on value\\n\\t\\tpair := strings.SplitN(e, \\\"=\\\", 2)\\n\\n\\t\\t// match on TF_VAR_*\\n\\t\\tif tfVar.MatchString(pair[0]) {\\n\\t\\t\\t// pull out the name\\n\\t\\t\\tname := strings.Split(pair[0], \\\"TF_VAR_\\\")\\n\\n\\t\\t\\t// lower case the terraform variable\\n\\t\\t\\t// to accommodate cicd injection capitalization\\n\\t\\t\\terr := os.Setenv(fmt.Sprintf(\\\"TF_VAR_%s\\\",\\n\\t\\t\\t\\tstrings.ToLower(name[1])), pair[1])\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\treturn err\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\treturn nil\\n}\",\n \"func validateEnv(vars []corev1.EnvVar, fldPath *field.Path) field.ErrorList {\\n\\tallErrs := field.ErrorList{}\\n\\n\\tfor i, ev := range vars {\\n\\t\\tidxPath := fldPath.Index(i)\\n\\t\\tif len(ev.Name) == 0 {\\n\\t\\t\\tallErrs = append(allErrs, field.Required(idxPath.Child(\\\"name\\\"), \\\"\\\"))\\n\\t\\t} else {\\n\\t\\t\\tfor _, msg := range validation.IsEnvVarName(ev.Name) {\\n\\t\\t\\t\\tallErrs = append(allErrs, field.Invalid(idxPath.Child(\\\"name\\\"), ev.Name, msg))\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tallErrs = append(allErrs, validateEnvVarValueFrom(ev, idxPath.Child(\\\"valueFrom\\\"))...)\\n\\t}\\n\\treturn allErrs\\n}\",\n \"func UnmarshalFromEnv(c interface{}) {\\n\\ttopType := reflect.TypeOf(c).Elem()\\n\\ttopValue := reflect.ValueOf(c)\\n\\tfor i := 0; i < topType.NumField(); i++ {\\n\\t\\tfield := topType.Field(i)\\n\\t\\tif field.Tag.Get(\\\"env\\\") != \\\"\\\" {\\n\\t\\t\\tenvVar := os.Getenv(field.Tag.Get(\\\"env\\\"))\\n\\t\\t\\tif envVar == \\\"\\\" {\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\n\\t\\t\\tswitch field.Type.Kind() {\\n\\t\\t\\tcase reflect.Bool:\\n\\t\\t\\t\\tb, err := strconv.ParseBool(envVar)\\n\\t\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t\\tfmt.Println(\\\"didn't set from \\\", field.Tag.Get(\\\"env\\\"), \\\" due to \\\", err)\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tf := topValue.Elem().Field(i)\\n\\t\\t\\t\\tf.SetBool(b)\\n\\t\\t\\tcase reflect.Int64:\\n\\t\\t\\t\\tinteger, err := strconv.ParseInt(envVar, 0, 64)\\n\\t\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t\\tfmt.Println(\\\"didn't set from \\\", field.Tag.Get(\\\"env\\\"), \\\" due to \\\", err)\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tf := topValue.Elem().Field(i)\\n\\t\\t\\t\\tf.SetInt(integer)\\n\\t\\t\\tcase reflect.String:\\n\\t\\t\\t\\tf := topValue.Elem().Field(i)\\n\\t\\t\\t\\tf.SetString(envVar)\\n\\t\\t\\tcase reflect.Float64:\\n\\t\\t\\t\\tfloat, err := strconv.ParseFloat(envVar, 64)\\n\\t\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t\\tfmt.Println(\\\"didn't set from \\\", field.Tag.Get(\\\"env\\\"), \\\" due to \\\", err)\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tf := topValue.Elem().Field(i)\\n\\t\\t\\t\\tf.SetFloat(float)\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n}\",\n \"func env(key string, defaultValue string) string {\\n\\tif value, exists := os.LookupEnv(key); exists {\\n\\t\\treturn value\\n\\t}\\n\\treturn defaultValue\\n}\",\n \"func NewJsonEnvironment() *JsonEnvironment {\\n\\tthis := JsonEnvironment{}\\n\\treturn &this\\n}\",\n \"func RunJSONSerializationTestForHostingEnvironmentProfile(subject HostingEnvironmentProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual HostingEnvironmentProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func MatchEnv(k string) bool {\\n\\n\\tkey := strings.TrimPrefix(k, \\\"/\\\")\\n\\tkeyEnv := strings.Split(key, \\\"/\\\")\\n\\tif len(keyEnv) > 3 {\\n\\t\\tif (keyEnv[2] == os.Getenv(\\\"VINE_ENV\\\")) && (keyEnv[3] == \\\"routes\\\") {\\n\\t\\t\\treturn true\\n\\t\\t}\\n\\t}\\n\\treturn false\\n}\",\n \"func (p RProc) Env() REnv {\\n\\tif !p.HasEnv() {\\n\\t\\treturn REnv{nil, p.mrb}\\n\\t}\\n\\treturn REnv{C._MRB_PROC_ENV(p.p), p.mrb}\\n}\",\n \"func parseIPEnvironment(envName, envValue string, version int) string {\\n\\t// To parse the environment (which could be an IP or a CIDR), convert\\n\\t// to a JSON string and use the UnmarshalJSON method on the IPNet\\n\\t// struct to parse the value.\\n\\tip := &cnet.IPNet{}\\n\\terr := ip.UnmarshalJSON([]byte(\\\"\\\\\\\"\\\" + envValue + \\\"\\\\\\\"\\\"))\\n\\tif err != nil || ip.Version() != version {\\n\\t\\tlog.Warnf(\\\"Environment does not contain a valid IPv%d address: %s=%s\\\", version, envName, envValue)\\n\\t\\tutils.Terminate()\\n\\t}\\n\\tlog.Infof(\\\"Using IPv%d address from environment: %s=%s\\\", ip.Version(), envName, envValue)\\n\\n\\treturn ip.String()\\n}\",\n \"func standardEnv() map[string]interface{} {\\r\\n env := make(map[string]interface{}, 0)\\r\\n env[\\\"false\\\"] = false\\r\\n env[\\\"true\\\"] = true\\r\\n env[\\\"+\\\"] = func(args []interface{}) interface{} {\\r\\n\\tn, ok1 := args[0].(int)\\r\\n\\tm, ok2 := args[1].(int)\\r\\n\\tif !ok1 || !ok2 {\\r\\n\\t panic(\\\"+ needs numbers\\\")\\r\\n\\t}\\r\\n\\treturn n + m\\r\\n }\\r\\n return env\\r\\n}\",\n \"func (b *builtinValuesJSONSig) evalJSON(_ chunk.Row) (types.BinaryJSON, bool, error) {\\n\\trow := b.ctx.GetSessionVars().CurrInsertValues\\n\\tif row.IsEmpty() {\\n\\t\\treturn types.BinaryJSON{}, true, nil\\n\\t}\\n\\tif b.offset < row.Len() {\\n\\t\\tif row.IsNull(b.offset) {\\n\\t\\t\\treturn types.BinaryJSON{}, true, nil\\n\\t\\t}\\n\\t\\treturn row.GetJSON(b.offset), false, nil\\n\\t}\\n\\treturn types.BinaryJSON{}, true, errors.Errorf(\\\"Session current insert values len %d and column's offset %v don't match\\\", row.Len(), b.offset)\\n}\",\n \"func MakeEvalEnv() eval.Env {\\n\\tvar pkgs map[string] eval.Pkg = make(map[string] eval.Pkg)\\n\\tEvalEnvironment(pkgs)\\n\\n\\tenv := eval.Env {\\n\\t\\tName: \\\".\\\",\\n\\t\\tVars: make(map[string] reflect.Value),\\n\\t\\tConsts: make(map[string] reflect.Value),\\n\\t\\tFuncs: make(map[string] reflect.Value),\\n\\t\\tTypes: make(map[string] reflect.Type),\\n\\t\\tPkgs: pkgs,\\n\\t}\\n\\treturn env\\n}\",\n \"func (r *CheckedDaemonSet) assertEnv(ctx context.Context, client client.Client, container, key, expectedValue string) error {\\n\\tif err := assertEnv(ctx, client, r.Spec.Template.Spec, ComponentCalicoNode, container, key, expectedValue); err != nil {\\n\\t\\treturn err\\n\\t}\\n\\tr.ignoreEnv(container, key)\\n\\treturn nil\\n}\",\n \"func CheckEnv(lookupFunc func(key string) (string, bool)) (err error) {\\n\\tif lookupFunc == nil {\\n\\t\\tlookupFunc = os.LookupEnv\\n\\t}\\n\\n\\tenvVars := [4]string{\\n\\t\\tEnvHueBridgeAddress,\\n\\t\\tEnvHueBridgeUsername,\\n\\t\\tEnvHueRemoteToken,\\n\\t\\tEnvRedisURL,\\n\\t}\\n\\n\\tfor _, v := range envVars {\\n\\t\\tif _, ok := lookupFunc(v); !ok {\\n\\t\\t\\treturn models.NewMissingEnvError(v)\\n\\t\\t}\\n\\t}\\n\\n\\treturn nil\\n}\",\n \"func toEnv(spec *engine.Spec, step *engine.Step) []v1.EnvVar {\\n\\tvar to []v1.EnvVar\\n\\tfor k, v := range step.Envs {\\n\\t\\tto = append(to, v1.EnvVar{\\n\\t\\t\\tName: k,\\n\\t\\t\\tValue: v,\\n\\t\\t})\\n\\t}\\n\\tto = append(to, v1.EnvVar{\\n\\t\\tName: \\\"KUBERNETES_NODE\\\",\\n\\t\\tValueFrom: &v1.EnvVarSource{\\n\\t\\t\\tFieldRef: &v1.ObjectFieldSelector{\\n\\t\\t\\t\\tFieldPath: \\\"spec.nodeName\\\",\\n\\t\\t\\t},\\n\\t\\t},\\n\\t})\\n\\tfor _, secret := range step.Secrets {\\n\\t\\tsec, ok := engine.LookupSecret(spec, secret)\\n\\t\\tif !ok {\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\t\\toptional := true\\n\\t\\tto = append(to, v1.EnvVar{\\n\\t\\t\\tName: secret.Env,\\n\\t\\t\\tValueFrom: &v1.EnvVarSource{\\n\\t\\t\\t\\tSecretKeyRef: &v1.SecretKeySelector{\\n\\t\\t\\t\\t\\tLocalObjectReference: v1.LocalObjectReference{\\n\\t\\t\\t\\t\\t\\tName: sec.Metadata.UID,\\n\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\tKey: sec.Metadata.UID,\\n\\t\\t\\t\\t\\tOptional: &optional,\\n\\t\\t\\t\\t},\\n\\t\\t\\t},\\n\\t\\t})\\n\\t}\\n\\treturn to\\n}\",\n \"func Eval(node ast.Node, env *object.Environment) object.Object {\\n\\tswitch node := node.(type) {\\n\\n\\t// Statements\\n\\tcase *ast.RootNode:\\n\\t\\treturn evalRootNode(node, env)\\n\\n\\tcase *ast.BlockStatement:\\n\\t\\treturn evalBlockStmt(node, env)\\n\\n\\tcase *ast.ExpressionStatement:\\n\\t\\treturn Eval(node.Expression, env)\\n\\n\\tcase *ast.ReturnStatement:\\n\\t\\tval := Eval(node.ReturnValue, env)\\n\\t\\tif isError(val) {\\n\\t\\t\\treturn val\\n\\t\\t}\\n\\t\\treturn &object.ReturnValue{Value: val}\\n\\n\\tcase *ast.LetStatement:\\n\\t\\tval := Eval(node.Value, env)\\n\\t\\tif isError(val) {\\n\\t\\t\\treturn val\\n\\t\\t}\\n\\t\\tenv.Set(node.Name.Value, val)\\n\\n\\tcase *ast.ConstStatement:\\n\\t\\tval := Eval(node.Value, env)\\n\\t\\tif isError(val) {\\n\\t\\t\\treturn val\\n\\t\\t}\\n\\t\\tenv.Set(node.Name.Value, val)\\n\\n\\t// Expressions\\n\\tcase *ast.IntegerLiteral:\\n\\t\\treturn &object.Integer{Value: node.Value}\\n\\n\\tcase *ast.StringLiteral:\\n\\t\\treturn &object.String{Value: node.Value}\\n\\n\\tcase *ast.Boolean:\\n\\t\\treturn nativeBoolToBooleanObj(node.Value)\\n\\n\\tcase *ast.PrefixExpression:\\n\\t\\tright := Eval(node.Right, env)\\n\\t\\tif isError(right) {\\n\\t\\t\\treturn right\\n\\t\\t}\\n\\t\\treturn evalPrefixExpr(node.Operator, right, node.Token.Line)\\n\\n\\tcase *ast.InfixExpression:\\n\\t\\tleft := Eval(node.Left, env)\\n\\t\\tif isError(left) {\\n\\t\\t\\treturn left\\n\\t\\t}\\n\\t\\tright := Eval(node.Right, env)\\n\\t\\tif isError(right) {\\n\\t\\t\\treturn right\\n\\t\\t}\\n\\t\\treturn evalInfixExpr(node.Operator, left, right, node.Token.Line)\\n\\n\\tcase *ast.PostfixExpression:\\n\\t\\treturn evalPostfixExpr(env, node.Operator, node)\\n\\n\\tcase *ast.IfExpression:\\n\\t\\treturn evalIfExpr(node, env)\\n\\n\\tcase *ast.Identifier:\\n\\t\\treturn evalIdentifier(node, env)\\n\\n\\tcase *ast.FunctionLiteral:\\n\\t\\tparams := node.Parameters\\n\\t\\tbody := node.Body\\n\\t\\treturn &object.Function{\\n\\t\\t\\tParameters: params,\\n\\t\\t\\tBody: body,\\n\\t\\t\\tEnv: env,\\n\\t\\t}\\n\\n\\tcase *ast.CallExpression:\\n\\t\\tfn := Eval(node.Function, env)\\n\\t\\tif isError(fn) {\\n\\t\\t\\treturn fn\\n\\t\\t}\\n\\t\\targs := evalExprs(node.Arguments, env)\\n\\t\\tif len(args) == 1 && isError(args[0]) {\\n\\t\\t\\treturn args[0]\\n\\t\\t}\\n\\t\\treturn applyFunction(fn, args, node.Token.Line)\\n\\n\\tcase *ast.ArrayLiteral:\\n\\t\\telements := evalExprs(node.Elements, env)\\n\\t\\tif len(elements) == 1 && isError(elements[0]) {\\n\\t\\t\\treturn elements[0]\\n\\t\\t}\\n\\t\\treturn &object.Array{Elements: elements}\\n\\n\\tcase *ast.IndexExpression:\\n\\t\\tleft := Eval(node.Left, env)\\n\\t\\tif isError(left) {\\n\\t\\t\\treturn left\\n\\t\\t}\\n\\t\\tindex := Eval(node.Index, env)\\n\\t\\tif isError(index) {\\n\\t\\t\\treturn index\\n\\t\\t}\\n\\t\\treturn evalIndexExpr(left, index, node.Token.Line)\\n\\n\\tcase *ast.HashLiteral:\\n\\t\\treturn evalHashLiteral(node, env)\\n\\t}\\n\\n\\treturn nil\\n}\",\n \"func (o BuildSpecRuntimePtrOutput) Env() pulumi.StringMapOutput {\\n\\treturn o.ApplyT(func(v *BuildSpecRuntime) map[string]string {\\n\\t\\tif v == nil {\\n\\t\\t\\treturn nil\\n\\t\\t}\\n\\t\\treturn v.Env\\n\\t}).(pulumi.StringMapOutput)\\n}\",\n \"func ExampleBind() {\\n\\t// Simple configuration struct\\n\\ttype config struct {\\n\\t\\tHostName string `env:\\\"HOSTNAME\\\"` // default: HOST_NAME\\n\\t\\tUserName string `env:\\\"USERNAME\\\"` // default: USER_NAME\\n\\t\\tSSL bool `env:\\\"USE_SSL\\\"` // default: SSL\\n\\t\\tPort int // leave as default (PORT)\\n\\t\\tPingInterval time.Duration `env:\\\"PING\\\"` // default: PING_INTERVAL\\n\\t\\tOnline bool `env:\\\"-\\\"` // ignore this field\\n\\t}\\n\\n\\t// Set some values in the environment for test purposes\\n\\t_ = os.Setenv(\\\"HOSTNAME\\\", \\\"api.example.com\\\")\\n\\t_ = os.Setenv(\\\"USERNAME\\\", \\\"\\\") // empty\\n\\t_ = os.Setenv(\\\"PORT\\\", \\\"443\\\")\\n\\t_ = os.Setenv(\\\"USE_SSL\\\", \\\"1\\\")\\n\\t_ = os.Setenv(\\\"PING\\\", \\\"5m\\\")\\n\\t_ = os.Setenv(\\\"ONLINE\\\", \\\"1\\\") // will be ignored\\n\\n\\t// Create a config and bind it to the environment\\n\\tc := &config{}\\n\\tif err := Bind(c); err != nil {\\n\\t\\t// handle error...\\n\\t}\\n\\n\\t// config struct now populated from the environment\\n\\tfmt.Println(c.HostName)\\n\\tfmt.Println(c.UserName)\\n\\tfmt.Printf(\\\"%d\\\\n\\\", c.Port)\\n\\tfmt.Printf(\\\"%v\\\\n\\\", c.SSL)\\n\\tfmt.Printf(\\\"%v\\\\n\\\", c.Online)\\n\\tfmt.Printf(\\\"%v\\\\n\\\", c.PingInterval*4) // it's not a string!\\n\\t// Output:\\n\\t// api.example.com\\n\\t//\\n\\t// 443\\n\\t// true\\n\\t// false\\n\\t// 20m0s\\n\\n\\tos.Clearenv()\\n}\",\n \"func EnvVarTest(resourceName string, sourceType string, envString string) {\\n\\n\\tif sourceType == \\\"git\\\" {\\n\\t\\t// checking the values of the env vars pairs in bc\\n\\t\\tenvVars := runCmd(\\\"oc get bc \\\" + resourceName + \\\" -o go-template='{{range .spec.strategy.sourceStrategy.env}}{{.name}}{{.value}}{{end}}'\\\")\\n\\t\\tExpect(envVars).To(Equal(envString))\\n\\t}\\n\\n\\t// checking the values of the env vars pairs in dc\\n\\tenvVars := runCmd(\\\"oc get dc \\\" + resourceName + \\\" -o go-template='{{range .spec.template.spec.containers}}{{range .env}}{{.name}}{{.value}}{{end}}{{end}}'\\\")\\n\\tExpect(envVars).To(Equal(envString))\\n}\",\n \"func (c *Env) MarshalJSON() ([]byte, error) {\\n\\tdata := map[string]interface{}{\\n\\t\\t\\\"appID\\\": strconv.FormatUint(c.appID, 10),\\n\\t\\t\\\"level\\\": c.level,\\n\\t\\t\\\"status\\\": c.Status,\\n\\t\\t\\\"frictionlessRequests\\\": c.FrictionlessRequests,\\n\\t\\t\\\"signedRequest\\\": c.SignedRequest,\\n\\t\\t\\\"viewMode\\\": c.ViewMode,\\n\\t\\t\\\"init\\\": c.Init,\\n\\t}\\n\\tif c.isEmployee {\\n\\t\\tdata[\\\"isEmployee\\\"] = true\\n\\t}\\n\\treturn json.Marshal(data)\\n}\",\n \"func Evaluate(thing interface{}, env Environment) (error, Value, Environment) {\\n\\tswitch thing.(type) {\\n\\tcase Value:\\n\\t\\treturn EvaluateValue(thing.(Value), env)\\n\\tcase SExpression:\\n\\t\\tsexp := thing.(SExpression)\\n\\t\\tif isSpecialForm(sexp.FormName.Contained) {\\n\\t\\t\\treturn EvaluateSpecialForm(sexp, env)\\n\\t\\t} else {\\n\\t\\t\\treturn EvaluateSexp(thing.(SExpression), env)\\n\\t\\t}\\n\\tdefault:\\n\\t\\treturn errors.New(fmt.Sprintf(\\\"No way to evaluate %v\\\\n\\\", thing)), Value{}, env\\n\\t}\\n}\",\n \"func (c *Client) EnvUpdate(ctx context.Context, req *EnvUpdateRequest) (*EnvUpdateResponse, error) {\\n\\tvar resp EnvUpdateResponse\\n\\tif err := c.client.Do(ctx, \\\"PATCH\\\", envURL, req, &resp); err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tresp.Normalize()\\n\\treturn &resp, nil\\n}\",\n \"func (config *Config) Get(key string, v interface{}) error {\\n\\tvar val interface{}\\n\\n\\tenv, set := os.LookupEnv(key)\\n\\n\\tif set {\\n\\t\\tswitch v.(type) {\\n\\t\\tcase *float64:\\n\\t\\t\\tval, err := strconv.ParseFloat(env, 64)\\n\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\treturn err\\n\\t\\t\\t}\\n\\n\\t\\t\\t*v.(*float64) = val\\n\\t\\t\\treturn nil\\n\\t\\tcase *int:\\n\\t\\t\\tval, err := strconv.ParseInt(env, 10, 64)\\n\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\treturn err\\n\\t\\t\\t}\\n\\n\\t\\t\\t*v.(*int) = int(val)\\n\\t\\t\\treturn nil\\n\\t\\tdefault:\\n\\t\\t\\tval = env\\n\\t\\t}\\n\\t} else if config.cache != nil {\\n\\t\\tval = (*config.cache)[key]\\n\\t}\\n\\n\\t// Cast JSON values\\n\\tswitch v.(type) {\\n\\tcase *string:\\n\\t\\tif val == nil {\\n\\t\\t\\tval = \\\"\\\"\\n\\t\\t}\\n\\n\\t\\tif b, ok := val.(bool); ok {\\n\\t\\t\\t*v.(*string) = strconv.FormatBool(b)\\n\\t\\t} else if f, ok := val.(float64); ok {\\n\\t\\t\\t*v.(*string) = strconv.FormatFloat(f, 'f', -1, 64)\\n\\t\\t} else {\\n\\t\\t\\t*v.(*string) = val.(string)\\n\\t\\t}\\n\\tcase *bool:\\n\\t\\tswitch val {\\n\\t\\tcase nil, 0, false, \\\"\\\", \\\"0\\\", \\\"false\\\":\\n\\t\\t\\t// falsey\\n\\t\\t\\tval = false\\n\\t\\tdefault:\\n\\t\\t\\t// truthy\\n\\t\\t\\tval = true\\n\\t\\t}\\n\\n\\t\\t*v.(*bool) = val.(bool)\\n\\tcase *float64:\\n\\t\\tif val == nil {\\n\\t\\t\\tval = float64(0)\\n\\t\\t}\\n\\n\\t\\tif s, ok := val.(string); ok {\\n\\t\\t\\tpf, err := strconv.ParseFloat(s, 64)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\treturn err\\n\\t\\t\\t}\\n\\n\\t\\t\\t*v.(*float64) = pf\\n\\t\\t} else {\\n\\t\\t\\t*v.(*float64) = val.(float64)\\n\\t\\t}\\n\\tcase *int:\\n\\t\\tif val == nil {\\n\\t\\t\\tval = float64(0)\\n\\t\\t}\\n\\n\\t\\t*v.(*int) = int(val.(float64))\\n\\tdefault:\\n\\t\\treturn errors.New(\\\"Type not supported\\\")\\n\\t}\\n\\n\\treturn nil\\n}\",\n \"func (a *Client) ModifyRuntimeEnv(params *ModifyRuntimeEnvParams) (*ModifyRuntimeEnvOK, error) {\\n\\t// TODO: Validate the params before sending\\n\\tif params == nil {\\n\\t\\tparams = NewModifyRuntimeEnvParams()\\n\\t}\\n\\n\\tresult, err := a.transport.Submit(&runtime.ClientOperation{\\n\\t\\tID: \\\"ModifyRuntimeEnv\\\",\\n\\t\\tMethod: \\\"PATCH\\\",\\n\\t\\tPathPattern: \\\"/v1/runtime_envs\\\",\\n\\t\\tProducesMediaTypes: []string{\\\"application/json\\\"},\\n\\t\\tConsumesMediaTypes: []string{\\\"application/json\\\"},\\n\\t\\tSchemes: []string{\\\"http\\\"},\\n\\t\\tParams: params,\\n\\t\\tReader: &ModifyRuntimeEnvReader{formats: a.formats},\\n\\t\\tContext: params.Context,\\n\\t\\tClient: params.HTTPClient,\\n\\t})\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn result.(*ModifyRuntimeEnvOK), nil\\n\\n}\",\n \"func (environment *Environment) String() string {\\n\\tmarshaledVal, _ := json.MarshalIndent(*environment, \\\"\\\", \\\" \\\") // Marshal to JSON\\n\\n\\treturn string(marshaledVal) // Return string value\\n}\",\n \"func Getenv(key string, fallbacks ...string) (value string) {\\n\\tvalue, _ = LookupEnv(key, fallbacks...)\\n\\treturn\\n}\",\n \"func (e *EnvironmentVariablesMapV0) UnmarshalJSON(data []byte) error {\\n\\tvar plain []string\\n\\tif err := json.Unmarshal(data, &plain); err == nil {\\n\\t\\te.RawCPU = []string{}\\n\\t\\te.RawGPU = []string{}\\n\\t\\te.RawCPU = append(e.RawCPU, plain...)\\n\\t\\te.RawGPU = append(e.RawGPU, plain...)\\n\\t\\treturn nil\\n\\t}\\n\\ttype DefaultParser EnvironmentVariablesMapV0\\n\\tvar jsonItems DefaultParser\\n\\tif err := json.Unmarshal(data, &jsonItems); err != nil {\\n\\t\\treturn errors.Wrapf(err, \\\"failed to parse runtime items\\\")\\n\\t}\\n\\te.RawCPU = []string{}\\n\\te.RawGPU = []string{}\\n\\tif jsonItems.RawCPU != nil {\\n\\t\\te.RawCPU = append(e.RawCPU, jsonItems.RawCPU...)\\n\\t}\\n\\tif jsonItems.RawGPU != nil {\\n\\t\\te.RawGPU = append(e.RawGPU, jsonItems.RawGPU...)\\n\\t}\\n\\treturn nil\\n}\",\n \"func eval(x interface{}, env map[string]interface{}) interface{} {\\r\\n if str, ok := isSymbol(x); ok { // variable reference\\r\\n\\treturn env[str]\\r\\n }\\r\\n l, ok := isList(x)\\r\\n if !ok { // constant literal\\r\\n\\treturn x\\r\\n }\\r\\n if len(l) == 0 {\\r\\n\\tpanic(\\\"empty list\\\")\\r\\n }\\r\\n if str, ok := isSymbol(l[0]); ok {\\r\\n\\tswitch (str) {\\r\\n\\tcase \\\"quote\\\": // (quote exp)\\r\\n\\t return l[1]\\r\\n\\tcase \\\"if\\\": // (if test conseq alt)\\r\\n\\t test := l[1]\\r\\n\\t conseq := l[2]\\r\\n\\t alt := l[3]\\r\\n\\t r := eval(test, env)\\r\\n\\t if b, ok := isFalse(r); ok && !b {\\r\\n\\t\\treturn eval(alt, env)\\r\\n\\t } else {\\r\\n\\t\\treturn eval(conseq, env)\\r\\n\\t }\\r\\n\\tcase \\\"define\\\": // (define var exp)\\r\\n\\t car := l[1]\\r\\n\\t cdr := l[2]\\r\\n\\t if str, ok = isSymbol(car); ok {\\r\\n\\t\\tenv[str] = eval(cdr, env)\\r\\n\\t\\treturn env[str]\\r\\n\\t } else {\\r\\n\\t\\tpanic(\\\"define needs a symbol\\\")\\r\\n\\t }\\r\\n\\tdefault: // (proc arg...)\\r\\n\\t car := eval(l[0], env)\\r\\n\\t proc, ok := car.(func([]interface{})interface{})\\r\\n\\t if !ok {\\r\\n\\t\\tpanic(\\\"not a procedure\\\")\\r\\n\\t }\\r\\n args := makeArgs(l[1:], env)\\r\\n return proc(args)\\r\\n\\t}\\r\\n }\\r\\n return nil\\r\\n}\",\n \"func evaluateAst(program *ast.RootNode) object.Object {\\n\\tenv := object.NewEnvironment()\\n\\treturn evaluator.Eval(program, env)\\n}\",\n \"func ExpandEnv(x *X, env *envvar.Vars) {\\n\\te := env.ToMap()\\n\\trootEnv := \\\"${\\\" + RootEnv + \\\"}\\\"\\n\\tfor k, v := range e {\\n\\t\\tn := strings.Replace(v, rootEnv, x.Root, -1)\\n\\t\\tif n != v {\\n\\t\\t\\tenv.Set(k, n)\\n\\t\\t}\\n\\t}\\n}\",\n \"func (o StorageClusterSpecStorkOutput) Env() StorageClusterSpecStorkEnvArrayOutput {\\n\\treturn o.ApplyT(func(v StorageClusterSpecStork) []StorageClusterSpecStorkEnv { return v.Env }).(StorageClusterSpecStorkEnvArrayOutput)\\n}\",\n \"func init() {\\n\\tenvironments = make(map[string]string)\\n\\n\\tfor _, e := range os.Environ() {\\n\\t\\tspl := strings.SplitN(e, \\\"=\\\", 2)\\n\\t\\tenvironments[spl[0]] = spl[1]\\n\\t}\\n}\",\n \"func (session Runtime) evaluate(expression string, contextID int64, async, returnByValue bool) (*devtool.RemoteObject, error) {\\n\\tp := &devtool.EvaluatesExpression{\\n\\t\\tExpression: expression,\\n\\t\\tIncludeCommandLineAPI: true,\\n\\t\\tContextID: contextID,\\n\\t\\tAwaitPromise: !async,\\n\\t\\tReturnByValue: returnByValue,\\n\\t}\\n\\tresult := new(devtool.EvaluatesResult)\\n\\tif err := session.call(\\\"Runtime.evaluate\\\", p, result); err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tif result.ExceptionDetails != nil {\\n\\t\\treturn nil, result.ExceptionDetails\\n\\t}\\n\\treturn result.Result, nil\\n}\",\n \"func LoadEnv() {\\n\\tif err := env.Parse(&Env); err != nil {\\n\\t\\tpanic(err.Error())\\n\\t}\\n}\",\n \"func (config *configuration) getEnvVariables() error {\\n\\t// method 1: Decode json file\\n\\tfile, err := os.Open(confFile)\\n\\tif err != nil {\\n\\t\\tpc, _, _, _ := runtime.Caller(0)\\n\\t\\terrorWebLogger.ClientIP = \\\"ClientIP is NOT existed.\\\"\\n\\t\\terrorWebLogger.FatalPrintln(getCurrentRPCmethod(pc), \\\"Open config file error.\\\", err)\\n\\t\\treturn err\\n\\t}\\n\\tdecoder := json.NewDecoder(file)\\n\\tdecoderErr := decoder.Decode(&config)\\n\\tif decoderErr != nil {\\n\\t\\tpc, _, _, _ := runtime.Caller(0)\\n\\t\\terrorWebLogger.ClientIP = \\\"ClientIP is NOT existed.\\\"\\n\\t\\terrorWebLogger.FatalPrintln(getCurrentRPCmethod(pc), \\\"Decode config file error.\\\", decoderErr)\\n\\t\\treturn decoderErr\\n\\t}\\n\\n\\t// method 2: Unmarshal json file\\n\\t// jsonData, err := ioutil.ReadFile(confFile)\\n\\t// if err != nil {\\n\\t// \\treturn err\\n\\t// }\\n\\t// unmarshalErr := json.Unmarshal(jsonData, &config)\\n\\t// if unmarshalErr != nil {\\n\\t// \\treturn unmarshalErr\\n\\t// }\\n\\treturn nil\\n}\"\n]"},"negative_scores":{"kind":"list like","value":["0.6012806","0.57397014","0.5641687","0.562627","0.5615011","0.5526408","0.5431782","0.53011316","0.5275546","0.52288705","0.52123624","0.5184238","0.51708984","0.51405346","0.50925577","0.5086788","0.508465","0.4974547","0.49473223","0.49283746","0.49105817","0.4858023","0.4823975","0.48168898","0.47934678","0.4780211","0.47458574","0.47359398","0.47352475","0.47280318","0.47279152","0.4725421","0.47247875","0.47198552","0.46976775","0.46925792","0.46793276","0.46762416","0.46510607","0.4642032","0.46396163","0.46392596","0.4636361","0.4623645","0.4619046","0.46121714","0.46084854","0.45997494","0.45964465","0.45959422","0.45957252","0.45936358","0.45902616","0.45837587","0.45804453","0.4572201","0.45718783","0.45715857","0.45678344","0.45673263","0.45641345","0.4556822","0.455366","0.4542691","0.4542603","0.4540475","0.45363402","0.45356238","0.4524845","0.45219144","0.45195252","0.45112938","0.45072275","0.4502684","0.45025","0.45017365","0.44971296","0.4493616","0.44911042","0.44865406","0.44626948","0.44613728","0.44542572","0.4453042","0.4451882","0.44499618","0.4445243","0.44431216","0.44427878","0.44415182","0.44390374","0.4438952","0.4438583","0.44378188","0.44325697","0.44271952","0.4425578","0.4424562","0.4423951","0.4422418"],"string":"[\n \"0.6012806\",\n \"0.57397014\",\n \"0.5641687\",\n \"0.562627\",\n \"0.5615011\",\n \"0.5526408\",\n \"0.5431782\",\n \"0.53011316\",\n \"0.5275546\",\n \"0.52288705\",\n \"0.52123624\",\n \"0.5184238\",\n \"0.51708984\",\n \"0.51405346\",\n \"0.50925577\",\n \"0.5086788\",\n \"0.508465\",\n \"0.4974547\",\n \"0.49473223\",\n \"0.49283746\",\n \"0.49105817\",\n \"0.4858023\",\n \"0.4823975\",\n \"0.48168898\",\n \"0.47934678\",\n \"0.4780211\",\n \"0.47458574\",\n \"0.47359398\",\n \"0.47352475\",\n \"0.47280318\",\n \"0.47279152\",\n \"0.4725421\",\n \"0.47247875\",\n \"0.47198552\",\n \"0.46976775\",\n \"0.46925792\",\n \"0.46793276\",\n \"0.46762416\",\n \"0.46510607\",\n \"0.4642032\",\n \"0.46396163\",\n \"0.46392596\",\n \"0.4636361\",\n \"0.4623645\",\n \"0.4619046\",\n \"0.46121714\",\n \"0.46084854\",\n \"0.45997494\",\n \"0.45964465\",\n \"0.45959422\",\n \"0.45957252\",\n \"0.45936358\",\n \"0.45902616\",\n \"0.45837587\",\n \"0.45804453\",\n \"0.4572201\",\n \"0.45718783\",\n \"0.45715857\",\n \"0.45678344\",\n \"0.45673263\",\n \"0.45641345\",\n \"0.4556822\",\n \"0.455366\",\n \"0.4542691\",\n \"0.4542603\",\n \"0.4540475\",\n \"0.45363402\",\n \"0.45356238\",\n \"0.4524845\",\n \"0.45219144\",\n \"0.45195252\",\n \"0.45112938\",\n \"0.45072275\",\n \"0.4502684\",\n \"0.45025\",\n \"0.45017365\",\n \"0.44971296\",\n \"0.4493616\",\n \"0.44911042\",\n \"0.44865406\",\n \"0.44626948\",\n \"0.44613728\",\n \"0.44542572\",\n \"0.4453042\",\n \"0.4451882\",\n \"0.44499618\",\n \"0.4445243\",\n \"0.44431216\",\n \"0.44427878\",\n \"0.44415182\",\n \"0.44390374\",\n \"0.4438952\",\n \"0.4438583\",\n \"0.44378188\",\n \"0.44325697\",\n \"0.44271952\",\n \"0.4425578\",\n \"0.4424562\",\n \"0.4423951\",\n \"0.4422418\"\n]"},"document_score":{"kind":"string","value":"0.7880987"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":105055,"cells":{"query":{"kind":"string","value":"EvaluateComponent evaluates a component with jsonnet using a path."},"document":{"kind":"string","value":"func EvaluateComponent(a app.App, sourcePath, paramsStr, envName string, useMemoryImporter bool) (string, error) {\n\tsnippet, err := afero.ReadFile(a.Fs(), sourcePath)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn EvaluateComponentSnippet(a, string(snippet), paramsStr, envName, useMemoryImporter)\n}"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["func EvaluateComponentSnippet(a app.App, snippet, paramsStr, envName string, useMemoryImporter bool) (string, error) {\n\tlibPath, err := a.LibPath(envName)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvm := jsonnet.NewVM()\n\tif useMemoryImporter {\n\t\tvm.Fs = a.Fs()\n\t\tvm.UseMemoryImporter = true\n\t}\n\n\tvm.JPaths = []string{\n\t\tlibPath,\n\t\tfilepath.Join(a.Root(), \"vendor\"),\n\t}\n\tvm.ExtCode(\"__ksonnet/params\", paramsStr)\n\n\tenvDetails, err := a.Environment(envName)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tdest := map[string]string{\n\t\t\"server\": envDetails.Destination.Server,\n\t\t\"namespace\": envDetails.Destination.Namespace,\n\t}\n\n\tmarshalledDestination, err := json.Marshal(&dest)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tvm.ExtCode(\"__ksonnet/environments\", string(marshalledDestination))\n\n\treturn vm.EvaluateSnippet(\"snippet\", snippet)\n}","func EvaluateEnv(a app.App, sourcePath, paramsStr, envName string) (string, error) {\n\tlibPath, err := a.LibPath(envName)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvm := jsonnet.NewVM()\n\n\tvm.JPaths = []string{\n\t\tlibPath,\n\t\tfilepath.Join(a.Root(), \"vendor\"),\n\t}\n\tvm.ExtCode(\"__ksonnet/params\", paramsStr)\n\n\tsnippet, err := afero.ReadFile(a.Fs(), sourcePath)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn vm.EvaluateSnippet(sourcePath, string(snippet))\n}","func (l *Loader) EvaluateDependencies(c *ComponentNode) {\n\ttracer := l.tracer.Tracer(\"\")\n\n\tl.mut.RLock()\n\tdefer l.mut.RUnlock()\n\n\tl.cm.controllerEvaluation.Set(1)\n\tdefer l.cm.controllerEvaluation.Set(0)\n\tstart := time.Now()\n\n\tspanCtx, span := tracer.Start(context.Background(), \"GraphEvaluatePartial\", trace.WithSpanKind(trace.SpanKindInternal))\n\tspan.SetAttributes(attribute.String(\"initiator\", c.NodeID()))\n\tdefer span.End()\n\n\tlogger := log.With(l.log, \"trace_id\", span.SpanContext().TraceID())\n\tlevel.Info(logger).Log(\"msg\", \"starting partial graph evaluation\")\n\tdefer func() {\n\t\tspan.SetStatus(codes.Ok, \"\")\n\n\t\tduration := time.Since(start)\n\t\tlevel.Info(logger).Log(\"msg\", \"finished partial graph evaluation\", \"duration\", duration)\n\t\tl.cm.componentEvaluationTime.Observe(duration.Seconds())\n\t}()\n\n\t// Make sure we're in-sync with the current exports of c.\n\tl.cache.CacheExports(c.ID(), c.Exports())\n\n\t_ = dag.WalkReverse(l.graph, []dag.Node{c}, func(n dag.Node) error {\n\t\tif n == c {\n\t\t\t// Skip over the starting component; the starting component passed to\n\t\t\t// EvaluateDependencies had its exports changed and none of its input\n\t\t\t// arguments will need re-evaluation.\n\t\t\treturn nil\n\t\t}\n\n\t\t_, span := tracer.Start(spanCtx, \"EvaluateNode\", trace.WithSpanKind(trace.SpanKindInternal))\n\t\tspan.SetAttributes(attribute.String(\"node_id\", n.NodeID()))\n\t\tdefer span.End()\n\n\t\tstart := time.Now()\n\t\tdefer func() {\n\t\t\tlevel.Info(logger).Log(\"msg\", \"finished node evaluation\", \"node_id\", n.NodeID(), \"duration\", time.Since(start))\n\t\t}()\n\n\t\tvar err error\n\n\t\tswitch n := n.(type) {\n\t\tcase BlockNode:\n\t\t\terr = l.evaluate(logger, n)\n\t\t\tif exp, ok := n.(*ExportConfigNode); ok {\n\t\t\t\tl.cache.CacheModuleExportValue(exp.Label(), exp.Value())\n\t\t\t}\n\t\t}\n\n\t\t// We only use the error for updating the span status; we don't return the\n\t\t// error because we want to evaluate as many nodes as we can.\n\t\tif err != nil {\n\t\t\tspan.SetStatus(codes.Error, err.Error())\n\t\t} else {\n\t\t\tspan.SetStatus(codes.Ok, \"\")\n\t\t}\n\t\treturn nil\n\t})\n\n\tif l.globals.OnExportsChange != nil && l.cache.ExportChangeIndex() != l.moduleExportIndex {\n\t\tl.globals.OnExportsChange(l.cache.CreateModuleExports())\n\t\tl.moduleExportIndex = l.cache.ExportChangeIndex()\n\t}\n}","func ParseJSONPathExpr(pathExpr string) (PathExpression, error) {\n\tpeCache.mu.Lock()\n\tval, ok := peCache.cache.Get(pathExpressionKey(pathExpr))\n\tif ok {\n\t\tpeCache.mu.Unlock()\n\t\treturn val.(PathExpression), nil\n\t}\n\tpeCache.mu.Unlock()\n\n\tpathExpression, err := parseJSONPathExpr(pathExpr)\n\tif err == nil {\n\t\tpeCache.mu.Lock()\n\t\tpeCache.cache.Put(pathExpressionKey(pathExpr), kvcache.Value(pathExpression))\n\t\tpeCache.mu.Unlock()\n\t}\n\treturn pathExpression, err\n}","func (ctx *TemplateContext) JSON(path string) (string, error) {\n\tdata := make(map[string]interface{})\n\tdec := json.NewDecoder(strings.NewReader(ctx.Payload))\n\terr := dec.Decode(&data)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tparts := strings.Split(path, \".\")\n\n\tquery := jsonq.NewQuery(data)\n\tvalue, err := query.Interface(parts...)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// converts int, float, bool, etc to string\n\treturn fmt.Sprintf(\"%v\", value), nil\n}","func jsonizePath(mi *Model, path string) string {\n\texprs := strings.Split(path, ExprSep)\n\texprs = jsonizeExpr(mi, exprs)\n\treturn strings.Join(exprs, ExprSep)\n}","func jsonizePath(mi *modelInfo, path string) string {\n\texprs := strings.Split(path, ExprSep)\n\texprs = jsonizeExpr(mi, exprs)\n\treturn strings.Join(exprs, ExprSep)\n}","func (l *Loader) Apply(args map[string]any, componentBlocks []*ast.BlockStmt, configBlocks []*ast.BlockStmt) diag.Diagnostics {\n\tstart := time.Now()\n\tl.mut.Lock()\n\tdefer l.mut.Unlock()\n\tl.cm.controllerEvaluation.Set(1)\n\tdefer l.cm.controllerEvaluation.Set(0)\n\n\tfor key, value := range args {\n\t\tl.cache.CacheModuleArgument(key, value)\n\t}\n\tl.cache.SyncModuleArgs(args)\n\n\tnewGraph, diags := l.loadNewGraph(args, componentBlocks, configBlocks)\n\tif diags.HasErrors() {\n\t\treturn diags\n\t}\n\n\tvar (\n\t\tcomponents = make([]*ComponentNode, 0, len(componentBlocks))\n\t\tcomponentIDs = make([]ComponentID, 0, len(componentBlocks))\n\t\tservices = make([]*ServiceNode, 0, len(l.services))\n\t)\n\n\ttracer := l.tracer.Tracer(\"\")\n\tspanCtx, span := tracer.Start(context.Background(), \"GraphEvaluate\", trace.WithSpanKind(trace.SpanKindInternal))\n\tdefer span.End()\n\n\tlogger := log.With(l.log, \"trace_id\", span.SpanContext().TraceID())\n\tlevel.Info(logger).Log(\"msg\", \"starting complete graph evaluation\")\n\tdefer func() {\n\t\tspan.SetStatus(codes.Ok, \"\")\n\n\t\tduration := time.Since(start)\n\t\tlevel.Info(logger).Log(\"msg\", \"finished complete graph evaluation\", \"duration\", duration)\n\t\tl.cm.componentEvaluationTime.Observe(duration.Seconds())\n\t}()\n\n\tl.cache.ClearModuleExports()\n\n\t// Evaluate all the components.\n\t_ = dag.WalkTopological(&newGraph, newGraph.Leaves(), func(n dag.Node) error {\n\t\t_, span := tracer.Start(spanCtx, \"EvaluateNode\", trace.WithSpanKind(trace.SpanKindInternal))\n\t\tspan.SetAttributes(attribute.String(\"node_id\", n.NodeID()))\n\t\tdefer span.End()\n\n\t\tstart := time.Now()\n\t\tdefer func() {\n\t\t\tlevel.Info(logger).Log(\"msg\", \"finished node evaluation\", \"node_id\", n.NodeID(), \"duration\", time.Since(start))\n\t\t}()\n\n\t\tvar err error\n\n\t\tswitch n := n.(type) {\n\t\tcase *ComponentNode:\n\t\t\tcomponents = append(components, n)\n\t\t\tcomponentIDs = append(componentIDs, n.ID())\n\n\t\t\tif err = l.evaluate(logger, n); err != nil {\n\t\t\t\tvar evalDiags diag.Diagnostics\n\t\t\t\tif errors.As(err, &evalDiags) {\n\t\t\t\t\tdiags = append(diags, evalDiags...)\n\t\t\t\t} else {\n\t\t\t\t\tdiags.Add(diag.Diagnostic{\n\t\t\t\t\t\tSeverity: diag.SeverityLevelError,\n\t\t\t\t\t\tMessage: fmt.Sprintf(\"Failed to build component: %s\", err),\n\t\t\t\t\t\tStartPos: ast.StartPos(n.Block()).Position(),\n\t\t\t\t\t\tEndPos: ast.EndPos(n.Block()).Position(),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\n\t\tcase *ServiceNode:\n\t\t\tservices = append(services, n)\n\n\t\t\tif err = l.evaluate(logger, n); err != nil {\n\t\t\t\tvar evalDiags diag.Diagnostics\n\t\t\t\tif errors.As(err, &evalDiags) {\n\t\t\t\t\tdiags = append(diags, evalDiags...)\n\t\t\t\t} else {\n\t\t\t\t\tdiags.Add(diag.Diagnostic{\n\t\t\t\t\t\tSeverity: diag.SeverityLevelError,\n\t\t\t\t\t\tMessage: fmt.Sprintf(\"Failed to evaluate service: %s\", err),\n\t\t\t\t\t\tStartPos: ast.StartPos(n.Block()).Position(),\n\t\t\t\t\t\tEndPos: ast.EndPos(n.Block()).Position(),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\n\t\tcase BlockNode:\n\t\t\tif err = l.evaluate(logger, n); err != nil {\n\t\t\t\tdiags.Add(diag.Diagnostic{\n\t\t\t\t\tSeverity: diag.SeverityLevelError,\n\t\t\t\t\tMessage: fmt.Sprintf(\"Failed to evaluate node for config block: %s\", err),\n\t\t\t\t\tStartPos: ast.StartPos(n.Block()).Position(),\n\t\t\t\t\tEndPos: ast.EndPos(n.Block()).Position(),\n\t\t\t\t})\n\t\t\t}\n\t\t\tif exp, ok := n.(*ExportConfigNode); ok {\n\t\t\t\tl.cache.CacheModuleExportValue(exp.Label(), exp.Value())\n\t\t\t}\n\t\t}\n\n\t\t// We only use the error for updating the span status; we don't return the\n\t\t// error because we want to evaluate as many nodes as we can.\n\t\tif err != nil {\n\t\t\tspan.SetStatus(codes.Error, err.Error())\n\t\t} else {\n\t\t\tspan.SetStatus(codes.Ok, \"\")\n\t\t}\n\t\treturn nil\n\t})\n\n\tl.componentNodes = components\n\tl.serviceNodes = services\n\tl.graph = &newGraph\n\tl.cache.SyncIDs(componentIDs)\n\tl.blocks = componentBlocks\n\tl.cm.componentEvaluationTime.Observe(time.Since(start).Seconds())\n\tif l.globals.OnExportsChange != nil && l.cache.ExportChangeIndex() != l.moduleExportIndex {\n\t\tl.moduleExportIndex = l.cache.ExportChangeIndex()\n\t\tl.globals.OnExportsChange(l.cache.CreateModuleExports())\n\t}\n\treturn diags\n}","func (cx *Context) Eval(source string, result interface{}) (err error) {\n\tcx.do(func(ptr *C.JSAPIContext) {\n\t\t// alloc C-string\n\t\tcsource := C.CString(source)\n\t\tdefer C.free(unsafe.Pointer(csource))\n\t\tvar jsonData *C.char\n\t\tvar jsonLen C.int\n\t\tfilename := \"eval\"\n\t\tcfilename := C.CString(filename)\n\t\tdefer C.free(unsafe.Pointer(cfilename))\n\t\t// eval\n\t\tif C.JSAPI_EvalJSON(ptr, csource, cfilename, &jsonData, &jsonLen) != C.JSAPI_OK {\n\t\t\terr = cx.getError(filename)\n\t\t\treturn\n\t\t}\n\t\tdefer C.free(unsafe.Pointer(jsonData))\n\t\t// convert to go\n\t\tb := []byte(C.GoStringN(jsonData, jsonLen))\n\t\tif raw, ok := result.(*Raw); ok {\n\t\t\t*raw = Raw(string(b))\n\t\t} else {\n\t\t\terr = json.Unmarshal(b, result)\n\t\t}\n\t})\n\treturn err\n}","func Get(path string, value interface{}) (interface{}, error) {\n\teval, err := lang.NewEvaluable(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn eval(context.Background(), value)\n}","func LoadComponentFromPath(path string) (*Component, error) {\n\tdata, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdef, err := LoadComponent(data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdef.Path = path\n\treturn def, nil\n}","func (myjson *JSONModel) Get(nodePath string) (interface{}, error) {\n\tif len(nodePath) == 0 {\n\t\tpanic(\"The parameter \\\"nodePath\\\" is nil or empty\")\n\t}\n\tif e := myjson.toJSONObj(); e != nil {\n\t\treturn nil, e\n\t}\n\tif myjson.jsonObj == nil {\n\t\treturn nil, errors.New(\"Parse json to the type \\\"interface{}\\\" is nil \")\n\t}\n\n\tnodes := strings.Split(nodePath, \".\")\n\treturn adaptor(myjson.jsonObj, nodes)\n}","func RunTemplate(template []byte, input []byte) (interface{}, error) {\n\n\tvar data interface{}\n\tjson.Unmarshal(input, &data)\n\n\tv, err := jsonfilter.FilterJsonFromTextWithFilterRunner(string(template), string(template), func(command string, value string) (string, error) {\n\t\tfilterval, _ := jsonpath.Read(data, value)\n\t\t// fmt.Println(filterval)\n\t\tret := fmt.Sprintf(\"%v\", filterval)\n\t\treturn ret, nil\n\t})\n\n\treturn v, err\n\n}","func (r *NuxeoReconciler) getValueByPath(resource v1alpha1.BackingServiceResource, namespace string,\n\tfrom string) ([]byte, string, error) {\n\tif from == \"\" {\n\t\treturn nil, \"\", fmt.Errorf(\"no path provided in projection\")\n\t}\n\tu := unstructured.Unstructured{}\n\tgvk := schema.GroupVersionKind{\n\t\tGroup: resource.Group,\n\t\tVersion: resource.Version,\n\t\tKind: resource.Kind,\n\t}\n\tu.SetGroupVersionKind(gvk)\n\tif err := r.Get(context.TODO(), client.ObjectKey{Namespace: namespace, Name: resource.Name},\n\t\t&u); err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"unable to get resource: %v\", resource.Name)\n\t}\n\tresVer := \"\"\n\tif rv, rve := util.GetJsonPathValueU(u.Object, \"{.metadata.resourceVersion}\"); rve == nil && rv != nil {\n\t\tresVer = string(rv)\n\t} else if rve != nil {\n\t\treturn nil, \"\", rve\n\t} else if rv == nil {\n\t\treturn nil, \"\", fmt.Errorf(\"unable to get resource version from resource: %v\", resource.Name)\n\t}\n\tresVal, resErr := util.GetJsonPathValueU(u.Object, from)\n\treturn resVal, resVer, resErr\n}","func RunJSONSerializationTestForUrlPathMatchConditionParameters(subject UrlPathMatchConditionParameters) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual UrlPathMatchConditionParameters\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func (l *Loader) evaluate(logger log.Logger, bn BlockNode) error {\n\tectx := l.cache.BuildContext()\n\terr := bn.Evaluate(ectx)\n\n\tswitch c := bn.(type) {\n\tcase *ComponentNode:\n\t\t// Always update the cache both the arguments and exports, since both might\n\t\t// change when a component gets re-evaluated. We also want to cache the arguments and exports in case of an error\n\t\tl.cache.CacheArguments(c.ID(), c.Arguments())\n\t\tl.cache.CacheExports(c.ID(), c.Exports())\n\tcase *ArgumentConfigNode:\n\t\tif _, found := l.cache.moduleArguments[c.Label()]; !found {\n\t\t\tif c.Optional() {\n\t\t\t\tl.cache.CacheModuleArgument(c.Label(), c.Default())\n\t\t\t} else {\n\t\t\t\terr = fmt.Errorf(\"missing required argument %q to module\", c.Label())\n\t\t\t}\n\t\t}\n\t}\n\n\tif err != nil {\n\t\tlevel.Error(logger).Log(\"msg\", \"failed to evaluate config\", \"node\", bn.NodeID(), \"err\", err)\n\t\treturn err\n\t}\n\treturn nil\n}","func loadSpec(cPath string) (spec *specs.Spec, err error) {\n\tcf, err := os.Open(cPath)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn nil, fmt.Errorf(\"JSON specification file %s not found\", cPath)\n\t\t}\n\t\treturn nil, err\n\t}\n\tdefer cf.Close()\n\n\tif err = json.NewDecoder(cf).Decode(&spec); err != nil {\n\t\treturn nil, err\n\t}\n\t// return spec, validateProcessSpec(spec.Process)\n\treturn spec, nil\n}","func jsonPathValue(yamlConfig string, jsonPath string) (interface{}, error) {\n\tu, err := k8sutil.YAMLToUnstructured([]byte(yamlConfig))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"YAML to unstructured object: %w\", err)\n\t}\n\n\tgot, err := valFromObject(jsonPath, u)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"JSON path value in YAML: %w\", err)\n\t}\n\n\tswitch got.Kind() { //nolint:exhaustive\n\tcase reflect.Interface:\n\t\t// TODO: Add type switch here for concrete types.\n\t\treturn got.Interface(), nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"extracted object has an unknown type: %v\", got.Kind())\n\t}\n}","func LoadComponentConfig(structConfig interface{}, configFile string) {\n\n\tif _, err := os.Stat(configFile); os.IsNotExist(err) {\n\t\tlog.Fatalln(configFile + \" file not found\")\n\t} else if err != nil {\n\t\tlog.Fatalln(err.Error())\n\t}\n\n\tif _, err := toml.DecodeFile(configFile, structConfig); err != nil {\n\t\tlog.Fatalln(err.Error())\n\t}\n\n}","func TestCSharpCompat(t *testing.T) {\n\tjs := `{\n \"store\": {\n \"book\": [\n {\n \"category\": \"reference\",\n \"author\": \"Nigel Rees\",\n \"title\": \"Sayings of the Century\",\n \"price\": 8.95\n },\n {\n \"category\": \"fiction\",\n \"author\": \"Evelyn Waugh\",\n \"title\": \"Sword of Honour\",\n \"price\": 12.99\n },\n {\n \"category\": \"fiction\",\n \"author\": \"Herman Melville\",\n \"title\": \"Moby Dick\",\n \"isbn\": \"0-553-21311-3\",\n \"price\": 8.99\n },\n {\n \"category\": \"fiction\",\n \"author\": \"J. R. R. Tolkien\",\n \"title\": \"The Lord of the Rings\",\n \"isbn\": \"0-395-19395-8\",\n \"price\": null\n }\n ],\n \"bicycle\": {\n \"color\": \"red\",\n \"price\": 19.95\n }\n },\n \"expensive\": 10,\n \"data\": null\n}`\n\n\ttestCases := []pathTestCase{\n\t\t{\"$.store.book[*].author\", `[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]`},\n\t\t{\"$..author\", `[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]`},\n\t\t{\"$.store.*\", `[[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":8.95},{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":12.99},{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99},{\"category\":\"fiction\",\"author\":\"J. R. R. Tolkien\",\"title\":\"The Lord of the Rings\",\"isbn\":\"0-395-19395-8\",\"price\":null}],{\"color\":\"red\",\"price\":19.95}]`},\n\t\t{\"$.store..price\", `[19.95,8.95,12.99,8.99,null]`},\n\t\t{\"$..book[2]\", `[{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99}]`},\n\t\t{\"$..book[-2]\", `[{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99}]`},\n\t\t{\"$..book[0,1]\", `[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":8.95},{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":12.99}]`},\n\t\t{\"$..book[:2]\", `[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":8.95},{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":12.99}]`},\n\t\t{\"$..book[1:2]\", `[{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":12.99}]`},\n\t\t{\"$..book[-2:]\", `[{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99},{\"category\":\"fiction\",\"author\":\"J. R. R. Tolkien\",\"title\":\"The Lord of the Rings\",\"isbn\":\"0-395-19395-8\",\"price\":null}]`},\n\t\t{\"$..book[2:]\", `[{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99},{\"category\":\"fiction\",\"author\":\"J. R. R. Tolkien\",\"title\":\"The Lord of the Rings\",\"isbn\":\"0-395-19395-8\",\"price\":null}]`},\n\t\t{\"\", `[{\"store\":{\"book\":[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":8.95},{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":12.99},{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99},{\"category\":\"fiction\",\"author\":\"J. R. R. Tolkien\",\"title\":\"The Lord of the Rings\",\"isbn\":\"0-395-19395-8\",\"price\":null}],\"bicycle\":{\"color\":\"red\",\"price\":19.95}},\"expensive\":10,\"data\":null}]`},\n\t\t{\"$.*\", `[{\"book\":[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":8.95},{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":12.99},{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99},{\"category\":\"fiction\",\"author\":\"J. R. R. Tolkien\",\"title\":\"The Lord of the Rings\",\"isbn\":\"0-395-19395-8\",\"price\":null}],\"bicycle\":{\"color\":\"red\",\"price\":19.95}},10,null]`},\n\t\t{\"$..invalidfield\", `[]`},\n\t}\n\n\tfor _, tc := range testCases {\n\t\tt.Run(tc.path, func(t *testing.T) {\n\t\t\ttc.testUnmarshalGet(t, js)\n\t\t})\n\t}\n\n\tt.Run(\"bad cases\", func(t *testing.T) {\n\t\t_, ok := unmarshalGet(t, js, `$..book[*].author\"`)\n\t\trequire.False(t, ok)\n\t})\n}","func EvaluateBundle(ctx context.Context, bundle []byte) (rel.Value, error) {\n\tctx, err := WithBundleRun(ctx, bundle)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tctx, mainFileSource, path := GetMainBundleSource(ctx)\n\treturn EvaluateExpr(ctx, path, string(mainFileSource))\n}","func (e *Implementation) Evaluate(template string) (string, error) {\n\tp := tmpl.Parameters{\n\t\tTestNamespace: e.TestNamespace,\n\t\tDependencyNamespace: e.DependencyNamespace,\n\t}\n\n\treturn tmpl.Evaluate(template, p)\n}","func EvaluateComponents(iq IQ, components []Component, applicationID string) (*Evaluation, error) {\n\trequest, err := json.Marshal(iqEvaluationRequest{Components: components})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not build the request: %v\", err)\n\t}\n\n\trequestEndpoint := fmt.Sprintf(restEvaluation, applicationID)\n\tbody, _, err := iq.Post(requestEndpoint, bytes.NewBuffer(request))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"components not evaluated: %v\", err)\n\t}\n\n\tvar results iqEvaluationRequestResponse\n\tif err = json.Unmarshal(body, &results); err != nil {\n\t\treturn nil, fmt.Errorf(\"could not parse evaluation response: %v\", err)\n\t}\n\n\tgetEvaluationResults := func() (*Evaluation, error) {\n\t\tbody, resp, e := iq.Get(results.ResultsURL)\n\t\tif e != nil {\n\t\t\tif resp.StatusCode != http.StatusNotFound {\n\t\t\t\treturn nil, fmt.Errorf(\"could not retrieve evaluation results: %v\", err)\n\t\t\t}\n\t\t\treturn nil, nil\n\t\t}\n\n\t\tvar ev Evaluation\n\t\tif err = json.Unmarshal(body, &ev); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn &ev, nil\n\t}\n\n\tvar eval *Evaluation\n\tticker := time.NewTicker(5 * time.Second)\n\tfor {\n\t\tselect {\n\t\tcase <-ticker.C:\n\t\t\tif eval, err = getEvaluationResults(); eval != nil || err != nil {\n\t\t\t\tticker.Stop()\n\t\t\t\treturn eval, err\n\t\t\t}\n\t\tcase <-time.After(5 * time.Minute):\n\t\t\tticker.Stop()\n\t\t\treturn nil, errors.New(\"timed out waiting for valid evaluation results\")\n\t\t}\n\t}\n}","func Eval(t testing.TestingT, options *EvalOptions, jsonFilePaths []string, resultQuery string) {\n\trequire.NoError(t, EvalE(t, options, jsonFilePaths, resultQuery))\n}","func MarshalToJsonPathWrapper(expression string) OutputFormater {\n\texpr := expression\n\t// aka MarshalToJsonPath\n\treturn func(input interface{}) ([]byte, error) {\n\t\tjp := jsonpath.New(\"json-path\")\n\n\t\tif err := jp.Parse(expr); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Failed to parse jsonpath expression: %v\", err)\n\t\t}\n\n\t\tvalues, err := jp.FindResults(input)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Failed to execute jsonpath %s on input %s: %v \", expr, input, err)\n\t\t}\n\n\t\tif values == nil || len(values) == 0 || len(values[0]) == 0 {\n\t\t\treturn nil, errors.New(fmt.Sprintf(\"Error parsing value from input %v using template %s: %v \", input, expr, err))\n\t\t}\n\n\t\tjson, err := MarshalToJson(values[0][0].Interface())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn unquote(json), err\n\t}\n}","func RunJSONSerializationTestForExtendedLocation(subject ExtendedLocation) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ExtendedLocation\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForExtendedLocation(subject ExtendedLocation) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ExtendedLocation\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForExtendedLocation(subject ExtendedLocation) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ExtendedLocation\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func (s *server) resolveComponent(dirPath, childQuery string, predicate func(os.FileInfo) bool) (string, error) {\n\tvar err error\n\tvar children []string\n\n\tkey := strings.ToLower(dirPath)\n\tif s.cache != nil && s.cache.Contains(key) {\n\t\tentry, _ := s.cache.Get(key)\n\t\tchildren = entry.([]string)\n\t} else {\n\t\tchildren, err = godirwalk.ReadDirnames(dirPath, nil)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\n\t\tsort.Strings(children)\n\t\tif s.cache != nil {\n\t\t\ts.cache.Add(key, children)\n\t\t}\n\t}\n\n\tnormSegment := \"\"\n\tfor _, child := range children {\n\t\tif strings.EqualFold(child, childQuery) {\n\t\t\tchildPath := filepath.Join(dirPath, child)\n\t\t\tfi, err := os.Stat(childPath)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\tif predicate(fi) {\n\t\t\t\tnormSegment = child\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tif normSegment == \"\" {\n\t\treturn \"\", nil\n\t}\n\n\treturn filepath.Join(dirPath, normSegment), nil\n}","func (a *JSONDataDecouplerActivity) Eval(ctx activity.Context) (done bool, err error) {\n\n\toriginJSONObject := ctx.GetInput(input)\n\ttargetPath, targetPathElements, _ := a.getTarget(ctx)\n\ttarget := originJSONObject\n\tfor _, targetPathElement := range targetPathElements {\n\t\ttarget = target.(map[string]interface{})[targetPathElement]\n\t}\n\n\ttargetArray := target.([]interface{})\n\toutputArray := make([]interface{}, len(targetArray))\n\tfor index, targetElement := range targetArray {\n\t\toutputElement := make(map[string]interface{})\n\t\toutputElement[\"originJSONObject\"] = originJSONObject\n\t\toutputElement[fmt.Sprintf(\"%s.%s\", targetPath, \"Index\")] = index\n\t\toutputElement[fmt.Sprintf(\"%s.%s\", targetPath, \"Element\")] = targetElement\n\t\tif len(targetArray)-1 == index {\n\t\t\toutputElement[\"LastElement\"] = true\n\t\t} else {\n\t\t\toutputElement[\"LastElement\"] = false\n\t\t}\n\t}\n\n\tjsondata := &data.ComplexObject{Metadata: \"Data\", Value: outputArray}\n\n\tctx.SetOutput(output, jsondata)\n\n\treturn true, nil\n}","func (session Runtime) evaluate(expression string, contextID int64, async, returnByValue bool) (*devtool.RemoteObject, error) {\n\tp := &devtool.EvaluatesExpression{\n\t\tExpression: expression,\n\t\tIncludeCommandLineAPI: true,\n\t\tContextID: contextID,\n\t\tAwaitPromise: !async,\n\t\tReturnByValue: returnByValue,\n\t}\n\tresult := new(devtool.EvaluatesResult)\n\tif err := session.call(\"Runtime.evaluate\", p, result); err != nil {\n\t\treturn nil, err\n\t}\n\tif result.ExceptionDetails != nil {\n\t\treturn nil, result.ExceptionDetails\n\t}\n\treturn result.Result, nil\n}","func (p *Parser) Load(filename string) (string, error) {\n\tdirectory := filepath.Dir(filename)\n\tdata, err := ioutil.ReadFile(filename)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvm := jsonnet.MakeVM()\n\tvm.Importer(&jsonnet.FileImporter{\n\t\tJPaths: []string{directory},\n\t})\n\n\treturn vm.EvaluateAnonymousSnippet(filename, string(data))\n}","func (this *Value) Path(path string) (*Value, error) {\n\t// aliases always have priority\n\n\tif this.alias != nil {\n\t\tresult, ok := this.alias[path]\n\t\tif ok {\n\t\t\treturn result, nil\n\t\t}\n\t}\n\t// next we already parsed, used that\n\tswitch parsedValue := this.parsedValue.(type) {\n\tcase map[string]*Value:\n\t\tresult, ok := parsedValue[path]\n\t\tif ok {\n\t\t\treturn result, nil\n\t\t}\n\t}\n\t// finally, consult the raw bytes\n\tif this.raw != nil {\n\t\tres, err := jsonpointer.Find(this.raw, \"/\"+path)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif res != nil {\n\t\t\treturn NewValueFromBytes(res), nil\n\t\t}\n\t}\n\n\treturn nil, &Undefined{path}\n}","func (a *Activity) Eval(ctx activity.Context) (done bool, err error) {\n\n\t//call neural network here\n ctx.Logger().Debugf(\"result of picking out a person: %s\", \"found\") //log is also dummy here\n\terr = nil //set if neural network go wrong\n\tif err != nil {\n\t\treturn true, err\n\t}\n//dummy json generation here\n\timgId:=215\n\timgPath:=\"/home/test.jpg/\"\n\tbboxid:=0\n\tx1:=1\n\ty1:=1\n\tx2:=3\n\ty2:=3\n\timgjson:=imgJson{\n\t\tImgid: imgId,\n\t\tImgpath: imgPath,\n\t\tBboxs:[]Bbox{\n\t\t\t Bbox{\n\t\t\t\tBoxid:bboxid,\n\t\t\t\tX1:x1,\n\t\t\t\tY1:y1,\n\t\t\t\tX2:x2,\n\t\t\t\tY2:y2,\n\t\t\t },\n\t\t\t},\t \n\t}\n\tif jsonString, err := json.Marshal(imgjson); err == nil {\n fmt.Println(\"================struct to json str==\")\n fmt.Println(string(jsonString))\n\t\toutput := &Output{Serial: string(jsonString)}\n\t\terr = ctx.SetOutputObject(output)\n\t if err != nil {\n\t\t return true, err\n\t }\n }\n\tif err != nil {\n\t\treturn true, err\n\t}\n\t\t\n\t//output := &Output{Serial: \"1\"}//should be serial of the record in the database\n\n\n\treturn true, nil\n}","func parseJSON(jsonPath string, v interface{}) error {\n\tif !osutil.Exists(jsonPath) {\n\t\twarn.Printf(\"unable to locate JSON file %q\", jsonPath)\n\t\treturn nil\n\t}\n\treturn jsonutil.ParseFile(jsonPath, v)\n}","func (o *Object) Path(path string) *Value {\n\topChain := o.chain.enter(\"Path(%q)\", path)\n\tdefer opChain.leave()\n\n\treturn jsonPath(opChain, o.value, path)\n}","func (session Runtime) Evaluate(code string, async bool, returnByValue bool) (interface{}, error) {\n\tresult, err := session.evaluate(code, session.currentContext(), async, returnByValue)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn result.Value, nil\n}","func (nc nameConfig) render(job, test string, metadatas ...map[string]string) string {\n\tparsed := make([]interface{}, len(nc.parts))\n\tfor i, p := range nc.parts {\n\t\tvar s string\n\t\tswitch p {\n\t\tcase jobName:\n\t\t\ts = job\n\t\tcase testsName:\n\t\t\ts = test\n\t\tdefault:\n\t\t\tfor _, metadata := range metadatas {\n\t\t\t\tv, present := metadata[p]\n\t\t\t\tif present {\n\t\t\t\t\ts = v\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tparsed[i] = s\n\t}\n\treturn fmt.Sprintf(nc.format, parsed...)\n}","func (p *Path) Render(values map[string]string, usedValues map[string]struct{}) (string, error) {\n\tvar path string\n\n\tfor _, part := range p.parts {\n\t\tval, used, err := part.render(values, p.normalize)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\n\t\tpath += `/` + val\n\t\tfor _, u := range used {\n\t\t\tusedValues[u] = struct{}{}\n\t\t}\n\t}\n\n\tif len(path) == 0 {\n\t\tpath = \"/\"\n\t} else if p.trailingSlash && !strings.HasSuffix(path, \"/\") {\n\t\tpath += \"/\"\n\t}\n\n\tquery := url.Values{}\n\tqueryUsed := false\n\tfor k, v := range values {\n\t\tif _, ok := usedValues[k]; !ok {\n\t\t\tqueryUsed = true\n\t\t\tquery.Set(k, v)\n\t\t}\n\t}\n\n\tif queryUsed {\n\t\treturn path + `?` + query.Encode(), nil\n\t}\n\treturn path, nil\n}","func operatorPresentAtPath(jplan []byte, path string, operator string) error {\n\t// fmt.Printf(\"%s\\n\", string(jplan))\n\tv := interface{}(nil)\n\terr := json.Unmarshal(jplan, &v)\n\tif err != nil {\n\t\treturn errors.Wrap(err, fmt.Sprintf(\"expected '%s' to be present\", operator))\n\t}\n\n\tbuilder := gval.Full(jsonpath.PlaceholderExtension())\n\texpr, err := builder.NewEvaluable(path)\n\tif err != nil {\n\t\treturn errors.Wrap(err, fmt.Sprintf(\"expected '%s' to be present\", operator))\n\t}\n\teval, err := expr(context.Background(), v)\n\tif err != nil {\n\t\treturn errors.Wrap(err, fmt.Sprintf(\"expected '%s' to be present\", operator))\n\t}\n\ts, ok := eval.(string)\n\tif ok && strings.EqualFold(s, operator) {\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"expected '%s' to be present\", operator)\n}","func jsonPath(name string) string {\n\treturn path.Join(dataPath, fmt.Sprintf(\"rove-%s.json\", name))\n}","func RunJSONSerializationTestForDeliveryRuleUrlPathCondition(subject DeliveryRuleUrlPathCondition) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual DeliveryRuleUrlPathCondition\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func Load (path string, unsafe...bool) (*Parser, error) {\n if j, e := gjson.Load(path, unsafe...); e == nil {\n return &Parser{j}, nil\n } else {\n return nil, e\n }\n}","func fnEval(ctx Context, doc *JDoc, params []string) interface{} {\n\tstats := ctx.Value(EelTotalStats).(*ServiceStats)\n\tif params == nil || len(params) == 0 || len(params) > 2 {\n\t\tctx.Log().Error(\"error_type\", \"func_eval\", \"op\", \"eval\", \"cause\", \"wrong_number_of_parameters\", \"params\", params)\n\t\tstats.IncErrors()\n\t\tAddError(ctx, SyntaxError{fmt.Sprintf(\"wrong number of parameters in call to eval function\"), \"eval\", params})\n\t\treturn \"\"\n\t} else if len(params) == 1 {\n\t\treturn doc.EvalPath(ctx, extractStringParam(params[0]))\n\t} else {\n\t\tldoc, err := NewJDocFromString(extractStringParam(params[1]))\n\t\tif err != nil {\n\t\t\tctx.Log().Error(\"error_type\", \"func_eval\", \"op\", \"eval\", \"cause\", \"json_expected\", \"params\", params, \"error\", err.Error())\n\t\t\tstats.IncErrors()\n\t\t\tAddError(ctx, SyntaxError{fmt.Sprintf(\"non json parameters in call to eval function\"), \"eval\", params})\n\t\t\treturn \"\"\n\t\t}\n\t\treturn ldoc.EvalPath(ctx, extractStringParam(params[0]))\n\t}\n}","func evaluate(node ast.Node, ext vmExtMap, tla vmExtMap, nativeFuncs map[string]*NativeFunction,\n\tmaxStack int, ic *importCache, traceOut io.Writer, stringOutputMode bool) (string, error) {\n\n\ti, err := buildInterpreter(ext, nativeFuncs, maxStack, ic, traceOut)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tresult, err := evaluateAux(i, node, tla)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvar buf bytes.Buffer\n\ti.stack.setCurrentTrace(manifestationTrace())\n\tif stringOutputMode {\n\t\terr = i.manifestString(&buf, result)\n\t} else {\n\t\terr = i.manifestAndSerializeJSON(&buf, result, true, \"\")\n\t}\n\ti.stack.clearCurrentTrace()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tbuf.WriteString(\"\\n\")\n\treturn buf.String(), nil\n}","func (p PathParser) Value(raw string) ValueImpl {\n\tif len(raw) == 0 {\n\t\treturn ValueImpl{parser: p} // empty value\n\t}\n\n\tif p.AllowMultiple && strings.HasPrefix(raw, \"[\") {\n\t\t// parse as JSON\n\t\tvar rc = ValueImpl{parser: p}\n\n\t\tif err := json.Unmarshal([]byte(raw), &rc.values); err != nil {\n\t\t\treturn ValueImpl{err: fmt.Errorf(\"failed to parse JSON path: %s\", err.Error())}\n\t\t}\n\n\t\t// valid JSON list -> check each individual item\n\t\tfor _, value := range rc.values {\n\t\t\tif rc.err = p.validatePath(value); rc.err != nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn rc\n\t}\n\n\t// default behaviour: put it into the first slice\n\treturn ValueImpl{\n\t\tvalues: []string{raw},\n\t\terr: p.validatePath(raw),\n\t\tparser: p,\n\t}\n}","func FetchPath(j JSON, path []string) (JSON, error) {\n\tvar next JSON\n\tvar err error\n\tfor _, v := range path {\n\t\tnext, err = j.FetchValKeyOrIdx(v)\n\t\tif next == nil {\n\t\t\treturn nil, nil\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tj = next\n\t}\n\treturn j, nil\n}","func (opa *client) EvaluatePolicy(policy string, input []byte) (*EvaluatePolicyResponse, error) {\n\tlog := opa.logger.Named(\"Evalute Policy\")\n\n\trequest, err := json.Marshal(&EvalutePolicyRequest{Input: input})\n\tif err != nil {\n\t\tlog.Error(\"failed to encode OPA input\", zap.Error(err), zap.String(\"input\", string(input)))\n\t\treturn nil, fmt.Errorf(\"failed to encode OPA input: %s\", err)\n\t}\n\n\thttpResponse, err := opa.httpClient.Post(opa.getDataQueryURL(getOpaPackagePath(policy)), \"application/json\", bytes.NewReader(request))\n\tif err != nil {\n\t\tlog.Error(\"http request to OPA failed\", zap.Error(err))\n\t\treturn nil, fmt.Errorf(\"http request to OPA failed: %s\", err)\n\t}\n\tif httpResponse.StatusCode != http.StatusOK {\n\t\tlog.Error(\"http response status from OPA not OK\", zap.Any(\"status\", httpResponse.Status))\n\t\treturn nil, fmt.Errorf(\"http response status not OK\")\n\t}\n\n\tresponse := &EvaluatePolicyResponse{}\n\terr = json.NewDecoder(httpResponse.Body).Decode(&response)\n\tif err != nil {\n\t\tlog.Error(\"failed to decode OPA result\", zap.Error(err))\n\t\treturn nil, fmt.Errorf(\"failed to decode OPA result: %s\", err)\n\t}\n\n\treturn response, nil\n}","func evaluateAst(program *ast.RootNode) object.Object {\n\tenv := object.NewEnvironment()\n\treturn evaluator.Eval(program, env)\n}","func (a *PipelineControllerApiService) EvaluateExpressionForExecutionUsingGET(ctx _context.Context, id string) apiEvaluateExpressionForExecutionUsingGETRequest {\n\treturn apiEvaluateExpressionForExecutionUsingGETRequest{\n\t\tapiService: a,\n\t\tctx: ctx,\n\t\tid: id,\n\t}\n}","func update(path []string, src string, params map[string]interface{}) (string, error) {\n\tobj, err := jsonnetParseFn(\"params.libsonnet\", src)\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"parse jsonnet\")\n\t}\n\n\tparamsObject, err := nmKVFromMapFn(params)\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"convert params to object\")\n\t}\n\n\tif err := jsonnetSetFn(obj, path, paramsObject.Node()); err != nil {\n\t\treturn \"\", errors.Wrap(err, \"update params\")\n\t}\n\n\tvar buf bytes.Buffer\n\tif err := jsonnetPrinterFn(&buf, obj); err != nil {\n\t\treturn \"\", errors.Wrap(err, \"rebuild params\")\n\t}\n\n\treturn buf.String(), nil\n}","func (m *Map) traversePath(path string, updateValue interface{}, createPaths bool) (interface{}, error) {\n\tpath = strings.TrimPrefix(path, \"/\")\n\tcomponents := strings.Split(path, \"/\")\n\n\tLog.Debug.Printf(\"Traversing path %v with value %v\", path, updateValue)\n\n\tif len(components) == 1 && components[0] == \"\" && updateValue != nil {\n\t\t// Complete replacement of root map, updateValue must be a generic map\n\t\t*m = Map(updateValue.(map[string]interface{}))\n\t\treturn m, nil\n\t}\n\n\tvar lastIndex = len(components) - 1\n\n\tref := *m\n\tvar child interface{} = nil\n\n\tfor i, component := range components {\n\t\tvar ok bool\n\n\t\tif component == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"Empty component encountered in path %v\", path)\n\t\t}\n\n\t\tisUpdate := updateValue != nil\n\n\t\tif i == lastIndex && isUpdate {\n\t\t\tLog.Debug.Printf(\"Updating component %v value %+v\", component, updateValue)\n\n\t\t\tvar jsonUpdateValue = updateValue\n\t\t\tif updateValue == Nil {\n\t\t\t\tjsonUpdateValue = nil\n\t\t\t} else if updateValue == Remove {\n\t\t\t\tdelete(ref, component)\n\t\t\t\treturn Remove, nil\n\t\t\t}\n\n\t\t\tref[component] = jsonUpdateValue\n\t\t\treturn ref[component], nil\n\t\t} else {\n\t\t\tchild, ok = ref[component]\n\t\t\t// Error if this child is not found\n\t\t\tif !ok {\n\t\t\t\tif createPaths && isUpdate {\n\t\t\t\t\tLog.Debug.Printf(\"Creating path for component %v\", component)\n\t\t\t\t\tnewPath := map[string]interface{}{}\n\t\t\t\t\tref[component] = newPath\n\t\t\t\t\tref = newPath\n\t\t\t\t\tcontinue\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, fmt.Errorf(\"Child component %v of path %v not found\", component, path)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif i == lastIndex && !isUpdate {\n\t\t\t\t// Return the queried value\n\t\t\t\tLog.Debug.Printf(\"Returning query value %+v\", child)\n\t\t\t\treturn child, nil\n\t\t\t}\n\n\t\t\t// Keep going - child must be a map to enable further traversal\n\t\t\tref, ok = child.(map[string]interface{})\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"Child component %v of path %v is not a map\", component, path)\n\t\t\t}\n\t\t}\n\t}\n\n\t// XXX Shouldn't get here\n\treturn nil, fmt.Errorf(\"Unexpected return from TraversePath %v\", path)\n}","func (r *Rule) Eval(json []byte) (int, error) {\n\tjq := gojsonq.New().Reader(bytes.NewReader(json)).From(\"kind\")\n\tif jq.Error() != nil {\n\t\treturn 0, jq.Error()\n\t}\n\n\tkind := fmt.Sprintf(\"%s\", jq.Get())\n\n\tvar match bool\n\tfor _, k := range r.Kinds {\n\t\tif k == kind {\n\t\t\tmatch = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif match {\n\t\tcount := r.Predicate(json)\n\t\treturn count, nil\n\t} else {\n\t\treturn 0, &NotSupportedError{Kind: kind}\n\t}\n}","func LoadConfig(path string, c interface{}) (err error) {\n\tvar jsonFile *os.File\n\tvar byteValue []byte\n\n\tfmt.Println(\"Path \", path)\n\t// Open our jsonFile\n\tjsonFile, err = os.Open(path)\n\t// if we os.Open returns an error then handle it\n\tif err != nil {\n\t\tfmt.Println(\"LoadConfig error \", err)\n\t\treturn\n\t}\n\tfmt.Println(\"Successfully Opened json\")\n\t// defer the closing of our jsonFile so that we can parse it later on\n\tdefer jsonFile.Close()\n\n\t// read our opened xmlFile as a byte array.\n\tbyteValue, err = ioutil.ReadAll(jsonFile)\n\tif err != nil {\n\t\tfmt.Println(\"ReadAll error \", err)\n\t\treturn\n\t}\n\n\terr = json.Unmarshal(byteValue, &c)\n\tif err != nil {\n\t\tfmt.Println(\"Unmarshal error \", err)\n\t\treturn\n\t}\n\treturn\n}","func LoadConfig(path string, c interface{}) (err error) {\n\tvar jsonFile *os.File\n\tvar byteValue []byte\n\n\tfmt.Println(\"Path \", path)\n\t// Open our jsonFile\n\tjsonFile, err = os.Open(path)\n\t// if we os.Open returns an error then handle it\n\tif err != nil {\n\t\tfmt.Println(\"LoadConfig error \", err)\n\t\treturn\n\t}\n\tfmt.Println(\"Successfully Opened json\")\n\t// defer the closing of our jsonFile so that we can parse it later on\n\tdefer jsonFile.Close()\n\n\t// read our opened xmlFile as a byte array.\n\tbyteValue, err = ioutil.ReadAll(jsonFile)\n\tif err != nil {\n\t\tfmt.Println(\"ReadAll error \", err)\n\t\treturn\n\t}\n\n\terr = json.Unmarshal(byteValue, &c)\n\tif err != nil {\n\t\tfmt.Println(\"Unmarshal error \", err)\n\t\treturn\n\t}\n\treturn\n}","func Load(path string, unsafe...bool) (*Parser, error) {\n if j, e := gjson.Load(path, unsafe...); e == nil {\n return &Parser{j}, nil\n } else {\n return nil, e\n }\n}","func getJSONRaw(data []byte, path string, pathRequired bool) ([]byte, error) {\n\tobjectKeys := customSplit(path)\n\tfor element, k := range objectKeys {\n\t\t// check the object key to see if it also contains an array reference\n\t\tarrayRefs := jsonPathRe.FindAllStringSubmatch(k, -1)\n\t\tif arrayRefs != nil && len(arrayRefs) > 0 {\n\t\t\tarrayKeyStrs := jsonArrayRe.FindAllString(k, -1)\n\t\t\textracted := false\n\t\t\tobjKey := arrayRefs[0][1] // the key\n\t\t\tresults, newPath, err := getArrayResults(data, objectKeys, objKey, element)\n\t\t\tif err == jsonparser.KeyPathNotFoundError {\n\t\t\t\tif pathRequired {\n\t\t\t\t\treturn nil, NonExistentPath\n\t\t\t\t}\n\t\t\t} else if err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tfor _, arrayKeyStr := range arrayKeyStrs {\n\t\t\t\t// trim the square brackets\n\t\t\t\tarrayKeyStr = arrayKeyStr[1 : len(arrayKeyStr)-1]\n\t\t\t\terr = validateArrayKeyString(arrayKeyStr)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\t// if there's a wildcard array reference\n\t\t\t\tif arrayKeyStr == \"*\" {\n\t\t\t\t\t// We won't filter anything with a wildcard\n\t\t\t\t\tcontinue\n\t\t\t\t} else if filterPattern := jsonFilterRe.FindString(arrayKeyStr); filterPattern != \"\" {\n\t\t\t\t\t// MODIFICATIONS --- FILTER SUPPORT\n\t\t\t\t\t// right now we only support filter expressions of the form ?(@.some.json.path Op \"someData\")\n\t\t\t\t\t// Op must be a boolean operator: '==', '<' are fine, '+', '%' are not. Spaces ARE required\n\n\t\t\t\t\t// get the filter jsonpath expression\n\t\t\t\t\tfilterPattern = filterPattern[2 : len(filterPattern)-1]\n\t\t\t\t\tfilterParts := strings.Split(filterPattern, \" \")\n\t\t\t\t\tvar filterPath string\n\t\t\t\t\tif len(filterParts[0]) > 2 {\n\t\t\t\t\t\tfilterPath = filterParts[0][2:]\n\t\t\t\t\t}\n\t\t\t\t\tvar filterObjs [][]byte\n\t\t\t\t\tvar filteredResults [][]byte\n\n\t\t\t\t\t// evaluate the jsonpath filter jsonpath for each index\n\t\t\t\t\tif newPath != \"\" {\n\t\t\t\t\t\t// we are filtering against a list of objects, lookup the data recursively\n\t\t\t\t\t\tfor _, v := range results {\n\t\t\t\t\t\t\tintermediate, err := getJSONRaw(v, filterPath, true)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\tif err == NonExistentPath {\n\t\t\t\t\t\t\t\t\t// this is fine, we'll just filter these out\n\t\t\t\t\t\t\t\t\tfilterObjs = append(filterObjs, nil)\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tfilterObjs = append(filterObjs, intermediate)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if filterPath == \"\" {\n\t\t\t\t\t\t// we are filtering against a list of primitives - we won't match any non-empty filterPath\n\t\t\t\t\t\tfor _, v := range results {\n\t\t\t\t\t\t\tfilterObjs = append(filterObjs, v)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// evaluate the filter\n\t\t\t\t\tfor i, v := range filterObjs {\n\t\t\t\t\t\tif v != nil {\n\t\t\t\t\t\t\tfilterParts[0] = string(v)\n\t\t\t\t\t\t\texprString := strings.Join(filterParts, \" \")\n\t\t\t\t\t\t\t// filter the objects based on the results\n\t\t\t\t\t\t\texpr, err := govaluate.NewEvaluableExpression(exprString)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tresult, err := expr.Evaluate(nil)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// We pass through the filter if the filter is a boolean expression\n\t\t\t\t\t\t\t// If the filter is not a boolean expression, just pass everything through\n\t\t\t\t\t\t\tif accepted, ok := result.(bool); accepted || !ok {\n\t\t\t\t\t\t\t\tfilteredResults = append(filteredResults, results[i])\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Set the results for the next pass\n\t\t\t\t\tresults = filteredResults\n\t\t\t\t} else {\n\t\t\t\t\tindex, err := strconv.ParseInt(arrayKeyStr, 10, 64)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\tif index < int64(len(results)) {\n\t\t\t\t\t\tresults = [][]byte{results[index]}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresults = [][]byte{}\n\t\t\t\t\t}\n\t\t\t\t\textracted = true\n\t\t\t\t}\n\t\t\t}\n\t\t\toutput, err := lookupAndWriteMulti(results, newPath, pathRequired)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t// if we have access a specific index, we want to extract the value from the array\n\t\t\t// we just do this manually\n\t\t\tif extracted {\n\t\t\t\toutput = output[1 : len(output)-1]\n\t\t\t}\n\t\t\treturn output, nil\n\t\t} else {\n\t\t\t// no array reference, good to go\n\t\t\tcontinue\n\t\t}\n\t}\n\tresult, dataType, _, err := jsonparser.Get(data, objectKeys...)\n\n\t// jsonparser strips quotes from Strings\n\tif dataType == jsonparser.String {\n\t\t// bookend() is destructive to underlying slice, need to copy.\n\t\t// extra capacity saves an allocation and copy during bookend.\n\t\tresult = HandleUnquotedStrings(result, dataType)\n\t}\n\tif len(result) == 0 {\n\t\tresult = []byte(\"null\")\n\t}\n\tif err == jsonparser.KeyPathNotFoundError {\n\t\tif pathRequired {\n\t\t\treturn nil, NonExistentPath\n\t\t}\n\t} else if err != nil {\n\t\treturn nil, err\n\t}\n\treturn result, nil\n}","func (r *SourceResolver) Component(ctx context.Context, source *model.Source) (*model.Component, error) {\n\tresults, err := r.DataLoaders.SourceLoader(ctx).ComponentBySource(source.ID)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to get component from loader\")\n\t}\n\treturn results, nil\n}","func (p *prog) Eval(input any) (v ref.Val, det *EvalDetails, err error) {\n\t// Configure error recovery for unexpected panics during evaluation. Note, the use of named\n\t// return values makes it possible to modify the error response during the recovery\n\t// function.\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tswitch t := r.(type) {\n\t\t\tcase interpreter.EvalCancelledError:\n\t\t\t\terr = t\n\t\t\tdefault:\n\t\t\t\terr = fmt.Errorf(\"internal error: %v\", r)\n\t\t\t}\n\t\t}\n\t}()\n\t// Build a hierarchical activation if there are default vars set.\n\tvar vars interpreter.Activation\n\tswitch v := input.(type) {\n\tcase interpreter.Activation:\n\t\tvars = v\n\tcase map[string]any:\n\t\tvars = activationPool.Setup(v)\n\t\tdefer activationPool.Put(vars)\n\tdefault:\n\t\treturn nil, nil, fmt.Errorf(\"invalid input, wanted Activation or map[string]any, got: (%T)%v\", input, input)\n\t}\n\tif p.defaultVars != nil {\n\t\tvars = interpreter.NewHierarchicalActivation(p.defaultVars, vars)\n\t}\n\tv = p.interpretable.Eval(vars)\n\t// The output of an internal Eval may have a value (`v`) that is a types.Err. This step\n\t// translates the CEL value to a Go error response. This interface does not quite match the\n\t// RPC signature which allows for multiple errors to be returned, but should be sufficient.\n\tif types.IsError(v) {\n\t\terr = v.(*types.Err)\n\t}\n\treturn\n}","func (t *TypeSystem) Evaluate(typename string, object interface{}, op string, value string) (bool, error) {\n\tswitch typename {\n\tcase String:\n\t\treturn t.stringts.Evaluate(object, op, value)\n\tcase Number:\n\t\treturn t.numberts.Evaluate(object, op, value)\n\tcase Boolean:\n\t\treturn t.boolts.Evaluate(object, op, value)\n\tcase Strings:\n\t\treturn t.stringsts.Evaluate(object, op, value)\n\tcase Date:\n\t\treturn t.datets.Evaluate(object, op, value)\n\tdefault:\n\t\treturn false, fmt.Errorf(\"type/golang/type.go: unsupport type, %s, %v, %s, %s\", typename, object, op, value)\n\t}\n}","func Evaluate(expr string, contextVars map[string]logol.Match) bool {\n\tlogger.Debugf(\"Evaluate expression: %s\", expr)\n\n\tre := regexp.MustCompile(\"[$@#]+\\\\w+\")\n\tres := re.FindAllString(expr, -1)\n\t// msg, _ := json.Marshal(contextVars)\n\t// logger.Errorf(\"CONTEXT: %s\", msg)\n\tparameters := make(map[string]interface{}, 8)\n\tvarIndex := 0\n\tfor _, val := range res {\n\t\tt := strconv.Itoa(varIndex)\n\t\tvarName := \"VAR\" + t\n\t\tr := strings.NewReplacer(val, varName)\n\t\texpr = r.Replace(expr)\n\t\tvarIndex++\n\t\tcValue, cerr := getValueFromExpression(val, contextVars)\n\t\tif cerr {\n\t\t\tlogger.Debugf(\"Failed to get value from expression %s\", val)\n\t\t\treturn false\n\t\t}\n\t\tparameters[varName] = cValue\n\t}\n\tlogger.Debugf(\"New expr: %s with params %v\", expr, parameters)\n\n\texpression, err := govaluate.NewEvaluableExpression(expr)\n\tif err != nil {\n\t\tlogger.Errorf(\"Failed to evaluate expression %s\", expr)\n\t\treturn false\n\t}\n\tresult, _ := expression.Evaluate(parameters)\n\tif result == true {\n\t\treturn true\n\t}\n\treturn false\n}","func jsonpt(data, key string) string {\n\tdatamap := make(map[string]interface{})\n\terr := json.Unmarshal([]byte(data), &datamap)\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"%s cannot be parsed as json\", data)\n\t}\n\tres, err := jsonpath.JsonPathLookup(datamap, key)\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"%q not found in data: %v\", key, err)\n\t}\n\treturn fmt.Sprintf(\"%s\", res)\n}","func RunJSONSerializationTestForUrlFileExtensionMatchConditionParameters(subject UrlFileExtensionMatchConditionParameters) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual UrlFileExtensionMatchConditionParameters\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForResourceReference(subject ResourceReference) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ResourceReference\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForResourceReference(subject ResourceReference) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ResourceReference\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func (j *Js) Getpath(args ...string) *Js {\n\td := j\n\tfor i := range args {\n\t\tm := d.Getdata()\n\n\t\tif val, ok := m[args[i]]; ok {\n\t\t\td.data = val\n\t\t} else {\n\t\t\td.data = nil\n\t\t\treturn d\n\t\t}\n\t}\n\treturn d\n}","func renderValueTemplate(valueTemplate string, variables map[string]apiextensionsv1.JSON) (*apiextensionsv1.JSON, error) {\n\t// Parse the template.\n\ttpl, err := template.New(\"tpl\").Funcs(sprig.HermeticTxtFuncMap()).Parse(valueTemplate)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to parse template: %q\", valueTemplate)\n\t}\n\n\t// Convert the flat variables map in a nested map, so that variables can be\n\t// consumed in templates like this: `{{ .builtin.cluster.name }}`\n\t// NOTE: Variable values are also converted to their Go types as\n\t// they cannot be directly consumed as byte arrays.\n\tdata, err := calculateTemplateData(variables)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to calculate template data\")\n\t}\n\n\t// Render the template.\n\tvar buf bytes.Buffer\n\tif err := tpl.Execute(&buf, data); err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to render template: %q\", valueTemplate)\n\t}\n\n\t// Unmarshal the rendered template.\n\t// NOTE: The YAML library is used for unmarshalling, to be able to handle YAML and JSON.\n\tvalue := apiextensionsv1.JSON{}\n\tif err := yaml.Unmarshal(buf.Bytes(), &value); err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to unmarshal rendered template: %q\", buf.String())\n\t}\n\n\treturn &value, nil\n}","func componentConfig(component *models.Component) (config map[string]interface{}, err error) {\n\n\t// fetch the env\n\tenv, err := models.FindEnvByID(component.EnvID)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"failed to load env model: %s\", err.Error())\n\t\treturn\n\t}\n\n\tbox := boxfile.New([]byte(env.BuiltBoxfile))\n\tconfig = box.Node(component.Name).Node(\"config\").Parsed\n\n\tswitch component.Name {\n\tcase \"portal\", \"logvac\", \"hoarder\", \"mist\":\n\t\tconfig[\"token\"] = \"123\"\n\t}\n\treturn\n}","func (r *Response) JSONPath(expression string, assert func(interface{})) *Response {\n\tr.jsonPathExpression = expression\n\tr.jsonPathAssert = assert\n\treturn r.apiTest.response\n}","func Componentgen(nr, nl *Node) bool","func LoadJSON(r io.Reader, filePath, urlPath string) (*Graph, error) {\n\tdec := json.NewDecoder(r)\n\tg := &Graph{\n\t\tFilePath: filePath,\n\t\tURLPath: urlPath,\n\t}\n\tif err := dec.Decode(g); err != nil {\n\t\treturn nil, err\n\t}\n\t// Each node and channel should cache it's own name.\n\tfor k, c := range g.Channels {\n\t\tc.Name = k\n\t}\n\tfor k, n := range g.Nodes {\n\t\tn.Name = k\n\t}\n\t// Finally, set up channel pin caches.\n\tg.RefreshChannelsPins()\n\treturn g, nil\n}","func Evaluate(tpl string, data interface{}) (string, error) {\n\tt, err := Parse(tpl)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn Execute(t, data)\n}","func Get(json []byte, path ...string) ([]byte, error) {\n\tif len(path) == 0 {\n\t\treturn json, nil\n\t}\n\t_, start, end, err := core(json, false, path...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn json[start:end], err\n}","func RunJSONSerializationTestForComponent_STATUS_ARM(subject Component_STATUS_ARM) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual Component_STATUS_ARM\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForKubeletConfig(subject KubeletConfig) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual KubeletConfig\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForUrlFileNameMatchConditionParameters(subject UrlFileNameMatchConditionParameters) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual UrlFileNameMatchConditionParameters\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func ExampleJsonpath() {\n\tconst jsonString = `{\n\t \"firstName\": \"John\",\n\t \"lastName\" : \"doe\",\n\t \"age\" : 26,\n\t \"address\" : {\n\t\t\"streetAddress\": \"naist street\",\n\t\t\"city\" : \"Nara\",\n\t\t\"postalCode\" : \"630-0192\"\n\t },\n\t \"phoneNumbers\": [\n\t\t{\n\t\t \"type\" : \"iPhone\",\n\t\t \"number\": \"0123-4567-8888\"\n\t\t},\n\t\t{\n\t\t \"type\" : \"home\",\n\t\t \"number\": \"0123-4567-8910\"\n\t\t},\n\t\t{\n\t\t \"type\": \"mobile\",\n\t\t \"number\": \"0913-8532-8492\"\n\t\t}\n\t ]\n\t}`\n\n\tresult, err := Jsonpath([]byte(jsonString), \"$.phoneNumbers[*].type\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfor _, item := range result {\n\t\tfmt.Println(item)\n\t}\n\t// Output:\n\t// iPhone\n\t// home\n\t// mobile\n}","func (self *Map) JSONPath(query string, fallback ...interface{}) interface{} {\n\tif d, err := JSONPath(self.MapNative(), query); err == nil && d != nil {\n\t\treturn d\n\t}\n\n\treturn sliceutil.First(fallback)\n}","func parseComponents(t *template.Template, dir string) (*template.Template, error) {\n\tcomponents, err := readComponents(dir)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, c := range components {\n\t\tp := strings.TrimPrefix(c.Path, dir)\n\t\tp = strings.TrimPrefix(p, \"/\")\n\t\tfmt.Println(\"Parsing component\", p)\n\t\tt, err = t.New(p).Parse(c.Content)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn t, nil\n}","func TestUpdateJsonFileWithString(t *testing.T) {\n\tfile := \"/tmp/testpathstring.json\"\n\tpaths := []string{\"testpathstring\"}\n\tui := &packer.BasicUi{\n\t\tReader: new(bytes.Buffer),\n\t\tWriter: new(bytes.Buffer),\n\t\tErrorWriter: new(bytes.Buffer),\n\t}\n\tvalue := \"simplevalue_string\"\n\t_ = UpdateJsonFile(file, paths, value, ui, true)\n}","func RunJSONSerializationTestForRequestUriMatchConditionParameters(subject RequestUriMatchConditionParameters) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual RequestUriMatchConditionParameters\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func parse(input string) (output *js.Object, err error) {\n\tvar ast interface{}\n\terr = hcl.Unmarshal([]byte(input), &ast)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tdata, err := json.MarshalIndent(ast, \"\", \" \")\n\tif err != nil {\n\t\treturn\n\t}\n\toutput = js.Global.Get(\"JSON\").Call(\"parse\", string(data))\n\treturn\n}","func (d *Data) getValue(path string, source interface{}) interface{} {\n\ti := strings.Index(path, d.as+\".\")\n\tif i == 0 {\n\t\tpath = path[len(d.as)+1:]\n\t}\n\ttr, br := splitpath(path)\n\tif tr == \"\" {\n\t\treturn nil\n\t}\n\n\tv, ok := source.(reflect.Value)\n\tif !ok {\n\t\tv = reflect.ValueOf(source)\n\t}\n\tif v.Kind() == reflect.Ptr {\n\t\tv = v.Elem()\n\t}\n\n\tswitch v.Kind() {\n\tcase reflect.Map:\n\t\tv = v.MapIndex(reflect.ValueOf(tr))\n\tcase reflect.Struct:\n\t\tv = v.FieldByName(tr)\n\n\tdefault:\n\t\treturn nil\n\t}\n\n\tif !v.IsValid() {\n\t\treturn nil\n\t}\n\n\tvar inf interface{} = v\n\n\tif v.CanInterface() {\n\t\tinf = v.Interface()\n\t}\n\n\tif br != \"\" {\n\t\treturn d.getValue(br, inf)\n\t}\n\n\treturn inf\n}","func (rt *importRuntime) Eval(vs parser.Scope, is map[string]interface{}, tid uint64) (interface{}, error) {\n\t_, err := rt.baseRuntime.Eval(vs, is, tid)\n\n\tif rt.erp.ImportLocator == nil {\n\t\terr = rt.erp.NewRuntimeError(util.ErrRuntimeError, \"No import locator was specified\", rt.node)\n\t}\n\n\tif err == nil {\n\n\t\tvar importPath interface{}\n\t\tif importPath, err = rt.node.Children[0].Runtime.Eval(vs, is, tid); err == nil {\n\n\t\t\tvar codeText string\n\t\t\tif codeText, err = rt.erp.ImportLocator.Resolve(fmt.Sprint(importPath)); err == nil {\n\t\t\t\tvar ast *parser.ASTNode\n\n\t\t\t\tif ast, err = parser.ParseWithRuntime(fmt.Sprint(importPath), codeText, rt.erp); err == nil {\n\t\t\t\t\tif err = ast.Runtime.Validate(); err == nil {\n\n\t\t\t\t\t\tivs := scope.NewScope(scope.GlobalScope)\n\t\t\t\t\t\tif _, err = ast.Runtime.Eval(ivs, make(map[string]interface{}), tid); err == nil {\n\t\t\t\t\t\t\tirt := rt.node.Children[1].Runtime.(*identifierRuntime)\n\t\t\t\t\t\t\tirt.Set(vs, is, tid, scope.ToObject(ivs))\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil, err\n}","func (g *GraphiteProvider) RunQuery(query string) (float64, error) {\n\tquery = g.trimQuery(query)\n\tu, err := url.Parse(fmt.Sprintf(\"./render?%s\", query))\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"url.Parse failed: %w\", err)\n\t}\n\n\tq := u.Query()\n\tq.Set(\"format\", \"json\")\n\tu.RawQuery = q.Encode()\n\n\tu.Path = path.Join(g.url.Path, u.Path)\n\tu = g.url.ResolveReference(u)\n\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"http.NewRequest failed: %w\", err)\n\t}\n\n\tif g.username != \"\" && g.password != \"\" {\n\t\treq.SetBasicAuth(g.username, g.password)\n\t}\n\n\tctx, cancel := context.WithTimeout(req.Context(), g.timeout)\n\tdefer cancel()\n\n\tr, err := g.client.Do(req.WithContext(ctx))\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"request failed: %w\", err)\n\t}\n\tdefer r.Body.Close()\n\n\tb, err := io.ReadAll(r.Body)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"error reading body: %w\", err)\n\t}\n\n\tif 400 <= r.StatusCode {\n\t\treturn 0, fmt.Errorf(\"error response: %s\", string(b))\n\t}\n\n\tvar result graphiteResponse\n\terr = json.Unmarshal(b, &result)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"error unmarshaling result: %w, '%s'\", err, string(b))\n\t}\n\n\tvar value *float64\n\tfor _, tr := range result {\n\t\tfor _, dp := range tr.DataPoints {\n\t\t\tif dp.Value != nil {\n\t\t\t\tvalue = dp.Value\n\t\t\t}\n\t\t}\n\t}\n\tif value == nil {\n\t\treturn 0, ErrNoValuesFound\n\t}\n\n\treturn *value, nil\n}","func RunJSONSerializationTestForManagedClusters_AgentPool_Spec(subject ManagedClusters_AgentPool_Spec) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusters_AgentPool_Spec\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func renderCUETemplate(elem types.AddonElementFile, parameters string, args map[string]string) (*common2.ApplicationComponent, error) {\n\tbt, err := json.Marshal(args)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar paramFile = cuemodel.ParameterFieldName + \": {}\"\n\tif string(bt) != \"null\" {\n\t\tparamFile = fmt.Sprintf(\"%s: %s\", cuemodel.ParameterFieldName, string(bt))\n\t}\n\tparam := fmt.Sprintf(\"%s\\n%s\", paramFile, parameters)\n\tv, err := value.NewValue(param, nil, \"\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tout, err := v.LookupByScript(fmt.Sprintf(\"{%s}\", elem.Data))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcompContent, err := out.LookupValue(\"output\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tb, err := cueyaml.Encode(compContent.CueValue())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcomp := common2.ApplicationComponent{\n\t\tName: strings.Join(append(elem.Path, elem.Name), \"-\"),\n\t}\n\terr = yaml.Unmarshal(b, &comp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &comp, err\n}","func (gm *GraphicsManager) JsonCreate(id component.GOiD, compData []byte) error {\n\tobj := graphics.GraphicsComponent{}\n\terr := json.Unmarshal(compData, &obj)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to unmarshal graphics component, error: %s\", err.Error())\n\t}\n\n\tgm.CreateComponent(id, obj)\n\n\treturn nil\n}","func Jsonnet(service core.FileService, enabled bool) core.ConfigService {\n\treturn &jsonnetPlugin{\n\t\tenabled: enabled,\n\t\trepos: &repo{files: service},\n\t}\n}","func ExprCmpDynamic(lzVars *base.Vars, labels base.Labels,\n\tparams []interface{}, path string, cmps []base.Val,\n\tcmpEQ base.Val, cmpEQOnly bool) (lzExprFunc base.ExprFunc) {\n\tcmpLT, cmpGT := cmps[0], cmps[1]\n\n\tvar lzCmpLT base.Val = cmpLT // <== varLift: lzCmpLT by path\n\tvar lzCmpEQ base.Val = cmpEQ // <== varLift: lzCmpEQ by path\n\tvar lzCmpGT base.Val = cmpGT // <== varLift: lzCmpGT by path\n\n\tbiExprFunc := func(lzA, lzB base.ExprFunc, lzVals base.Vals, lzYieldErr base.YieldErr) (lzVal base.Val) { // !lz\n\t\t_, _, _ = lzCmpLT, lzCmpEQ, lzCmpGT\n\n\t\tif LzScope {\n\t\t\tlzVal = lzA(lzVals, lzYieldErr) // <== emitCaptured: path \"A\"\n\n\t\t\tlzValA, lzTypeA := base.Parse(lzVal)\n\t\t\tif base.ParseTypeHasValue(lzTypeA) {\n\t\t\t\tlzVal = lzB(lzVals, lzYieldErr) // <== emitCaptured: path \"B\"\n\n\t\t\t\tlzValB, lzTypeB := base.Parse(lzVal)\n\t\t\t\tif base.ParseTypeHasValue(lzTypeB) {\n\t\t\t\t\tlzCmp := lzVars.Ctx.ValComparer.CompareWithType(\n\t\t\t\t\t\tlzValA, lzValB, lzTypeA, lzTypeB, 0)\n\t\t\t\t\tif lzCmp == 0 {\n\t\t\t\t\t\tlzVal = lzCmpEQ\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlzVal = lzCmpGT\n\t\t\t\t\t\tif !cmpEQOnly { // !lz\n\t\t\t\t\t\t\tif lzCmp < 0 {\n\t\t\t\t\t\t\t\tlzVal = lzCmpLT\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} // !lz\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn lzVal\n\t} // !lz\n\n\tlzExprFunc =\n\t\tMakeBiExprFunc(lzVars, labels, params, path, biExprFunc) // !lz\n\n\treturn lzExprFunc\n}","func marshalComponentRequestBodyToStorageComponent(v *ComponentRequestBody) *storage.Component {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tres := &storage.Component{\n\t\tVarietal: v.Varietal,\n\t\tPercentage: v.Percentage,\n\t}\n\n\treturn res\n}","func RunJSONSerializationTestForServers_VirtualNetworkRule_Spec(subject Servers_VirtualNetworkRule_Spec) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual Servers_VirtualNetworkRule_Spec\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func (t *TestRuntime) GetDataWithInput(path string, input interface{}) ([]byte, error) {\n\tinputPayload := util.MustMarshalJSON(map[string]interface{}{\n\t\t\"input\": input,\n\t})\n\n\tpath = strings.TrimPrefix(path, \"/\")\n\tif !strings.HasPrefix(path, \"data\") {\n\t\tpath = \"data/\" + path\n\t}\n\n\tresp, err := t.GetDataWithRawInput(t.URL()+\"/v1/\"+path, bytes.NewReader(inputPayload))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbody, err := io.ReadAll(resp)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unexpected error reading response body: %s\", err)\n\t}\n\tresp.Close()\n\treturn body, nil\n}","func renderRawComponent(elem types.AddonElementFile) (*common2.ApplicationComponent, error) {\n\tbaseRawComponent := common2.ApplicationComponent{\n\t\tType: \"raw\",\n\t\tName: strings.Join(append(elem.Path, elem.Name), \"-\"),\n\t}\n\tobj, err := renderObject(elem)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbaseRawComponent.Properties = util.Object2RawExtension(obj)\n\treturn &baseRawComponent, nil\n}","func (*ConditionObjrefs) GetPath() string { return \"/api/objects/condition/objref/\" }","func Read(vm *jsonnet.VM, path string) ([]runtime.Object, error) {\n\text := filepath.Ext(path)\n\tif ext == \".json\" {\n\t\tf, err := os.Open(path)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer f.Close()\n\t\treturn jsonReader(f)\n\t} else if ext == \".yaml\" {\n\t\tf, err := os.Open(path)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer f.Close()\n\t\treturn yamlReader(f)\n\t} else if ext == \".jsonnet\" {\n\t\treturn jsonnetReader(vm, path)\n\t}\n\n\treturn nil, fmt.Errorf(\"Unknown file extension: %s\", path)\n}","func (r *Repository) ComponentsPath() string {\n\treturn dummyComponentPath\n}","func JsonnetVM(cmd *cobra.Command) (*jsonnet.VM, error) {\n\tvm := jsonnet.Make()\n\tflags := cmd.Flags()\n\n\tjpath := os.Getenv(\"KUBECFG_JPATH\")\n\tfor _, p := range filepath.SplitList(jpath) {\n\t\tglog.V(2).Infoln(\"Adding jsonnet search path\", p)\n\t\tvm.JpathAdd(p)\n\t}\n\n\tjpath, err := flags.GetString(\"jpath\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, p := range filepath.SplitList(jpath) {\n\t\tglog.V(2).Infoln(\"Adding jsonnet search path\", p)\n\t\tvm.JpathAdd(p)\n\t}\n\n\treturn vm, nil\n}","func Process(w http.ResponseWriter, r *http.Request, configPath string) {\n\tvar cr []aggregator.ComponentResponse\n\tvar components componentsList\n\n\tconfig := config.Parse(configPath)\n\tyaml.Unmarshal(config, &components)\n\n\tch = make(chan aggregator.ComponentResponse, len(components.Components))\n\n\tfor i, v := range components.Components {\n\t\twg.Add(1)\n\t\tgo getComponent(i, v)\n\t}\n\twg.Wait()\n\tclose(ch)\n\n\tfor component := range ch {\n\t\tcr = append(cr, component)\n\t}\n\n\tresponse, err := aggregator.Process(cr)\n\tif err != nil {\n\t\tfmt.Printf(\"There was an error aggregating a response: %s\", err.Error())\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Write(response)\n}","func RunJSONSerializationTestForUrlPathMatchConditionParameters_STATUS(subject UrlPathMatchConditionParameters_STATUS) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual UrlPathMatchConditionParameters_STATUS\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}"],"string":"[\n \"func EvaluateComponentSnippet(a app.App, snippet, paramsStr, envName string, useMemoryImporter bool) (string, error) {\\n\\tlibPath, err := a.LibPath(envName)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\tvm := jsonnet.NewVM()\\n\\tif useMemoryImporter {\\n\\t\\tvm.Fs = a.Fs()\\n\\t\\tvm.UseMemoryImporter = true\\n\\t}\\n\\n\\tvm.JPaths = []string{\\n\\t\\tlibPath,\\n\\t\\tfilepath.Join(a.Root(), \\\"vendor\\\"),\\n\\t}\\n\\tvm.ExtCode(\\\"__ksonnet/params\\\", paramsStr)\\n\\n\\tenvDetails, err := a.Environment(envName)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\tdest := map[string]string{\\n\\t\\t\\\"server\\\": envDetails.Destination.Server,\\n\\t\\t\\\"namespace\\\": envDetails.Destination.Namespace,\\n\\t}\\n\\n\\tmarshalledDestination, err := json.Marshal(&dest)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\tvm.ExtCode(\\\"__ksonnet/environments\\\", string(marshalledDestination))\\n\\n\\treturn vm.EvaluateSnippet(\\\"snippet\\\", snippet)\\n}\",\n \"func EvaluateEnv(a app.App, sourcePath, paramsStr, envName string) (string, error) {\\n\\tlibPath, err := a.LibPath(envName)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\tvm := jsonnet.NewVM()\\n\\n\\tvm.JPaths = []string{\\n\\t\\tlibPath,\\n\\t\\tfilepath.Join(a.Root(), \\\"vendor\\\"),\\n\\t}\\n\\tvm.ExtCode(\\\"__ksonnet/params\\\", paramsStr)\\n\\n\\tsnippet, err := afero.ReadFile(a.Fs(), sourcePath)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\treturn vm.EvaluateSnippet(sourcePath, string(snippet))\\n}\",\n \"func (l *Loader) EvaluateDependencies(c *ComponentNode) {\\n\\ttracer := l.tracer.Tracer(\\\"\\\")\\n\\n\\tl.mut.RLock()\\n\\tdefer l.mut.RUnlock()\\n\\n\\tl.cm.controllerEvaluation.Set(1)\\n\\tdefer l.cm.controllerEvaluation.Set(0)\\n\\tstart := time.Now()\\n\\n\\tspanCtx, span := tracer.Start(context.Background(), \\\"GraphEvaluatePartial\\\", trace.WithSpanKind(trace.SpanKindInternal))\\n\\tspan.SetAttributes(attribute.String(\\\"initiator\\\", c.NodeID()))\\n\\tdefer span.End()\\n\\n\\tlogger := log.With(l.log, \\\"trace_id\\\", span.SpanContext().TraceID())\\n\\tlevel.Info(logger).Log(\\\"msg\\\", \\\"starting partial graph evaluation\\\")\\n\\tdefer func() {\\n\\t\\tspan.SetStatus(codes.Ok, \\\"\\\")\\n\\n\\t\\tduration := time.Since(start)\\n\\t\\tlevel.Info(logger).Log(\\\"msg\\\", \\\"finished partial graph evaluation\\\", \\\"duration\\\", duration)\\n\\t\\tl.cm.componentEvaluationTime.Observe(duration.Seconds())\\n\\t}()\\n\\n\\t// Make sure we're in-sync with the current exports of c.\\n\\tl.cache.CacheExports(c.ID(), c.Exports())\\n\\n\\t_ = dag.WalkReverse(l.graph, []dag.Node{c}, func(n dag.Node) error {\\n\\t\\tif n == c {\\n\\t\\t\\t// Skip over the starting component; the starting component passed to\\n\\t\\t\\t// EvaluateDependencies had its exports changed and none of its input\\n\\t\\t\\t// arguments will need re-evaluation.\\n\\t\\t\\treturn nil\\n\\t\\t}\\n\\n\\t\\t_, span := tracer.Start(spanCtx, \\\"EvaluateNode\\\", trace.WithSpanKind(trace.SpanKindInternal))\\n\\t\\tspan.SetAttributes(attribute.String(\\\"node_id\\\", n.NodeID()))\\n\\t\\tdefer span.End()\\n\\n\\t\\tstart := time.Now()\\n\\t\\tdefer func() {\\n\\t\\t\\tlevel.Info(logger).Log(\\\"msg\\\", \\\"finished node evaluation\\\", \\\"node_id\\\", n.NodeID(), \\\"duration\\\", time.Since(start))\\n\\t\\t}()\\n\\n\\t\\tvar err error\\n\\n\\t\\tswitch n := n.(type) {\\n\\t\\tcase BlockNode:\\n\\t\\t\\terr = l.evaluate(logger, n)\\n\\t\\t\\tif exp, ok := n.(*ExportConfigNode); ok {\\n\\t\\t\\t\\tl.cache.CacheModuleExportValue(exp.Label(), exp.Value())\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\t// We only use the error for updating the span status; we don't return the\\n\\t\\t// error because we want to evaluate as many nodes as we can.\\n\\t\\tif err != nil {\\n\\t\\t\\tspan.SetStatus(codes.Error, err.Error())\\n\\t\\t} else {\\n\\t\\t\\tspan.SetStatus(codes.Ok, \\\"\\\")\\n\\t\\t}\\n\\t\\treturn nil\\n\\t})\\n\\n\\tif l.globals.OnExportsChange != nil && l.cache.ExportChangeIndex() != l.moduleExportIndex {\\n\\t\\tl.globals.OnExportsChange(l.cache.CreateModuleExports())\\n\\t\\tl.moduleExportIndex = l.cache.ExportChangeIndex()\\n\\t}\\n}\",\n \"func ParseJSONPathExpr(pathExpr string) (PathExpression, error) {\\n\\tpeCache.mu.Lock()\\n\\tval, ok := peCache.cache.Get(pathExpressionKey(pathExpr))\\n\\tif ok {\\n\\t\\tpeCache.mu.Unlock()\\n\\t\\treturn val.(PathExpression), nil\\n\\t}\\n\\tpeCache.mu.Unlock()\\n\\n\\tpathExpression, err := parseJSONPathExpr(pathExpr)\\n\\tif err == nil {\\n\\t\\tpeCache.mu.Lock()\\n\\t\\tpeCache.cache.Put(pathExpressionKey(pathExpr), kvcache.Value(pathExpression))\\n\\t\\tpeCache.mu.Unlock()\\n\\t}\\n\\treturn pathExpression, err\\n}\",\n \"func (ctx *TemplateContext) JSON(path string) (string, error) {\\n\\tdata := make(map[string]interface{})\\n\\tdec := json.NewDecoder(strings.NewReader(ctx.Payload))\\n\\terr := dec.Decode(&data)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\tparts := strings.Split(path, \\\".\\\")\\n\\n\\tquery := jsonq.NewQuery(data)\\n\\tvalue, err := query.Interface(parts...)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\t// converts int, float, bool, etc to string\\n\\treturn fmt.Sprintf(\\\"%v\\\", value), nil\\n}\",\n \"func jsonizePath(mi *Model, path string) string {\\n\\texprs := strings.Split(path, ExprSep)\\n\\texprs = jsonizeExpr(mi, exprs)\\n\\treturn strings.Join(exprs, ExprSep)\\n}\",\n \"func jsonizePath(mi *modelInfo, path string) string {\\n\\texprs := strings.Split(path, ExprSep)\\n\\texprs = jsonizeExpr(mi, exprs)\\n\\treturn strings.Join(exprs, ExprSep)\\n}\",\n \"func (l *Loader) Apply(args map[string]any, componentBlocks []*ast.BlockStmt, configBlocks []*ast.BlockStmt) diag.Diagnostics {\\n\\tstart := time.Now()\\n\\tl.mut.Lock()\\n\\tdefer l.mut.Unlock()\\n\\tl.cm.controllerEvaluation.Set(1)\\n\\tdefer l.cm.controllerEvaluation.Set(0)\\n\\n\\tfor key, value := range args {\\n\\t\\tl.cache.CacheModuleArgument(key, value)\\n\\t}\\n\\tl.cache.SyncModuleArgs(args)\\n\\n\\tnewGraph, diags := l.loadNewGraph(args, componentBlocks, configBlocks)\\n\\tif diags.HasErrors() {\\n\\t\\treturn diags\\n\\t}\\n\\n\\tvar (\\n\\t\\tcomponents = make([]*ComponentNode, 0, len(componentBlocks))\\n\\t\\tcomponentIDs = make([]ComponentID, 0, len(componentBlocks))\\n\\t\\tservices = make([]*ServiceNode, 0, len(l.services))\\n\\t)\\n\\n\\ttracer := l.tracer.Tracer(\\\"\\\")\\n\\tspanCtx, span := tracer.Start(context.Background(), \\\"GraphEvaluate\\\", trace.WithSpanKind(trace.SpanKindInternal))\\n\\tdefer span.End()\\n\\n\\tlogger := log.With(l.log, \\\"trace_id\\\", span.SpanContext().TraceID())\\n\\tlevel.Info(logger).Log(\\\"msg\\\", \\\"starting complete graph evaluation\\\")\\n\\tdefer func() {\\n\\t\\tspan.SetStatus(codes.Ok, \\\"\\\")\\n\\n\\t\\tduration := time.Since(start)\\n\\t\\tlevel.Info(logger).Log(\\\"msg\\\", \\\"finished complete graph evaluation\\\", \\\"duration\\\", duration)\\n\\t\\tl.cm.componentEvaluationTime.Observe(duration.Seconds())\\n\\t}()\\n\\n\\tl.cache.ClearModuleExports()\\n\\n\\t// Evaluate all the components.\\n\\t_ = dag.WalkTopological(&newGraph, newGraph.Leaves(), func(n dag.Node) error {\\n\\t\\t_, span := tracer.Start(spanCtx, \\\"EvaluateNode\\\", trace.WithSpanKind(trace.SpanKindInternal))\\n\\t\\tspan.SetAttributes(attribute.String(\\\"node_id\\\", n.NodeID()))\\n\\t\\tdefer span.End()\\n\\n\\t\\tstart := time.Now()\\n\\t\\tdefer func() {\\n\\t\\t\\tlevel.Info(logger).Log(\\\"msg\\\", \\\"finished node evaluation\\\", \\\"node_id\\\", n.NodeID(), \\\"duration\\\", time.Since(start))\\n\\t\\t}()\\n\\n\\t\\tvar err error\\n\\n\\t\\tswitch n := n.(type) {\\n\\t\\tcase *ComponentNode:\\n\\t\\t\\tcomponents = append(components, n)\\n\\t\\t\\tcomponentIDs = append(componentIDs, n.ID())\\n\\n\\t\\t\\tif err = l.evaluate(logger, n); err != nil {\\n\\t\\t\\t\\tvar evalDiags diag.Diagnostics\\n\\t\\t\\t\\tif errors.As(err, &evalDiags) {\\n\\t\\t\\t\\t\\tdiags = append(diags, evalDiags...)\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tdiags.Add(diag.Diagnostic{\\n\\t\\t\\t\\t\\t\\tSeverity: diag.SeverityLevelError,\\n\\t\\t\\t\\t\\t\\tMessage: fmt.Sprintf(\\\"Failed to build component: %s\\\", err),\\n\\t\\t\\t\\t\\t\\tStartPos: ast.StartPos(n.Block()).Position(),\\n\\t\\t\\t\\t\\t\\tEndPos: ast.EndPos(n.Block()).Position(),\\n\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\t\\tcase *ServiceNode:\\n\\t\\t\\tservices = append(services, n)\\n\\n\\t\\t\\tif err = l.evaluate(logger, n); err != nil {\\n\\t\\t\\t\\tvar evalDiags diag.Diagnostics\\n\\t\\t\\t\\tif errors.As(err, &evalDiags) {\\n\\t\\t\\t\\t\\tdiags = append(diags, evalDiags...)\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tdiags.Add(diag.Diagnostic{\\n\\t\\t\\t\\t\\t\\tSeverity: diag.SeverityLevelError,\\n\\t\\t\\t\\t\\t\\tMessage: fmt.Sprintf(\\\"Failed to evaluate service: %s\\\", err),\\n\\t\\t\\t\\t\\t\\tStartPos: ast.StartPos(n.Block()).Position(),\\n\\t\\t\\t\\t\\t\\tEndPos: ast.EndPos(n.Block()).Position(),\\n\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\t\\tcase BlockNode:\\n\\t\\t\\tif err = l.evaluate(logger, n); err != nil {\\n\\t\\t\\t\\tdiags.Add(diag.Diagnostic{\\n\\t\\t\\t\\t\\tSeverity: diag.SeverityLevelError,\\n\\t\\t\\t\\t\\tMessage: fmt.Sprintf(\\\"Failed to evaluate node for config block: %s\\\", err),\\n\\t\\t\\t\\t\\tStartPos: ast.StartPos(n.Block()).Position(),\\n\\t\\t\\t\\t\\tEndPos: ast.EndPos(n.Block()).Position(),\\n\\t\\t\\t\\t})\\n\\t\\t\\t}\\n\\t\\t\\tif exp, ok := n.(*ExportConfigNode); ok {\\n\\t\\t\\t\\tl.cache.CacheModuleExportValue(exp.Label(), exp.Value())\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\t// We only use the error for updating the span status; we don't return the\\n\\t\\t// error because we want to evaluate as many nodes as we can.\\n\\t\\tif err != nil {\\n\\t\\t\\tspan.SetStatus(codes.Error, err.Error())\\n\\t\\t} else {\\n\\t\\t\\tspan.SetStatus(codes.Ok, \\\"\\\")\\n\\t\\t}\\n\\t\\treturn nil\\n\\t})\\n\\n\\tl.componentNodes = components\\n\\tl.serviceNodes = services\\n\\tl.graph = &newGraph\\n\\tl.cache.SyncIDs(componentIDs)\\n\\tl.blocks = componentBlocks\\n\\tl.cm.componentEvaluationTime.Observe(time.Since(start).Seconds())\\n\\tif l.globals.OnExportsChange != nil && l.cache.ExportChangeIndex() != l.moduleExportIndex {\\n\\t\\tl.moduleExportIndex = l.cache.ExportChangeIndex()\\n\\t\\tl.globals.OnExportsChange(l.cache.CreateModuleExports())\\n\\t}\\n\\treturn diags\\n}\",\n \"func (cx *Context) Eval(source string, result interface{}) (err error) {\\n\\tcx.do(func(ptr *C.JSAPIContext) {\\n\\t\\t// alloc C-string\\n\\t\\tcsource := C.CString(source)\\n\\t\\tdefer C.free(unsafe.Pointer(csource))\\n\\t\\tvar jsonData *C.char\\n\\t\\tvar jsonLen C.int\\n\\t\\tfilename := \\\"eval\\\"\\n\\t\\tcfilename := C.CString(filename)\\n\\t\\tdefer C.free(unsafe.Pointer(cfilename))\\n\\t\\t// eval\\n\\t\\tif C.JSAPI_EvalJSON(ptr, csource, cfilename, &jsonData, &jsonLen) != C.JSAPI_OK {\\n\\t\\t\\terr = cx.getError(filename)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tdefer C.free(unsafe.Pointer(jsonData))\\n\\t\\t// convert to go\\n\\t\\tb := []byte(C.GoStringN(jsonData, jsonLen))\\n\\t\\tif raw, ok := result.(*Raw); ok {\\n\\t\\t\\t*raw = Raw(string(b))\\n\\t\\t} else {\\n\\t\\t\\terr = json.Unmarshal(b, result)\\n\\t\\t}\\n\\t})\\n\\treturn err\\n}\",\n \"func Get(path string, value interface{}) (interface{}, error) {\\n\\teval, err := lang.NewEvaluable(path)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn eval(context.Background(), value)\\n}\",\n \"func LoadComponentFromPath(path string) (*Component, error) {\\n\\tdata, err := ioutil.ReadFile(path)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tdef, err := LoadComponent(data)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tdef.Path = path\\n\\treturn def, nil\\n}\",\n \"func (myjson *JSONModel) Get(nodePath string) (interface{}, error) {\\n\\tif len(nodePath) == 0 {\\n\\t\\tpanic(\\\"The parameter \\\\\\\"nodePath\\\\\\\" is nil or empty\\\")\\n\\t}\\n\\tif e := myjson.toJSONObj(); e != nil {\\n\\t\\treturn nil, e\\n\\t}\\n\\tif myjson.jsonObj == nil {\\n\\t\\treturn nil, errors.New(\\\"Parse json to the type \\\\\\\"interface{}\\\\\\\" is nil \\\")\\n\\t}\\n\\n\\tnodes := strings.Split(nodePath, \\\".\\\")\\n\\treturn adaptor(myjson.jsonObj, nodes)\\n}\",\n \"func RunTemplate(template []byte, input []byte) (interface{}, error) {\\n\\n\\tvar data interface{}\\n\\tjson.Unmarshal(input, &data)\\n\\n\\tv, err := jsonfilter.FilterJsonFromTextWithFilterRunner(string(template), string(template), func(command string, value string) (string, error) {\\n\\t\\tfilterval, _ := jsonpath.Read(data, value)\\n\\t\\t// fmt.Println(filterval)\\n\\t\\tret := fmt.Sprintf(\\\"%v\\\", filterval)\\n\\t\\treturn ret, nil\\n\\t})\\n\\n\\treturn v, err\\n\\n}\",\n \"func (r *NuxeoReconciler) getValueByPath(resource v1alpha1.BackingServiceResource, namespace string,\\n\\tfrom string) ([]byte, string, error) {\\n\\tif from == \\\"\\\" {\\n\\t\\treturn nil, \\\"\\\", fmt.Errorf(\\\"no path provided in projection\\\")\\n\\t}\\n\\tu := unstructured.Unstructured{}\\n\\tgvk := schema.GroupVersionKind{\\n\\t\\tGroup: resource.Group,\\n\\t\\tVersion: resource.Version,\\n\\t\\tKind: resource.Kind,\\n\\t}\\n\\tu.SetGroupVersionKind(gvk)\\n\\tif err := r.Get(context.TODO(), client.ObjectKey{Namespace: namespace, Name: resource.Name},\\n\\t\\t&u); err != nil {\\n\\t\\treturn nil, \\\"\\\", fmt.Errorf(\\\"unable to get resource: %v\\\", resource.Name)\\n\\t}\\n\\tresVer := \\\"\\\"\\n\\tif rv, rve := util.GetJsonPathValueU(u.Object, \\\"{.metadata.resourceVersion}\\\"); rve == nil && rv != nil {\\n\\t\\tresVer = string(rv)\\n\\t} else if rve != nil {\\n\\t\\treturn nil, \\\"\\\", rve\\n\\t} else if rv == nil {\\n\\t\\treturn nil, \\\"\\\", fmt.Errorf(\\\"unable to get resource version from resource: %v\\\", resource.Name)\\n\\t}\\n\\tresVal, resErr := util.GetJsonPathValueU(u.Object, from)\\n\\treturn resVal, resVer, resErr\\n}\",\n \"func RunJSONSerializationTestForUrlPathMatchConditionParameters(subject UrlPathMatchConditionParameters) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual UrlPathMatchConditionParameters\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func (l *Loader) evaluate(logger log.Logger, bn BlockNode) error {\\n\\tectx := l.cache.BuildContext()\\n\\terr := bn.Evaluate(ectx)\\n\\n\\tswitch c := bn.(type) {\\n\\tcase *ComponentNode:\\n\\t\\t// Always update the cache both the arguments and exports, since both might\\n\\t\\t// change when a component gets re-evaluated. We also want to cache the arguments and exports in case of an error\\n\\t\\tl.cache.CacheArguments(c.ID(), c.Arguments())\\n\\t\\tl.cache.CacheExports(c.ID(), c.Exports())\\n\\tcase *ArgumentConfigNode:\\n\\t\\tif _, found := l.cache.moduleArguments[c.Label()]; !found {\\n\\t\\t\\tif c.Optional() {\\n\\t\\t\\t\\tl.cache.CacheModuleArgument(c.Label(), c.Default())\\n\\t\\t\\t} else {\\n\\t\\t\\t\\terr = fmt.Errorf(\\\"missing required argument %q to module\\\", c.Label())\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tif err != nil {\\n\\t\\tlevel.Error(logger).Log(\\\"msg\\\", \\\"failed to evaluate config\\\", \\\"node\\\", bn.NodeID(), \\\"err\\\", err)\\n\\t\\treturn err\\n\\t}\\n\\treturn nil\\n}\",\n \"func loadSpec(cPath string) (spec *specs.Spec, err error) {\\n\\tcf, err := os.Open(cPath)\\n\\tif err != nil {\\n\\t\\tif os.IsNotExist(err) {\\n\\t\\t\\treturn nil, fmt.Errorf(\\\"JSON specification file %s not found\\\", cPath)\\n\\t\\t}\\n\\t\\treturn nil, err\\n\\t}\\n\\tdefer cf.Close()\\n\\n\\tif err = json.NewDecoder(cf).Decode(&spec); err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\t// return spec, validateProcessSpec(spec.Process)\\n\\treturn spec, nil\\n}\",\n \"func jsonPathValue(yamlConfig string, jsonPath string) (interface{}, error) {\\n\\tu, err := k8sutil.YAMLToUnstructured([]byte(yamlConfig))\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"YAML to unstructured object: %w\\\", err)\\n\\t}\\n\\n\\tgot, err := valFromObject(jsonPath, u)\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"JSON path value in YAML: %w\\\", err)\\n\\t}\\n\\n\\tswitch got.Kind() { //nolint:exhaustive\\n\\tcase reflect.Interface:\\n\\t\\t// TODO: Add type switch here for concrete types.\\n\\t\\treturn got.Interface(), nil\\n\\tdefault:\\n\\t\\treturn nil, fmt.Errorf(\\\"extracted object has an unknown type: %v\\\", got.Kind())\\n\\t}\\n}\",\n \"func LoadComponentConfig(structConfig interface{}, configFile string) {\\n\\n\\tif _, err := os.Stat(configFile); os.IsNotExist(err) {\\n\\t\\tlog.Fatalln(configFile + \\\" file not found\\\")\\n\\t} else if err != nil {\\n\\t\\tlog.Fatalln(err.Error())\\n\\t}\\n\\n\\tif _, err := toml.DecodeFile(configFile, structConfig); err != nil {\\n\\t\\tlog.Fatalln(err.Error())\\n\\t}\\n\\n}\",\n \"func TestCSharpCompat(t *testing.T) {\\n\\tjs := `{\\n \\\"store\\\": {\\n \\\"book\\\": [\\n {\\n \\\"category\\\": \\\"reference\\\",\\n \\\"author\\\": \\\"Nigel Rees\\\",\\n \\\"title\\\": \\\"Sayings of the Century\\\",\\n \\\"price\\\": 8.95\\n },\\n {\\n \\\"category\\\": \\\"fiction\\\",\\n \\\"author\\\": \\\"Evelyn Waugh\\\",\\n \\\"title\\\": \\\"Sword of Honour\\\",\\n \\\"price\\\": 12.99\\n },\\n {\\n \\\"category\\\": \\\"fiction\\\",\\n \\\"author\\\": \\\"Herman Melville\\\",\\n \\\"title\\\": \\\"Moby Dick\\\",\\n \\\"isbn\\\": \\\"0-553-21311-3\\\",\\n \\\"price\\\": 8.99\\n },\\n {\\n \\\"category\\\": \\\"fiction\\\",\\n \\\"author\\\": \\\"J. R. R. Tolkien\\\",\\n \\\"title\\\": \\\"The Lord of the Rings\\\",\\n \\\"isbn\\\": \\\"0-395-19395-8\\\",\\n \\\"price\\\": null\\n }\\n ],\\n \\\"bicycle\\\": {\\n \\\"color\\\": \\\"red\\\",\\n \\\"price\\\": 19.95\\n }\\n },\\n \\\"expensive\\\": 10,\\n \\\"data\\\": null\\n}`\\n\\n\\ttestCases := []pathTestCase{\\n\\t\\t{\\\"$.store.book[*].author\\\", `[\\\"Nigel Rees\\\",\\\"Evelyn Waugh\\\",\\\"Herman Melville\\\",\\\"J. R. R. Tolkien\\\"]`},\\n\\t\\t{\\\"$..author\\\", `[\\\"Nigel Rees\\\",\\\"Evelyn Waugh\\\",\\\"Herman Melville\\\",\\\"J. R. R. Tolkien\\\"]`},\\n\\t\\t{\\\"$.store.*\\\", `[[{\\\"category\\\":\\\"reference\\\",\\\"author\\\":\\\"Nigel Rees\\\",\\\"title\\\":\\\"Sayings of the Century\\\",\\\"price\\\":8.95},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Evelyn Waugh\\\",\\\"title\\\":\\\"Sword of Honour\\\",\\\"price\\\":12.99},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Herman Melville\\\",\\\"title\\\":\\\"Moby Dick\\\",\\\"isbn\\\":\\\"0-553-21311-3\\\",\\\"price\\\":8.99},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"J. R. R. Tolkien\\\",\\\"title\\\":\\\"The Lord of the Rings\\\",\\\"isbn\\\":\\\"0-395-19395-8\\\",\\\"price\\\":null}],{\\\"color\\\":\\\"red\\\",\\\"price\\\":19.95}]`},\\n\\t\\t{\\\"$.store..price\\\", `[19.95,8.95,12.99,8.99,null]`},\\n\\t\\t{\\\"$..book[2]\\\", `[{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Herman Melville\\\",\\\"title\\\":\\\"Moby Dick\\\",\\\"isbn\\\":\\\"0-553-21311-3\\\",\\\"price\\\":8.99}]`},\\n\\t\\t{\\\"$..book[-2]\\\", `[{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Herman Melville\\\",\\\"title\\\":\\\"Moby Dick\\\",\\\"isbn\\\":\\\"0-553-21311-3\\\",\\\"price\\\":8.99}]`},\\n\\t\\t{\\\"$..book[0,1]\\\", `[{\\\"category\\\":\\\"reference\\\",\\\"author\\\":\\\"Nigel Rees\\\",\\\"title\\\":\\\"Sayings of the Century\\\",\\\"price\\\":8.95},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Evelyn Waugh\\\",\\\"title\\\":\\\"Sword of Honour\\\",\\\"price\\\":12.99}]`},\\n\\t\\t{\\\"$..book[:2]\\\", `[{\\\"category\\\":\\\"reference\\\",\\\"author\\\":\\\"Nigel Rees\\\",\\\"title\\\":\\\"Sayings of the Century\\\",\\\"price\\\":8.95},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Evelyn Waugh\\\",\\\"title\\\":\\\"Sword of Honour\\\",\\\"price\\\":12.99}]`},\\n\\t\\t{\\\"$..book[1:2]\\\", `[{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Evelyn Waugh\\\",\\\"title\\\":\\\"Sword of Honour\\\",\\\"price\\\":12.99}]`},\\n\\t\\t{\\\"$..book[-2:]\\\", `[{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Herman Melville\\\",\\\"title\\\":\\\"Moby Dick\\\",\\\"isbn\\\":\\\"0-553-21311-3\\\",\\\"price\\\":8.99},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"J. R. R. Tolkien\\\",\\\"title\\\":\\\"The Lord of the Rings\\\",\\\"isbn\\\":\\\"0-395-19395-8\\\",\\\"price\\\":null}]`},\\n\\t\\t{\\\"$..book[2:]\\\", `[{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Herman Melville\\\",\\\"title\\\":\\\"Moby Dick\\\",\\\"isbn\\\":\\\"0-553-21311-3\\\",\\\"price\\\":8.99},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"J. R. R. Tolkien\\\",\\\"title\\\":\\\"The Lord of the Rings\\\",\\\"isbn\\\":\\\"0-395-19395-8\\\",\\\"price\\\":null}]`},\\n\\t\\t{\\\"\\\", `[{\\\"store\\\":{\\\"book\\\":[{\\\"category\\\":\\\"reference\\\",\\\"author\\\":\\\"Nigel Rees\\\",\\\"title\\\":\\\"Sayings of the Century\\\",\\\"price\\\":8.95},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Evelyn Waugh\\\",\\\"title\\\":\\\"Sword of Honour\\\",\\\"price\\\":12.99},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Herman Melville\\\",\\\"title\\\":\\\"Moby Dick\\\",\\\"isbn\\\":\\\"0-553-21311-3\\\",\\\"price\\\":8.99},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"J. R. R. Tolkien\\\",\\\"title\\\":\\\"The Lord of the Rings\\\",\\\"isbn\\\":\\\"0-395-19395-8\\\",\\\"price\\\":null}],\\\"bicycle\\\":{\\\"color\\\":\\\"red\\\",\\\"price\\\":19.95}},\\\"expensive\\\":10,\\\"data\\\":null}]`},\\n\\t\\t{\\\"$.*\\\", `[{\\\"book\\\":[{\\\"category\\\":\\\"reference\\\",\\\"author\\\":\\\"Nigel Rees\\\",\\\"title\\\":\\\"Sayings of the Century\\\",\\\"price\\\":8.95},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Evelyn Waugh\\\",\\\"title\\\":\\\"Sword of Honour\\\",\\\"price\\\":12.99},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Herman Melville\\\",\\\"title\\\":\\\"Moby Dick\\\",\\\"isbn\\\":\\\"0-553-21311-3\\\",\\\"price\\\":8.99},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"J. R. R. Tolkien\\\",\\\"title\\\":\\\"The Lord of the Rings\\\",\\\"isbn\\\":\\\"0-395-19395-8\\\",\\\"price\\\":null}],\\\"bicycle\\\":{\\\"color\\\":\\\"red\\\",\\\"price\\\":19.95}},10,null]`},\\n\\t\\t{\\\"$..invalidfield\\\", `[]`},\\n\\t}\\n\\n\\tfor _, tc := range testCases {\\n\\t\\tt.Run(tc.path, func(t *testing.T) {\\n\\t\\t\\ttc.testUnmarshalGet(t, js)\\n\\t\\t})\\n\\t}\\n\\n\\tt.Run(\\\"bad cases\\\", func(t *testing.T) {\\n\\t\\t_, ok := unmarshalGet(t, js, `$..book[*].author\\\"`)\\n\\t\\trequire.False(t, ok)\\n\\t})\\n}\",\n \"func EvaluateBundle(ctx context.Context, bundle []byte) (rel.Value, error) {\\n\\tctx, err := WithBundleRun(ctx, bundle)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tctx, mainFileSource, path := GetMainBundleSource(ctx)\\n\\treturn EvaluateExpr(ctx, path, string(mainFileSource))\\n}\",\n \"func (e *Implementation) Evaluate(template string) (string, error) {\\n\\tp := tmpl.Parameters{\\n\\t\\tTestNamespace: e.TestNamespace,\\n\\t\\tDependencyNamespace: e.DependencyNamespace,\\n\\t}\\n\\n\\treturn tmpl.Evaluate(template, p)\\n}\",\n \"func EvaluateComponents(iq IQ, components []Component, applicationID string) (*Evaluation, error) {\\n\\trequest, err := json.Marshal(iqEvaluationRequest{Components: components})\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"could not build the request: %v\\\", err)\\n\\t}\\n\\n\\trequestEndpoint := fmt.Sprintf(restEvaluation, applicationID)\\n\\tbody, _, err := iq.Post(requestEndpoint, bytes.NewBuffer(request))\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"components not evaluated: %v\\\", err)\\n\\t}\\n\\n\\tvar results iqEvaluationRequestResponse\\n\\tif err = json.Unmarshal(body, &results); err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"could not parse evaluation response: %v\\\", err)\\n\\t}\\n\\n\\tgetEvaluationResults := func() (*Evaluation, error) {\\n\\t\\tbody, resp, e := iq.Get(results.ResultsURL)\\n\\t\\tif e != nil {\\n\\t\\t\\tif resp.StatusCode != http.StatusNotFound {\\n\\t\\t\\t\\treturn nil, fmt.Errorf(\\\"could not retrieve evaluation results: %v\\\", err)\\n\\t\\t\\t}\\n\\t\\t\\treturn nil, nil\\n\\t\\t}\\n\\n\\t\\tvar ev Evaluation\\n\\t\\tif err = json.Unmarshal(body, &ev); err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\n\\t\\treturn &ev, nil\\n\\t}\\n\\n\\tvar eval *Evaluation\\n\\tticker := time.NewTicker(5 * time.Second)\\n\\tfor {\\n\\t\\tselect {\\n\\t\\tcase <-ticker.C:\\n\\t\\t\\tif eval, err = getEvaluationResults(); eval != nil || err != nil {\\n\\t\\t\\t\\tticker.Stop()\\n\\t\\t\\t\\treturn eval, err\\n\\t\\t\\t}\\n\\t\\tcase <-time.After(5 * time.Minute):\\n\\t\\t\\tticker.Stop()\\n\\t\\t\\treturn nil, errors.New(\\\"timed out waiting for valid evaluation results\\\")\\n\\t\\t}\\n\\t}\\n}\",\n \"func Eval(t testing.TestingT, options *EvalOptions, jsonFilePaths []string, resultQuery string) {\\n\\trequire.NoError(t, EvalE(t, options, jsonFilePaths, resultQuery))\\n}\",\n \"func MarshalToJsonPathWrapper(expression string) OutputFormater {\\n\\texpr := expression\\n\\t// aka MarshalToJsonPath\\n\\treturn func(input interface{}) ([]byte, error) {\\n\\t\\tjp := jsonpath.New(\\\"json-path\\\")\\n\\n\\t\\tif err := jp.Parse(expr); err != nil {\\n\\t\\t\\treturn nil, fmt.Errorf(\\\"Failed to parse jsonpath expression: %v\\\", err)\\n\\t\\t}\\n\\n\\t\\tvalues, err := jp.FindResults(input)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, fmt.Errorf(\\\"Failed to execute jsonpath %s on input %s: %v \\\", expr, input, err)\\n\\t\\t}\\n\\n\\t\\tif values == nil || len(values) == 0 || len(values[0]) == 0 {\\n\\t\\t\\treturn nil, errors.New(fmt.Sprintf(\\\"Error parsing value from input %v using template %s: %v \\\", input, expr, err))\\n\\t\\t}\\n\\n\\t\\tjson, err := MarshalToJson(values[0][0].Interface())\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t\\treturn unquote(json), err\\n\\t}\\n}\",\n \"func RunJSONSerializationTestForExtendedLocation(subject ExtendedLocation) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ExtendedLocation\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForExtendedLocation(subject ExtendedLocation) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ExtendedLocation\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForExtendedLocation(subject ExtendedLocation) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ExtendedLocation\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func (s *server) resolveComponent(dirPath, childQuery string, predicate func(os.FileInfo) bool) (string, error) {\\n\\tvar err error\\n\\tvar children []string\\n\\n\\tkey := strings.ToLower(dirPath)\\n\\tif s.cache != nil && s.cache.Contains(key) {\\n\\t\\tentry, _ := s.cache.Get(key)\\n\\t\\tchildren = entry.([]string)\\n\\t} else {\\n\\t\\tchildren, err = godirwalk.ReadDirnames(dirPath, nil)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn \\\"\\\", err\\n\\t\\t}\\n\\n\\t\\tsort.Strings(children)\\n\\t\\tif s.cache != nil {\\n\\t\\t\\ts.cache.Add(key, children)\\n\\t\\t}\\n\\t}\\n\\n\\tnormSegment := \\\"\\\"\\n\\tfor _, child := range children {\\n\\t\\tif strings.EqualFold(child, childQuery) {\\n\\t\\t\\tchildPath := filepath.Join(dirPath, child)\\n\\t\\t\\tfi, err := os.Stat(childPath)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\treturn \\\"\\\", err\\n\\t\\t\\t}\\n\\t\\t\\tif predicate(fi) {\\n\\t\\t\\t\\tnormSegment = child\\n\\t\\t\\t\\tbreak\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\tif normSegment == \\\"\\\" {\\n\\t\\treturn \\\"\\\", nil\\n\\t}\\n\\n\\treturn filepath.Join(dirPath, normSegment), nil\\n}\",\n \"func (a *JSONDataDecouplerActivity) Eval(ctx activity.Context) (done bool, err error) {\\n\\n\\toriginJSONObject := ctx.GetInput(input)\\n\\ttargetPath, targetPathElements, _ := a.getTarget(ctx)\\n\\ttarget := originJSONObject\\n\\tfor _, targetPathElement := range targetPathElements {\\n\\t\\ttarget = target.(map[string]interface{})[targetPathElement]\\n\\t}\\n\\n\\ttargetArray := target.([]interface{})\\n\\toutputArray := make([]interface{}, len(targetArray))\\n\\tfor index, targetElement := range targetArray {\\n\\t\\toutputElement := make(map[string]interface{})\\n\\t\\toutputElement[\\\"originJSONObject\\\"] = originJSONObject\\n\\t\\toutputElement[fmt.Sprintf(\\\"%s.%s\\\", targetPath, \\\"Index\\\")] = index\\n\\t\\toutputElement[fmt.Sprintf(\\\"%s.%s\\\", targetPath, \\\"Element\\\")] = targetElement\\n\\t\\tif len(targetArray)-1 == index {\\n\\t\\t\\toutputElement[\\\"LastElement\\\"] = true\\n\\t\\t} else {\\n\\t\\t\\toutputElement[\\\"LastElement\\\"] = false\\n\\t\\t}\\n\\t}\\n\\n\\tjsondata := &data.ComplexObject{Metadata: \\\"Data\\\", Value: outputArray}\\n\\n\\tctx.SetOutput(output, jsondata)\\n\\n\\treturn true, nil\\n}\",\n \"func (session Runtime) evaluate(expression string, contextID int64, async, returnByValue bool) (*devtool.RemoteObject, error) {\\n\\tp := &devtool.EvaluatesExpression{\\n\\t\\tExpression: expression,\\n\\t\\tIncludeCommandLineAPI: true,\\n\\t\\tContextID: contextID,\\n\\t\\tAwaitPromise: !async,\\n\\t\\tReturnByValue: returnByValue,\\n\\t}\\n\\tresult := new(devtool.EvaluatesResult)\\n\\tif err := session.call(\\\"Runtime.evaluate\\\", p, result); err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tif result.ExceptionDetails != nil {\\n\\t\\treturn nil, result.ExceptionDetails\\n\\t}\\n\\treturn result.Result, nil\\n}\",\n \"func (p *Parser) Load(filename string) (string, error) {\\n\\tdirectory := filepath.Dir(filename)\\n\\tdata, err := ioutil.ReadFile(filename)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\tvm := jsonnet.MakeVM()\\n\\tvm.Importer(&jsonnet.FileImporter{\\n\\t\\tJPaths: []string{directory},\\n\\t})\\n\\n\\treturn vm.EvaluateAnonymousSnippet(filename, string(data))\\n}\",\n \"func (this *Value) Path(path string) (*Value, error) {\\n\\t// aliases always have priority\\n\\n\\tif this.alias != nil {\\n\\t\\tresult, ok := this.alias[path]\\n\\t\\tif ok {\\n\\t\\t\\treturn result, nil\\n\\t\\t}\\n\\t}\\n\\t// next we already parsed, used that\\n\\tswitch parsedValue := this.parsedValue.(type) {\\n\\tcase map[string]*Value:\\n\\t\\tresult, ok := parsedValue[path]\\n\\t\\tif ok {\\n\\t\\t\\treturn result, nil\\n\\t\\t}\\n\\t}\\n\\t// finally, consult the raw bytes\\n\\tif this.raw != nil {\\n\\t\\tres, err := jsonpointer.Find(this.raw, \\\"/\\\"+path)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t\\tif res != nil {\\n\\t\\t\\treturn NewValueFromBytes(res), nil\\n\\t\\t}\\n\\t}\\n\\n\\treturn nil, &Undefined{path}\\n}\",\n \"func (a *Activity) Eval(ctx activity.Context) (done bool, err error) {\\n\\n\\t//call neural network here\\n ctx.Logger().Debugf(\\\"result of picking out a person: %s\\\", \\\"found\\\") //log is also dummy here\\n\\terr = nil //set if neural network go wrong\\n\\tif err != nil {\\n\\t\\treturn true, err\\n\\t}\\n//dummy json generation here\\n\\timgId:=215\\n\\timgPath:=\\\"/home/test.jpg/\\\"\\n\\tbboxid:=0\\n\\tx1:=1\\n\\ty1:=1\\n\\tx2:=3\\n\\ty2:=3\\n\\timgjson:=imgJson{\\n\\t\\tImgid: imgId,\\n\\t\\tImgpath: imgPath,\\n\\t\\tBboxs:[]Bbox{\\n\\t\\t\\t Bbox{\\n\\t\\t\\t\\tBoxid:bboxid,\\n\\t\\t\\t\\tX1:x1,\\n\\t\\t\\t\\tY1:y1,\\n\\t\\t\\t\\tX2:x2,\\n\\t\\t\\t\\tY2:y2,\\n\\t\\t\\t },\\n\\t\\t\\t},\\t \\n\\t}\\n\\tif jsonString, err := json.Marshal(imgjson); err == nil {\\n fmt.Println(\\\"================struct to json str==\\\")\\n fmt.Println(string(jsonString))\\n\\t\\toutput := &Output{Serial: string(jsonString)}\\n\\t\\terr = ctx.SetOutputObject(output)\\n\\t if err != nil {\\n\\t\\t return true, err\\n\\t }\\n }\\n\\tif err != nil {\\n\\t\\treturn true, err\\n\\t}\\n\\t\\t\\n\\t//output := &Output{Serial: \\\"1\\\"}//should be serial of the record in the database\\n\\n\\n\\treturn true, nil\\n}\",\n \"func parseJSON(jsonPath string, v interface{}) error {\\n\\tif !osutil.Exists(jsonPath) {\\n\\t\\twarn.Printf(\\\"unable to locate JSON file %q\\\", jsonPath)\\n\\t\\treturn nil\\n\\t}\\n\\treturn jsonutil.ParseFile(jsonPath, v)\\n}\",\n \"func (o *Object) Path(path string) *Value {\\n\\topChain := o.chain.enter(\\\"Path(%q)\\\", path)\\n\\tdefer opChain.leave()\\n\\n\\treturn jsonPath(opChain, o.value, path)\\n}\",\n \"func (session Runtime) Evaluate(code string, async bool, returnByValue bool) (interface{}, error) {\\n\\tresult, err := session.evaluate(code, session.currentContext(), async, returnByValue)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\treturn result.Value, nil\\n}\",\n \"func (nc nameConfig) render(job, test string, metadatas ...map[string]string) string {\\n\\tparsed := make([]interface{}, len(nc.parts))\\n\\tfor i, p := range nc.parts {\\n\\t\\tvar s string\\n\\t\\tswitch p {\\n\\t\\tcase jobName:\\n\\t\\t\\ts = job\\n\\t\\tcase testsName:\\n\\t\\t\\ts = test\\n\\t\\tdefault:\\n\\t\\t\\tfor _, metadata := range metadatas {\\n\\t\\t\\t\\tv, present := metadata[p]\\n\\t\\t\\t\\tif present {\\n\\t\\t\\t\\t\\ts = v\\n\\t\\t\\t\\t\\tbreak\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tparsed[i] = s\\n\\t}\\n\\treturn fmt.Sprintf(nc.format, parsed...)\\n}\",\n \"func (p *Path) Render(values map[string]string, usedValues map[string]struct{}) (string, error) {\\n\\tvar path string\\n\\n\\tfor _, part := range p.parts {\\n\\t\\tval, used, err := part.render(values, p.normalize)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn \\\"\\\", err\\n\\t\\t}\\n\\n\\t\\tpath += `/` + val\\n\\t\\tfor _, u := range used {\\n\\t\\t\\tusedValues[u] = struct{}{}\\n\\t\\t}\\n\\t}\\n\\n\\tif len(path) == 0 {\\n\\t\\tpath = \\\"/\\\"\\n\\t} else if p.trailingSlash && !strings.HasSuffix(path, \\\"/\\\") {\\n\\t\\tpath += \\\"/\\\"\\n\\t}\\n\\n\\tquery := url.Values{}\\n\\tqueryUsed := false\\n\\tfor k, v := range values {\\n\\t\\tif _, ok := usedValues[k]; !ok {\\n\\t\\t\\tqueryUsed = true\\n\\t\\t\\tquery.Set(k, v)\\n\\t\\t}\\n\\t}\\n\\n\\tif queryUsed {\\n\\t\\treturn path + `?` + query.Encode(), nil\\n\\t}\\n\\treturn path, nil\\n}\",\n \"func operatorPresentAtPath(jplan []byte, path string, operator string) error {\\n\\t// fmt.Printf(\\\"%s\\\\n\\\", string(jplan))\\n\\tv := interface{}(nil)\\n\\terr := json.Unmarshal(jplan, &v)\\n\\tif err != nil {\\n\\t\\treturn errors.Wrap(err, fmt.Sprintf(\\\"expected '%s' to be present\\\", operator))\\n\\t}\\n\\n\\tbuilder := gval.Full(jsonpath.PlaceholderExtension())\\n\\texpr, err := builder.NewEvaluable(path)\\n\\tif err != nil {\\n\\t\\treturn errors.Wrap(err, fmt.Sprintf(\\\"expected '%s' to be present\\\", operator))\\n\\t}\\n\\teval, err := expr(context.Background(), v)\\n\\tif err != nil {\\n\\t\\treturn errors.Wrap(err, fmt.Sprintf(\\\"expected '%s' to be present\\\", operator))\\n\\t}\\n\\ts, ok := eval.(string)\\n\\tif ok && strings.EqualFold(s, operator) {\\n\\t\\treturn nil\\n\\t}\\n\\treturn fmt.Errorf(\\\"expected '%s' to be present\\\", operator)\\n}\",\n \"func jsonPath(name string) string {\\n\\treturn path.Join(dataPath, fmt.Sprintf(\\\"rove-%s.json\\\", name))\\n}\",\n \"func RunJSONSerializationTestForDeliveryRuleUrlPathCondition(subject DeliveryRuleUrlPathCondition) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual DeliveryRuleUrlPathCondition\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func Load (path string, unsafe...bool) (*Parser, error) {\\n if j, e := gjson.Load(path, unsafe...); e == nil {\\n return &Parser{j}, nil\\n } else {\\n return nil, e\\n }\\n}\",\n \"func fnEval(ctx Context, doc *JDoc, params []string) interface{} {\\n\\tstats := ctx.Value(EelTotalStats).(*ServiceStats)\\n\\tif params == nil || len(params) == 0 || len(params) > 2 {\\n\\t\\tctx.Log().Error(\\\"error_type\\\", \\\"func_eval\\\", \\\"op\\\", \\\"eval\\\", \\\"cause\\\", \\\"wrong_number_of_parameters\\\", \\\"params\\\", params)\\n\\t\\tstats.IncErrors()\\n\\t\\tAddError(ctx, SyntaxError{fmt.Sprintf(\\\"wrong number of parameters in call to eval function\\\"), \\\"eval\\\", params})\\n\\t\\treturn \\\"\\\"\\n\\t} else if len(params) == 1 {\\n\\t\\treturn doc.EvalPath(ctx, extractStringParam(params[0]))\\n\\t} else {\\n\\t\\tldoc, err := NewJDocFromString(extractStringParam(params[1]))\\n\\t\\tif err != nil {\\n\\t\\t\\tctx.Log().Error(\\\"error_type\\\", \\\"func_eval\\\", \\\"op\\\", \\\"eval\\\", \\\"cause\\\", \\\"json_expected\\\", \\\"params\\\", params, \\\"error\\\", err.Error())\\n\\t\\t\\tstats.IncErrors()\\n\\t\\t\\tAddError(ctx, SyntaxError{fmt.Sprintf(\\\"non json parameters in call to eval function\\\"), \\\"eval\\\", params})\\n\\t\\t\\treturn \\\"\\\"\\n\\t\\t}\\n\\t\\treturn ldoc.EvalPath(ctx, extractStringParam(params[0]))\\n\\t}\\n}\",\n \"func evaluate(node ast.Node, ext vmExtMap, tla vmExtMap, nativeFuncs map[string]*NativeFunction,\\n\\tmaxStack int, ic *importCache, traceOut io.Writer, stringOutputMode bool) (string, error) {\\n\\n\\ti, err := buildInterpreter(ext, nativeFuncs, maxStack, ic, traceOut)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\tresult, err := evaluateAux(i, node, tla)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\tvar buf bytes.Buffer\\n\\ti.stack.setCurrentTrace(manifestationTrace())\\n\\tif stringOutputMode {\\n\\t\\terr = i.manifestString(&buf, result)\\n\\t} else {\\n\\t\\terr = i.manifestAndSerializeJSON(&buf, result, true, \\\"\\\")\\n\\t}\\n\\ti.stack.clearCurrentTrace()\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\tbuf.WriteString(\\\"\\\\n\\\")\\n\\treturn buf.String(), nil\\n}\",\n \"func (p PathParser) Value(raw string) ValueImpl {\\n\\tif len(raw) == 0 {\\n\\t\\treturn ValueImpl{parser: p} // empty value\\n\\t}\\n\\n\\tif p.AllowMultiple && strings.HasPrefix(raw, \\\"[\\\") {\\n\\t\\t// parse as JSON\\n\\t\\tvar rc = ValueImpl{parser: p}\\n\\n\\t\\tif err := json.Unmarshal([]byte(raw), &rc.values); err != nil {\\n\\t\\t\\treturn ValueImpl{err: fmt.Errorf(\\\"failed to parse JSON path: %s\\\", err.Error())}\\n\\t\\t}\\n\\n\\t\\t// valid JSON list -> check each individual item\\n\\t\\tfor _, value := range rc.values {\\n\\t\\t\\tif rc.err = p.validatePath(value); rc.err != nil {\\n\\t\\t\\t\\tbreak\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\treturn rc\\n\\t}\\n\\n\\t// default behaviour: put it into the first slice\\n\\treturn ValueImpl{\\n\\t\\tvalues: []string{raw},\\n\\t\\terr: p.validatePath(raw),\\n\\t\\tparser: p,\\n\\t}\\n}\",\n \"func FetchPath(j JSON, path []string) (JSON, error) {\\n\\tvar next JSON\\n\\tvar err error\\n\\tfor _, v := range path {\\n\\t\\tnext, err = j.FetchValKeyOrIdx(v)\\n\\t\\tif next == nil {\\n\\t\\t\\treturn nil, nil\\n\\t\\t}\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t\\tj = next\\n\\t}\\n\\treturn j, nil\\n}\",\n \"func (opa *client) EvaluatePolicy(policy string, input []byte) (*EvaluatePolicyResponse, error) {\\n\\tlog := opa.logger.Named(\\\"Evalute Policy\\\")\\n\\n\\trequest, err := json.Marshal(&EvalutePolicyRequest{Input: input})\\n\\tif err != nil {\\n\\t\\tlog.Error(\\\"failed to encode OPA input\\\", zap.Error(err), zap.String(\\\"input\\\", string(input)))\\n\\t\\treturn nil, fmt.Errorf(\\\"failed to encode OPA input: %s\\\", err)\\n\\t}\\n\\n\\thttpResponse, err := opa.httpClient.Post(opa.getDataQueryURL(getOpaPackagePath(policy)), \\\"application/json\\\", bytes.NewReader(request))\\n\\tif err != nil {\\n\\t\\tlog.Error(\\\"http request to OPA failed\\\", zap.Error(err))\\n\\t\\treturn nil, fmt.Errorf(\\\"http request to OPA failed: %s\\\", err)\\n\\t}\\n\\tif httpResponse.StatusCode != http.StatusOK {\\n\\t\\tlog.Error(\\\"http response status from OPA not OK\\\", zap.Any(\\\"status\\\", httpResponse.Status))\\n\\t\\treturn nil, fmt.Errorf(\\\"http response status not OK\\\")\\n\\t}\\n\\n\\tresponse := &EvaluatePolicyResponse{}\\n\\terr = json.NewDecoder(httpResponse.Body).Decode(&response)\\n\\tif err != nil {\\n\\t\\tlog.Error(\\\"failed to decode OPA result\\\", zap.Error(err))\\n\\t\\treturn nil, fmt.Errorf(\\\"failed to decode OPA result: %s\\\", err)\\n\\t}\\n\\n\\treturn response, nil\\n}\",\n \"func evaluateAst(program *ast.RootNode) object.Object {\\n\\tenv := object.NewEnvironment()\\n\\treturn evaluator.Eval(program, env)\\n}\",\n \"func (a *PipelineControllerApiService) EvaluateExpressionForExecutionUsingGET(ctx _context.Context, id string) apiEvaluateExpressionForExecutionUsingGETRequest {\\n\\treturn apiEvaluateExpressionForExecutionUsingGETRequest{\\n\\t\\tapiService: a,\\n\\t\\tctx: ctx,\\n\\t\\tid: id,\\n\\t}\\n}\",\n \"func update(path []string, src string, params map[string]interface{}) (string, error) {\\n\\tobj, err := jsonnetParseFn(\\\"params.libsonnet\\\", src)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", errors.Wrap(err, \\\"parse jsonnet\\\")\\n\\t}\\n\\n\\tparamsObject, err := nmKVFromMapFn(params)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", errors.Wrap(err, \\\"convert params to object\\\")\\n\\t}\\n\\n\\tif err := jsonnetSetFn(obj, path, paramsObject.Node()); err != nil {\\n\\t\\treturn \\\"\\\", errors.Wrap(err, \\\"update params\\\")\\n\\t}\\n\\n\\tvar buf bytes.Buffer\\n\\tif err := jsonnetPrinterFn(&buf, obj); err != nil {\\n\\t\\treturn \\\"\\\", errors.Wrap(err, \\\"rebuild params\\\")\\n\\t}\\n\\n\\treturn buf.String(), nil\\n}\",\n \"func (m *Map) traversePath(path string, updateValue interface{}, createPaths bool) (interface{}, error) {\\n\\tpath = strings.TrimPrefix(path, \\\"/\\\")\\n\\tcomponents := strings.Split(path, \\\"/\\\")\\n\\n\\tLog.Debug.Printf(\\\"Traversing path %v with value %v\\\", path, updateValue)\\n\\n\\tif len(components) == 1 && components[0] == \\\"\\\" && updateValue != nil {\\n\\t\\t// Complete replacement of root map, updateValue must be a generic map\\n\\t\\t*m = Map(updateValue.(map[string]interface{}))\\n\\t\\treturn m, nil\\n\\t}\\n\\n\\tvar lastIndex = len(components) - 1\\n\\n\\tref := *m\\n\\tvar child interface{} = nil\\n\\n\\tfor i, component := range components {\\n\\t\\tvar ok bool\\n\\n\\t\\tif component == \\\"\\\" {\\n\\t\\t\\treturn nil, fmt.Errorf(\\\"Empty component encountered in path %v\\\", path)\\n\\t\\t}\\n\\n\\t\\tisUpdate := updateValue != nil\\n\\n\\t\\tif i == lastIndex && isUpdate {\\n\\t\\t\\tLog.Debug.Printf(\\\"Updating component %v value %+v\\\", component, updateValue)\\n\\n\\t\\t\\tvar jsonUpdateValue = updateValue\\n\\t\\t\\tif updateValue == Nil {\\n\\t\\t\\t\\tjsonUpdateValue = nil\\n\\t\\t\\t} else if updateValue == Remove {\\n\\t\\t\\t\\tdelete(ref, component)\\n\\t\\t\\t\\treturn Remove, nil\\n\\t\\t\\t}\\n\\n\\t\\t\\tref[component] = jsonUpdateValue\\n\\t\\t\\treturn ref[component], nil\\n\\t\\t} else {\\n\\t\\t\\tchild, ok = ref[component]\\n\\t\\t\\t// Error if this child is not found\\n\\t\\t\\tif !ok {\\n\\t\\t\\t\\tif createPaths && isUpdate {\\n\\t\\t\\t\\t\\tLog.Debug.Printf(\\\"Creating path for component %v\\\", component)\\n\\t\\t\\t\\t\\tnewPath := map[string]interface{}{}\\n\\t\\t\\t\\t\\tref[component] = newPath\\n\\t\\t\\t\\t\\tref = newPath\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\treturn nil, fmt.Errorf(\\\"Child component %v of path %v not found\\\", component, path)\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\t\\t\\tif i == lastIndex && !isUpdate {\\n\\t\\t\\t\\t// Return the queried value\\n\\t\\t\\t\\tLog.Debug.Printf(\\\"Returning query value %+v\\\", child)\\n\\t\\t\\t\\treturn child, nil\\n\\t\\t\\t}\\n\\n\\t\\t\\t// Keep going - child must be a map to enable further traversal\\n\\t\\t\\tref, ok = child.(map[string]interface{})\\n\\t\\t\\tif !ok {\\n\\t\\t\\t\\treturn nil, fmt.Errorf(\\\"Child component %v of path %v is not a map\\\", component, path)\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\t// XXX Shouldn't get here\\n\\treturn nil, fmt.Errorf(\\\"Unexpected return from TraversePath %v\\\", path)\\n}\",\n \"func (r *Rule) Eval(json []byte) (int, error) {\\n\\tjq := gojsonq.New().Reader(bytes.NewReader(json)).From(\\\"kind\\\")\\n\\tif jq.Error() != nil {\\n\\t\\treturn 0, jq.Error()\\n\\t}\\n\\n\\tkind := fmt.Sprintf(\\\"%s\\\", jq.Get())\\n\\n\\tvar match bool\\n\\tfor _, k := range r.Kinds {\\n\\t\\tif k == kind {\\n\\t\\t\\tmatch = true\\n\\t\\t\\tbreak\\n\\t\\t}\\n\\t}\\n\\n\\tif match {\\n\\t\\tcount := r.Predicate(json)\\n\\t\\treturn count, nil\\n\\t} else {\\n\\t\\treturn 0, &NotSupportedError{Kind: kind}\\n\\t}\\n}\",\n \"func LoadConfig(path string, c interface{}) (err error) {\\n\\tvar jsonFile *os.File\\n\\tvar byteValue []byte\\n\\n\\tfmt.Println(\\\"Path \\\", path)\\n\\t// Open our jsonFile\\n\\tjsonFile, err = os.Open(path)\\n\\t// if we os.Open returns an error then handle it\\n\\tif err != nil {\\n\\t\\tfmt.Println(\\\"LoadConfig error \\\", err)\\n\\t\\treturn\\n\\t}\\n\\tfmt.Println(\\\"Successfully Opened json\\\")\\n\\t// defer the closing of our jsonFile so that we can parse it later on\\n\\tdefer jsonFile.Close()\\n\\n\\t// read our opened xmlFile as a byte array.\\n\\tbyteValue, err = ioutil.ReadAll(jsonFile)\\n\\tif err != nil {\\n\\t\\tfmt.Println(\\\"ReadAll error \\\", err)\\n\\t\\treturn\\n\\t}\\n\\n\\terr = json.Unmarshal(byteValue, &c)\\n\\tif err != nil {\\n\\t\\tfmt.Println(\\\"Unmarshal error \\\", err)\\n\\t\\treturn\\n\\t}\\n\\treturn\\n}\",\n \"func LoadConfig(path string, c interface{}) (err error) {\\n\\tvar jsonFile *os.File\\n\\tvar byteValue []byte\\n\\n\\tfmt.Println(\\\"Path \\\", path)\\n\\t// Open our jsonFile\\n\\tjsonFile, err = os.Open(path)\\n\\t// if we os.Open returns an error then handle it\\n\\tif err != nil {\\n\\t\\tfmt.Println(\\\"LoadConfig error \\\", err)\\n\\t\\treturn\\n\\t}\\n\\tfmt.Println(\\\"Successfully Opened json\\\")\\n\\t// defer the closing of our jsonFile so that we can parse it later on\\n\\tdefer jsonFile.Close()\\n\\n\\t// read our opened xmlFile as a byte array.\\n\\tbyteValue, err = ioutil.ReadAll(jsonFile)\\n\\tif err != nil {\\n\\t\\tfmt.Println(\\\"ReadAll error \\\", err)\\n\\t\\treturn\\n\\t}\\n\\n\\terr = json.Unmarshal(byteValue, &c)\\n\\tif err != nil {\\n\\t\\tfmt.Println(\\\"Unmarshal error \\\", err)\\n\\t\\treturn\\n\\t}\\n\\treturn\\n}\",\n \"func Load(path string, unsafe...bool) (*Parser, error) {\\n if j, e := gjson.Load(path, unsafe...); e == nil {\\n return &Parser{j}, nil\\n } else {\\n return nil, e\\n }\\n}\",\n \"func getJSONRaw(data []byte, path string, pathRequired bool) ([]byte, error) {\\n\\tobjectKeys := customSplit(path)\\n\\tfor element, k := range objectKeys {\\n\\t\\t// check the object key to see if it also contains an array reference\\n\\t\\tarrayRefs := jsonPathRe.FindAllStringSubmatch(k, -1)\\n\\t\\tif arrayRefs != nil && len(arrayRefs) > 0 {\\n\\t\\t\\tarrayKeyStrs := jsonArrayRe.FindAllString(k, -1)\\n\\t\\t\\textracted := false\\n\\t\\t\\tobjKey := arrayRefs[0][1] // the key\\n\\t\\t\\tresults, newPath, err := getArrayResults(data, objectKeys, objKey, element)\\n\\t\\t\\tif err == jsonparser.KeyPathNotFoundError {\\n\\t\\t\\t\\tif pathRequired {\\n\\t\\t\\t\\t\\treturn nil, NonExistentPath\\n\\t\\t\\t\\t}\\n\\t\\t\\t} else if err != nil {\\n\\t\\t\\t\\treturn nil, err\\n\\t\\t\\t}\\n\\t\\t\\tfor _, arrayKeyStr := range arrayKeyStrs {\\n\\t\\t\\t\\t// trim the square brackets\\n\\t\\t\\t\\tarrayKeyStr = arrayKeyStr[1 : len(arrayKeyStr)-1]\\n\\t\\t\\t\\terr = validateArrayKeyString(arrayKeyStr)\\n\\t\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t\\treturn nil, err\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\t// if there's a wildcard array reference\\n\\t\\t\\t\\tif arrayKeyStr == \\\"*\\\" {\\n\\t\\t\\t\\t\\t// We won't filter anything with a wildcard\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t} else if filterPattern := jsonFilterRe.FindString(arrayKeyStr); filterPattern != \\\"\\\" {\\n\\t\\t\\t\\t\\t// MODIFICATIONS --- FILTER SUPPORT\\n\\t\\t\\t\\t\\t// right now we only support filter expressions of the form ?(@.some.json.path Op \\\"someData\\\")\\n\\t\\t\\t\\t\\t// Op must be a boolean operator: '==', '<' are fine, '+', '%' are not. Spaces ARE required\\n\\n\\t\\t\\t\\t\\t// get the filter jsonpath expression\\n\\t\\t\\t\\t\\tfilterPattern = filterPattern[2 : len(filterPattern)-1]\\n\\t\\t\\t\\t\\tfilterParts := strings.Split(filterPattern, \\\" \\\")\\n\\t\\t\\t\\t\\tvar filterPath string\\n\\t\\t\\t\\t\\tif len(filterParts[0]) > 2 {\\n\\t\\t\\t\\t\\t\\tfilterPath = filterParts[0][2:]\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tvar filterObjs [][]byte\\n\\t\\t\\t\\t\\tvar filteredResults [][]byte\\n\\n\\t\\t\\t\\t\\t// evaluate the jsonpath filter jsonpath for each index\\n\\t\\t\\t\\t\\tif newPath != \\\"\\\" {\\n\\t\\t\\t\\t\\t\\t// we are filtering against a list of objects, lookup the data recursively\\n\\t\\t\\t\\t\\t\\tfor _, v := range results {\\n\\t\\t\\t\\t\\t\\t\\tintermediate, err := getJSONRaw(v, filterPath, true)\\n\\t\\t\\t\\t\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t\\t\\t\\t\\tif err == NonExistentPath {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t// this is fine, we'll just filter these out\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tfilterObjs = append(filterObjs, nil)\\n\\t\\t\\t\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\treturn nil, err\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\t\\t\\tfilterObjs = append(filterObjs, intermediate)\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t} else if filterPath == \\\"\\\" {\\n\\t\\t\\t\\t\\t\\t// we are filtering against a list of primitives - we won't match any non-empty filterPath\\n\\t\\t\\t\\t\\t\\tfor _, v := range results {\\n\\t\\t\\t\\t\\t\\t\\tfilterObjs = append(filterObjs, v)\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t\\t// evaluate the filter\\n\\t\\t\\t\\t\\tfor i, v := range filterObjs {\\n\\t\\t\\t\\t\\t\\tif v != nil {\\n\\t\\t\\t\\t\\t\\t\\tfilterParts[0] = string(v)\\n\\t\\t\\t\\t\\t\\t\\texprString := strings.Join(filterParts, \\\" \\\")\\n\\t\\t\\t\\t\\t\\t\\t// filter the objects based on the results\\n\\t\\t\\t\\t\\t\\t\\texpr, err := govaluate.NewEvaluableExpression(exprString)\\n\\t\\t\\t\\t\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t\\t\\t\\t\\treturn nil, err\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\tresult, err := expr.Evaluate(nil)\\n\\t\\t\\t\\t\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t\\t\\t\\t\\treturn nil, err\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t// We pass through the filter if the filter is a boolean expression\\n\\t\\t\\t\\t\\t\\t\\t// If the filter is not a boolean expression, just pass everything through\\n\\t\\t\\t\\t\\t\\t\\tif accepted, ok := result.(bool); accepted || !ok {\\n\\t\\t\\t\\t\\t\\t\\t\\tfilteredResults = append(filteredResults, results[i])\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t\\t// Set the results for the next pass\\n\\t\\t\\t\\t\\tresults = filteredResults\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tindex, err := strconv.ParseInt(arrayKeyStr, 10, 64)\\n\\t\\t\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t\\t\\treturn nil, err\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tif index < int64(len(results)) {\\n\\t\\t\\t\\t\\t\\tresults = [][]byte{results[index]}\\n\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\tresults = [][]byte{}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\textracted = true\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\toutput, err := lookupAndWriteMulti(results, newPath, pathRequired)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\treturn nil, err\\n\\t\\t\\t}\\n\\t\\t\\t// if we have access a specific index, we want to extract the value from the array\\n\\t\\t\\t// we just do this manually\\n\\t\\t\\tif extracted {\\n\\t\\t\\t\\toutput = output[1 : len(output)-1]\\n\\t\\t\\t}\\n\\t\\t\\treturn output, nil\\n\\t\\t} else {\\n\\t\\t\\t// no array reference, good to go\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\t}\\n\\tresult, dataType, _, err := jsonparser.Get(data, objectKeys...)\\n\\n\\t// jsonparser strips quotes from Strings\\n\\tif dataType == jsonparser.String {\\n\\t\\t// bookend() is destructive to underlying slice, need to copy.\\n\\t\\t// extra capacity saves an allocation and copy during bookend.\\n\\t\\tresult = HandleUnquotedStrings(result, dataType)\\n\\t}\\n\\tif len(result) == 0 {\\n\\t\\tresult = []byte(\\\"null\\\")\\n\\t}\\n\\tif err == jsonparser.KeyPathNotFoundError {\\n\\t\\tif pathRequired {\\n\\t\\t\\treturn nil, NonExistentPath\\n\\t\\t}\\n\\t} else if err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn result, nil\\n}\",\n \"func (r *SourceResolver) Component(ctx context.Context, source *model.Source) (*model.Component, error) {\\n\\tresults, err := r.DataLoaders.SourceLoader(ctx).ComponentBySource(source.ID)\\n\\tif err != nil {\\n\\t\\treturn nil, errors.Wrap(err, \\\"failed to get component from loader\\\")\\n\\t}\\n\\treturn results, nil\\n}\",\n \"func (p *prog) Eval(input any) (v ref.Val, det *EvalDetails, err error) {\\n\\t// Configure error recovery for unexpected panics during evaluation. Note, the use of named\\n\\t// return values makes it possible to modify the error response during the recovery\\n\\t// function.\\n\\tdefer func() {\\n\\t\\tif r := recover(); r != nil {\\n\\t\\t\\tswitch t := r.(type) {\\n\\t\\t\\tcase interpreter.EvalCancelledError:\\n\\t\\t\\t\\terr = t\\n\\t\\t\\tdefault:\\n\\t\\t\\t\\terr = fmt.Errorf(\\\"internal error: %v\\\", r)\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}()\\n\\t// Build a hierarchical activation if there are default vars set.\\n\\tvar vars interpreter.Activation\\n\\tswitch v := input.(type) {\\n\\tcase interpreter.Activation:\\n\\t\\tvars = v\\n\\tcase map[string]any:\\n\\t\\tvars = activationPool.Setup(v)\\n\\t\\tdefer activationPool.Put(vars)\\n\\tdefault:\\n\\t\\treturn nil, nil, fmt.Errorf(\\\"invalid input, wanted Activation or map[string]any, got: (%T)%v\\\", input, input)\\n\\t}\\n\\tif p.defaultVars != nil {\\n\\t\\tvars = interpreter.NewHierarchicalActivation(p.defaultVars, vars)\\n\\t}\\n\\tv = p.interpretable.Eval(vars)\\n\\t// The output of an internal Eval may have a value (`v`) that is a types.Err. This step\\n\\t// translates the CEL value to a Go error response. This interface does not quite match the\\n\\t// RPC signature which allows for multiple errors to be returned, but should be sufficient.\\n\\tif types.IsError(v) {\\n\\t\\terr = v.(*types.Err)\\n\\t}\\n\\treturn\\n}\",\n \"func (t *TypeSystem) Evaluate(typename string, object interface{}, op string, value string) (bool, error) {\\n\\tswitch typename {\\n\\tcase String:\\n\\t\\treturn t.stringts.Evaluate(object, op, value)\\n\\tcase Number:\\n\\t\\treturn t.numberts.Evaluate(object, op, value)\\n\\tcase Boolean:\\n\\t\\treturn t.boolts.Evaluate(object, op, value)\\n\\tcase Strings:\\n\\t\\treturn t.stringsts.Evaluate(object, op, value)\\n\\tcase Date:\\n\\t\\treturn t.datets.Evaluate(object, op, value)\\n\\tdefault:\\n\\t\\treturn false, fmt.Errorf(\\\"type/golang/type.go: unsupport type, %s, %v, %s, %s\\\", typename, object, op, value)\\n\\t}\\n}\",\n \"func Evaluate(expr string, contextVars map[string]logol.Match) bool {\\n\\tlogger.Debugf(\\\"Evaluate expression: %s\\\", expr)\\n\\n\\tre := regexp.MustCompile(\\\"[$@#]+\\\\\\\\w+\\\")\\n\\tres := re.FindAllString(expr, -1)\\n\\t// msg, _ := json.Marshal(contextVars)\\n\\t// logger.Errorf(\\\"CONTEXT: %s\\\", msg)\\n\\tparameters := make(map[string]interface{}, 8)\\n\\tvarIndex := 0\\n\\tfor _, val := range res {\\n\\t\\tt := strconv.Itoa(varIndex)\\n\\t\\tvarName := \\\"VAR\\\" + t\\n\\t\\tr := strings.NewReplacer(val, varName)\\n\\t\\texpr = r.Replace(expr)\\n\\t\\tvarIndex++\\n\\t\\tcValue, cerr := getValueFromExpression(val, contextVars)\\n\\t\\tif cerr {\\n\\t\\t\\tlogger.Debugf(\\\"Failed to get value from expression %s\\\", val)\\n\\t\\t\\treturn false\\n\\t\\t}\\n\\t\\tparameters[varName] = cValue\\n\\t}\\n\\tlogger.Debugf(\\\"New expr: %s with params %v\\\", expr, parameters)\\n\\n\\texpression, err := govaluate.NewEvaluableExpression(expr)\\n\\tif err != nil {\\n\\t\\tlogger.Errorf(\\\"Failed to evaluate expression %s\\\", expr)\\n\\t\\treturn false\\n\\t}\\n\\tresult, _ := expression.Evaluate(parameters)\\n\\tif result == true {\\n\\t\\treturn true\\n\\t}\\n\\treturn false\\n}\",\n \"func jsonpt(data, key string) string {\\n\\tdatamap := make(map[string]interface{})\\n\\terr := json.Unmarshal([]byte(data), &datamap)\\n\\tif err != nil {\\n\\t\\treturn fmt.Sprintf(\\\"%s cannot be parsed as json\\\", data)\\n\\t}\\n\\tres, err := jsonpath.JsonPathLookup(datamap, key)\\n\\tif err != nil {\\n\\t\\treturn fmt.Sprintf(\\\"%q not found in data: %v\\\", key, err)\\n\\t}\\n\\treturn fmt.Sprintf(\\\"%s\\\", res)\\n}\",\n \"func RunJSONSerializationTestForUrlFileExtensionMatchConditionParameters(subject UrlFileExtensionMatchConditionParameters) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual UrlFileExtensionMatchConditionParameters\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForResourceReference(subject ResourceReference) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ResourceReference\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForResourceReference(subject ResourceReference) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ResourceReference\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func (j *Js) Getpath(args ...string) *Js {\\n\\td := j\\n\\tfor i := range args {\\n\\t\\tm := d.Getdata()\\n\\n\\t\\tif val, ok := m[args[i]]; ok {\\n\\t\\t\\td.data = val\\n\\t\\t} else {\\n\\t\\t\\td.data = nil\\n\\t\\t\\treturn d\\n\\t\\t}\\n\\t}\\n\\treturn d\\n}\",\n \"func renderValueTemplate(valueTemplate string, variables map[string]apiextensionsv1.JSON) (*apiextensionsv1.JSON, error) {\\n\\t// Parse the template.\\n\\ttpl, err := template.New(\\\"tpl\\\").Funcs(sprig.HermeticTxtFuncMap()).Parse(valueTemplate)\\n\\tif err != nil {\\n\\t\\treturn nil, errors.Wrapf(err, \\\"failed to parse template: %q\\\", valueTemplate)\\n\\t}\\n\\n\\t// Convert the flat variables map in a nested map, so that variables can be\\n\\t// consumed in templates like this: `{{ .builtin.cluster.name }}`\\n\\t// NOTE: Variable values are also converted to their Go types as\\n\\t// they cannot be directly consumed as byte arrays.\\n\\tdata, err := calculateTemplateData(variables)\\n\\tif err != nil {\\n\\t\\treturn nil, errors.Wrap(err, \\\"failed to calculate template data\\\")\\n\\t}\\n\\n\\t// Render the template.\\n\\tvar buf bytes.Buffer\\n\\tif err := tpl.Execute(&buf, data); err != nil {\\n\\t\\treturn nil, errors.Wrapf(err, \\\"failed to render template: %q\\\", valueTemplate)\\n\\t}\\n\\n\\t// Unmarshal the rendered template.\\n\\t// NOTE: The YAML library is used for unmarshalling, to be able to handle YAML and JSON.\\n\\tvalue := apiextensionsv1.JSON{}\\n\\tif err := yaml.Unmarshal(buf.Bytes(), &value); err != nil {\\n\\t\\treturn nil, errors.Wrapf(err, \\\"failed to unmarshal rendered template: %q\\\", buf.String())\\n\\t}\\n\\n\\treturn &value, nil\\n}\",\n \"func componentConfig(component *models.Component) (config map[string]interface{}, err error) {\\n\\n\\t// fetch the env\\n\\tenv, err := models.FindEnvByID(component.EnvID)\\n\\tif err != nil {\\n\\t\\terr = fmt.Errorf(\\\"failed to load env model: %s\\\", err.Error())\\n\\t\\treturn\\n\\t}\\n\\n\\tbox := boxfile.New([]byte(env.BuiltBoxfile))\\n\\tconfig = box.Node(component.Name).Node(\\\"config\\\").Parsed\\n\\n\\tswitch component.Name {\\n\\tcase \\\"portal\\\", \\\"logvac\\\", \\\"hoarder\\\", \\\"mist\\\":\\n\\t\\tconfig[\\\"token\\\"] = \\\"123\\\"\\n\\t}\\n\\treturn\\n}\",\n \"func (r *Response) JSONPath(expression string, assert func(interface{})) *Response {\\n\\tr.jsonPathExpression = expression\\n\\tr.jsonPathAssert = assert\\n\\treturn r.apiTest.response\\n}\",\n \"func Componentgen(nr, nl *Node) bool\",\n \"func LoadJSON(r io.Reader, filePath, urlPath string) (*Graph, error) {\\n\\tdec := json.NewDecoder(r)\\n\\tg := &Graph{\\n\\t\\tFilePath: filePath,\\n\\t\\tURLPath: urlPath,\\n\\t}\\n\\tif err := dec.Decode(g); err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\t// Each node and channel should cache it's own name.\\n\\tfor k, c := range g.Channels {\\n\\t\\tc.Name = k\\n\\t}\\n\\tfor k, n := range g.Nodes {\\n\\t\\tn.Name = k\\n\\t}\\n\\t// Finally, set up channel pin caches.\\n\\tg.RefreshChannelsPins()\\n\\treturn g, nil\\n}\",\n \"func Evaluate(tpl string, data interface{}) (string, error) {\\n\\tt, err := Parse(tpl)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\treturn Execute(t, data)\\n}\",\n \"func Get(json []byte, path ...string) ([]byte, error) {\\n\\tif len(path) == 0 {\\n\\t\\treturn json, nil\\n\\t}\\n\\t_, start, end, err := core(json, false, path...)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn json[start:end], err\\n}\",\n \"func RunJSONSerializationTestForComponent_STATUS_ARM(subject Component_STATUS_ARM) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual Component_STATUS_ARM\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForKubeletConfig(subject KubeletConfig) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual KubeletConfig\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForUrlFileNameMatchConditionParameters(subject UrlFileNameMatchConditionParameters) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual UrlFileNameMatchConditionParameters\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func ExampleJsonpath() {\\n\\tconst jsonString = `{\\n\\t \\\"firstName\\\": \\\"John\\\",\\n\\t \\\"lastName\\\" : \\\"doe\\\",\\n\\t \\\"age\\\" : 26,\\n\\t \\\"address\\\" : {\\n\\t\\t\\\"streetAddress\\\": \\\"naist street\\\",\\n\\t\\t\\\"city\\\" : \\\"Nara\\\",\\n\\t\\t\\\"postalCode\\\" : \\\"630-0192\\\"\\n\\t },\\n\\t \\\"phoneNumbers\\\": [\\n\\t\\t{\\n\\t\\t \\\"type\\\" : \\\"iPhone\\\",\\n\\t\\t \\\"number\\\": \\\"0123-4567-8888\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t \\\"type\\\" : \\\"home\\\",\\n\\t\\t \\\"number\\\": \\\"0123-4567-8910\\\"\\n\\t\\t},\\n\\t\\t{\\n\\t\\t \\\"type\\\": \\\"mobile\\\",\\n\\t\\t \\\"number\\\": \\\"0913-8532-8492\\\"\\n\\t\\t}\\n\\t ]\\n\\t}`\\n\\n\\tresult, err := Jsonpath([]byte(jsonString), \\\"$.phoneNumbers[*].type\\\")\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n\\n\\tfor _, item := range result {\\n\\t\\tfmt.Println(item)\\n\\t}\\n\\t// Output:\\n\\t// iPhone\\n\\t// home\\n\\t// mobile\\n}\",\n \"func (self *Map) JSONPath(query string, fallback ...interface{}) interface{} {\\n\\tif d, err := JSONPath(self.MapNative(), query); err == nil && d != nil {\\n\\t\\treturn d\\n\\t}\\n\\n\\treturn sliceutil.First(fallback)\\n}\",\n \"func parseComponents(t *template.Template, dir string) (*template.Template, error) {\\n\\tcomponents, err := readComponents(dir)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tfor _, c := range components {\\n\\t\\tp := strings.TrimPrefix(c.Path, dir)\\n\\t\\tp = strings.TrimPrefix(p, \\\"/\\\")\\n\\t\\tfmt.Println(\\\"Parsing component\\\", p)\\n\\t\\tt, err = t.New(p).Parse(c.Content)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t}\\n\\treturn t, nil\\n}\",\n \"func TestUpdateJsonFileWithString(t *testing.T) {\\n\\tfile := \\\"/tmp/testpathstring.json\\\"\\n\\tpaths := []string{\\\"testpathstring\\\"}\\n\\tui := &packer.BasicUi{\\n\\t\\tReader: new(bytes.Buffer),\\n\\t\\tWriter: new(bytes.Buffer),\\n\\t\\tErrorWriter: new(bytes.Buffer),\\n\\t}\\n\\tvalue := \\\"simplevalue_string\\\"\\n\\t_ = UpdateJsonFile(file, paths, value, ui, true)\\n}\",\n \"func RunJSONSerializationTestForRequestUriMatchConditionParameters(subject RequestUriMatchConditionParameters) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual RequestUriMatchConditionParameters\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func parse(input string) (output *js.Object, err error) {\\n\\tvar ast interface{}\\n\\terr = hcl.Unmarshal([]byte(input), &ast)\\n\\tif err != nil {\\n\\t\\treturn\\n\\t}\\n\\n\\tdata, err := json.MarshalIndent(ast, \\\"\\\", \\\" \\\")\\n\\tif err != nil {\\n\\t\\treturn\\n\\t}\\n\\toutput = js.Global.Get(\\\"JSON\\\").Call(\\\"parse\\\", string(data))\\n\\treturn\\n}\",\n \"func (d *Data) getValue(path string, source interface{}) interface{} {\\n\\ti := strings.Index(path, d.as+\\\".\\\")\\n\\tif i == 0 {\\n\\t\\tpath = path[len(d.as)+1:]\\n\\t}\\n\\ttr, br := splitpath(path)\\n\\tif tr == \\\"\\\" {\\n\\t\\treturn nil\\n\\t}\\n\\n\\tv, ok := source.(reflect.Value)\\n\\tif !ok {\\n\\t\\tv = reflect.ValueOf(source)\\n\\t}\\n\\tif v.Kind() == reflect.Ptr {\\n\\t\\tv = v.Elem()\\n\\t}\\n\\n\\tswitch v.Kind() {\\n\\tcase reflect.Map:\\n\\t\\tv = v.MapIndex(reflect.ValueOf(tr))\\n\\tcase reflect.Struct:\\n\\t\\tv = v.FieldByName(tr)\\n\\n\\tdefault:\\n\\t\\treturn nil\\n\\t}\\n\\n\\tif !v.IsValid() {\\n\\t\\treturn nil\\n\\t}\\n\\n\\tvar inf interface{} = v\\n\\n\\tif v.CanInterface() {\\n\\t\\tinf = v.Interface()\\n\\t}\\n\\n\\tif br != \\\"\\\" {\\n\\t\\treturn d.getValue(br, inf)\\n\\t}\\n\\n\\treturn inf\\n}\",\n \"func (rt *importRuntime) Eval(vs parser.Scope, is map[string]interface{}, tid uint64) (interface{}, error) {\\n\\t_, err := rt.baseRuntime.Eval(vs, is, tid)\\n\\n\\tif rt.erp.ImportLocator == nil {\\n\\t\\terr = rt.erp.NewRuntimeError(util.ErrRuntimeError, \\\"No import locator was specified\\\", rt.node)\\n\\t}\\n\\n\\tif err == nil {\\n\\n\\t\\tvar importPath interface{}\\n\\t\\tif importPath, err = rt.node.Children[0].Runtime.Eval(vs, is, tid); err == nil {\\n\\n\\t\\t\\tvar codeText string\\n\\t\\t\\tif codeText, err = rt.erp.ImportLocator.Resolve(fmt.Sprint(importPath)); err == nil {\\n\\t\\t\\t\\tvar ast *parser.ASTNode\\n\\n\\t\\t\\t\\tif ast, err = parser.ParseWithRuntime(fmt.Sprint(importPath), codeText, rt.erp); err == nil {\\n\\t\\t\\t\\t\\tif err = ast.Runtime.Validate(); err == nil {\\n\\n\\t\\t\\t\\t\\t\\tivs := scope.NewScope(scope.GlobalScope)\\n\\t\\t\\t\\t\\t\\tif _, err = ast.Runtime.Eval(ivs, make(map[string]interface{}), tid); err == nil {\\n\\t\\t\\t\\t\\t\\t\\tirt := rt.node.Children[1].Runtime.(*identifierRuntime)\\n\\t\\t\\t\\t\\t\\t\\tirt.Set(vs, is, tid, scope.ToObject(ivs))\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\treturn nil, err\\n}\",\n \"func (g *GraphiteProvider) RunQuery(query string) (float64, error) {\\n\\tquery = g.trimQuery(query)\\n\\tu, err := url.Parse(fmt.Sprintf(\\\"./render?%s\\\", query))\\n\\tif err != nil {\\n\\t\\treturn 0, fmt.Errorf(\\\"url.Parse failed: %w\\\", err)\\n\\t}\\n\\n\\tq := u.Query()\\n\\tq.Set(\\\"format\\\", \\\"json\\\")\\n\\tu.RawQuery = q.Encode()\\n\\n\\tu.Path = path.Join(g.url.Path, u.Path)\\n\\tu = g.url.ResolveReference(u)\\n\\n\\treq, err := http.NewRequest(\\\"GET\\\", u.String(), nil)\\n\\tif err != nil {\\n\\t\\treturn 0, fmt.Errorf(\\\"http.NewRequest failed: %w\\\", err)\\n\\t}\\n\\n\\tif g.username != \\\"\\\" && g.password != \\\"\\\" {\\n\\t\\treq.SetBasicAuth(g.username, g.password)\\n\\t}\\n\\n\\tctx, cancel := context.WithTimeout(req.Context(), g.timeout)\\n\\tdefer cancel()\\n\\n\\tr, err := g.client.Do(req.WithContext(ctx))\\n\\tif err != nil {\\n\\t\\treturn 0, fmt.Errorf(\\\"request failed: %w\\\", err)\\n\\t}\\n\\tdefer r.Body.Close()\\n\\n\\tb, err := io.ReadAll(r.Body)\\n\\tif err != nil {\\n\\t\\treturn 0, fmt.Errorf(\\\"error reading body: %w\\\", err)\\n\\t}\\n\\n\\tif 400 <= r.StatusCode {\\n\\t\\treturn 0, fmt.Errorf(\\\"error response: %s\\\", string(b))\\n\\t}\\n\\n\\tvar result graphiteResponse\\n\\terr = json.Unmarshal(b, &result)\\n\\tif err != nil {\\n\\t\\treturn 0, fmt.Errorf(\\\"error unmarshaling result: %w, '%s'\\\", err, string(b))\\n\\t}\\n\\n\\tvar value *float64\\n\\tfor _, tr := range result {\\n\\t\\tfor _, dp := range tr.DataPoints {\\n\\t\\t\\tif dp.Value != nil {\\n\\t\\t\\t\\tvalue = dp.Value\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\tif value == nil {\\n\\t\\treturn 0, ErrNoValuesFound\\n\\t}\\n\\n\\treturn *value, nil\\n}\",\n \"func RunJSONSerializationTestForManagedClusters_AgentPool_Spec(subject ManagedClusters_AgentPool_Spec) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusters_AgentPool_Spec\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func renderCUETemplate(elem types.AddonElementFile, parameters string, args map[string]string) (*common2.ApplicationComponent, error) {\\n\\tbt, err := json.Marshal(args)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tvar paramFile = cuemodel.ParameterFieldName + \\\": {}\\\"\\n\\tif string(bt) != \\\"null\\\" {\\n\\t\\tparamFile = fmt.Sprintf(\\\"%s: %s\\\", cuemodel.ParameterFieldName, string(bt))\\n\\t}\\n\\tparam := fmt.Sprintf(\\\"%s\\\\n%s\\\", paramFile, parameters)\\n\\tv, err := value.NewValue(param, nil, \\\"\\\")\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tout, err := v.LookupByScript(fmt.Sprintf(\\\"{%s}\\\", elem.Data))\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tcompContent, err := out.LookupValue(\\\"output\\\")\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tb, err := cueyaml.Encode(compContent.CueValue())\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tcomp := common2.ApplicationComponent{\\n\\t\\tName: strings.Join(append(elem.Path, elem.Name), \\\"-\\\"),\\n\\t}\\n\\terr = yaml.Unmarshal(b, &comp)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\treturn &comp, err\\n}\",\n \"func (gm *GraphicsManager) JsonCreate(id component.GOiD, compData []byte) error {\\n\\tobj := graphics.GraphicsComponent{}\\n\\terr := json.Unmarshal(compData, &obj)\\n\\tif err != nil {\\n\\t\\treturn fmt.Errorf(\\\"failed to unmarshal graphics component, error: %s\\\", err.Error())\\n\\t}\\n\\n\\tgm.CreateComponent(id, obj)\\n\\n\\treturn nil\\n}\",\n \"func Jsonnet(service core.FileService, enabled bool) core.ConfigService {\\n\\treturn &jsonnetPlugin{\\n\\t\\tenabled: enabled,\\n\\t\\trepos: &repo{files: service},\\n\\t}\\n}\",\n \"func ExprCmpDynamic(lzVars *base.Vars, labels base.Labels,\\n\\tparams []interface{}, path string, cmps []base.Val,\\n\\tcmpEQ base.Val, cmpEQOnly bool) (lzExprFunc base.ExprFunc) {\\n\\tcmpLT, cmpGT := cmps[0], cmps[1]\\n\\n\\tvar lzCmpLT base.Val = cmpLT // <== varLift: lzCmpLT by path\\n\\tvar lzCmpEQ base.Val = cmpEQ // <== varLift: lzCmpEQ by path\\n\\tvar lzCmpGT base.Val = cmpGT // <== varLift: lzCmpGT by path\\n\\n\\tbiExprFunc := func(lzA, lzB base.ExprFunc, lzVals base.Vals, lzYieldErr base.YieldErr) (lzVal base.Val) { // !lz\\n\\t\\t_, _, _ = lzCmpLT, lzCmpEQ, lzCmpGT\\n\\n\\t\\tif LzScope {\\n\\t\\t\\tlzVal = lzA(lzVals, lzYieldErr) // <== emitCaptured: path \\\"A\\\"\\n\\n\\t\\t\\tlzValA, lzTypeA := base.Parse(lzVal)\\n\\t\\t\\tif base.ParseTypeHasValue(lzTypeA) {\\n\\t\\t\\t\\tlzVal = lzB(lzVals, lzYieldErr) // <== emitCaptured: path \\\"B\\\"\\n\\n\\t\\t\\t\\tlzValB, lzTypeB := base.Parse(lzVal)\\n\\t\\t\\t\\tif base.ParseTypeHasValue(lzTypeB) {\\n\\t\\t\\t\\t\\tlzCmp := lzVars.Ctx.ValComparer.CompareWithType(\\n\\t\\t\\t\\t\\t\\tlzValA, lzValB, lzTypeA, lzTypeB, 0)\\n\\t\\t\\t\\t\\tif lzCmp == 0 {\\n\\t\\t\\t\\t\\t\\tlzVal = lzCmpEQ\\n\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\tlzVal = lzCmpGT\\n\\t\\t\\t\\t\\t\\tif !cmpEQOnly { // !lz\\n\\t\\t\\t\\t\\t\\t\\tif lzCmp < 0 {\\n\\t\\t\\t\\t\\t\\t\\t\\tlzVal = lzCmpLT\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t} // !lz\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\treturn lzVal\\n\\t} // !lz\\n\\n\\tlzExprFunc =\\n\\t\\tMakeBiExprFunc(lzVars, labels, params, path, biExprFunc) // !lz\\n\\n\\treturn lzExprFunc\\n}\",\n \"func marshalComponentRequestBodyToStorageComponent(v *ComponentRequestBody) *storage.Component {\\n\\tif v == nil {\\n\\t\\treturn nil\\n\\t}\\n\\tres := &storage.Component{\\n\\t\\tVarietal: v.Varietal,\\n\\t\\tPercentage: v.Percentage,\\n\\t}\\n\\n\\treturn res\\n}\",\n \"func RunJSONSerializationTestForServers_VirtualNetworkRule_Spec(subject Servers_VirtualNetworkRule_Spec) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual Servers_VirtualNetworkRule_Spec\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func (t *TestRuntime) GetDataWithInput(path string, input interface{}) ([]byte, error) {\\n\\tinputPayload := util.MustMarshalJSON(map[string]interface{}{\\n\\t\\t\\\"input\\\": input,\\n\\t})\\n\\n\\tpath = strings.TrimPrefix(path, \\\"/\\\")\\n\\tif !strings.HasPrefix(path, \\\"data\\\") {\\n\\t\\tpath = \\\"data/\\\" + path\\n\\t}\\n\\n\\tresp, err := t.GetDataWithRawInput(t.URL()+\\\"/v1/\\\"+path, bytes.NewReader(inputPayload))\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tbody, err := io.ReadAll(resp)\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"unexpected error reading response body: %s\\\", err)\\n\\t}\\n\\tresp.Close()\\n\\treturn body, nil\\n}\",\n \"func renderRawComponent(elem types.AddonElementFile) (*common2.ApplicationComponent, error) {\\n\\tbaseRawComponent := common2.ApplicationComponent{\\n\\t\\tType: \\\"raw\\\",\\n\\t\\tName: strings.Join(append(elem.Path, elem.Name), \\\"-\\\"),\\n\\t}\\n\\tobj, err := renderObject(elem)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tbaseRawComponent.Properties = util.Object2RawExtension(obj)\\n\\treturn &baseRawComponent, nil\\n}\",\n \"func (*ConditionObjrefs) GetPath() string { return \\\"/api/objects/condition/objref/\\\" }\",\n \"func Read(vm *jsonnet.VM, path string) ([]runtime.Object, error) {\\n\\text := filepath.Ext(path)\\n\\tif ext == \\\".json\\\" {\\n\\t\\tf, err := os.Open(path)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t\\tdefer f.Close()\\n\\t\\treturn jsonReader(f)\\n\\t} else if ext == \\\".yaml\\\" {\\n\\t\\tf, err := os.Open(path)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t\\tdefer f.Close()\\n\\t\\treturn yamlReader(f)\\n\\t} else if ext == \\\".jsonnet\\\" {\\n\\t\\treturn jsonnetReader(vm, path)\\n\\t}\\n\\n\\treturn nil, fmt.Errorf(\\\"Unknown file extension: %s\\\", path)\\n}\",\n \"func (r *Repository) ComponentsPath() string {\\n\\treturn dummyComponentPath\\n}\",\n \"func JsonnetVM(cmd *cobra.Command) (*jsonnet.VM, error) {\\n\\tvm := jsonnet.Make()\\n\\tflags := cmd.Flags()\\n\\n\\tjpath := os.Getenv(\\\"KUBECFG_JPATH\\\")\\n\\tfor _, p := range filepath.SplitList(jpath) {\\n\\t\\tglog.V(2).Infoln(\\\"Adding jsonnet search path\\\", p)\\n\\t\\tvm.JpathAdd(p)\\n\\t}\\n\\n\\tjpath, err := flags.GetString(\\\"jpath\\\")\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tfor _, p := range filepath.SplitList(jpath) {\\n\\t\\tglog.V(2).Infoln(\\\"Adding jsonnet search path\\\", p)\\n\\t\\tvm.JpathAdd(p)\\n\\t}\\n\\n\\treturn vm, nil\\n}\",\n \"func Process(w http.ResponseWriter, r *http.Request, configPath string) {\\n\\tvar cr []aggregator.ComponentResponse\\n\\tvar components componentsList\\n\\n\\tconfig := config.Parse(configPath)\\n\\tyaml.Unmarshal(config, &components)\\n\\n\\tch = make(chan aggregator.ComponentResponse, len(components.Components))\\n\\n\\tfor i, v := range components.Components {\\n\\t\\twg.Add(1)\\n\\t\\tgo getComponent(i, v)\\n\\t}\\n\\twg.Wait()\\n\\tclose(ch)\\n\\n\\tfor component := range ch {\\n\\t\\tcr = append(cr, component)\\n\\t}\\n\\n\\tresponse, err := aggregator.Process(cr)\\n\\tif err != nil {\\n\\t\\tfmt.Printf(\\\"There was an error aggregating a response: %s\\\", err.Error())\\n\\t\\treturn\\n\\t}\\n\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"application/json\\\")\\n\\tw.Write(response)\\n}\",\n \"func RunJSONSerializationTestForUrlPathMatchConditionParameters_STATUS(subject UrlPathMatchConditionParameters_STATUS) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual UrlPathMatchConditionParameters_STATUS\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\"\n]"},"negative_scores":{"kind":"list like","value":["0.6119853","0.47705746","0.47354072","0.46243235","0.45931298","0.4567701","0.45610455","0.45374703","0.45025703","0.43760028","0.4339587","0.43366817","0.42999598","0.4297617","0.4273561","0.4254796","0.42360145","0.42228198","0.42005682","0.41736546","0.41517466","0.40808854","0.4077454","0.4072576","0.40299582","0.40055433","0.40055433","0.40055433","0.40007722","0.39933807","0.3984514","0.39804155","0.39728805","0.39343232","0.3925781","0.3920715","0.3918482","0.39163017","0.3913441","0.39131635","0.39109868","0.39079583","0.39073348","0.39042586","0.38975018","0.38962954","0.38914463","0.38901392","0.38880306","0.38805607","0.38695878","0.38599935","0.38508764","0.3847522","0.3847522","0.38472497","0.38434973","0.3842332","0.38415912","0.38380307","0.38264036","0.38229704","0.38219035","0.38201475","0.38201475","0.38167048","0.38130802","0.38108155","0.38006306","0.38000786","0.37997362","0.37987956","0.37939638","0.37936184","0.3788396","0.37867364","0.37836084","0.377424","0.37652978","0.3762576","0.37606928","0.3759514","0.37502944","0.37484947","0.3747945","0.37377465","0.3735945","0.37341788","0.3728369","0.37274444","0.37210694","0.3719959","0.37158304","0.37111482","0.37110743","0.37047973","0.37017986","0.37017548","0.37005028","0.36908263"],"string":"[\n \"0.6119853\",\n \"0.47705746\",\n \"0.47354072\",\n \"0.46243235\",\n \"0.45931298\",\n \"0.4567701\",\n \"0.45610455\",\n \"0.45374703\",\n \"0.45025703\",\n \"0.43760028\",\n \"0.4339587\",\n \"0.43366817\",\n \"0.42999598\",\n \"0.4297617\",\n \"0.4273561\",\n \"0.4254796\",\n \"0.42360145\",\n \"0.42228198\",\n \"0.42005682\",\n \"0.41736546\",\n \"0.41517466\",\n \"0.40808854\",\n \"0.4077454\",\n \"0.4072576\",\n \"0.40299582\",\n \"0.40055433\",\n \"0.40055433\",\n \"0.40055433\",\n \"0.40007722\",\n \"0.39933807\",\n \"0.3984514\",\n \"0.39804155\",\n \"0.39728805\",\n \"0.39343232\",\n \"0.3925781\",\n \"0.3920715\",\n \"0.3918482\",\n \"0.39163017\",\n \"0.3913441\",\n \"0.39131635\",\n \"0.39109868\",\n \"0.39079583\",\n \"0.39073348\",\n \"0.39042586\",\n \"0.38975018\",\n \"0.38962954\",\n \"0.38914463\",\n \"0.38901392\",\n \"0.38880306\",\n \"0.38805607\",\n \"0.38695878\",\n \"0.38599935\",\n \"0.38508764\",\n \"0.3847522\",\n \"0.3847522\",\n \"0.38472497\",\n \"0.38434973\",\n \"0.3842332\",\n \"0.38415912\",\n \"0.38380307\",\n \"0.38264036\",\n \"0.38229704\",\n \"0.38219035\",\n \"0.38201475\",\n \"0.38201475\",\n \"0.38167048\",\n \"0.38130802\",\n \"0.38108155\",\n \"0.38006306\",\n \"0.38000786\",\n \"0.37997362\",\n \"0.37987956\",\n \"0.37939638\",\n \"0.37936184\",\n \"0.3788396\",\n \"0.37867364\",\n \"0.37836084\",\n \"0.377424\",\n \"0.37652978\",\n \"0.3762576\",\n \"0.37606928\",\n \"0.3759514\",\n \"0.37502944\",\n \"0.37484947\",\n \"0.3747945\",\n \"0.37377465\",\n \"0.3735945\",\n \"0.37341788\",\n \"0.3728369\",\n \"0.37274444\",\n \"0.37210694\",\n \"0.3719959\",\n \"0.37158304\",\n \"0.37111482\",\n \"0.37110743\",\n \"0.37047973\",\n \"0.37017986\",\n \"0.37017548\",\n \"0.37005028\",\n \"0.36908263\"\n]"},"document_score":{"kind":"string","value":"0.61542064"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":105056,"cells":{"query":{"kind":"string","value":"EvaluateComponentSnippet evaluates a component with jsonnet using a snippet."},"document":{"kind":"string","value":"func EvaluateComponentSnippet(a app.App, snippet, paramsStr, envName string, useMemoryImporter bool) (string, error) {\n\tlibPath, err := a.LibPath(envName)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvm := jsonnet.NewVM()\n\tif useMemoryImporter {\n\t\tvm.Fs = a.Fs()\n\t\tvm.UseMemoryImporter = true\n\t}\n\n\tvm.JPaths = []string{\n\t\tlibPath,\n\t\tfilepath.Join(a.Root(), \"vendor\"),\n\t}\n\tvm.ExtCode(\"__ksonnet/params\", paramsStr)\n\n\tenvDetails, err := a.Environment(envName)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tdest := map[string]string{\n\t\t\"server\": envDetails.Destination.Server,\n\t\t\"namespace\": envDetails.Destination.Namespace,\n\t}\n\n\tmarshalledDestination, err := json.Marshal(&dest)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tvm.ExtCode(\"__ksonnet/environments\", string(marshalledDestination))\n\n\treturn vm.EvaluateSnippet(\"snippet\", snippet)\n}"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["func EvaluateComponent(a app.App, sourcePath, paramsStr, envName string, useMemoryImporter bool) (string, error) {\n\tsnippet, err := afero.ReadFile(a.Fs(), sourcePath)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn EvaluateComponentSnippet(a, string(snippet), paramsStr, envName, useMemoryImporter)\n}","func (vm *VM) EvaluateSnippet(filename string, snippet string) (json string, formattedErr error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tformattedErr = errors.New(vm.ef.format(fmt.Errorf(\"(CRASH) %v\\n%s\", r, debug.Stack())))\n\t\t}\n\t}()\n\tjson, err := vm.evaluateSnippet(filename, snippet)\n\tif err != nil {\n\t\treturn \"\", errors.New(vm.ef.format(err))\n\t}\n\treturn json, nil\n}","func (cx *Context) Eval(source string, result interface{}) (err error) {\n\tcx.do(func(ptr *C.JSAPIContext) {\n\t\t// alloc C-string\n\t\tcsource := C.CString(source)\n\t\tdefer C.free(unsafe.Pointer(csource))\n\t\tvar jsonData *C.char\n\t\tvar jsonLen C.int\n\t\tfilename := \"eval\"\n\t\tcfilename := C.CString(filename)\n\t\tdefer C.free(unsafe.Pointer(cfilename))\n\t\t// eval\n\t\tif C.JSAPI_EvalJSON(ptr, csource, cfilename, &jsonData, &jsonLen) != C.JSAPI_OK {\n\t\t\terr = cx.getError(filename)\n\t\t\treturn\n\t\t}\n\t\tdefer C.free(unsafe.Pointer(jsonData))\n\t\t// convert to go\n\t\tb := []byte(C.GoStringN(jsonData, jsonLen))\n\t\tif raw, ok := result.(*Raw); ok {\n\t\t\t*raw = Raw(string(b))\n\t\t} else {\n\t\t\terr = json.Unmarshal(b, result)\n\t\t}\n\t})\n\treturn err\n}","func jsonCodeBlock(value interface{}) string {\n\tblock, _ := json.MarshalIndent(value, \"\", \" \")\n\treturn fmt.Sprintf(\"```javascript\\n%s\\n```\", block)\n}","func renderRawComponent(elem types.AddonElementFile) (*common2.ApplicationComponent, error) {\n\tbaseRawComponent := common2.ApplicationComponent{\n\t\tType: \"raw\",\n\t\tName: strings.Join(append(elem.Path, elem.Name), \"-\"),\n\t}\n\tobj, err := renderObject(elem)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbaseRawComponent.Properties = util.Object2RawExtension(obj)\n\treturn &baseRawComponent, nil\n}","func RunJSONSerializationTestForManagedClusters_AgentPool_Spec(subject ManagedClusters_AgentPool_Spec) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusters_AgentPool_Spec\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func Snippet(value string) *SimpleElement { return newSEString(\"snippet\", value) }","func RunJSONSerializationTestForLoadBalancers_InboundNatRule_Spec(subject LoadBalancers_InboundNatRule_Spec) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual LoadBalancers_InboundNatRule_Spec\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForAgentPoolNetworkProfile(subject AgentPoolNetworkProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual AgentPoolNetworkProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func EvaluateEnv(a app.App, sourcePath, paramsStr, envName string) (string, error) {\n\tlibPath, err := a.LibPath(envName)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvm := jsonnet.NewVM()\n\n\tvm.JPaths = []string{\n\t\tlibPath,\n\t\tfilepath.Join(a.Root(), \"vendor\"),\n\t}\n\tvm.ExtCode(\"__ksonnet/params\", paramsStr)\n\n\tsnippet, err := afero.ReadFile(a.Fs(), sourcePath)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn vm.EvaluateSnippet(sourcePath, string(snippet))\n}","func Componentgen(nr, nl *Node) bool","func (ecr *EnvComponentRemover) Remove(componentName, snippet string) (string, error) {\n\tif componentName == \"\" {\n\t\treturn \"\", errors.New(\"component name was blank\")\n\t}\n\n\tlogger := logrus.WithField(\"component-name\", componentName)\n\tlogger.Info(\"removing environment component\")\n\n\tn, err := jsonnet.ParseNode(\"params.libsonnet\", snippet)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tobj, err := componentParams(n, componentName)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif err = ecr.deleteEntry(obj, componentName); err != nil {\n\t\treturn \"\", errors.Wrap(err, \"delete entry\")\n\t}\n\n\tvar buf bytes.Buffer\n\tif err = jsonnetPrinterFn(&buf, n); err != nil {\n\t\treturn \"\", errors.Wrap(err, \"unable to update snippet\")\n\t}\n\n\treturn buf.String(), nil\n}","func RunJSONSerializationTestForExtendedLocation(subject ExtendedLocation) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ExtendedLocation\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForExtendedLocation(subject ExtendedLocation) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ExtendedLocation\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForExtendedLocation(subject ExtendedLocation) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ExtendedLocation\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForIpsecPolicy(subject IpsecPolicy) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual IpsecPolicy\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForContainerServiceNetworkProfile(subject ContainerServiceNetworkProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ContainerServiceNetworkProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForComponent_STATUS_ARM(subject Component_STATUS_ARM) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual Component_STATUS_ARM\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForNetworkProfile(subject NetworkProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual NetworkProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForKubeletConfig(subject KubeletConfig) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual KubeletConfig\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForInboundIpRule(subject InboundIpRule) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual InboundIpRule\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func renderCUETemplate(elem types.AddonElementFile, parameters string, args map[string]string) (*common2.ApplicationComponent, error) {\n\tbt, err := json.Marshal(args)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar paramFile = cuemodel.ParameterFieldName + \": {}\"\n\tif string(bt) != \"null\" {\n\t\tparamFile = fmt.Sprintf(\"%s: %s\", cuemodel.ParameterFieldName, string(bt))\n\t}\n\tparam := fmt.Sprintf(\"%s\\n%s\", paramFile, parameters)\n\tv, err := value.NewValue(param, nil, \"\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tout, err := v.LookupByScript(fmt.Sprintf(\"{%s}\", elem.Data))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcompContent, err := out.LookupValue(\"output\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tb, err := cueyaml.Encode(compContent.CueValue())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcomp := common2.ApplicationComponent{\n\t\tName: strings.Join(append(elem.Path, elem.Name), \"-\"),\n\t}\n\terr = yaml.Unmarshal(b, &comp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &comp, err\n}","func RunJSONSerializationTestForManagedCluster_Spec(subject ManagedCluster_Spec) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedCluster_Spec\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func (l *Loader) EvaluateDependencies(c *ComponentNode) {\n\ttracer := l.tracer.Tracer(\"\")\n\n\tl.mut.RLock()\n\tdefer l.mut.RUnlock()\n\n\tl.cm.controllerEvaluation.Set(1)\n\tdefer l.cm.controllerEvaluation.Set(0)\n\tstart := time.Now()\n\n\tspanCtx, span := tracer.Start(context.Background(), \"GraphEvaluatePartial\", trace.WithSpanKind(trace.SpanKindInternal))\n\tspan.SetAttributes(attribute.String(\"initiator\", c.NodeID()))\n\tdefer span.End()\n\n\tlogger := log.With(l.log, \"trace_id\", span.SpanContext().TraceID())\n\tlevel.Info(logger).Log(\"msg\", \"starting partial graph evaluation\")\n\tdefer func() {\n\t\tspan.SetStatus(codes.Ok, \"\")\n\n\t\tduration := time.Since(start)\n\t\tlevel.Info(logger).Log(\"msg\", \"finished partial graph evaluation\", \"duration\", duration)\n\t\tl.cm.componentEvaluationTime.Observe(duration.Seconds())\n\t}()\n\n\t// Make sure we're in-sync with the current exports of c.\n\tl.cache.CacheExports(c.ID(), c.Exports())\n\n\t_ = dag.WalkReverse(l.graph, []dag.Node{c}, func(n dag.Node) error {\n\t\tif n == c {\n\t\t\t// Skip over the starting component; the starting component passed to\n\t\t\t// EvaluateDependencies had its exports changed and none of its input\n\t\t\t// arguments will need re-evaluation.\n\t\t\treturn nil\n\t\t}\n\n\t\t_, span := tracer.Start(spanCtx, \"EvaluateNode\", trace.WithSpanKind(trace.SpanKindInternal))\n\t\tspan.SetAttributes(attribute.String(\"node_id\", n.NodeID()))\n\t\tdefer span.End()\n\n\t\tstart := time.Now()\n\t\tdefer func() {\n\t\t\tlevel.Info(logger).Log(\"msg\", \"finished node evaluation\", \"node_id\", n.NodeID(), \"duration\", time.Since(start))\n\t\t}()\n\n\t\tvar err error\n\n\t\tswitch n := n.(type) {\n\t\tcase BlockNode:\n\t\t\terr = l.evaluate(logger, n)\n\t\t\tif exp, ok := n.(*ExportConfigNode); ok {\n\t\t\t\tl.cache.CacheModuleExportValue(exp.Label(), exp.Value())\n\t\t\t}\n\t\t}\n\n\t\t// We only use the error for updating the span status; we don't return the\n\t\t// error because we want to evaluate as many nodes as we can.\n\t\tif err != nil {\n\t\t\tspan.SetStatus(codes.Error, err.Error())\n\t\t} else {\n\t\t\tspan.SetStatus(codes.Ok, \"\")\n\t\t}\n\t\treturn nil\n\t})\n\n\tif l.globals.OnExportsChange != nil && l.cache.ExportChangeIndex() != l.moduleExportIndex {\n\t\tl.globals.OnExportsChange(l.cache.CreateModuleExports())\n\t\tl.moduleExportIndex = l.cache.ExportChangeIndex()\n\t}\n}","func RunJSONSerializationTestForVaultCertificate(subject VaultCertificate) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual VaultCertificate\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForProfiles_Endpoint_Spec(subject Profiles_Endpoint_Spec) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual Profiles_Endpoint_Spec\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func EvaluateComponents(iq IQ, components []Component, applicationID string) (*Evaluation, error) {\n\trequest, err := json.Marshal(iqEvaluationRequest{Components: components})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not build the request: %v\", err)\n\t}\n\n\trequestEndpoint := fmt.Sprintf(restEvaluation, applicationID)\n\tbody, _, err := iq.Post(requestEndpoint, bytes.NewBuffer(request))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"components not evaluated: %v\", err)\n\t}\n\n\tvar results iqEvaluationRequestResponse\n\tif err = json.Unmarshal(body, &results); err != nil {\n\t\treturn nil, fmt.Errorf(\"could not parse evaluation response: %v\", err)\n\t}\n\n\tgetEvaluationResults := func() (*Evaluation, error) {\n\t\tbody, resp, e := iq.Get(results.ResultsURL)\n\t\tif e != nil {\n\t\t\tif resp.StatusCode != http.StatusNotFound {\n\t\t\t\treturn nil, fmt.Errorf(\"could not retrieve evaluation results: %v\", err)\n\t\t\t}\n\t\t\treturn nil, nil\n\t\t}\n\n\t\tvar ev Evaluation\n\t\tif err = json.Unmarshal(body, &ev); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn &ev, nil\n\t}\n\n\tvar eval *Evaluation\n\tticker := time.NewTicker(5 * time.Second)\n\tfor {\n\t\tselect {\n\t\tcase <-ticker.C:\n\t\t\tif eval, err = getEvaluationResults(); eval != nil || err != nil {\n\t\t\t\tticker.Stop()\n\t\t\t\treturn eval, err\n\t\t\t}\n\t\tcase <-time.After(5 * time.Minute):\n\t\t\tticker.Stop()\n\t\t\treturn nil, errors.New(\"timed out waiting for valid evaluation results\")\n\t\t}\n\t}\n}","func RunTemplate(template []byte, input []byte) (interface{}, error) {\n\n\tvar data interface{}\n\tjson.Unmarshal(input, &data)\n\n\tv, err := jsonfilter.FilterJsonFromTextWithFilterRunner(string(template), string(template), func(command string, value string) (string, error) {\n\t\tfilterval, _ := jsonpath.Read(data, value)\n\t\t// fmt.Println(filterval)\n\t\tret := fmt.Sprintf(\"%v\", filterval)\n\t\treturn ret, nil\n\t})\n\n\treturn v, err\n\n}","func RunJSONSerializationTestForManagedClusterAgentPoolProfile(subject ManagedClusterAgentPoolProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterAgentPoolProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForNatGateway_Spec_ARM(subject NatGateway_Spec_ARM) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual NatGateway_Spec_ARM\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func (in *SampleIn) FetchComponent() *proIntegrator.Component {\n\tin.Component.Name = \"SampleIn\"\n\n\tmapParamIn := make(map[string]*proIntegrator.DataType)\n\tmapParamOut := make(map[string]*proIntegrator.DataType)\n\n\tmapParamIn[\"Param1\"] = &proIntegrator.DataType{Type: proIntegrator.DataType_STR}\n\tmapParamIn[\"Param2\"] = &proIntegrator.DataType{Type: proIntegrator.DataType_STR}\n\n\tmapParamOut[\"Param1\"] = &proIntegrator.DataType{Type: proIntegrator.DataType_STR}\n\tmapParamOut[\"Param2\"] = &proIntegrator.DataType{Type: proIntegrator.DataType_STR}\n\n\tin.Component.ParamsInput = mapParamIn\n\tin.Component.ParamsOutput = mapParamOut\n\treturn &in.Component\n}","func RunJSONSerializationTestForManagedClusterNATGatewayProfile(subject ManagedClusterNATGatewayProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterNATGatewayProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForAdditionalUnattendContent(subject AdditionalUnattendContent) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual AdditionalUnattendContent\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForServers_VirtualNetworkRule_Spec(subject Servers_VirtualNetworkRule_Spec) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual Servers_VirtualNetworkRule_Spec\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForContainerServiceLinuxProfile(subject ContainerServiceLinuxProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ContainerServiceLinuxProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForCapability(subject Capability) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual Capability\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForAgentPoolWindowsProfile(subject AgentPoolWindowsProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual AgentPoolWindowsProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func templateFunctionSnippet(entry *registry.Entry) func(name string) (interface{}, error) {\n\treturn func(name string) (interface{}, error) {\n\t\tglog.V(log.LevelDebug).Infof(\"template: name '%s'\", name)\n\n\t\ttemplate, err := getTemplate(name)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\ttemplate, err = renderTemplate(template, entry, nil)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvar value interface{}\n\n\t\tif err := json.Unmarshal(template.Template.Raw, &value); err != nil {\n\t\t\treturn nil, errors.NewConfigurationError(\"template not JSON formatted: %v\", err)\n\t\t}\n\n\t\tglog.V(log.LevelDebug).Infof(\"template: value '%v'\", value)\n\n\t\treturn value, nil\n\t}\n}","func RunJSONSerializationTestForDomain_Spec(subject Domain_Spec) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual Domain_Spec\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForManagedClusterSecurityProfileWorkloadIdentity(subject ManagedClusterSecurityProfileWorkloadIdentity) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterSecurityProfileWorkloadIdentity\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForUrlSigningParamIdentifier(subject UrlSigningParamIdentifier) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual UrlSigningParamIdentifier\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForManagedClusterAddonProfile(subject ManagedClusterAddonProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterAddonProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForManagedClusterOIDCIssuerProfile(subject ManagedClusterOIDCIssuerProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterOIDCIssuerProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func evaluate(node ast.Node, ext vmExtMap, tla vmExtMap, nativeFuncs map[string]*NativeFunction,\n\tmaxStack int, ic *importCache, traceOut io.Writer, stringOutputMode bool) (string, error) {\n\n\ti, err := buildInterpreter(ext, nativeFuncs, maxStack, ic, traceOut)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tresult, err := evaluateAux(i, node, tla)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvar buf bytes.Buffer\n\ti.stack.setCurrentTrace(manifestationTrace())\n\tif stringOutputMode {\n\t\terr = i.manifestString(&buf, result)\n\t} else {\n\t\terr = i.manifestAndSerializeJSON(&buf, result, true, \"\")\n\t}\n\ti.stack.clearCurrentTrace()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tbuf.WriteString(\"\\n\")\n\treturn buf.String(), nil\n}","func RunJSONSerializationTestForManagedClusterOperatorSpec(subject ManagedClusterOperatorSpec) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterOperatorSpec\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func (l *Loader) Apply(args map[string]any, componentBlocks []*ast.BlockStmt, configBlocks []*ast.BlockStmt) diag.Diagnostics {\n\tstart := time.Now()\n\tl.mut.Lock()\n\tdefer l.mut.Unlock()\n\tl.cm.controllerEvaluation.Set(1)\n\tdefer l.cm.controllerEvaluation.Set(0)\n\n\tfor key, value := range args {\n\t\tl.cache.CacheModuleArgument(key, value)\n\t}\n\tl.cache.SyncModuleArgs(args)\n\n\tnewGraph, diags := l.loadNewGraph(args, componentBlocks, configBlocks)\n\tif diags.HasErrors() {\n\t\treturn diags\n\t}\n\n\tvar (\n\t\tcomponents = make([]*ComponentNode, 0, len(componentBlocks))\n\t\tcomponentIDs = make([]ComponentID, 0, len(componentBlocks))\n\t\tservices = make([]*ServiceNode, 0, len(l.services))\n\t)\n\n\ttracer := l.tracer.Tracer(\"\")\n\tspanCtx, span := tracer.Start(context.Background(), \"GraphEvaluate\", trace.WithSpanKind(trace.SpanKindInternal))\n\tdefer span.End()\n\n\tlogger := log.With(l.log, \"trace_id\", span.SpanContext().TraceID())\n\tlevel.Info(logger).Log(\"msg\", \"starting complete graph evaluation\")\n\tdefer func() {\n\t\tspan.SetStatus(codes.Ok, \"\")\n\n\t\tduration := time.Since(start)\n\t\tlevel.Info(logger).Log(\"msg\", \"finished complete graph evaluation\", \"duration\", duration)\n\t\tl.cm.componentEvaluationTime.Observe(duration.Seconds())\n\t}()\n\n\tl.cache.ClearModuleExports()\n\n\t// Evaluate all the components.\n\t_ = dag.WalkTopological(&newGraph, newGraph.Leaves(), func(n dag.Node) error {\n\t\t_, span := tracer.Start(spanCtx, \"EvaluateNode\", trace.WithSpanKind(trace.SpanKindInternal))\n\t\tspan.SetAttributes(attribute.String(\"node_id\", n.NodeID()))\n\t\tdefer span.End()\n\n\t\tstart := time.Now()\n\t\tdefer func() {\n\t\t\tlevel.Info(logger).Log(\"msg\", \"finished node evaluation\", \"node_id\", n.NodeID(), \"duration\", time.Since(start))\n\t\t}()\n\n\t\tvar err error\n\n\t\tswitch n := n.(type) {\n\t\tcase *ComponentNode:\n\t\t\tcomponents = append(components, n)\n\t\t\tcomponentIDs = append(componentIDs, n.ID())\n\n\t\t\tif err = l.evaluate(logger, n); err != nil {\n\t\t\t\tvar evalDiags diag.Diagnostics\n\t\t\t\tif errors.As(err, &evalDiags) {\n\t\t\t\t\tdiags = append(diags, evalDiags...)\n\t\t\t\t} else {\n\t\t\t\t\tdiags.Add(diag.Diagnostic{\n\t\t\t\t\t\tSeverity: diag.SeverityLevelError,\n\t\t\t\t\t\tMessage: fmt.Sprintf(\"Failed to build component: %s\", err),\n\t\t\t\t\t\tStartPos: ast.StartPos(n.Block()).Position(),\n\t\t\t\t\t\tEndPos: ast.EndPos(n.Block()).Position(),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\n\t\tcase *ServiceNode:\n\t\t\tservices = append(services, n)\n\n\t\t\tif err = l.evaluate(logger, n); err != nil {\n\t\t\t\tvar evalDiags diag.Diagnostics\n\t\t\t\tif errors.As(err, &evalDiags) {\n\t\t\t\t\tdiags = append(diags, evalDiags...)\n\t\t\t\t} else {\n\t\t\t\t\tdiags.Add(diag.Diagnostic{\n\t\t\t\t\t\tSeverity: diag.SeverityLevelError,\n\t\t\t\t\t\tMessage: fmt.Sprintf(\"Failed to evaluate service: %s\", err),\n\t\t\t\t\t\tStartPos: ast.StartPos(n.Block()).Position(),\n\t\t\t\t\t\tEndPos: ast.EndPos(n.Block()).Position(),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\n\t\tcase BlockNode:\n\t\t\tif err = l.evaluate(logger, n); err != nil {\n\t\t\t\tdiags.Add(diag.Diagnostic{\n\t\t\t\t\tSeverity: diag.SeverityLevelError,\n\t\t\t\t\tMessage: fmt.Sprintf(\"Failed to evaluate node for config block: %s\", err),\n\t\t\t\t\tStartPos: ast.StartPos(n.Block()).Position(),\n\t\t\t\t\tEndPos: ast.EndPos(n.Block()).Position(),\n\t\t\t\t})\n\t\t\t}\n\t\t\tif exp, ok := n.(*ExportConfigNode); ok {\n\t\t\t\tl.cache.CacheModuleExportValue(exp.Label(), exp.Value())\n\t\t\t}\n\t\t}\n\n\t\t// We only use the error for updating the span status; we don't return the\n\t\t// error because we want to evaluate as many nodes as we can.\n\t\tif err != nil {\n\t\t\tspan.SetStatus(codes.Error, err.Error())\n\t\t} else {\n\t\t\tspan.SetStatus(codes.Ok, \"\")\n\t\t}\n\t\treturn nil\n\t})\n\n\tl.componentNodes = components\n\tl.serviceNodes = services\n\tl.graph = &newGraph\n\tl.cache.SyncIDs(componentIDs)\n\tl.blocks = componentBlocks\n\tl.cm.componentEvaluationTime.Observe(time.Since(start).Seconds())\n\tif l.globals.OnExportsChange != nil && l.cache.ExportChangeIndex() != l.moduleExportIndex {\n\t\tl.moduleExportIndex = l.cache.ExportChangeIndex()\n\t\tl.globals.OnExportsChange(l.cache.CreateModuleExports())\n\t}\n\treturn diags\n}","func TestRemoteComponent(t *testing.T) {\n\trunPolicyPackIntegrationTest(t, \"remote_component\", NodeJS, nil, []policyTestScenario{\n\t\t{\n\t\t\tWantErrors: []string{\n\t\t\t\t\"[advisory] remote-component-policy v0.0.1 resource-validation (random:index/randomString:RandomString: innerRandom)\",\n\t\t\t\t\"can't run policy 'resource-validation' during preview: string value at .keepers.hi can't be known during preview\",\n\t\t\t},\n\t\t\tAdvisory: true,\n\t\t},\n\t})\n}","func RunJSONSerializationTestForLoadBalancersInboundNatRule(subject LoadBalancersInboundNatRule) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual LoadBalancersInboundNatRule\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForVirtualMachine_Spec(subject VirtualMachine_Spec) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual VirtualMachine_Spec\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForProfilesEndpoint(subject ProfilesEndpoint) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ProfilesEndpoint\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForNetwork_ARM(subject Network_ARM) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual Network_ARM\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForKeyVaultSecretReference(subject KeyVaultSecretReference) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual KeyVaultSecretReference\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForManagedClustersAgentPool(subject ManagedClustersAgentPool) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClustersAgentPool\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForManagedClusterStorageProfileSnapshotController(subject ManagedClusterStorageProfileSnapshotController) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterStorageProfileSnapshotController\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func (s *Script) rawScriptSource(script string) (interface{}, error) {\n\tv := strings.TrimSpace(script)\n\tif !strings.HasPrefix(v, \"{\") && !strings.HasPrefix(v, `\"`) {\n\t\tv = fmt.Sprintf(\"%q\", v)\n\t}\n\traw := json.RawMessage(v)\n\treturn &raw, nil\n}","func getComponentContent(name string, style string) string {\n\tstyleFile := fmt.Sprintf(\"%s.%s\", name, style)\n\tcomponentName := strings.ReplaceAll(name, \"-\", \" \")\n\tcomponentName = strings.Title(componentName)\n\tcomponentName = strings.ReplaceAll(componentName, \" \", \"\")\n\treturn fmt.Sprintf(\n\t\t`import React from \"react\";\nimport \"./%s\";\n\nconst %s = () => {\n\treturn
;\n}\n\nexport default %s;`, styleFile, componentName, name, componentName)\n}","func RunJSONSerializationTestForNetworkInterface_Spec(subject NetworkInterface_Spec) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual NetworkInterface_Spec\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForIPTag(subject IPTag) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual IPTag\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForVpnClientRevokedCertificate(subject VpnClientRevokedCertificate) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual VpnClientRevokedCertificate\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForNatGatewayPropertiesFormat_ARM(subject NatGatewayPropertiesFormat_ARM) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual NatGatewayPropertiesFormat_ARM\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForManagedClusterStorageProfileFileCSIDriver(subject ManagedClusterStorageProfileFileCSIDriver) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterStorageProfileFileCSIDriver\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func (c *Codegen) AddDefaultSnippets() {\n\t/* common props */\n\tc.AddSnippet(\"php\", \"add($prop);\")\n\tc.AddSnippet(\"iblock_prop_check\", \"if ($r) { \"+c.LineBreak+c.Indent+\"echo 'Added prop with ID: ' . $r . PHP_EOL; \"+c.LineBreak+\"} else { \"+c.LineBreak+c.Indent+\"echo 'Error adding prop: ' . $ibp->LAST_ERROR . PHP_EOL; \"+c.LineBreak+\"}\")\n\n\t/* specially for user fields */\n\tc.AddSnippet(\"uf_obj\", \"$ufo = new CUserTypeEntity;\")\n\tc.AddSnippet(\"uf_data_st\", \"$uf = array(\")\n\tc.AddSnippet(\"uf_data_en\", \");\")\n\tc.AddSnippet(\"uf_data_run\", \"$r = $ufo->add($uf);\")\n\tc.AddSnippet(\"uf_data_check\", \"if ($r) { \"+c.LineBreak+c.Indent+\"echo 'Added UserField with ID: ' . $r . PHP_EOL; \"+c.LineBreak+\"} else { \"+c.LineBreak+c.Indent+\"echo 'Error adding UserField: ' . $ufo->LAST_ERROR . PHP_EOL; \"+c.LineBreak+\"}\")\n\t// TODO - no LAST_ERROR here, catch exception?\n\n\t/* specially for mail event/template */\n\tc.AddSnippet(\"mevent_obj\", \"$meo = new CEventType;\")\n\tc.AddSnippet(\"mevent_data_st\", \"$me = array(\")\n\tc.AddSnippet(\"mevent_data_en\", \");\")\n\tc.AddSnippet(\"mevent_run\", \"$r = $meo->add($me);\")\n\tc.AddSnippet(\"mevent_run_succ_wo_mm\", \"if ($r) { \"+c.LineBreak+c.Indent+\"echo 'Added MailEvent with ID: ' . $r . PHP_EOL; \"+c.LineBreak+\"} else { \"+c.LineBreak+c.Indent+\"echo 'Error adding MailEvent: ' . $meo->LAST_ERROR . PHP_EOL; \"+c.LineBreak+\"}\")\n\tc.AddSnippet(\"mevent_run_check\", \"if ($r) {\")\n\tc.AddSnippet(\"mevent_run_check_else\", \"} else {\"+c.LineBreak+c.Indent+\"echo 'Error adding MailEvent: ' . $meo->LAST_ERROR . PHP_EOL; \"+c.LineBreak+\"}\")\n\tc.AddSnippet(\"mevent_succ\", c.Indent+\"echo 'Added MailEvent with ID: ' . $r . PHP_EOL;\"+c.LineBreak)\n\n\tc.AddSnippet(\"mtpl_warn\", c.Indent+\"// TODO - set proper LID for template!\")\n\tc.AddSnippet(\"mtpl_obj\", \"$mmo = new CEventMessage;\")\n\tc.AddSnippet(\"mtpl_data_st\", \"$mm = array(\")\n\tc.AddSnippet(\"mtpl_data_en\", \");\")\n\tc.AddSnippet(\"mtpl_run\", \"$r = $mmo->add($mm);\")\n\tc.AddSnippet(\"mtpl_run_check\", c.Indent+\"if ($r) {\"+c.LineBreak+c.Indent+c.Indent+\"echo 'Added MailTemplate with ID: ' . $r . PHP_EOL;\"+c.LineBreak+c.Indent+\"} else {\"+c.LineBreak+c.Indent+c.Indent+\"echo 'Error adding MailTemplate: ' . $mmo->LAST_ERROR . PHP_EOL;\"+c.LineBreak+c.Indent+\"}\")\n\n\t/* common, group 2 */\n\tc.AddSnippet(\"done\", \"echo 'Done!' . PHP_EOL;\")\n}","func (l *Loader) populateComponentNodes(g *dag.Graph, componentBlocks []*ast.BlockStmt) diag.Diagnostics {\n\tvar (\n\t\tdiags diag.Diagnostics\n\t\tblockMap = make(map[string]*ast.BlockStmt, len(componentBlocks))\n\t)\n\tfor _, block := range componentBlocks {\n\t\tvar c *ComponentNode\n\t\tid := BlockComponentID(block).String()\n\n\t\tif orig, redefined := blockMap[id]; redefined {\n\t\t\tdiags.Add(diag.Diagnostic{\n\t\t\t\tSeverity: diag.SeverityLevelError,\n\t\t\t\tMessage: fmt.Sprintf(\"Component %s already declared at %s\", id, ast.StartPos(orig).Position()),\n\t\t\t\tStartPos: block.NamePos.Position(),\n\t\t\t\tEndPos: block.NamePos.Add(len(id) - 1).Position(),\n\t\t\t})\n\t\t\tcontinue\n\t\t}\n\t\tblockMap[id] = block\n\n\t\t// Check the graph from the previous call to Load to see we can copy an\n\t\t// existing instance of ComponentNode.\n\t\tif exist := l.graph.GetByID(id); exist != nil {\n\t\t\tc = exist.(*ComponentNode)\n\t\t\tc.UpdateBlock(block)\n\t\t} else {\n\t\t\tcomponentName := block.GetBlockName()\n\t\t\tregistration, exists := l.componentReg.Get(componentName)\n\t\t\tif !exists {\n\t\t\t\tdiags.Add(diag.Diagnostic{\n\t\t\t\t\tSeverity: diag.SeverityLevelError,\n\t\t\t\t\tMessage: fmt.Sprintf(\"Unrecognized component name %q\", componentName),\n\t\t\t\t\tStartPos: block.NamePos.Position(),\n\t\t\t\t\tEndPos: block.NamePos.Add(len(componentName) - 1).Position(),\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif registration.Singleton && block.Label != \"\" {\n\t\t\t\tdiags.Add(diag.Diagnostic{\n\t\t\t\t\tSeverity: diag.SeverityLevelError,\n\t\t\t\t\tMessage: fmt.Sprintf(\"Component %q does not support labels\", componentName),\n\t\t\t\t\tStartPos: block.LabelPos.Position(),\n\t\t\t\t\tEndPos: block.LabelPos.Add(len(block.Label) + 1).Position(),\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif !registration.Singleton && block.Label == \"\" {\n\t\t\t\tdiags.Add(diag.Diagnostic{\n\t\t\t\t\tSeverity: diag.SeverityLevelError,\n\t\t\t\t\tMessage: fmt.Sprintf(\"Component %q must have a label\", componentName),\n\t\t\t\t\tStartPos: block.NamePos.Position(),\n\t\t\t\t\tEndPos: block.NamePos.Add(len(componentName) - 1).Position(),\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif registration.Singleton && l.isModule() {\n\t\t\t\tdiags.Add(diag.Diagnostic{\n\t\t\t\t\tSeverity: diag.SeverityLevelError,\n\t\t\t\t\tMessage: fmt.Sprintf(\"Component %q is a singleton and unsupported inside a module\", componentName),\n\t\t\t\t\tStartPos: block.NamePos.Position(),\n\t\t\t\t\tEndPos: block.NamePos.Add(len(componentName) - 1).Position(),\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Create a new component\n\t\t\tc = NewComponentNode(l.globals, registration, block)\n\t\t}\n\n\t\tg.Add(c)\n\t}\n\n\treturn diags\n}","func RunJSONSerializationTestForManagedClusterSKU(subject ManagedClusterSKU) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterSKU\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForManagedClusterWindowsProfile(subject ManagedClusterWindowsProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterWindowsProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForPowerState(subject PowerState) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual PowerState\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForResourceReference(subject ResourceReference) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ResourceReference\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForResourceReference(subject ResourceReference) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ResourceReference\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func ParseApplicationComponent(jsn string) (acomp v1alpha1.Component, err error) {\n\terr = json.Unmarshal([]byte(jsn), &acomp)\n\treturn\n}","func Render(comp Component, container *js.Object) {\n\tcomp.Reconcile(nil)\n\tcontainer.Call(\"appendChild\", comp.Node())\n}","func RunJSONSerializationTestForImageReference(subject ImageReference) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ImageReference\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForVpnClientConfiguration(subject VpnClientConfiguration) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual VpnClientConfiguration\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func (opa *client) EvaluatePolicy(policy string, input []byte) (*EvaluatePolicyResponse, error) {\n\tlog := opa.logger.Named(\"Evalute Policy\")\n\n\trequest, err := json.Marshal(&EvalutePolicyRequest{Input: input})\n\tif err != nil {\n\t\tlog.Error(\"failed to encode OPA input\", zap.Error(err), zap.String(\"input\", string(input)))\n\t\treturn nil, fmt.Errorf(\"failed to encode OPA input: %s\", err)\n\t}\n\n\thttpResponse, err := opa.httpClient.Post(opa.getDataQueryURL(getOpaPackagePath(policy)), \"application/json\", bytes.NewReader(request))\n\tif err != nil {\n\t\tlog.Error(\"http request to OPA failed\", zap.Error(err))\n\t\treturn nil, fmt.Errorf(\"http request to OPA failed: %s\", err)\n\t}\n\tif httpResponse.StatusCode != http.StatusOK {\n\t\tlog.Error(\"http response status from OPA not OK\", zap.Any(\"status\", httpResponse.Status))\n\t\treturn nil, fmt.Errorf(\"http response status not OK\")\n\t}\n\n\tresponse := &EvaluatePolicyResponse{}\n\terr = json.NewDecoder(httpResponse.Body).Decode(&response)\n\tif err != nil {\n\t\tlog.Error(\"failed to decode OPA result\", zap.Error(err))\n\t\treturn nil, fmt.Errorf(\"failed to decode OPA result: %s\", err)\n\t}\n\n\treturn response, nil\n}","func RunJSONSerializationTestForUrlSigningParamIdentifier_ARM(subject UrlSigningParamIdentifier_ARM) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual UrlSigningParamIdentifier_ARM\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForManagedClusterLoadBalancerProfile(subject ManagedClusterLoadBalancerProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterLoadBalancerProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForNetworkInterface_Spec_ARM(subject NetworkInterface_Spec_ARM) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual NetworkInterface_Spec_ARM\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func TestCSharpCompat(t *testing.T) {\n\tjs := `{\n \"store\": {\n \"book\": [\n {\n \"category\": \"reference\",\n \"author\": \"Nigel Rees\",\n \"title\": \"Sayings of the Century\",\n \"price\": 8.95\n },\n {\n \"category\": \"fiction\",\n \"author\": \"Evelyn Waugh\",\n \"title\": \"Sword of Honour\",\n \"price\": 12.99\n },\n {\n \"category\": \"fiction\",\n \"author\": \"Herman Melville\",\n \"title\": \"Moby Dick\",\n \"isbn\": \"0-553-21311-3\",\n \"price\": 8.99\n },\n {\n \"category\": \"fiction\",\n \"author\": \"J. R. R. Tolkien\",\n \"title\": \"The Lord of the Rings\",\n \"isbn\": \"0-395-19395-8\",\n \"price\": null\n }\n ],\n \"bicycle\": {\n \"color\": \"red\",\n \"price\": 19.95\n }\n },\n \"expensive\": 10,\n \"data\": null\n}`\n\n\ttestCases := []pathTestCase{\n\t\t{\"$.store.book[*].author\", `[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]`},\n\t\t{\"$..author\", `[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]`},\n\t\t{\"$.store.*\", `[[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":8.95},{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":12.99},{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99},{\"category\":\"fiction\",\"author\":\"J. R. R. Tolkien\",\"title\":\"The Lord of the Rings\",\"isbn\":\"0-395-19395-8\",\"price\":null}],{\"color\":\"red\",\"price\":19.95}]`},\n\t\t{\"$.store..price\", `[19.95,8.95,12.99,8.99,null]`},\n\t\t{\"$..book[2]\", `[{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99}]`},\n\t\t{\"$..book[-2]\", `[{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99}]`},\n\t\t{\"$..book[0,1]\", `[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":8.95},{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":12.99}]`},\n\t\t{\"$..book[:2]\", `[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":8.95},{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":12.99}]`},\n\t\t{\"$..book[1:2]\", `[{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":12.99}]`},\n\t\t{\"$..book[-2:]\", `[{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99},{\"category\":\"fiction\",\"author\":\"J. R. R. Tolkien\",\"title\":\"The Lord of the Rings\",\"isbn\":\"0-395-19395-8\",\"price\":null}]`},\n\t\t{\"$..book[2:]\", `[{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99},{\"category\":\"fiction\",\"author\":\"J. R. R. Tolkien\",\"title\":\"The Lord of the Rings\",\"isbn\":\"0-395-19395-8\",\"price\":null}]`},\n\t\t{\"\", `[{\"store\":{\"book\":[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":8.95},{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":12.99},{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99},{\"category\":\"fiction\",\"author\":\"J. R. R. Tolkien\",\"title\":\"The Lord of the Rings\",\"isbn\":\"0-395-19395-8\",\"price\":null}],\"bicycle\":{\"color\":\"red\",\"price\":19.95}},\"expensive\":10,\"data\":null}]`},\n\t\t{\"$.*\", `[{\"book\":[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":8.95},{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":12.99},{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99},{\"category\":\"fiction\",\"author\":\"J. R. R. Tolkien\",\"title\":\"The Lord of the Rings\",\"isbn\":\"0-395-19395-8\",\"price\":null}],\"bicycle\":{\"color\":\"red\",\"price\":19.95}},10,null]`},\n\t\t{\"$..invalidfield\", `[]`},\n\t}\n\n\tfor _, tc := range testCases {\n\t\tt.Run(tc.path, func(t *testing.T) {\n\t\t\ttc.testUnmarshalGet(t, js)\n\t\t})\n\t}\n\n\tt.Run(\"bad cases\", func(t *testing.T) {\n\t\t_, ok := unmarshalGet(t, js, `$..book[*].author\"`)\n\t\trequire.False(t, ok)\n\t})\n}","func RunJSONSerializationTestForManagedClusterPodIdentityProfile(subject ManagedClusterPodIdentityProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterPodIdentityProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForManagedClusterManagedOutboundIPProfile(subject ManagedClusterManagedOutboundIPProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterManagedOutboundIPProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForAgentPoolNetworkProfile_STATUS(subject AgentPoolNetworkProfile_STATUS) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual AgentPoolNetworkProfile_STATUS\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForApplicationInsightsComponentProperties_STATUS_ARM(subject ApplicationInsightsComponentProperties_STATUS_ARM) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ApplicationInsightsComponentProperties_STATUS_ARM\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForManagedClusterSecurityProfile(subject ManagedClusterSecurityProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterSecurityProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForProfiles_Endpoint_Spec_ARM(subject Profiles_Endpoint_Spec_ARM) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual Profiles_Endpoint_Spec_ARM\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func generatePerNodeConfigSnippet(pathStructName string, nodeData *ypathgen.NodeData, fakeRootTypeName, schemaStructPkgAccessor string, preferShadowPath bool) (GoPerNodeCodeSnippet, goTypeData, util.Errors) {\n\t// TODO: See if a float32 -> binary helper should be provided\n\t// for setting a float32 leaf.\n\tvar errs util.Errors\n\ts := struct {\n\t\tPathStructName string\n\t\tGoType goTypeData\n\t\tGoFieldName string\n\t\tGoStructTypeName string\n\t\tYANGPath string\n\t\tFakeRootTypeName string\n\t\tIsScalarField bool\n\t\tIsRoot bool\n\t\tSchemaStructPkgAccessor string\n\t\tWildcardSuffix string\n\t\tSpecialConversionFn string\n\t\tPreferShadowPath bool\n\t}{\n\t\tPathStructName: pathStructName,\n\t\tGoType: goTypeData{\n\t\t\tGoTypeName: nodeData.GoTypeName,\n\t\t\tTransformedGoTypeName: transformGoTypeName(nodeData),\n\t\t\tIsLeaf: nodeData.IsLeaf,\n\t\t\tHasDefault: nodeData.HasDefault,\n\t\t},\n\t\tGoFieldName: nodeData.GoFieldName,\n\t\tGoStructTypeName: nodeData.SubsumingGoStructName,\n\t\tYANGPath: nodeData.YANGPath,\n\t\tFakeRootTypeName: fakeRootTypeName,\n\t\tIsScalarField: nodeData.IsScalarField,\n\t\tIsRoot: nodeData.YANGPath == \"/\",\n\t\tWildcardSuffix: ypathgen.WildcardSuffix,\n\t\tSchemaStructPkgAccessor: schemaStructPkgAccessor,\n\t\tPreferShadowPath: preferShadowPath,\n\t}\n\tvar getMethod, replaceMethod, convertHelper strings.Builder\n\tif nodeData.IsLeaf {\n\t\t// Leaf types use their parent GoStruct to unmarshal, before\n\t\t// being retrieved out when returned to the user.\n\t\tif err := goLeafConvertTemplate.Execute(&convertHelper, s); err != nil {\n\t\t\tutil.AppendErr(errs, err)\n\t\t}\n\t}\n\tif err := goNodeSetTemplate.Execute(&replaceMethod, s); err != nil {\n\t\tutil.AppendErr(errs, err)\n\t}\n\tif err := goNodeGetTemplate.Execute(&getMethod, s); err != nil {\n\t\tutil.AppendErr(errs, err)\n\t}\n\n\treturn GoPerNodeCodeSnippet{\n\t\tPathStructName: pathStructName,\n\t\tGetMethod: getMethod.String(),\n\t\tConvertHelper: convertHelper.String(),\n\t\tReplaceMethod: replaceMethod.String(),\n\t}, s.GoType, errs\n}","func RunJSONSerializationTestForEndpointProperties_ARM(subject EndpointProperties_ARM) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual EndpointProperties_ARM\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForVirtualMachineNetworkInterfaceIPConfiguration(subject VirtualMachineNetworkInterfaceIPConfiguration) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual VirtualMachineNetworkInterfaceIPConfiguration\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForManagedClusterWorkloadAutoScalerProfile(subject ManagedClusterWorkloadAutoScalerProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterWorkloadAutoScalerProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForProfile_Spec_ARM(subject Profile_Spec_ARM) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual Profile_Spec_ARM\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForManagedClusterLoadBalancerProfile_OutboundIPs(subject ManagedClusterLoadBalancerProfile_OutboundIPs) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterLoadBalancerProfile_OutboundIPs\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForAdditionalCapabilities(subject AdditionalCapabilities) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual AdditionalCapabilities\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForFailoverGroupReadOnlyEndpoint(subject FailoverGroupReadOnlyEndpoint) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual FailoverGroupReadOnlyEndpoint\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForSearchService_Spec_ARM(subject SearchService_Spec_ARM) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual SearchService_Spec_ARM\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForNetworkInterfacePropertiesFormat_ARM(subject NetworkInterfacePropertiesFormat_ARM) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual NetworkInterfacePropertiesFormat_ARM\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForManagedClusterOperatorSecrets(subject ManagedClusterOperatorSecrets) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ManagedClusterOperatorSecrets\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func (p *Parser) Load(filename string) (string, error) {\n\tdirectory := filepath.Dir(filename)\n\tdata, err := ioutil.ReadFile(filename)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvm := jsonnet.MakeVM()\n\tvm.Importer(&jsonnet.FileImporter{\n\t\tJPaths: []string{directory},\n\t})\n\n\treturn vm.EvaluateAnonymousSnippet(filename, string(data))\n}","func (c *Codegen) AddSnippet(key, value string) {\n\tc.phpSnippets[key] = value\n}","func TestConstructPlainGo(t *testing.T) {\n\ttests := []struct {\n\t\tcomponentDir string\n\t\texpectedResourceCount int\n\t\tenv []string\n\t}{\n\t\t{\n\t\t\tcomponentDir: \"testcomponent\",\n\t\t\texpectedResourceCount: 9,\n\t\t\t// TODO[pulumi/pulumi#5455]: Dynamic providers fail to load when used from multi-lang components.\n\t\t\t// Until we've addressed this, set PULUMI_TEST_YARN_LINK_PULUMI, which tells the integration test\n\t\t\t// module to run `yarn install && yarn link @pulumi/pulumi` in the Go program's directory, allowing\n\t\t\t// the Node.js dynamic provider plugin to load.\n\t\t\t// When the underlying issue has been fixed, the use of this environment variable inside the integration\n\t\t\t// test module should be removed.\n\t\t\tenv: []string{\"PULUMI_TEST_YARN_LINK_PULUMI=true\"},\n\t\t},\n\t\t{\n\t\t\tcomponentDir: \"testcomponent-python\",\n\t\t\texpectedResourceCount: 9,\n\t\t\tenv: []string{pulumiRuntimeVirtualEnv(t, filepath.Join(\"..\", \"..\"))},\n\t\t},\n\t\t{\n\t\t\tcomponentDir: \"testcomponent-go\",\n\t\t\texpectedResourceCount: 8, // One less because no dynamic provider.\n\t\t},\n\t}\n\n\tfor _, test := range tests {\n\t\tt.Run(test.componentDir, func(t *testing.T) {\n\t\t\tpathEnv := pathEnv(t, filepath.Join(\"construct_component_plain\", test.componentDir))\n\t\t\tintegration.ProgramTest(t,\n\t\t\t\toptsForConstructPlainGo(t, test.expectedResourceCount, append(test.env, pathEnv)...))\n\t\t})\n\t}\n}","func evaluateAst(program *ast.RootNode) object.Object {\n\tenv := object.NewEnvironment()\n\treturn evaluator.Eval(program, env)\n}","func RunJSONSerializationTestForContainerServiceNetworkProfile_STATUS(subject ContainerServiceNetworkProfile_STATUS) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual ContainerServiceNetworkProfile_STATUS\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}","func RunJSONSerializationTestForHardwareProfile(subject HardwareProfile) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual HardwareProfile\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}"],"string":"[\n \"func EvaluateComponent(a app.App, sourcePath, paramsStr, envName string, useMemoryImporter bool) (string, error) {\\n\\tsnippet, err := afero.ReadFile(a.Fs(), sourcePath)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\treturn EvaluateComponentSnippet(a, string(snippet), paramsStr, envName, useMemoryImporter)\\n}\",\n \"func (vm *VM) EvaluateSnippet(filename string, snippet string) (json string, formattedErr error) {\\n\\tdefer func() {\\n\\t\\tif r := recover(); r != nil {\\n\\t\\t\\tformattedErr = errors.New(vm.ef.format(fmt.Errorf(\\\"(CRASH) %v\\\\n%s\\\", r, debug.Stack())))\\n\\t\\t}\\n\\t}()\\n\\tjson, err := vm.evaluateSnippet(filename, snippet)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", errors.New(vm.ef.format(err))\\n\\t}\\n\\treturn json, nil\\n}\",\n \"func (cx *Context) Eval(source string, result interface{}) (err error) {\\n\\tcx.do(func(ptr *C.JSAPIContext) {\\n\\t\\t// alloc C-string\\n\\t\\tcsource := C.CString(source)\\n\\t\\tdefer C.free(unsafe.Pointer(csource))\\n\\t\\tvar jsonData *C.char\\n\\t\\tvar jsonLen C.int\\n\\t\\tfilename := \\\"eval\\\"\\n\\t\\tcfilename := C.CString(filename)\\n\\t\\tdefer C.free(unsafe.Pointer(cfilename))\\n\\t\\t// eval\\n\\t\\tif C.JSAPI_EvalJSON(ptr, csource, cfilename, &jsonData, &jsonLen) != C.JSAPI_OK {\\n\\t\\t\\terr = cx.getError(filename)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tdefer C.free(unsafe.Pointer(jsonData))\\n\\t\\t// convert to go\\n\\t\\tb := []byte(C.GoStringN(jsonData, jsonLen))\\n\\t\\tif raw, ok := result.(*Raw); ok {\\n\\t\\t\\t*raw = Raw(string(b))\\n\\t\\t} else {\\n\\t\\t\\terr = json.Unmarshal(b, result)\\n\\t\\t}\\n\\t})\\n\\treturn err\\n}\",\n \"func jsonCodeBlock(value interface{}) string {\\n\\tblock, _ := json.MarshalIndent(value, \\\"\\\", \\\" \\\")\\n\\treturn fmt.Sprintf(\\\"```javascript\\\\n%s\\\\n```\\\", block)\\n}\",\n \"func renderRawComponent(elem types.AddonElementFile) (*common2.ApplicationComponent, error) {\\n\\tbaseRawComponent := common2.ApplicationComponent{\\n\\t\\tType: \\\"raw\\\",\\n\\t\\tName: strings.Join(append(elem.Path, elem.Name), \\\"-\\\"),\\n\\t}\\n\\tobj, err := renderObject(elem)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tbaseRawComponent.Properties = util.Object2RawExtension(obj)\\n\\treturn &baseRawComponent, nil\\n}\",\n \"func RunJSONSerializationTestForManagedClusters_AgentPool_Spec(subject ManagedClusters_AgentPool_Spec) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusters_AgentPool_Spec\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func Snippet(value string) *SimpleElement { return newSEString(\\\"snippet\\\", value) }\",\n \"func RunJSONSerializationTestForLoadBalancers_InboundNatRule_Spec(subject LoadBalancers_InboundNatRule_Spec) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual LoadBalancers_InboundNatRule_Spec\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForAgentPoolNetworkProfile(subject AgentPoolNetworkProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual AgentPoolNetworkProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func EvaluateEnv(a app.App, sourcePath, paramsStr, envName string) (string, error) {\\n\\tlibPath, err := a.LibPath(envName)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\tvm := jsonnet.NewVM()\\n\\n\\tvm.JPaths = []string{\\n\\t\\tlibPath,\\n\\t\\tfilepath.Join(a.Root(), \\\"vendor\\\"),\\n\\t}\\n\\tvm.ExtCode(\\\"__ksonnet/params\\\", paramsStr)\\n\\n\\tsnippet, err := afero.ReadFile(a.Fs(), sourcePath)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\treturn vm.EvaluateSnippet(sourcePath, string(snippet))\\n}\",\n \"func Componentgen(nr, nl *Node) bool\",\n \"func (ecr *EnvComponentRemover) Remove(componentName, snippet string) (string, error) {\\n\\tif componentName == \\\"\\\" {\\n\\t\\treturn \\\"\\\", errors.New(\\\"component name was blank\\\")\\n\\t}\\n\\n\\tlogger := logrus.WithField(\\\"component-name\\\", componentName)\\n\\tlogger.Info(\\\"removing environment component\\\")\\n\\n\\tn, err := jsonnet.ParseNode(\\\"params.libsonnet\\\", snippet)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\tobj, err := componentParams(n, componentName)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\tif err = ecr.deleteEntry(obj, componentName); err != nil {\\n\\t\\treturn \\\"\\\", errors.Wrap(err, \\\"delete entry\\\")\\n\\t}\\n\\n\\tvar buf bytes.Buffer\\n\\tif err = jsonnetPrinterFn(&buf, n); err != nil {\\n\\t\\treturn \\\"\\\", errors.Wrap(err, \\\"unable to update snippet\\\")\\n\\t}\\n\\n\\treturn buf.String(), nil\\n}\",\n \"func RunJSONSerializationTestForExtendedLocation(subject ExtendedLocation) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ExtendedLocation\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForExtendedLocation(subject ExtendedLocation) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ExtendedLocation\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForExtendedLocation(subject ExtendedLocation) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ExtendedLocation\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForIpsecPolicy(subject IpsecPolicy) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual IpsecPolicy\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForContainerServiceNetworkProfile(subject ContainerServiceNetworkProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ContainerServiceNetworkProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForComponent_STATUS_ARM(subject Component_STATUS_ARM) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual Component_STATUS_ARM\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForNetworkProfile(subject NetworkProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual NetworkProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForKubeletConfig(subject KubeletConfig) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual KubeletConfig\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForInboundIpRule(subject InboundIpRule) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual InboundIpRule\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func renderCUETemplate(elem types.AddonElementFile, parameters string, args map[string]string) (*common2.ApplicationComponent, error) {\\n\\tbt, err := json.Marshal(args)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tvar paramFile = cuemodel.ParameterFieldName + \\\": {}\\\"\\n\\tif string(bt) != \\\"null\\\" {\\n\\t\\tparamFile = fmt.Sprintf(\\\"%s: %s\\\", cuemodel.ParameterFieldName, string(bt))\\n\\t}\\n\\tparam := fmt.Sprintf(\\\"%s\\\\n%s\\\", paramFile, parameters)\\n\\tv, err := value.NewValue(param, nil, \\\"\\\")\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tout, err := v.LookupByScript(fmt.Sprintf(\\\"{%s}\\\", elem.Data))\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tcompContent, err := out.LookupValue(\\\"output\\\")\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tb, err := cueyaml.Encode(compContent.CueValue())\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tcomp := common2.ApplicationComponent{\\n\\t\\tName: strings.Join(append(elem.Path, elem.Name), \\\"-\\\"),\\n\\t}\\n\\terr = yaml.Unmarshal(b, &comp)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\treturn &comp, err\\n}\",\n \"func RunJSONSerializationTestForManagedCluster_Spec(subject ManagedCluster_Spec) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedCluster_Spec\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func (l *Loader) EvaluateDependencies(c *ComponentNode) {\\n\\ttracer := l.tracer.Tracer(\\\"\\\")\\n\\n\\tl.mut.RLock()\\n\\tdefer l.mut.RUnlock()\\n\\n\\tl.cm.controllerEvaluation.Set(1)\\n\\tdefer l.cm.controllerEvaluation.Set(0)\\n\\tstart := time.Now()\\n\\n\\tspanCtx, span := tracer.Start(context.Background(), \\\"GraphEvaluatePartial\\\", trace.WithSpanKind(trace.SpanKindInternal))\\n\\tspan.SetAttributes(attribute.String(\\\"initiator\\\", c.NodeID()))\\n\\tdefer span.End()\\n\\n\\tlogger := log.With(l.log, \\\"trace_id\\\", span.SpanContext().TraceID())\\n\\tlevel.Info(logger).Log(\\\"msg\\\", \\\"starting partial graph evaluation\\\")\\n\\tdefer func() {\\n\\t\\tspan.SetStatus(codes.Ok, \\\"\\\")\\n\\n\\t\\tduration := time.Since(start)\\n\\t\\tlevel.Info(logger).Log(\\\"msg\\\", \\\"finished partial graph evaluation\\\", \\\"duration\\\", duration)\\n\\t\\tl.cm.componentEvaluationTime.Observe(duration.Seconds())\\n\\t}()\\n\\n\\t// Make sure we're in-sync with the current exports of c.\\n\\tl.cache.CacheExports(c.ID(), c.Exports())\\n\\n\\t_ = dag.WalkReverse(l.graph, []dag.Node{c}, func(n dag.Node) error {\\n\\t\\tif n == c {\\n\\t\\t\\t// Skip over the starting component; the starting component passed to\\n\\t\\t\\t// EvaluateDependencies had its exports changed and none of its input\\n\\t\\t\\t// arguments will need re-evaluation.\\n\\t\\t\\treturn nil\\n\\t\\t}\\n\\n\\t\\t_, span := tracer.Start(spanCtx, \\\"EvaluateNode\\\", trace.WithSpanKind(trace.SpanKindInternal))\\n\\t\\tspan.SetAttributes(attribute.String(\\\"node_id\\\", n.NodeID()))\\n\\t\\tdefer span.End()\\n\\n\\t\\tstart := time.Now()\\n\\t\\tdefer func() {\\n\\t\\t\\tlevel.Info(logger).Log(\\\"msg\\\", \\\"finished node evaluation\\\", \\\"node_id\\\", n.NodeID(), \\\"duration\\\", time.Since(start))\\n\\t\\t}()\\n\\n\\t\\tvar err error\\n\\n\\t\\tswitch n := n.(type) {\\n\\t\\tcase BlockNode:\\n\\t\\t\\terr = l.evaluate(logger, n)\\n\\t\\t\\tif exp, ok := n.(*ExportConfigNode); ok {\\n\\t\\t\\t\\tl.cache.CacheModuleExportValue(exp.Label(), exp.Value())\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\t// We only use the error for updating the span status; we don't return the\\n\\t\\t// error because we want to evaluate as many nodes as we can.\\n\\t\\tif err != nil {\\n\\t\\t\\tspan.SetStatus(codes.Error, err.Error())\\n\\t\\t} else {\\n\\t\\t\\tspan.SetStatus(codes.Ok, \\\"\\\")\\n\\t\\t}\\n\\t\\treturn nil\\n\\t})\\n\\n\\tif l.globals.OnExportsChange != nil && l.cache.ExportChangeIndex() != l.moduleExportIndex {\\n\\t\\tl.globals.OnExportsChange(l.cache.CreateModuleExports())\\n\\t\\tl.moduleExportIndex = l.cache.ExportChangeIndex()\\n\\t}\\n}\",\n \"func RunJSONSerializationTestForVaultCertificate(subject VaultCertificate) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual VaultCertificate\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForProfiles_Endpoint_Spec(subject Profiles_Endpoint_Spec) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual Profiles_Endpoint_Spec\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func EvaluateComponents(iq IQ, components []Component, applicationID string) (*Evaluation, error) {\\n\\trequest, err := json.Marshal(iqEvaluationRequest{Components: components})\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"could not build the request: %v\\\", err)\\n\\t}\\n\\n\\trequestEndpoint := fmt.Sprintf(restEvaluation, applicationID)\\n\\tbody, _, err := iq.Post(requestEndpoint, bytes.NewBuffer(request))\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"components not evaluated: %v\\\", err)\\n\\t}\\n\\n\\tvar results iqEvaluationRequestResponse\\n\\tif err = json.Unmarshal(body, &results); err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"could not parse evaluation response: %v\\\", err)\\n\\t}\\n\\n\\tgetEvaluationResults := func() (*Evaluation, error) {\\n\\t\\tbody, resp, e := iq.Get(results.ResultsURL)\\n\\t\\tif e != nil {\\n\\t\\t\\tif resp.StatusCode != http.StatusNotFound {\\n\\t\\t\\t\\treturn nil, fmt.Errorf(\\\"could not retrieve evaluation results: %v\\\", err)\\n\\t\\t\\t}\\n\\t\\t\\treturn nil, nil\\n\\t\\t}\\n\\n\\t\\tvar ev Evaluation\\n\\t\\tif err = json.Unmarshal(body, &ev); err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\n\\t\\treturn &ev, nil\\n\\t}\\n\\n\\tvar eval *Evaluation\\n\\tticker := time.NewTicker(5 * time.Second)\\n\\tfor {\\n\\t\\tselect {\\n\\t\\tcase <-ticker.C:\\n\\t\\t\\tif eval, err = getEvaluationResults(); eval != nil || err != nil {\\n\\t\\t\\t\\tticker.Stop()\\n\\t\\t\\t\\treturn eval, err\\n\\t\\t\\t}\\n\\t\\tcase <-time.After(5 * time.Minute):\\n\\t\\t\\tticker.Stop()\\n\\t\\t\\treturn nil, errors.New(\\\"timed out waiting for valid evaluation results\\\")\\n\\t\\t}\\n\\t}\\n}\",\n \"func RunTemplate(template []byte, input []byte) (interface{}, error) {\\n\\n\\tvar data interface{}\\n\\tjson.Unmarshal(input, &data)\\n\\n\\tv, err := jsonfilter.FilterJsonFromTextWithFilterRunner(string(template), string(template), func(command string, value string) (string, error) {\\n\\t\\tfilterval, _ := jsonpath.Read(data, value)\\n\\t\\t// fmt.Println(filterval)\\n\\t\\tret := fmt.Sprintf(\\\"%v\\\", filterval)\\n\\t\\treturn ret, nil\\n\\t})\\n\\n\\treturn v, err\\n\\n}\",\n \"func RunJSONSerializationTestForManagedClusterAgentPoolProfile(subject ManagedClusterAgentPoolProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterAgentPoolProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForNatGateway_Spec_ARM(subject NatGateway_Spec_ARM) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual NatGateway_Spec_ARM\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func (in *SampleIn) FetchComponent() *proIntegrator.Component {\\n\\tin.Component.Name = \\\"SampleIn\\\"\\n\\n\\tmapParamIn := make(map[string]*proIntegrator.DataType)\\n\\tmapParamOut := make(map[string]*proIntegrator.DataType)\\n\\n\\tmapParamIn[\\\"Param1\\\"] = &proIntegrator.DataType{Type: proIntegrator.DataType_STR}\\n\\tmapParamIn[\\\"Param2\\\"] = &proIntegrator.DataType{Type: proIntegrator.DataType_STR}\\n\\n\\tmapParamOut[\\\"Param1\\\"] = &proIntegrator.DataType{Type: proIntegrator.DataType_STR}\\n\\tmapParamOut[\\\"Param2\\\"] = &proIntegrator.DataType{Type: proIntegrator.DataType_STR}\\n\\n\\tin.Component.ParamsInput = mapParamIn\\n\\tin.Component.ParamsOutput = mapParamOut\\n\\treturn &in.Component\\n}\",\n \"func RunJSONSerializationTestForManagedClusterNATGatewayProfile(subject ManagedClusterNATGatewayProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterNATGatewayProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForAdditionalUnattendContent(subject AdditionalUnattendContent) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual AdditionalUnattendContent\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForServers_VirtualNetworkRule_Spec(subject Servers_VirtualNetworkRule_Spec) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual Servers_VirtualNetworkRule_Spec\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForContainerServiceLinuxProfile(subject ContainerServiceLinuxProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ContainerServiceLinuxProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForCapability(subject Capability) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual Capability\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForAgentPoolWindowsProfile(subject AgentPoolWindowsProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual AgentPoolWindowsProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func templateFunctionSnippet(entry *registry.Entry) func(name string) (interface{}, error) {\\n\\treturn func(name string) (interface{}, error) {\\n\\t\\tglog.V(log.LevelDebug).Infof(\\\"template: name '%s'\\\", name)\\n\\n\\t\\ttemplate, err := getTemplate(name)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\n\\t\\ttemplate, err = renderTemplate(template, entry, nil)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\n\\t\\tvar value interface{}\\n\\n\\t\\tif err := json.Unmarshal(template.Template.Raw, &value); err != nil {\\n\\t\\t\\treturn nil, errors.NewConfigurationError(\\\"template not JSON formatted: %v\\\", err)\\n\\t\\t}\\n\\n\\t\\tglog.V(log.LevelDebug).Infof(\\\"template: value '%v'\\\", value)\\n\\n\\t\\treturn value, nil\\n\\t}\\n}\",\n \"func RunJSONSerializationTestForDomain_Spec(subject Domain_Spec) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual Domain_Spec\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForManagedClusterSecurityProfileWorkloadIdentity(subject ManagedClusterSecurityProfileWorkloadIdentity) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterSecurityProfileWorkloadIdentity\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForUrlSigningParamIdentifier(subject UrlSigningParamIdentifier) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual UrlSigningParamIdentifier\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForManagedClusterAddonProfile(subject ManagedClusterAddonProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterAddonProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForManagedClusterOIDCIssuerProfile(subject ManagedClusterOIDCIssuerProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterOIDCIssuerProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func evaluate(node ast.Node, ext vmExtMap, tla vmExtMap, nativeFuncs map[string]*NativeFunction,\\n\\tmaxStack int, ic *importCache, traceOut io.Writer, stringOutputMode bool) (string, error) {\\n\\n\\ti, err := buildInterpreter(ext, nativeFuncs, maxStack, ic, traceOut)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\tresult, err := evaluateAux(i, node, tla)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\tvar buf bytes.Buffer\\n\\ti.stack.setCurrentTrace(manifestationTrace())\\n\\tif stringOutputMode {\\n\\t\\terr = i.manifestString(&buf, result)\\n\\t} else {\\n\\t\\terr = i.manifestAndSerializeJSON(&buf, result, true, \\\"\\\")\\n\\t}\\n\\ti.stack.clearCurrentTrace()\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\tbuf.WriteString(\\\"\\\\n\\\")\\n\\treturn buf.String(), nil\\n}\",\n \"func RunJSONSerializationTestForManagedClusterOperatorSpec(subject ManagedClusterOperatorSpec) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterOperatorSpec\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func (l *Loader) Apply(args map[string]any, componentBlocks []*ast.BlockStmt, configBlocks []*ast.BlockStmt) diag.Diagnostics {\\n\\tstart := time.Now()\\n\\tl.mut.Lock()\\n\\tdefer l.mut.Unlock()\\n\\tl.cm.controllerEvaluation.Set(1)\\n\\tdefer l.cm.controllerEvaluation.Set(0)\\n\\n\\tfor key, value := range args {\\n\\t\\tl.cache.CacheModuleArgument(key, value)\\n\\t}\\n\\tl.cache.SyncModuleArgs(args)\\n\\n\\tnewGraph, diags := l.loadNewGraph(args, componentBlocks, configBlocks)\\n\\tif diags.HasErrors() {\\n\\t\\treturn diags\\n\\t}\\n\\n\\tvar (\\n\\t\\tcomponents = make([]*ComponentNode, 0, len(componentBlocks))\\n\\t\\tcomponentIDs = make([]ComponentID, 0, len(componentBlocks))\\n\\t\\tservices = make([]*ServiceNode, 0, len(l.services))\\n\\t)\\n\\n\\ttracer := l.tracer.Tracer(\\\"\\\")\\n\\tspanCtx, span := tracer.Start(context.Background(), \\\"GraphEvaluate\\\", trace.WithSpanKind(trace.SpanKindInternal))\\n\\tdefer span.End()\\n\\n\\tlogger := log.With(l.log, \\\"trace_id\\\", span.SpanContext().TraceID())\\n\\tlevel.Info(logger).Log(\\\"msg\\\", \\\"starting complete graph evaluation\\\")\\n\\tdefer func() {\\n\\t\\tspan.SetStatus(codes.Ok, \\\"\\\")\\n\\n\\t\\tduration := time.Since(start)\\n\\t\\tlevel.Info(logger).Log(\\\"msg\\\", \\\"finished complete graph evaluation\\\", \\\"duration\\\", duration)\\n\\t\\tl.cm.componentEvaluationTime.Observe(duration.Seconds())\\n\\t}()\\n\\n\\tl.cache.ClearModuleExports()\\n\\n\\t// Evaluate all the components.\\n\\t_ = dag.WalkTopological(&newGraph, newGraph.Leaves(), func(n dag.Node) error {\\n\\t\\t_, span := tracer.Start(spanCtx, \\\"EvaluateNode\\\", trace.WithSpanKind(trace.SpanKindInternal))\\n\\t\\tspan.SetAttributes(attribute.String(\\\"node_id\\\", n.NodeID()))\\n\\t\\tdefer span.End()\\n\\n\\t\\tstart := time.Now()\\n\\t\\tdefer func() {\\n\\t\\t\\tlevel.Info(logger).Log(\\\"msg\\\", \\\"finished node evaluation\\\", \\\"node_id\\\", n.NodeID(), \\\"duration\\\", time.Since(start))\\n\\t\\t}()\\n\\n\\t\\tvar err error\\n\\n\\t\\tswitch n := n.(type) {\\n\\t\\tcase *ComponentNode:\\n\\t\\t\\tcomponents = append(components, n)\\n\\t\\t\\tcomponentIDs = append(componentIDs, n.ID())\\n\\n\\t\\t\\tif err = l.evaluate(logger, n); err != nil {\\n\\t\\t\\t\\tvar evalDiags diag.Diagnostics\\n\\t\\t\\t\\tif errors.As(err, &evalDiags) {\\n\\t\\t\\t\\t\\tdiags = append(diags, evalDiags...)\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tdiags.Add(diag.Diagnostic{\\n\\t\\t\\t\\t\\t\\tSeverity: diag.SeverityLevelError,\\n\\t\\t\\t\\t\\t\\tMessage: fmt.Sprintf(\\\"Failed to build component: %s\\\", err),\\n\\t\\t\\t\\t\\t\\tStartPos: ast.StartPos(n.Block()).Position(),\\n\\t\\t\\t\\t\\t\\tEndPos: ast.EndPos(n.Block()).Position(),\\n\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\t\\tcase *ServiceNode:\\n\\t\\t\\tservices = append(services, n)\\n\\n\\t\\t\\tif err = l.evaluate(logger, n); err != nil {\\n\\t\\t\\t\\tvar evalDiags diag.Diagnostics\\n\\t\\t\\t\\tif errors.As(err, &evalDiags) {\\n\\t\\t\\t\\t\\tdiags = append(diags, evalDiags...)\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tdiags.Add(diag.Diagnostic{\\n\\t\\t\\t\\t\\t\\tSeverity: diag.SeverityLevelError,\\n\\t\\t\\t\\t\\t\\tMessage: fmt.Sprintf(\\\"Failed to evaluate service: %s\\\", err),\\n\\t\\t\\t\\t\\t\\tStartPos: ast.StartPos(n.Block()).Position(),\\n\\t\\t\\t\\t\\t\\tEndPos: ast.EndPos(n.Block()).Position(),\\n\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\t\\tcase BlockNode:\\n\\t\\t\\tif err = l.evaluate(logger, n); err != nil {\\n\\t\\t\\t\\tdiags.Add(diag.Diagnostic{\\n\\t\\t\\t\\t\\tSeverity: diag.SeverityLevelError,\\n\\t\\t\\t\\t\\tMessage: fmt.Sprintf(\\\"Failed to evaluate node for config block: %s\\\", err),\\n\\t\\t\\t\\t\\tStartPos: ast.StartPos(n.Block()).Position(),\\n\\t\\t\\t\\t\\tEndPos: ast.EndPos(n.Block()).Position(),\\n\\t\\t\\t\\t})\\n\\t\\t\\t}\\n\\t\\t\\tif exp, ok := n.(*ExportConfigNode); ok {\\n\\t\\t\\t\\tl.cache.CacheModuleExportValue(exp.Label(), exp.Value())\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\t// We only use the error for updating the span status; we don't return the\\n\\t\\t// error because we want to evaluate as many nodes as we can.\\n\\t\\tif err != nil {\\n\\t\\t\\tspan.SetStatus(codes.Error, err.Error())\\n\\t\\t} else {\\n\\t\\t\\tspan.SetStatus(codes.Ok, \\\"\\\")\\n\\t\\t}\\n\\t\\treturn nil\\n\\t})\\n\\n\\tl.componentNodes = components\\n\\tl.serviceNodes = services\\n\\tl.graph = &newGraph\\n\\tl.cache.SyncIDs(componentIDs)\\n\\tl.blocks = componentBlocks\\n\\tl.cm.componentEvaluationTime.Observe(time.Since(start).Seconds())\\n\\tif l.globals.OnExportsChange != nil && l.cache.ExportChangeIndex() != l.moduleExportIndex {\\n\\t\\tl.moduleExportIndex = l.cache.ExportChangeIndex()\\n\\t\\tl.globals.OnExportsChange(l.cache.CreateModuleExports())\\n\\t}\\n\\treturn diags\\n}\",\n \"func TestRemoteComponent(t *testing.T) {\\n\\trunPolicyPackIntegrationTest(t, \\\"remote_component\\\", NodeJS, nil, []policyTestScenario{\\n\\t\\t{\\n\\t\\t\\tWantErrors: []string{\\n\\t\\t\\t\\t\\\"[advisory] remote-component-policy v0.0.1 resource-validation (random:index/randomString:RandomString: innerRandom)\\\",\\n\\t\\t\\t\\t\\\"can't run policy 'resource-validation' during preview: string value at .keepers.hi can't be known during preview\\\",\\n\\t\\t\\t},\\n\\t\\t\\tAdvisory: true,\\n\\t\\t},\\n\\t})\\n}\",\n \"func RunJSONSerializationTestForLoadBalancersInboundNatRule(subject LoadBalancersInboundNatRule) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual LoadBalancersInboundNatRule\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForVirtualMachine_Spec(subject VirtualMachine_Spec) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual VirtualMachine_Spec\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForProfilesEndpoint(subject ProfilesEndpoint) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ProfilesEndpoint\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForNetwork_ARM(subject Network_ARM) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual Network_ARM\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForKeyVaultSecretReference(subject KeyVaultSecretReference) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual KeyVaultSecretReference\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForManagedClustersAgentPool(subject ManagedClustersAgentPool) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClustersAgentPool\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForManagedClusterStorageProfileSnapshotController(subject ManagedClusterStorageProfileSnapshotController) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterStorageProfileSnapshotController\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func (s *Script) rawScriptSource(script string) (interface{}, error) {\\n\\tv := strings.TrimSpace(script)\\n\\tif !strings.HasPrefix(v, \\\"{\\\") && !strings.HasPrefix(v, `\\\"`) {\\n\\t\\tv = fmt.Sprintf(\\\"%q\\\", v)\\n\\t}\\n\\traw := json.RawMessage(v)\\n\\treturn &raw, nil\\n}\",\n \"func getComponentContent(name string, style string) string {\\n\\tstyleFile := fmt.Sprintf(\\\"%s.%s\\\", name, style)\\n\\tcomponentName := strings.ReplaceAll(name, \\\"-\\\", \\\" \\\")\\n\\tcomponentName = strings.Title(componentName)\\n\\tcomponentName = strings.ReplaceAll(componentName, \\\" \\\", \\\"\\\")\\n\\treturn fmt.Sprintf(\\n\\t\\t`import React from \\\"react\\\";\\nimport \\\"./%s\\\";\\n\\nconst %s = () => {\\n\\treturn
;\\n}\\n\\nexport default %s;`, styleFile, componentName, name, componentName)\\n}\",\n \"func RunJSONSerializationTestForNetworkInterface_Spec(subject NetworkInterface_Spec) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual NetworkInterface_Spec\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForIPTag(subject IPTag) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual IPTag\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForVpnClientRevokedCertificate(subject VpnClientRevokedCertificate) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual VpnClientRevokedCertificate\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForNatGatewayPropertiesFormat_ARM(subject NatGatewayPropertiesFormat_ARM) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual NatGatewayPropertiesFormat_ARM\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForManagedClusterStorageProfileFileCSIDriver(subject ManagedClusterStorageProfileFileCSIDriver) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterStorageProfileFileCSIDriver\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func (c *Codegen) AddDefaultSnippets() {\\n\\t/* common props */\\n\\tc.AddSnippet(\\\"php\\\", \\\"add($prop);\\\")\\n\\tc.AddSnippet(\\\"iblock_prop_check\\\", \\\"if ($r) { \\\"+c.LineBreak+c.Indent+\\\"echo 'Added prop with ID: ' . $r . PHP_EOL; \\\"+c.LineBreak+\\\"} else { \\\"+c.LineBreak+c.Indent+\\\"echo 'Error adding prop: ' . $ibp->LAST_ERROR . PHP_EOL; \\\"+c.LineBreak+\\\"}\\\")\\n\\n\\t/* specially for user fields */\\n\\tc.AddSnippet(\\\"uf_obj\\\", \\\"$ufo = new CUserTypeEntity;\\\")\\n\\tc.AddSnippet(\\\"uf_data_st\\\", \\\"$uf = array(\\\")\\n\\tc.AddSnippet(\\\"uf_data_en\\\", \\\");\\\")\\n\\tc.AddSnippet(\\\"uf_data_run\\\", \\\"$r = $ufo->add($uf);\\\")\\n\\tc.AddSnippet(\\\"uf_data_check\\\", \\\"if ($r) { \\\"+c.LineBreak+c.Indent+\\\"echo 'Added UserField with ID: ' . $r . PHP_EOL; \\\"+c.LineBreak+\\\"} else { \\\"+c.LineBreak+c.Indent+\\\"echo 'Error adding UserField: ' . $ufo->LAST_ERROR . PHP_EOL; \\\"+c.LineBreak+\\\"}\\\")\\n\\t// TODO - no LAST_ERROR here, catch exception?\\n\\n\\t/* specially for mail event/template */\\n\\tc.AddSnippet(\\\"mevent_obj\\\", \\\"$meo = new CEventType;\\\")\\n\\tc.AddSnippet(\\\"mevent_data_st\\\", \\\"$me = array(\\\")\\n\\tc.AddSnippet(\\\"mevent_data_en\\\", \\\");\\\")\\n\\tc.AddSnippet(\\\"mevent_run\\\", \\\"$r = $meo->add($me);\\\")\\n\\tc.AddSnippet(\\\"mevent_run_succ_wo_mm\\\", \\\"if ($r) { \\\"+c.LineBreak+c.Indent+\\\"echo 'Added MailEvent with ID: ' . $r . PHP_EOL; \\\"+c.LineBreak+\\\"} else { \\\"+c.LineBreak+c.Indent+\\\"echo 'Error adding MailEvent: ' . $meo->LAST_ERROR . PHP_EOL; \\\"+c.LineBreak+\\\"}\\\")\\n\\tc.AddSnippet(\\\"mevent_run_check\\\", \\\"if ($r) {\\\")\\n\\tc.AddSnippet(\\\"mevent_run_check_else\\\", \\\"} else {\\\"+c.LineBreak+c.Indent+\\\"echo 'Error adding MailEvent: ' . $meo->LAST_ERROR . PHP_EOL; \\\"+c.LineBreak+\\\"}\\\")\\n\\tc.AddSnippet(\\\"mevent_succ\\\", c.Indent+\\\"echo 'Added MailEvent with ID: ' . $r . PHP_EOL;\\\"+c.LineBreak)\\n\\n\\tc.AddSnippet(\\\"mtpl_warn\\\", c.Indent+\\\"// TODO - set proper LID for template!\\\")\\n\\tc.AddSnippet(\\\"mtpl_obj\\\", \\\"$mmo = new CEventMessage;\\\")\\n\\tc.AddSnippet(\\\"mtpl_data_st\\\", \\\"$mm = array(\\\")\\n\\tc.AddSnippet(\\\"mtpl_data_en\\\", \\\");\\\")\\n\\tc.AddSnippet(\\\"mtpl_run\\\", \\\"$r = $mmo->add($mm);\\\")\\n\\tc.AddSnippet(\\\"mtpl_run_check\\\", c.Indent+\\\"if ($r) {\\\"+c.LineBreak+c.Indent+c.Indent+\\\"echo 'Added MailTemplate with ID: ' . $r . PHP_EOL;\\\"+c.LineBreak+c.Indent+\\\"} else {\\\"+c.LineBreak+c.Indent+c.Indent+\\\"echo 'Error adding MailTemplate: ' . $mmo->LAST_ERROR . PHP_EOL;\\\"+c.LineBreak+c.Indent+\\\"}\\\")\\n\\n\\t/* common, group 2 */\\n\\tc.AddSnippet(\\\"done\\\", \\\"echo 'Done!' . PHP_EOL;\\\")\\n}\",\n \"func (l *Loader) populateComponentNodes(g *dag.Graph, componentBlocks []*ast.BlockStmt) diag.Diagnostics {\\n\\tvar (\\n\\t\\tdiags diag.Diagnostics\\n\\t\\tblockMap = make(map[string]*ast.BlockStmt, len(componentBlocks))\\n\\t)\\n\\tfor _, block := range componentBlocks {\\n\\t\\tvar c *ComponentNode\\n\\t\\tid := BlockComponentID(block).String()\\n\\n\\t\\tif orig, redefined := blockMap[id]; redefined {\\n\\t\\t\\tdiags.Add(diag.Diagnostic{\\n\\t\\t\\t\\tSeverity: diag.SeverityLevelError,\\n\\t\\t\\t\\tMessage: fmt.Sprintf(\\\"Component %s already declared at %s\\\", id, ast.StartPos(orig).Position()),\\n\\t\\t\\t\\tStartPos: block.NamePos.Position(),\\n\\t\\t\\t\\tEndPos: block.NamePos.Add(len(id) - 1).Position(),\\n\\t\\t\\t})\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\t\\tblockMap[id] = block\\n\\n\\t\\t// Check the graph from the previous call to Load to see we can copy an\\n\\t\\t// existing instance of ComponentNode.\\n\\t\\tif exist := l.graph.GetByID(id); exist != nil {\\n\\t\\t\\tc = exist.(*ComponentNode)\\n\\t\\t\\tc.UpdateBlock(block)\\n\\t\\t} else {\\n\\t\\t\\tcomponentName := block.GetBlockName()\\n\\t\\t\\tregistration, exists := l.componentReg.Get(componentName)\\n\\t\\t\\tif !exists {\\n\\t\\t\\t\\tdiags.Add(diag.Diagnostic{\\n\\t\\t\\t\\t\\tSeverity: diag.SeverityLevelError,\\n\\t\\t\\t\\t\\tMessage: fmt.Sprintf(\\\"Unrecognized component name %q\\\", componentName),\\n\\t\\t\\t\\t\\tStartPos: block.NamePos.Position(),\\n\\t\\t\\t\\t\\tEndPos: block.NamePos.Add(len(componentName) - 1).Position(),\\n\\t\\t\\t\\t})\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\n\\n\\t\\t\\tif registration.Singleton && block.Label != \\\"\\\" {\\n\\t\\t\\t\\tdiags.Add(diag.Diagnostic{\\n\\t\\t\\t\\t\\tSeverity: diag.SeverityLevelError,\\n\\t\\t\\t\\t\\tMessage: fmt.Sprintf(\\\"Component %q does not support labels\\\", componentName),\\n\\t\\t\\t\\t\\tStartPos: block.LabelPos.Position(),\\n\\t\\t\\t\\t\\tEndPos: block.LabelPos.Add(len(block.Label) + 1).Position(),\\n\\t\\t\\t\\t})\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\n\\n\\t\\t\\tif !registration.Singleton && block.Label == \\\"\\\" {\\n\\t\\t\\t\\tdiags.Add(diag.Diagnostic{\\n\\t\\t\\t\\t\\tSeverity: diag.SeverityLevelError,\\n\\t\\t\\t\\t\\tMessage: fmt.Sprintf(\\\"Component %q must have a label\\\", componentName),\\n\\t\\t\\t\\t\\tStartPos: block.NamePos.Position(),\\n\\t\\t\\t\\t\\tEndPos: block.NamePos.Add(len(componentName) - 1).Position(),\\n\\t\\t\\t\\t})\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\n\\n\\t\\t\\tif registration.Singleton && l.isModule() {\\n\\t\\t\\t\\tdiags.Add(diag.Diagnostic{\\n\\t\\t\\t\\t\\tSeverity: diag.SeverityLevelError,\\n\\t\\t\\t\\t\\tMessage: fmt.Sprintf(\\\"Component %q is a singleton and unsupported inside a module\\\", componentName),\\n\\t\\t\\t\\t\\tStartPos: block.NamePos.Position(),\\n\\t\\t\\t\\t\\tEndPos: block.NamePos.Add(len(componentName) - 1).Position(),\\n\\t\\t\\t\\t})\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\n\\n\\t\\t\\t// Create a new component\\n\\t\\t\\tc = NewComponentNode(l.globals, registration, block)\\n\\t\\t}\\n\\n\\t\\tg.Add(c)\\n\\t}\\n\\n\\treturn diags\\n}\",\n \"func RunJSONSerializationTestForManagedClusterSKU(subject ManagedClusterSKU) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterSKU\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForManagedClusterWindowsProfile(subject ManagedClusterWindowsProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterWindowsProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForPowerState(subject PowerState) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual PowerState\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForResourceReference(subject ResourceReference) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ResourceReference\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForResourceReference(subject ResourceReference) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ResourceReference\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func ParseApplicationComponent(jsn string) (acomp v1alpha1.Component, err error) {\\n\\terr = json.Unmarshal([]byte(jsn), &acomp)\\n\\treturn\\n}\",\n \"func Render(comp Component, container *js.Object) {\\n\\tcomp.Reconcile(nil)\\n\\tcontainer.Call(\\\"appendChild\\\", comp.Node())\\n}\",\n \"func RunJSONSerializationTestForImageReference(subject ImageReference) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ImageReference\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForVpnClientConfiguration(subject VpnClientConfiguration) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual VpnClientConfiguration\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func (opa *client) EvaluatePolicy(policy string, input []byte) (*EvaluatePolicyResponse, error) {\\n\\tlog := opa.logger.Named(\\\"Evalute Policy\\\")\\n\\n\\trequest, err := json.Marshal(&EvalutePolicyRequest{Input: input})\\n\\tif err != nil {\\n\\t\\tlog.Error(\\\"failed to encode OPA input\\\", zap.Error(err), zap.String(\\\"input\\\", string(input)))\\n\\t\\treturn nil, fmt.Errorf(\\\"failed to encode OPA input: %s\\\", err)\\n\\t}\\n\\n\\thttpResponse, err := opa.httpClient.Post(opa.getDataQueryURL(getOpaPackagePath(policy)), \\\"application/json\\\", bytes.NewReader(request))\\n\\tif err != nil {\\n\\t\\tlog.Error(\\\"http request to OPA failed\\\", zap.Error(err))\\n\\t\\treturn nil, fmt.Errorf(\\\"http request to OPA failed: %s\\\", err)\\n\\t}\\n\\tif httpResponse.StatusCode != http.StatusOK {\\n\\t\\tlog.Error(\\\"http response status from OPA not OK\\\", zap.Any(\\\"status\\\", httpResponse.Status))\\n\\t\\treturn nil, fmt.Errorf(\\\"http response status not OK\\\")\\n\\t}\\n\\n\\tresponse := &EvaluatePolicyResponse{}\\n\\terr = json.NewDecoder(httpResponse.Body).Decode(&response)\\n\\tif err != nil {\\n\\t\\tlog.Error(\\\"failed to decode OPA result\\\", zap.Error(err))\\n\\t\\treturn nil, fmt.Errorf(\\\"failed to decode OPA result: %s\\\", err)\\n\\t}\\n\\n\\treturn response, nil\\n}\",\n \"func RunJSONSerializationTestForUrlSigningParamIdentifier_ARM(subject UrlSigningParamIdentifier_ARM) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual UrlSigningParamIdentifier_ARM\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForManagedClusterLoadBalancerProfile(subject ManagedClusterLoadBalancerProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterLoadBalancerProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForNetworkInterface_Spec_ARM(subject NetworkInterface_Spec_ARM) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual NetworkInterface_Spec_ARM\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func TestCSharpCompat(t *testing.T) {\\n\\tjs := `{\\n \\\"store\\\": {\\n \\\"book\\\": [\\n {\\n \\\"category\\\": \\\"reference\\\",\\n \\\"author\\\": \\\"Nigel Rees\\\",\\n \\\"title\\\": \\\"Sayings of the Century\\\",\\n \\\"price\\\": 8.95\\n },\\n {\\n \\\"category\\\": \\\"fiction\\\",\\n \\\"author\\\": \\\"Evelyn Waugh\\\",\\n \\\"title\\\": \\\"Sword of Honour\\\",\\n \\\"price\\\": 12.99\\n },\\n {\\n \\\"category\\\": \\\"fiction\\\",\\n \\\"author\\\": \\\"Herman Melville\\\",\\n \\\"title\\\": \\\"Moby Dick\\\",\\n \\\"isbn\\\": \\\"0-553-21311-3\\\",\\n \\\"price\\\": 8.99\\n },\\n {\\n \\\"category\\\": \\\"fiction\\\",\\n \\\"author\\\": \\\"J. R. R. Tolkien\\\",\\n \\\"title\\\": \\\"The Lord of the Rings\\\",\\n \\\"isbn\\\": \\\"0-395-19395-8\\\",\\n \\\"price\\\": null\\n }\\n ],\\n \\\"bicycle\\\": {\\n \\\"color\\\": \\\"red\\\",\\n \\\"price\\\": 19.95\\n }\\n },\\n \\\"expensive\\\": 10,\\n \\\"data\\\": null\\n}`\\n\\n\\ttestCases := []pathTestCase{\\n\\t\\t{\\\"$.store.book[*].author\\\", `[\\\"Nigel Rees\\\",\\\"Evelyn Waugh\\\",\\\"Herman Melville\\\",\\\"J. R. R. Tolkien\\\"]`},\\n\\t\\t{\\\"$..author\\\", `[\\\"Nigel Rees\\\",\\\"Evelyn Waugh\\\",\\\"Herman Melville\\\",\\\"J. R. R. Tolkien\\\"]`},\\n\\t\\t{\\\"$.store.*\\\", `[[{\\\"category\\\":\\\"reference\\\",\\\"author\\\":\\\"Nigel Rees\\\",\\\"title\\\":\\\"Sayings of the Century\\\",\\\"price\\\":8.95},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Evelyn Waugh\\\",\\\"title\\\":\\\"Sword of Honour\\\",\\\"price\\\":12.99},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Herman Melville\\\",\\\"title\\\":\\\"Moby Dick\\\",\\\"isbn\\\":\\\"0-553-21311-3\\\",\\\"price\\\":8.99},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"J. R. R. Tolkien\\\",\\\"title\\\":\\\"The Lord of the Rings\\\",\\\"isbn\\\":\\\"0-395-19395-8\\\",\\\"price\\\":null}],{\\\"color\\\":\\\"red\\\",\\\"price\\\":19.95}]`},\\n\\t\\t{\\\"$.store..price\\\", `[19.95,8.95,12.99,8.99,null]`},\\n\\t\\t{\\\"$..book[2]\\\", `[{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Herman Melville\\\",\\\"title\\\":\\\"Moby Dick\\\",\\\"isbn\\\":\\\"0-553-21311-3\\\",\\\"price\\\":8.99}]`},\\n\\t\\t{\\\"$..book[-2]\\\", `[{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Herman Melville\\\",\\\"title\\\":\\\"Moby Dick\\\",\\\"isbn\\\":\\\"0-553-21311-3\\\",\\\"price\\\":8.99}]`},\\n\\t\\t{\\\"$..book[0,1]\\\", `[{\\\"category\\\":\\\"reference\\\",\\\"author\\\":\\\"Nigel Rees\\\",\\\"title\\\":\\\"Sayings of the Century\\\",\\\"price\\\":8.95},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Evelyn Waugh\\\",\\\"title\\\":\\\"Sword of Honour\\\",\\\"price\\\":12.99}]`},\\n\\t\\t{\\\"$..book[:2]\\\", `[{\\\"category\\\":\\\"reference\\\",\\\"author\\\":\\\"Nigel Rees\\\",\\\"title\\\":\\\"Sayings of the Century\\\",\\\"price\\\":8.95},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Evelyn Waugh\\\",\\\"title\\\":\\\"Sword of Honour\\\",\\\"price\\\":12.99}]`},\\n\\t\\t{\\\"$..book[1:2]\\\", `[{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Evelyn Waugh\\\",\\\"title\\\":\\\"Sword of Honour\\\",\\\"price\\\":12.99}]`},\\n\\t\\t{\\\"$..book[-2:]\\\", `[{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Herman Melville\\\",\\\"title\\\":\\\"Moby Dick\\\",\\\"isbn\\\":\\\"0-553-21311-3\\\",\\\"price\\\":8.99},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"J. R. R. Tolkien\\\",\\\"title\\\":\\\"The Lord of the Rings\\\",\\\"isbn\\\":\\\"0-395-19395-8\\\",\\\"price\\\":null}]`},\\n\\t\\t{\\\"$..book[2:]\\\", `[{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Herman Melville\\\",\\\"title\\\":\\\"Moby Dick\\\",\\\"isbn\\\":\\\"0-553-21311-3\\\",\\\"price\\\":8.99},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"J. R. R. Tolkien\\\",\\\"title\\\":\\\"The Lord of the Rings\\\",\\\"isbn\\\":\\\"0-395-19395-8\\\",\\\"price\\\":null}]`},\\n\\t\\t{\\\"\\\", `[{\\\"store\\\":{\\\"book\\\":[{\\\"category\\\":\\\"reference\\\",\\\"author\\\":\\\"Nigel Rees\\\",\\\"title\\\":\\\"Sayings of the Century\\\",\\\"price\\\":8.95},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Evelyn Waugh\\\",\\\"title\\\":\\\"Sword of Honour\\\",\\\"price\\\":12.99},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Herman Melville\\\",\\\"title\\\":\\\"Moby Dick\\\",\\\"isbn\\\":\\\"0-553-21311-3\\\",\\\"price\\\":8.99},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"J. R. R. Tolkien\\\",\\\"title\\\":\\\"The Lord of the Rings\\\",\\\"isbn\\\":\\\"0-395-19395-8\\\",\\\"price\\\":null}],\\\"bicycle\\\":{\\\"color\\\":\\\"red\\\",\\\"price\\\":19.95}},\\\"expensive\\\":10,\\\"data\\\":null}]`},\\n\\t\\t{\\\"$.*\\\", `[{\\\"book\\\":[{\\\"category\\\":\\\"reference\\\",\\\"author\\\":\\\"Nigel Rees\\\",\\\"title\\\":\\\"Sayings of the Century\\\",\\\"price\\\":8.95},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Evelyn Waugh\\\",\\\"title\\\":\\\"Sword of Honour\\\",\\\"price\\\":12.99},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"Herman Melville\\\",\\\"title\\\":\\\"Moby Dick\\\",\\\"isbn\\\":\\\"0-553-21311-3\\\",\\\"price\\\":8.99},{\\\"category\\\":\\\"fiction\\\",\\\"author\\\":\\\"J. R. R. Tolkien\\\",\\\"title\\\":\\\"The Lord of the Rings\\\",\\\"isbn\\\":\\\"0-395-19395-8\\\",\\\"price\\\":null}],\\\"bicycle\\\":{\\\"color\\\":\\\"red\\\",\\\"price\\\":19.95}},10,null]`},\\n\\t\\t{\\\"$..invalidfield\\\", `[]`},\\n\\t}\\n\\n\\tfor _, tc := range testCases {\\n\\t\\tt.Run(tc.path, func(t *testing.T) {\\n\\t\\t\\ttc.testUnmarshalGet(t, js)\\n\\t\\t})\\n\\t}\\n\\n\\tt.Run(\\\"bad cases\\\", func(t *testing.T) {\\n\\t\\t_, ok := unmarshalGet(t, js, `$..book[*].author\\\"`)\\n\\t\\trequire.False(t, ok)\\n\\t})\\n}\",\n \"func RunJSONSerializationTestForManagedClusterPodIdentityProfile(subject ManagedClusterPodIdentityProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterPodIdentityProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForManagedClusterManagedOutboundIPProfile(subject ManagedClusterManagedOutboundIPProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterManagedOutboundIPProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForAgentPoolNetworkProfile_STATUS(subject AgentPoolNetworkProfile_STATUS) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual AgentPoolNetworkProfile_STATUS\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForApplicationInsightsComponentProperties_STATUS_ARM(subject ApplicationInsightsComponentProperties_STATUS_ARM) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ApplicationInsightsComponentProperties_STATUS_ARM\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForManagedClusterSecurityProfile(subject ManagedClusterSecurityProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterSecurityProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForProfiles_Endpoint_Spec_ARM(subject Profiles_Endpoint_Spec_ARM) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual Profiles_Endpoint_Spec_ARM\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func generatePerNodeConfigSnippet(pathStructName string, nodeData *ypathgen.NodeData, fakeRootTypeName, schemaStructPkgAccessor string, preferShadowPath bool) (GoPerNodeCodeSnippet, goTypeData, util.Errors) {\\n\\t// TODO: See if a float32 -> binary helper should be provided\\n\\t// for setting a float32 leaf.\\n\\tvar errs util.Errors\\n\\ts := struct {\\n\\t\\tPathStructName string\\n\\t\\tGoType goTypeData\\n\\t\\tGoFieldName string\\n\\t\\tGoStructTypeName string\\n\\t\\tYANGPath string\\n\\t\\tFakeRootTypeName string\\n\\t\\tIsScalarField bool\\n\\t\\tIsRoot bool\\n\\t\\tSchemaStructPkgAccessor string\\n\\t\\tWildcardSuffix string\\n\\t\\tSpecialConversionFn string\\n\\t\\tPreferShadowPath bool\\n\\t}{\\n\\t\\tPathStructName: pathStructName,\\n\\t\\tGoType: goTypeData{\\n\\t\\t\\tGoTypeName: nodeData.GoTypeName,\\n\\t\\t\\tTransformedGoTypeName: transformGoTypeName(nodeData),\\n\\t\\t\\tIsLeaf: nodeData.IsLeaf,\\n\\t\\t\\tHasDefault: nodeData.HasDefault,\\n\\t\\t},\\n\\t\\tGoFieldName: nodeData.GoFieldName,\\n\\t\\tGoStructTypeName: nodeData.SubsumingGoStructName,\\n\\t\\tYANGPath: nodeData.YANGPath,\\n\\t\\tFakeRootTypeName: fakeRootTypeName,\\n\\t\\tIsScalarField: nodeData.IsScalarField,\\n\\t\\tIsRoot: nodeData.YANGPath == \\\"/\\\",\\n\\t\\tWildcardSuffix: ypathgen.WildcardSuffix,\\n\\t\\tSchemaStructPkgAccessor: schemaStructPkgAccessor,\\n\\t\\tPreferShadowPath: preferShadowPath,\\n\\t}\\n\\tvar getMethod, replaceMethod, convertHelper strings.Builder\\n\\tif nodeData.IsLeaf {\\n\\t\\t// Leaf types use their parent GoStruct to unmarshal, before\\n\\t\\t// being retrieved out when returned to the user.\\n\\t\\tif err := goLeafConvertTemplate.Execute(&convertHelper, s); err != nil {\\n\\t\\t\\tutil.AppendErr(errs, err)\\n\\t\\t}\\n\\t}\\n\\tif err := goNodeSetTemplate.Execute(&replaceMethod, s); err != nil {\\n\\t\\tutil.AppendErr(errs, err)\\n\\t}\\n\\tif err := goNodeGetTemplate.Execute(&getMethod, s); err != nil {\\n\\t\\tutil.AppendErr(errs, err)\\n\\t}\\n\\n\\treturn GoPerNodeCodeSnippet{\\n\\t\\tPathStructName: pathStructName,\\n\\t\\tGetMethod: getMethod.String(),\\n\\t\\tConvertHelper: convertHelper.String(),\\n\\t\\tReplaceMethod: replaceMethod.String(),\\n\\t}, s.GoType, errs\\n}\",\n \"func RunJSONSerializationTestForEndpointProperties_ARM(subject EndpointProperties_ARM) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual EndpointProperties_ARM\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForVirtualMachineNetworkInterfaceIPConfiguration(subject VirtualMachineNetworkInterfaceIPConfiguration) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual VirtualMachineNetworkInterfaceIPConfiguration\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForManagedClusterWorkloadAutoScalerProfile(subject ManagedClusterWorkloadAutoScalerProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterWorkloadAutoScalerProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForProfile_Spec_ARM(subject Profile_Spec_ARM) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual Profile_Spec_ARM\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForManagedClusterLoadBalancerProfile_OutboundIPs(subject ManagedClusterLoadBalancerProfile_OutboundIPs) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterLoadBalancerProfile_OutboundIPs\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForAdditionalCapabilities(subject AdditionalCapabilities) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual AdditionalCapabilities\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForFailoverGroupReadOnlyEndpoint(subject FailoverGroupReadOnlyEndpoint) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual FailoverGroupReadOnlyEndpoint\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForSearchService_Spec_ARM(subject SearchService_Spec_ARM) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual SearchService_Spec_ARM\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForNetworkInterfacePropertiesFormat_ARM(subject NetworkInterfacePropertiesFormat_ARM) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual NetworkInterfacePropertiesFormat_ARM\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForManagedClusterOperatorSecrets(subject ManagedClusterOperatorSecrets) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ManagedClusterOperatorSecrets\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func (p *Parser) Load(filename string) (string, error) {\\n\\tdirectory := filepath.Dir(filename)\\n\\tdata, err := ioutil.ReadFile(filename)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\tvm := jsonnet.MakeVM()\\n\\tvm.Importer(&jsonnet.FileImporter{\\n\\t\\tJPaths: []string{directory},\\n\\t})\\n\\n\\treturn vm.EvaluateAnonymousSnippet(filename, string(data))\\n}\",\n \"func (c *Codegen) AddSnippet(key, value string) {\\n\\tc.phpSnippets[key] = value\\n}\",\n \"func TestConstructPlainGo(t *testing.T) {\\n\\ttests := []struct {\\n\\t\\tcomponentDir string\\n\\t\\texpectedResourceCount int\\n\\t\\tenv []string\\n\\t}{\\n\\t\\t{\\n\\t\\t\\tcomponentDir: \\\"testcomponent\\\",\\n\\t\\t\\texpectedResourceCount: 9,\\n\\t\\t\\t// TODO[pulumi/pulumi#5455]: Dynamic providers fail to load when used from multi-lang components.\\n\\t\\t\\t// Until we've addressed this, set PULUMI_TEST_YARN_LINK_PULUMI, which tells the integration test\\n\\t\\t\\t// module to run `yarn install && yarn link @pulumi/pulumi` in the Go program's directory, allowing\\n\\t\\t\\t// the Node.js dynamic provider plugin to load.\\n\\t\\t\\t// When the underlying issue has been fixed, the use of this environment variable inside the integration\\n\\t\\t\\t// test module should be removed.\\n\\t\\t\\tenv: []string{\\\"PULUMI_TEST_YARN_LINK_PULUMI=true\\\"},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tcomponentDir: \\\"testcomponent-python\\\",\\n\\t\\t\\texpectedResourceCount: 9,\\n\\t\\t\\tenv: []string{pulumiRuntimeVirtualEnv(t, filepath.Join(\\\"..\\\", \\\"..\\\"))},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tcomponentDir: \\\"testcomponent-go\\\",\\n\\t\\t\\texpectedResourceCount: 8, // One less because no dynamic provider.\\n\\t\\t},\\n\\t}\\n\\n\\tfor _, test := range tests {\\n\\t\\tt.Run(test.componentDir, func(t *testing.T) {\\n\\t\\t\\tpathEnv := pathEnv(t, filepath.Join(\\\"construct_component_plain\\\", test.componentDir))\\n\\t\\t\\tintegration.ProgramTest(t,\\n\\t\\t\\t\\toptsForConstructPlainGo(t, test.expectedResourceCount, append(test.env, pathEnv)...))\\n\\t\\t})\\n\\t}\\n}\",\n \"func evaluateAst(program *ast.RootNode) object.Object {\\n\\tenv := object.NewEnvironment()\\n\\treturn evaluator.Eval(program, env)\\n}\",\n \"func RunJSONSerializationTestForContainerServiceNetworkProfile_STATUS(subject ContainerServiceNetworkProfile_STATUS) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual ContainerServiceNetworkProfile_STATUS\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\",\n \"func RunJSONSerializationTestForHardwareProfile(subject HardwareProfile) string {\\n\\t// Serialize to JSON\\n\\tbin, err := json.Marshal(subject)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Deserialize back into memory\\n\\tvar actual HardwareProfile\\n\\terr = json.Unmarshal(bin, &actual)\\n\\tif err != nil {\\n\\t\\treturn err.Error()\\n\\t}\\n\\n\\t// Check for outcome\\n\\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\\n\\tif !match {\\n\\t\\tactualFmt := pretty.Sprint(actual)\\n\\t\\tsubjectFmt := pretty.Sprint(subject)\\n\\t\\tresult := diff.Diff(subjectFmt, actualFmt)\\n\\t\\treturn result\\n\\t}\\n\\n\\treturn \\\"\\\"\\n}\"\n]"},"negative_scores":{"kind":"list like","value":["0.6018792","0.5632424","0.448362","0.4453841","0.43523085","0.43367103","0.42906657","0.42196247","0.42056364","0.419578","0.41669178","0.4136577","0.4100212","0.4100212","0.4100212","0.40901154","0.40751195","0.40624303","0.40336677","0.4032413","0.40148476","0.4005937","0.40048996","0.40017948","0.39676642","0.3966732","0.39613116","0.39562455","0.39369887","0.39339995","0.39264905","0.39227432","0.39216796","0.3915142","0.390602","0.38871023","0.38829404","0.38703528","0.3870308","0.38615695","0.38598156","0.38577735","0.38569838","0.38564745","0.38560942","0.38530016","0.38443363","0.3840074","0.38186496","0.38124526","0.3807272","0.37960362","0.3789595","0.37885532","0.37860203","0.3777633","0.37747455","0.3771837","0.37686276","0.37654698","0.3762925","0.3757735","0.37542987","0.37514305","0.3741917","0.37416518","0.3738901","0.3738901","0.37358877","0.37295392","0.37287024","0.37278968","0.37262818","0.37242624","0.37215602","0.37182292","0.3717205","0.37169397","0.37115824","0.3711554","0.3702625","0.3700985","0.37000218","0.36971915","0.3695241","0.36944655","0.36940175","0.36936027","0.3691283","0.36905685","0.36877945","0.3686932","0.36793214","0.36780158","0.3673183","0.36706612","0.3661111","0.36606506","0.36542553","0.36492112"],"string":"[\n \"0.6018792\",\n \"0.5632424\",\n \"0.448362\",\n \"0.4453841\",\n \"0.43523085\",\n \"0.43367103\",\n \"0.42906657\",\n \"0.42196247\",\n \"0.42056364\",\n \"0.419578\",\n \"0.41669178\",\n \"0.4136577\",\n \"0.4100212\",\n \"0.4100212\",\n \"0.4100212\",\n \"0.40901154\",\n \"0.40751195\",\n \"0.40624303\",\n \"0.40336677\",\n \"0.4032413\",\n \"0.40148476\",\n \"0.4005937\",\n \"0.40048996\",\n \"0.40017948\",\n \"0.39676642\",\n \"0.3966732\",\n \"0.39613116\",\n \"0.39562455\",\n \"0.39369887\",\n \"0.39339995\",\n \"0.39264905\",\n \"0.39227432\",\n \"0.39216796\",\n \"0.3915142\",\n \"0.390602\",\n \"0.38871023\",\n \"0.38829404\",\n \"0.38703528\",\n \"0.3870308\",\n \"0.38615695\",\n \"0.38598156\",\n \"0.38577735\",\n \"0.38569838\",\n \"0.38564745\",\n \"0.38560942\",\n \"0.38530016\",\n \"0.38443363\",\n \"0.3840074\",\n \"0.38186496\",\n \"0.38124526\",\n \"0.3807272\",\n \"0.37960362\",\n \"0.3789595\",\n \"0.37885532\",\n \"0.37860203\",\n \"0.3777633\",\n \"0.37747455\",\n \"0.3771837\",\n \"0.37686276\",\n \"0.37654698\",\n \"0.3762925\",\n \"0.3757735\",\n \"0.37542987\",\n \"0.37514305\",\n \"0.3741917\",\n \"0.37416518\",\n \"0.3738901\",\n \"0.3738901\",\n \"0.37358877\",\n \"0.37295392\",\n \"0.37287024\",\n \"0.37278968\",\n \"0.37262818\",\n \"0.37242624\",\n \"0.37215602\",\n \"0.37182292\",\n \"0.3717205\",\n \"0.37169397\",\n \"0.37115824\",\n \"0.3711554\",\n \"0.3702625\",\n \"0.3700985\",\n \"0.37000218\",\n \"0.36971915\",\n \"0.3695241\",\n \"0.36944655\",\n \"0.36940175\",\n \"0.36936027\",\n \"0.3691283\",\n \"0.36905685\",\n \"0.36877945\",\n \"0.3686932\",\n \"0.36793214\",\n \"0.36780158\",\n \"0.3673183\",\n \"0.36706612\",\n \"0.3661111\",\n \"0.36606506\",\n \"0.36542553\",\n \"0.36492112\"\n]"},"document_score":{"kind":"string","value":"0.8140482"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":105057,"cells":{"query":{"kind":"string","value":"Get returns latest metrics from singleton"},"document":{"kind":"string","value":"func Get() []Metric {\n\tsingleton.mu.Lock()\n\thosts := singleton.hosts\n\tsingleton.mu.Unlock()\n\n\treturn hosts\n}"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["func (h *singleLhcNodeHarness) getMetrics() *metrics {\n\treturn &metrics{\n\t\ttimeSinceLastCommitMillis: h.metricRegistry.Get(\"ConsensusAlgo.LeanHelix.TimeSinceLastCommit.Millis\").(*metric.Histogram),\n\t\ttimeSinceLastElectionMillis: h.metricRegistry.Get(\"ConsensusAlgo.LeanHelix.TimeSinceLastElection.Millis\").(*metric.Histogram),\n\t\tcurrentElectionCount: h.metricRegistry.Get(\"ConsensusAlgo.LeanHelix.CurrentElection.Number\").(*metric.Gauge),\n\t\tcurrentLeaderMemberId: h.metricRegistry.Get(\"ConsensusAlgo.LeanHelix.CurrentLeaderMemberId.Number\").(*metric.Text),\n\t\tlastCommittedTime: h.metricRegistry.Get(\"ConsensusAlgo.LeanHelix.LastCommitted.TimeNano\").(*metric.Gauge),\n\t}\n}","func (s SolrPlugin) FetchMetrics() (map[string]interface{}, error) {\n\tstat := make(map[string]interface{})\n\tfor core, stats := range s.Stats {\n\t\tfor k, v := range stats {\n\t\t\tstat[core+\"_\"+k] = v\n\t\t}\n\t}\n\treturn stat, nil\n}","func (e Entry) GetMetrics(timeout time.Duration, h heimdall.Doer, debug bool) (Metrics, error) {\n\tvar m Metrics\n\n\t// Let's set the stuff we know already.\n\tm.Address = e.Address\n\tm.Regexp = e.Regexp\n\tm.CapturedAt = time.Now().UTC()\n\n\t// Set a timeout.\n\tctx, cancel := context.WithTimeout(context.Background(), timeout)\n\tdefer cancel()\n\n\t// Setup the request.\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, e.Address, nil)\n\tif err != nil {\n\t\treturn m, err\n\t}\n\n\tif debug {\n\t\tfmt.Printf(\"%#v\\n\", req)\n\t}\n\n\t// Let's do the request.\n\tstart := time.Now()\n\tres, err := h.Do(req)\n\tif err != nil {\n\t\treturn m, err\n\t}\n\n\t// We don't need the body unless we've got a regexp.\n\tif e.Regexp != \"\" {\n\t\tbody, err := ioutil.ReadAll(res.Body)\n\t\tif err != nil {\n\t\t\treturn m, err\n\t\t}\n\t\t// Do the regexp here and assign the value.\n\t\tmatch, _ := regexp.MatchString(e.Regexp, string(body))\n\t\tm.RegexpStatus = match\n\t}\n\ttook := time.Since(start)\n\n\t// Set the last few values\n\tm.StatusCode = res.StatusCode\n\tm.ResponseTime = took\n\n\tif debug {\n\t\tfmt.Printf(\"Result: %#v\\n\", res)\n\t\tfmt.Printf(\"Time Taken: %s\\n\", took)\n\t\tfmt.Printf(\"Metrics: %#v\\n\", m)\n\t}\n\n\tif ctx.Err() != nil {\n\t\treturn m, errors.New(\"context deadline exceeded\")\n\t}\n\treturn m, nil\n}","func (ms *metricsStore) getMetricData(currentTime time.Time) pmetric.Metrics {\n\tms.RLock()\n\tdefer ms.RUnlock()\n\n\tout := pmetric.NewMetrics()\n\tfor _, mds := range ms.metricsCache {\n\t\tfor i := range mds {\n\t\t\t// Set datapoint timestamp to be time of retrieval from cache.\n\t\t\tapplyCurrentTime(mds[i].Metrics, currentTime)\n\t\t\tinternaldata.OCToMetrics(mds[i].Node, mds[i].Resource, mds[i].Metrics).ResourceMetrics().MoveAndAppendTo(out.ResourceMetrics())\n\t\t}\n\t}\n\n\treturn out\n}","func (m Plugin) FetchMetrics() (map[string]float64, error) {\n\tresp, err := http.Get(fmt.Sprintf(\"http://%s/stats\", m.Target))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\tstats := struct {\n\t\tConnections float64 `json:\"connections\"`\n\t\tTotalConnections float64 `json:\"total_connections\"`\n\t\tTotalMessages float64 `json:\"total_messages\"`\n\t\tConnectErrors float64 `json:\"connect_errors\"`\n\t\tMessageErrors float64 `json:\"message_errors\"`\n\t\tClosingConnections float64 `json:\"closing_connections\"`\n\t}{}\n\tif err := json.NewDecoder(resp.Body).Decode(&stats); err != nil {\n\t\treturn nil, err\n\t}\n\tret := make(map[string]float64, 6)\n\tret[\"conn_current\"] = stats.Connections\n\tret[\"conn_total\"] = stats.TotalConnections\n\tret[\"conn_errors\"] = stats.ConnectErrors\n\tret[\"conn_closing\"] = stats.ClosingConnections\n\tret[\"messages_total\"] = stats.TotalMessages\n\tret[\"messages_errors\"] = stats.MessageErrors\n\n\treturn ret, nil\n}","func (m RedisPlugin) FetchMetrics() (map[string]interface{}, error) {\n\n\tpubClient := redis.NewClient(&m.PubRedisOpt)\n\tsubClient := redis.NewClient(&m.SubRedisOpt)\n\n\tsubscribe, err := subClient.Subscribe(m.ChannelName)\n\tif err != nil {\n\t\tlogger.Errorf(\"Failed to subscribe. %s\", err)\n\t\treturn nil, err\n\t}\n\tdefer subscribe.Close()\n\tif _, err := pubClient.Publish(m.ChannelName, m.Message).Result(); err != nil {\n\t\tlogger.Errorf(\"Failed to publish. %s\", err)\n\t\treturn nil, err\n\t}\n\tstart := time.Now()\n\tif _, err := subscribe.ReceiveMessage(); err != nil {\n\t\tlogger.Infof(\"Failed to calculate capacity. (The cause may be that AWS Elasticache Redis has no `CONFIG` command.) Skip these metrics. %s\", err)\n\t\treturn nil, err\n\t}\n\tduration := time.Now().Sub(start)\n\n\treturn map[string]interface{}{m.metricName(): float64(duration) / float64(time.Microsecond)}, nil\n\n}","func (s *Postgres) Get(filter Filter) ([]Metric, error) {\n\tmetrics := make([]Metric, 0)\n\n\terr := s.db.Model(&metrics).\n\t\tWhere(\"created_at >= ?\", filter.Since).\n\t\tWhere(\"name = ?\", filter.Name).\n\t\tSelect(&metrics)\n\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to get metrics %s\", filter)\n\t}\n\treturn metrics, nil\n}","func (p ECachePlugin) FetchMetrics() (map[string]float64, error) {\n\tsess, err := session.NewSession()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tconfig := aws.NewConfig()\n\tif p.AccessKeyID != \"\" && p.SecretAccessKey != \"\" {\n\t\tconfig = config.WithCredentials(credentials.NewStaticCredentials(p.AccessKeyID, p.SecretAccessKey, \"\"))\n\t}\n\tif p.Region != \"\" {\n\t\tconfig = config.WithRegion(p.Region)\n\t}\n\n\tcloudWatch := cloudwatch.New(sess, config)\n\n\tstat := make(map[string]float64)\n\n\tperInstances := []*cloudwatch.Dimension{\n\t\t{\n\t\t\tName: aws.String(\"CacheClusterId\"),\n\t\t\tValue: aws.String(p.CacheClusterID),\n\t\t},\n\t\t{\n\t\t\tName: aws.String(\"CacheNodeId\"),\n\t\t\tValue: aws.String(p.CacheNodeID),\n\t\t},\n\t}\n\n\tfor _, met := range p.CacheMetrics {\n\t\tv, err := getLastPoint(cloudWatch, perInstances, met)\n\t\tif err == nil {\n\t\t\tstat[met] = v\n\t\t} else {\n\t\t\tlog.Printf(\"%s: %s\", met, err)\n\t\t}\n\t}\n\n\treturn stat, nil\n}","func getMetrics() []Metric {\n\tms := make([]Metric, 0)\n\treturn append(ms, &SimpleEapMetric{})\n}","func (h *History) Compute() *Metrics {\n h.RLock()\n defer h.RUnlock()\n return h.compute()\n}","func (c Configuration) metrics() (*pkg.Metrics, error) {\n\tMetricsInitialised.Once.Do(func() {\n\t\tlogger := zerolog.New(os.Stderr).Level(zerolog.DebugLevel)\n\t\tmetrics := &pkg.Metrics{\n\t\t\tGraphiteHost: c.MetricsConfig.GraphiteHost,\n\t\t\tNamespace: c.MetricsConfig.NameSpace,\n\t\t\tGraphiteMode: c.MetricsConfig.GraphiteMode,\n\t\t\tMetricsInterval: c.MetricsConfig.CollectionInterval,\n\t\t\tLogger: logger,\n\t\t}\n\n\t\thostname, err := os.Hostname()\n\t\tif err != nil {\n\t\t\tMetricsInitialised.metrics, MetricsInitialised.err = nil, err\n\t\t\treturn\n\t\t}\n\t\tmetrics.Hostname = hostname\n\n\t\t// determine server Role name\n\t\tif c.MetricsConfig.HostRolePath != \"\" {\n\t\t\tfile, err := os.Open(c.MetricsConfig.HostRolePath)\n\t\t\tif err != nil {\n\t\t\t\tMetricsInitialised.metrics, MetricsInitialised.err = nil, err\n\t\t\t\treturn\n\t\t\t}\n\t\t\tscanner := bufio.NewScanner(file)\n\t\t\tfor scanner.Scan() {\n\t\t\t\ttokens := strings.Split(scanner.Text(), c.MetricsConfig.HostRoleToken)\n\t\t\t\tif len(tokens) < puppetFileColumnCount {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif tokens[0] == c.MetricsConfig.HostRoleKey {\n\t\t\t\t\tmetrics.RoleName = tokens[1]\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif err = file.Close(); err != nil {\n\t\t\t\tlogger.Error().Err(err)\n\t\t\t\tMetricsInitialised.metrics, MetricsInitialised.err = nil, err\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tmetrics.EveryHourRegister = goMetrics.NewPrefixedRegistry(metrics.Namespace)\n\t\tmetrics.EveryMinuteRegister = goMetrics.NewPrefixedRegistry(metrics.Namespace)\n\n\t\tMetricsInitialised.metrics, MetricsInitialised.err = metrics, nil\n\t})\n\n\treturn MetricsInitialised.metrics, MetricsInitialised.err\n}","func Metrics() (*statsd.Client, error) {\n\tonce.Do(func() {\n\t\tmetricsClientConf := config.Metrics()\n\t\tif !metricsClientConf.Enabled {\n\t\t\terr = errors.New(\"metrics collection has been disabled\")\n\t\t\tlog.Error(err)\n\t\t\tinstance = nil\n\t\t} else {\n\t\t\tconn := fmt.Sprintf(\"%s:%d\", metricsClientConf.Host, metricsClientConf.Port)\n\t\t\tinstance, err = statsd.New(conn)\n\t\t\tif err != nil {\n\t\t\t\tlog.Info(\"Unable to initialize statsd client.\")\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t\tinstance.Namespace = metricsClientConf.Prefix\n\t\t}\n\t})\n\treturn instance, err\n}","func (c *Cache) Get(ctx context.Context, job, instance, metric string) (*Entry, error) {\n\tif md, ok := c.staticMetadata[metric]; ok {\n\t\treturn md, nil\n\t}\n\tmd, ok := c.metadata[metric]\n\tif !ok || md.shouldRefetch() {\n\t\t// If we are seeing the job for the first time, preemptively get a full\n\t\t// list of all metadata for the instance.\n\t\tif _, ok := c.seenJobs[job]; !ok {\n\t\t\tmds, err := c.fetchBatch(ctx, job, instance)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Wrapf(err, \"fetch metadata for job %q\", job)\n\t\t\t}\n\t\t\tfor _, md := range mds {\n\t\t\t\t// Only set if we haven't seen the metric before. Changes to metadata\n\t\t\t\t// may need special handling in Stackdriver, which we do not provide\n\t\t\t\t// yet anyway.\n\t\t\t\tif _, ok := c.metadata[md.Metric]; !ok {\n\t\t\t\t\tc.metadata[md.Metric] = md\n\t\t\t\t}\n\t\t\t}\n\t\t\tc.seenJobs[job] = struct{}{}\n\t\t} else {\n\t\t\tmd, err := c.fetchMetric(ctx, job, instance, metric)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Wrapf(err, \"fetch metric metadata \\\"%s/%s/%s\\\"\", job, instance, metric)\n\t\t\t}\n\t\t\tc.metadata[metric] = md\n\t\t}\n\t\tmd = c.metadata[metric]\n\t}\n\tif md != nil && md.found {\n\t\treturn md.Entry, nil\n\t}\n\t// The metric might also be produced by a recording rule, which by convention\n\t// contain at least one `:` character. In that case we can generally assume that\n\t// it is a gauge. We leave the help text empty.\n\tif strings.Contains(metric, \":\") {\n\t\tentry := &Entry{Metric: metric, MetricType: textparse.MetricTypeGauge}\n\t\treturn entry, nil\n\t}\n\treturn nil, nil\n}","func (c *Client) getStatistics() *AllStats {\n\n\tvar status Status\n\tstatusURL := fmt.Sprintf(statusURLPattern, c.protocol, c.hostname, c.port)\n\tbody := c.MakeRequest(statusURL)\n\terr := json.Unmarshal(body, &status)\n\tif err != nil {\n\t\tlog.Println(\"Unable to unmarshal Adguard log statistics to log statistics struct model\", err)\n\t}\n\n\tvar stats Stats\n\tstatsURL := fmt.Sprintf(statsURLPattern, c.protocol, c.hostname, c.port)\n\tbody = c.MakeRequest(statsURL)\n\terr = json.Unmarshal(body, &stats)\n\tif err != nil {\n\t\tlog.Println(\"Unable to unmarshal Adguard statistics to statistics struct model\", err)\n\t}\n\n\tvar logstats LogStats\n\tlogstatsURL := fmt.Sprintf(logstatsURLPattern, c.protocol, c.hostname, c.port, c.logLimit)\n\tbody = c.MakeRequest(logstatsURL)\n\terr = json.Unmarshal(body, &logstats)\n\tif err != nil {\n\t\tlog.Println(\"Unable to unmarshal Adguard log statistics to log statistics struct model\", err)\n\t}\n\n\tvar allstats AllStats\n\tallstats.status = &status\n\tallstats.stats = &stats\n\tallstats.logStats = &logstats\n\n\treturn &allstats\n}","func (c *MetricsCollector) Metrics() *InvocationMetrics {\n\tc.Lock()\n\tdefer c.Unlock()\n\treturn c.metrics\n}","func (u UptimePlugin) FetchMetrics() (map[string]float64, error) {\n\tut, err := uptime.Get()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to fetch uptime metrics: %s\", err)\n\t}\n\treturn map[string]float64{\"seconds\": ut.Seconds()}, nil\n}","func GetAll() map[Type]time.Duration {\n\tmutex.RLock()\n\tdefer mutex.RUnlock()\n\treturn GlobalStats\n}","func (m *Manager) Get(base int64) *TimestampBuffering {\n\t// m.mutex.Lock()\n\t// defer m.mutex.Unlock()\n\n\t// get now\n\tindex := m.GetCurrentIndex(base)\n\tfmt.Printf(\"get current index :%d\\n\",index)\n\n\n\treturn m.targets[index]\n\n\t// return nil\n}","func (p S3RequestsPlugin) FetchMetrics() (map[string]float64, error) {\n\tstats := make(map[string]float64)\n\n\tfor _, met := range s3RequestMetricsGroup {\n\t\tv, err := getLastPointFromCloudWatch(p.CloudWatch, p.BucketName, p.FilterID, met)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"%s: %s\", met, err)\n\t\t} else if v != nil {\n\t\t\tstats = mergeStatsFromDatapoint(stats, v, met)\n\t\t}\n\t}\n\treturn stats, nil\n}","func (engine *DockerStatsEngine) GetInstanceMetrics() (*ecstcs.MetricsMetadata, []*ecstcs.TaskMetric, error) {\n\tvar taskMetrics []*ecstcs.TaskMetric\n\tidle := engine.isIdle()\n\tmetricsMetadata := &ecstcs.MetricsMetadata{\n\t\tCluster: aws.String(engine.cluster),\n\t\tContainerInstance: aws.String(engine.containerInstanceArn),\n\t\tIdle: aws.Bool(idle),\n\t\tMessageId: aws.String(uuid.NewRandom().String()),\n\t}\n\n\tif idle {\n\t\tlog.Debug(\"Instance is idle. No task metrics to report\")\n\t\tfin := true\n\t\tmetricsMetadata.Fin = &fin\n\t\treturn metricsMetadata, taskMetrics, nil\n\t}\n\n\tfor taskArn := range engine.tasksToContainers {\n\t\tcontainerMetrics, err := engine.getContainerMetricsForTask(taskArn)\n\t\tif err != nil {\n\t\t\tlog.Debug(\"Error getting container metrics for task\", \"err\", err, \"task\", taskArn)\n\t\t\tcontinue\n\t\t}\n\n\t\tif len(containerMetrics) == 0 {\n\t\t\tlog.Debug(\"Empty containerMetrics for task, ignoring\", \"task\", taskArn)\n\t\t\tcontinue\n\t\t}\n\n\t\ttaskDef, exists := engine.tasksToDefinitions[taskArn]\n\t\tif !exists {\n\t\t\tlog.Debug(\"Could not map task to definition\", \"task\", taskArn)\n\t\t\tcontinue\n\t\t}\n\n\t\tmetricTaskArn := taskArn\n\t\ttaskMetric := &ecstcs.TaskMetric{\n\t\t\tTaskArn: &metricTaskArn,\n\t\t\tTaskDefinitionFamily: &taskDef.family,\n\t\t\tTaskDefinitionVersion: &taskDef.version,\n\t\t\tContainerMetrics: containerMetrics,\n\t\t}\n\t\ttaskMetrics = append(taskMetrics, taskMetric)\n\t}\n\n\tif len(taskMetrics) == 0 {\n\t\t// Not idle. Expect taskMetrics to be there.\n\t\treturn nil, nil, fmt.Errorf(\"No task metrics to report\")\n\t}\n\n\t// Reset current stats. Retaining older stats results in incorrect utilization stats\n\t// until they are removed from the queue.\n\tengine.resetStats()\n\treturn metricsMetadata, taskMetrics, nil\n}","func (db *DB) Metrics() *Metrics {\n\treturn db.metrics\n}","func Latest() StatusData {\n\tlog.Println(\"LatestStatusData\")\n\tr := rp.Get()\n\tdefer r.Close()\n\n\tresult := StatusData{Success: true, Timestamp: time.Now(), Realtime: make(map[string]int), Total: make(map[string]int)}\n\n\tr.Send(\"SMEMBERS\", \"domains\")\n\tr.Flush()\n\tresult.Domains, _ = redis.Strings(redis.MultiBulk(r.Receive()))\n\n\tfor _, d := range result.Domains {\n\t\tvar key = d + \"_\" + result.Timestamp.Format(\"20060102\")\n\t\tval, _ := redis.Int(r.Do(\"GET\", key))\n\t\tif val > 0 {\n\t\t\tresult.Total[d] = val\n\t\t}\n\t}\n\n\treply, err := redis.Values(r.Do(\"SCAN\", 0, \"MATCH\", \"*:*\", \"COUNT\", 1000000))\n\tif err != nil {\n\t\tlog.Println(\"redis.Values\", err)\n\t}\n\tif _, err := redis.Scan(reply, nil, &result.Idents); err != nil {\n\t\tlog.Println(\"redis.Scan\", err)\n\t}\n\tresult.Current = len(result.Idents)\n\n\tfor _, ident := range result.Idents {\n\t\ttmp := strings.Split(ident, \":\")\n\t\tif val, ok := result.Realtime[tmp[0]]; ok {\n\t\t\tresult.Realtime[tmp[0]] = val + 1\n\t\t} else {\n\t\t\tresult.Realtime[tmp[0]] = 1\n\t\t}\n\t}\n\n\treturn result\n}","func (api *API) Get(k string) (MetricItem, bool) {\n\treturn api.metricItens.Get(k)\n}","func (p CognitoIdpPlugin) FetchMetrics() (map[string]interface{}, error) {\n\tstat := make(map[string]interface{})\n\n\tfor _, met := range [...]metrics{\n\t\t{CloudWatchName: \"SignUpSuccesses\", MackerelName: \"SignUpSuccesses\", Type: metricsTypeSum},\n\t\t{CloudWatchName: \"SignUpSuccesses\", MackerelName: \"SignUpParcentageOfSuccessful\", Type: metricsTypeAverage},\n\t\t{CloudWatchName: \"SignUpSuccesses\", MackerelName: \"SignUpSampleCount\", Type: metricsTypeSampleCount},\n\t\t{CloudWatchName: \"SignUpThrottles\", MackerelName: \"SignUpThrottles\", Type: metricsTypeSum},\n\t\t{CloudWatchName: \"SignInSuccesses\", MackerelName: \"SignInSuccesses\", Type: metricsTypeSum},\n\t\t{CloudWatchName: \"SignInSuccesses\", MackerelName: \"SignInParcentageOfSuccessful\", Type: metricsTypeAverage},\n\t\t{CloudWatchName: \"SignInSuccesses\", MackerelName: \"SignInSampleCount\", Type: metricsTypeSampleCount},\n\t\t{CloudWatchName: \"SignInThrottles\", MackerelName: \"SignInThrottles\", Type: metricsTypeSum},\n\t\t{CloudWatchName: \"TokenRefreshSuccesses\", MackerelName: \"TokenRefreshSuccesses\", Type: metricsTypeSum},\n\t\t{CloudWatchName: \"TokenRefreshSuccesses\", MackerelName: \"TokenRefreshParcentageOfSuccessful\", Type: metricsTypeAverage},\n\t\t{CloudWatchName: \"TokenRefreshSuccesses\", MackerelName: \"TokenRefreshSampleCount\", Type: metricsTypeSampleCount},\n\t\t{CloudWatchName: \"TokenRefreshThrottles\", MackerelName: \"TokenRefreshThrottles\", Type: metricsTypeSum},\n\t\t{CloudWatchName: \"FederationSuccesses\", MackerelName: \"FederationSuccesses\", Type: metricsTypeSum},\n\t\t{CloudWatchName: \"FederationSuccesses\", MackerelName: \"FederationParcentageOfSuccessful\", Type: metricsTypeAverage},\n\t\t{CloudWatchName: \"FederationSuccesses\", MackerelName: \"FederationSampleCount\", Type: metricsTypeSampleCount},\n\t\t{CloudWatchName: \"FederationThrottles\", MackerelName: \"FederationThrottles\", Type: metricsTypeSum},\n\t} {\n\t\tv, err := p.getLastPoint(met)\n\t\tif err == nil {\n\t\t\tstat[met.MackerelName] = v\n\t\t} else {\n\t\t\tlog.Printf(\"%s: %s\", met, err)\n\t\t}\n\t}\n\treturn stat, nil\n}","func (s *Stats) Get() Stats {\n\n\tout := Stats{\n\t\tEventsTotal: atomic.LoadUint64(&s.EventsTotal),\n\t\tEventsUpdate: atomic.LoadUint64(&s.EventsUpdate),\n\t\tEventsDestroy: atomic.LoadUint64(&s.EventsDestroy),\n\t}\n\n\t// Get Update source stats if present.\n\tif s.UpdateSourceStats != nil {\n\t\ts := s.UpdateSourceStats.Get()\n\t\tout.UpdateSourceStats = &s\n\t}\n\n\t// Get Destroy source stats if present.\n\tif s.DestroySourceStats != nil {\n\t\ts := s.DestroySourceStats.Get()\n\t\tout.DestroySourceStats = &s\n\t}\n\n\treturn out\n}","func (m *MetricsCacheType) GetMetrics() ([]string, bool) {\n\tif m.IsAvailable() && !m.TimedOut() {\n\t\treturn m.metrics, true\n\t}\n\n\tif !m.updating {\n\t\tgo m.RefreshCache()\n\t}\n\treturn nil, false\n}","func (c *ResourceCollector) Get(ch chan<- prometheus.Metric) (float64, error) {\n\n\tjsonResources, err := getResourceStats()\n\tif err != nil {\n\t\ttotalResourceErrors++\n\t\treturn totalResourceErrors, fmt.Errorf(\"cannot get resources: %s\", err)\n\t}\n\tif err := processResourceStats(ch, jsonResources); err != nil {\n\t\ttotalResourceErrors++\n\t\treturn totalResourceErrors, err\n\t}\n\treturn totalResourceErrors, nil\n\n}","func (c *PromMetricsClient) GetMetrics() ([]*Metric, error) {\n\tres, err := http.Get(c.URL)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif res.StatusCode != 200 {\n\t\treturn nil, ErrUnexpectedHTTPStatusCode\n\t}\n\n\tdefer res.Body.Close()\n\treturn Parse(res.Body)\n}","func (c *CAdvisor) GetMetrics() (*Metrics, error) {\n\tlog.Printf(\"[DEBUG] [cadvisor] Get metrics\")\n\tnodeSpec, err := c.Client.MachineInfo()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlog.Printf(\"[DEBUG] [cadvisor] Receive machine info : %#v\",\n\t\tnodeSpec)\n\tnodeInfo, err := c.Client.ContainerInfo(\"/\", c.Query)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlog.Printf(\"[DEBUG] [cadvisor] Receive container info : %#v\",\n\t\tnodeInfo)\n\tcontainersInfo, err := c.Client.AllDockerContainers(c.Query)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlog.Printf(\"[DEBUG] [cadvisor] Receive all docker containers : %#v\",\n\t\tcontainersInfo)\n\tmetrics := &Metrics{\n\t\tNodeSpec: nodeSpec,\n\t\tNodeInfo: nodeInfo,\n\t\tContainersInfo: containersInfo,\n\t}\n\t//log.Printf(\"[INFO] [cadvisor] Metrics: %#v\", metrics)\n\treturn metrics, nil\n}","func (p RekognitionPlugin) FetchMetrics() (map[string]float64, error) {\n\tstat := make(map[string]float64)\n\n\tfor _, met := range [...]string{\n\t\t\"SuccessfulRequestCount\",\n\t\t\"ThrottledCount\",\n\t\t\"ResponseTime\",\n\t\t\"DetectedFaceCount\",\n\t\t\"DetectedLabelCount\",\n\t\t\"ServerErrorCount\",\n\t\t\"UserErrorCount\",\n\t} {\n\t\tv, err := p.getLastPoint(met)\n\t\tif err == nil {\n\t\t\tstat[met] = v\n\t\t} else {\n\t\t\tlog.Printf(\"%s: %s\", met, err)\n\t\t}\n\t}\n\n\treturn stat, nil\n}","func (mw *Stats) Data() *Data {\n\tmw.mu.RLock()\n\n\tresponseCounts := make(map[string]int, len(mw.ResponseCounts))\n\ttotalResponseCounts := make(map[string]int, len(mw.TotalResponseCounts))\n\ttotalMetricsCounts := make(map[string]int, len(mw.MetricsCounts))\n\tmetricsCounts := make(map[string]float64, len(mw.MetricsCounts))\n\n\tnow := time.Now()\n\n\tuptime := now.Sub(mw.Uptime)\n\n\tcount := 0\n\tfor code, current := range mw.ResponseCounts {\n\t\tresponseCounts[code] = current\n\t\tcount += current\n\t}\n\n\ttotalCount := 0\n\tfor code, count := range mw.TotalResponseCounts {\n\t\ttotalResponseCounts[code] = count\n\t\ttotalCount += count\n\t}\n\n\ttotalResponseTime := mw.TotalResponseTime.Sub(time.Time{})\n\ttotalResponseSize := mw.TotalResponseSize\n\n\taverageResponseTime := time.Duration(0)\n\taverageResponseSize := int64(0)\n\tif totalCount > 0 {\n\t\tavgNs := int64(totalResponseTime) / int64(totalCount)\n\t\taverageResponseTime = time.Duration(avgNs)\n\t\taverageResponseSize = int64(totalResponseSize) / int64(totalCount)\n\t}\n\n\tfor key, count := range mw.MetricsCounts {\n\t\ttotalMetric := mw.MetricsTimers[key].Sub(time.Time{})\n\t\tavgNs := int64(totalMetric) / int64(count)\n\t\tmetricsCounts[key] = time.Duration(avgNs).Seconds()\n\t\ttotalMetricsCounts[key] = count\n\t}\n\n\tmw.mu.RUnlock()\n\n\tr := &Data{\n\t\tPid: mw.Pid,\n\t\tUpTime: uptime.String(),\n\t\tUpTimeSec: uptime.Seconds(),\n\t\tTime: now.String(),\n\t\tTimeUnix: now.Unix(),\n\t\tStatusCodeCount: responseCounts,\n\t\tTotalStatusCodeCount: totalResponseCounts,\n\t\tCount: count,\n\t\tTotalCount: totalCount,\n\t\tTotalResponseTime: totalResponseTime.String(),\n\t\tTotalResponseSize: totalResponseSize,\n\t\tTotalResponseTimeSec: totalResponseTime.Seconds(),\n\t\tTotalMetricsCounts: totalMetricsCounts,\n\t\tAverageResponseSize: averageResponseSize,\n\t\tAverageResponseTime: averageResponseTime.String(),\n\t\tAverageResponseTimeSec: averageResponseTime.Seconds(),\n\t\tAverageMetricsTimers: metricsCounts,\n\t}\n\n\treturn r\n}","func (r IpvsPlugin) FetchMetrics() (map[string]float64, error) {\n file, err := os.Open(r.Target)\n if err != nil {\n return nil, err\n }\n defer file.Close()\n\n return Parse(file)\n}","func (s *Store) Metrics() *StoreMetrics {\n\treturn s.metrics\n}","func (s *inMemoryStore) Get(ctx context.Context, h types.Metric, resetTime time.Time, fieldVals []any) any {\n\tif resetTime.IsZero() {\n\t\tresetTime = clock.Now(ctx)\n\t}\n\n\tm := s.getOrCreateData(h)\n\tt := s.findTarget(ctx, m)\n\tm.lock.Lock()\n\tdefer m.lock.Unlock()\n\treturn m.get(fieldVals, t, resetTime).Value\n}","func (c *MetricCollector) Get(ctx context.Context, namespace, name string) (*Metric, error) {\n\tc.collectionsMutex.RLock()\n\tdefer c.collectionsMutex.RUnlock()\n\n\tkey := NewMetricKey(namespace, name)\n\tcollector, ok := c.collections[key]\n\tif !ok {\n\t\treturn nil, k8serrors.NewNotFound(kpa.Resource(\"Deciders\"), key)\n\t}\n\n\treturn collector.metric.DeepCopy(), nil\n}","func (sink *influxdbSink) GetMetric(metricName string, metricKeys []core.HistoricalKey, start, end time.Time) (map[core.HistoricalKey][]core.TimestampedMetricValue, error) {\n\tfor _, key := range metricKeys {\n\t\tif err := sink.checkSanitizedKey(&key); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif err := sink.checkSanitizedMetricName(metricName); err != nil {\n\t\treturn nil, err\n\t}\n\n\tquery := sink.composeRawQuery(metricName, nil, metricKeys, start, end)\n\n\tsink.RLock()\n\tdefer sink.RUnlock()\n\n\tresp, err := sink.runQuery(query)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tres := make(map[core.HistoricalKey][]core.TimestampedMetricValue, len(metricKeys))\n\tfor i, key := range metricKeys {\n\t\tif len(resp[i].Series) < 1 {\n\t\t\treturn nil, fmt.Errorf(\"No results for metric %q describing %q\", metricName, key.String())\n\t\t}\n\n\t\tvals, err := sink.parseRawQueryRow(resp[i].Series[0])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tres[key] = vals\n\t}\n\n\treturn res, nil\n}","func setupMetrics() Metrics {\n\tm := Metrics{}\n\tm.LastBackupDuration = prometheus.NewGauge(prometheus.GaugeOpts{\n\t\tNamespace: \"clickhouse_backup\",\n\t\tName: \"last_backup_duration\",\n\t\tHelp: \"Backup duration in nanoseconds.\",\n\t})\n\tm.LastBackupSuccess = prometheus.NewGauge(prometheus.GaugeOpts{\n\t\tNamespace: \"clickhouse_backup\",\n\t\tName: \"last_backup_success\",\n\t\tHelp: \"Last backup success boolean: 0=failed, 1=success, 2=unknown.\",\n\t})\n\tm.LastBackupStart = prometheus.NewGauge(prometheus.GaugeOpts{\n\t\tNamespace: \"clickhouse_backup\",\n\t\tName: \"last_backup_start\",\n\t\tHelp: \"Last backup start timestamp.\",\n\t})\n\tm.LastBackupEnd = prometheus.NewGauge(prometheus.GaugeOpts{\n\t\tNamespace: \"clickhouse_backup\",\n\t\tName: \"last_backup_end\",\n\t\tHelp: \"Last backup end timestamp.\",\n\t})\n\tm.SuccessfulBackups = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tNamespace: \"clickhouse_backup\",\n\t\tName: \"successful_backups\",\n\t\tHelp: \"Number of Successful Backups.\",\n\t})\n\tm.FailedBackups = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tNamespace: \"clickhouse_backup\",\n\t\tName: \"failed_backups\",\n\t\tHelp: \"Number of Failed Backups.\",\n\t})\n\tprometheus.MustRegister(\n\t\tm.LastBackupDuration,\n\t\tm.LastBackupStart,\n\t\tm.LastBackupEnd,\n\t\tm.LastBackupSuccess,\n\t\tm.SuccessfulBackups,\n\t\tm.FailedBackups,\n\t)\n\tm.LastBackupSuccess.Set(2) // 0=failed, 1=success, 2=unknown\n\treturn m\n}","func NewMetrics(ns string) *Metrics {\n\tres := &Metrics{\n\t\tInfo: promauto.NewGaugeVec(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tNamespace: ns,\n\t\t\t\tName: \"info\",\n\t\t\t\tHelp: \"Informations about given repository, value always 1\",\n\t\t\t},\n\t\t\t[]string{\"module\", \"goversion\"},\n\t\t),\n\t\tDeprecated: promauto.NewGaugeVec(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tNamespace: ns,\n\t\t\t\tName: \"deprecated\",\n\t\t\t\tHelp: \"Number of days since given dependency of repository is out-of-date\",\n\t\t\t},\n\t\t\t[]string{\"module\", \"dependency\", \"type\", \"current\", \"latest\"},\n\t\t),\n\t\tReplaced: promauto.NewGaugeVec(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tNamespace: ns,\n\t\t\t\tName: \"replaced\",\n\t\t\t\tHelp: \"Give information about module replacements\",\n\t\t\t},\n\t\t\t[]string{\"module\", \"dependency\", \"type\", \"replacement\", \"version\"},\n\t\t),\n\t\tStatus: promauto.NewGaugeVec(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tNamespace: ns,\n\t\t\t\tName: \"status\",\n\t\t\t\tHelp: \"Status of last analysis of given repository, 0 for error\",\n\t\t\t},\n\t\t\t[]string{\"repository\"},\n\t\t),\n\t\tDuration: promauto.NewGauge(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tNamespace: ns,\n\t\t\t\tName: \"duration\",\n\t\t\t\tHelp: \"Duration of last analysis in second\",\n\t\t\t},\n\t\t),\n\t\tRegistry: prometheus.NewRegistry(),\n\t}\n\n\tres.Registry.Register(res.Info)\n\tres.Registry.Register(res.Deprecated)\n\tres.Registry.Register(res.Replaced)\n\tres.Registry.Register(res.Status)\n\tres.Registry.Register(res.Duration)\n\treturn res\n}","func (y *YarnMetrics) getMetrics() *NMMetrics {\n\tjmxResp := &JmxResp{}\n\terr := y.requestUrl(metricsSuffix, jmxResp)\n\tif err != nil {\n\t\tklog.V(5).Infof(\"request nodemanager metrics err: %v\", err)\n\t\treturn nil\n\t}\n\tif len(jmxResp.Beans) == 0 {\n\t\tklog.V(5).Infof(\"request nodemanager metrics, empty beans\")\n\t\treturn nil\n\t}\n\treturn &jmxResp.Beans[0]\n}","func (self *Metric) GetTime() time.Time {\n\treturn time.Unix(self.Time, 0).UTC()\n}","func (h *Handler) GetMetricSum(w http.ResponseWriter, r *http.Request) {\n\tvar b []byte\n\tkey := mux.Vars(r)[\"key\"]\n\n\tresp := response{}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusOK)\n\tcachedVal, ok := h.MetricsCache.Get(key)\n\tif !ok {\n\t\tb, _ = json.Marshal(resp)\n\t\tw.Write(b)\n\t\treturn\n\t}\n\n\tcachedList := cachedVal.(*list.List)\n\tnewList := list.New()\n\n\tfor element := cachedList.Front(); element != nil; element = element.Next() {\n\t\tdata := element.Value.(metricData)\n\t\tmetricTime := data.time\n\t\tvalidMetricTime := metricTime.Add(h.InstrumentationTimeInSeconds * time.Second)\n\n\t\tif validMetricTime.After(time.Now()) {\n\t\t\tresp.Value = resp.Value + data.value\n\t\t\tdata := metricData{value: data.value, time: data.time}\n\n\t\t\tnewList.PushBack(data)\n\t\t} else {\n\t\t\th.MetricsCache.Set(key, newList, cache.NoExpiration)\n\t\t\tbreak\n\t\t}\n\t}\n\n\tb, _ = json.Marshal(resp)\n\tw.Write(b)\n\n\treturn\n}","func (r Virtual_Guest) GetRecentMetricData(time *uint) (resp []datatypes.Metric_Tracking_Object, err error) {\n\tparams := []interface{}{\n\t\ttime,\n\t}\n\terr = r.Session.DoRequest(\"SoftLayer_Virtual_Guest\", \"getRecentMetricData\", params, &r.Options, &resp)\n\treturn\n}","func (c *client) getAllTicketMetrics(endpoint string, in interface{}) ([]TicketMetric, error) {\n\tresult := make([]TicketMetric, 0)\n\tpayload, err := marshall(in)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\theaders := map[string]string{}\n\tif in != nil {\n\t\theaders[\"Content-Type\"] = \"application/json\"\n\t}\n\n\tres, err := c.request(\"GET\", endpoint, headers, bytes.NewReader(payload))\n\tdataPerPage := new(APIPayload)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tapiV2 := \"/api/v2/\"\n\tfieldName := strings.Split(endpoint[len(apiV2):], \".\")[0]\n\tdefer res.Body.Close()\n\n\terr = unmarshall(res, dataPerPage)\n\n\tapiStartIndex := strings.Index(dataPerPage.NextPage, apiV2)\n\tcurrentPage := endpoint\n\n\tvar totalWaitTime int64\n\tfor currentPage != \"\" {\n\t\t// if too many requests(res.StatusCode == 429), delay sending request\n\t\tif res.StatusCode == 429 {\n\t\t\tafter, err := strconv.ParseInt(res.Header.Get(\"Retry-After\"), 10, 64)\n\t\t\tlog.Printf(\"[zd_ticket_metrics_service][getAllTicketMetrics] too many requests. Wait for %v seconds\\n\", after)\n\t\t\ttotalWaitTime += after\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\ttime.Sleep(time.Duration(after) * time.Second)\n\t\t} else {\n\t\t\tif fieldName == \"ticket_metrics\" {\n\t\t\t\tresult = append(result, dataPerPage.TicketMetrics...)\n\t\t\t}\n\t\t\tcurrentPage = dataPerPage.NextPage\n\t\t}\n\t\tres, _ = c.request(\"GET\", dataPerPage.NextPage[apiStartIndex:], headers, bytes.NewReader(payload))\n\t\tdataPerPage = new(APIPayload)\n\t\terr = unmarshall(res, dataPerPage)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tlog.Printf(\"[zd_ticket_metrics_service][getAllTicketMetrics] number of records pulled: %v\\n\", len(result))\n\tlog.Printf(\"[zd_ticket_metrics_service][getAllTicketMetrics] total waiting time due to rate limit: %v\\n\", totalWaitTime)\n\n\treturn result, err\n}","func (m *MetricSet) Fetch() (common.MapStr, error) {\n\n\thapc, err := haproxy.NewHaproxyClient(m.statsAddr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"HAProxy Client error: %s\", err)\n\t}\n\n\tres, err := hapc.GetInfo()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"HAProxy Client error fetching %s: %s\", statsMethod, err)\n\t}\n\n\tmappedEvent, err := eventMapping(res)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn mappedEvent, nil\n}","func getGlobalMetrics(\n\tctx context.Context,\n\tcl kubeClient,\n\tnow time.Time,\n\tclusterName string,\n) ([]types.MetricPoint, error) {\n\tvar (\n\t\terr error\n\t\tmultiErr prometheus.MultiError\n\t\tcache kubeCache\n\t)\n\n\t// Add resources to the cache.\n\tcache.pods, err = cl.GetPODs(ctx, \"\")\n\tmultiErr.Append(err)\n\n\tcache.namespaces, err = cl.GetNamespaces(ctx)\n\tmultiErr.Append(err)\n\n\tcache.nodes, err = cl.GetNodes(ctx)\n\tmultiErr.Append(err)\n\n\treplicasets, err := cl.GetReplicasets(ctx)\n\tmultiErr.Append(err)\n\n\tcache.replicasetOwnerByUID = make(map[string]metav1.OwnerReference, len(replicasets))\n\n\tfor _, replicaset := range replicasets {\n\t\tif len(replicaset.OwnerReferences) > 0 {\n\t\t\tcache.replicasetOwnerByUID[string(replicaset.UID)] = replicaset.OwnerReferences[0]\n\t\t}\n\t}\n\n\t// Compute cluster metrics.\n\tvar points []types.MetricPoint\n\n\tmetricFunctions := []metricsFunc{podsCount, requestsAndLimits, namespacesCount, nodesCount, podsRestartCount}\n\n\tfor _, f := range metricFunctions {\n\t\tpoints = append(points, f(cache, now)...)\n\t}\n\n\t// Add the Kubernetes cluster meta label to global metrics, this is used to\n\t// replace the agent ID by the Kubernetes agent ID in the relabel hook.\n\tfor _, point := range points {\n\t\tpoint.Labels[types.LabelMetaKubernetesCluster] = clusterName\n\t}\n\n\treturn points, multiErr.MaybeUnwrap()\n}","func (sm *SinkManager) LatestContainerMetrics(appID string) []*events.Envelope {\n\tif sink := sm.sinks.ContainerMetricsFor(appID); sink != nil {\n\t\treturn sink.GetLatest()\n\t}\n\treturn []*events.Envelope{}\n}","func (xratesKit *XRatesKit) GetLatest(currencyCode string, coinCodes *CoinCodes) *XRates {\n\n\tdata, err := xratesKit.ipfsHandler.GetLatestXRates(currencyCode, coinCodes.toStringArray())\n\n\tif err != nil {\n\n\t\t// Get data from CoinPaprika\n\t\tdata, err = xratesKit.coinPaprika.GetLatestXRates(currencyCode, coinCodes.toStringArray())\n\n\t\tif err != nil {\n\t\t\treturn nil\n\t\t}\n\t}\n\t//---------- Cache Data -------------------\n\n\txratesKit.cacheService.SetLatest(data)\n\n\t//-----------------------------------------\n\n\tlog.Println(data)\n\n\tvar result = make([]XRate, len(data))\n\tfor i, xrate := range data {\n\t\tresult[i] = XRate(xrate)\n\t}\n\treturn &XRates{result}\n}","func (s *Simulator) Stats() *Stats {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\telapsed := time.Since(s.now).Seconds()\n\tpThrough := float64(s.writtenN) / elapsed\n\trespMean := 0\n\tif len(s.latencyHistory) > 0 {\n\t\trespMean = int(s.totalLatency) / len(s.latencyHistory) / int(time.Millisecond)\n\t}\n\tstats := &Stats{\n\t\tTime: time.Unix(0, int64(time.Since(s.now))),\n\t\tTags: s.ReportTags,\n\t\tFields: models.Fields(map[string]interface{}{\n\t\t\t\"T\": int(elapsed),\n\t\t\t\"points_written\": s.writtenN,\n\t\t\t\"values_written\": s.writtenN * s.FieldsPerPoint,\n\t\t\t\"points_ps\": pThrough,\n\t\t\t\"values_ps\": pThrough * float64(s.FieldsPerPoint),\n\t\t\t\"write_error\": s.currentErrors,\n\t\t\t\"resp_wma\": int(s.wmaLatency),\n\t\t\t\"resp_mean\": respMean,\n\t\t\t\"resp_90\": int(s.quartileResponse(0.9) / time.Millisecond),\n\t\t\t\"resp_95\": int(s.quartileResponse(0.95) / time.Millisecond),\n\t\t\t\"resp_99\": int(s.quartileResponse(0.99) / time.Millisecond),\n\t\t}),\n\t}\n\n\tvar isCreating bool\n\tif s.writtenN < s.SeriesN() {\n\t\tisCreating = true\n\t}\n\tstats.Tags[\"creating_series\"] = fmt.Sprint(isCreating)\n\n\t// Reset error count for next reporting.\n\ts.currentErrors = 0\n\n\t// Add runtime stats for the remote instance.\n\tvar vars Vars\n\tresp, err := http.Get(strings.TrimSuffix(s.Host, \"/\") + \"/debug/vars\")\n\tif err != nil {\n\t\t// Don't log error as it can get spammy.\n\t\treturn stats\n\t}\n\tdefer resp.Body.Close()\n\n\tif err := json.NewDecoder(resp.Body).Decode(&vars); err != nil {\n\t\tfmt.Fprintln(s.Stderr, err)\n\t\treturn stats\n\t}\n\n\tstats.Fields[\"heap_alloc\"] = vars.Memstats.HeapAlloc\n\tstats.Fields[\"heap_in_use\"] = vars.Memstats.HeapInUse\n\tstats.Fields[\"heap_objects\"] = vars.Memstats.HeapObjects\n\treturn stats\n}","func (m *MetricSet) Fetch(r mb.ReporterV2) {\n\tvar uptime sigar.Uptime\n\tif err := uptime.Get(); err != nil {\n\t\tr.Error(errors.Wrap(err, \"failed to get uptime\"))\n\t\treturn\n\t}\n\n\tr.Event(mb.Event{\n\t\tMetricSetFields: common.MapStr{\n\t\t\t\"duration\": common.MapStr{\n\t\t\t\t\"ms\": int64(uptime.Length * 1000),\n\t\t\t},\n\t\t},\n\t})\n}","func Metrics(cl client.Client) (*v1.Metrics, error) {\n\n\t// Get metrics\n\treq, err := http.NewRequest(\"GET\", cl.MetronomeUrl()+\"/v1/metrics\", nil)\n\tres, err := cl.DoRequest(req)\n\tif err != nil {\n\t\treturn nil, errors.New(\"failed to fetch metrics due to \" + err.Error())\n\t}\n\n\t// Parse metrics\n\tvar metrics v1.Metrics\n\tif err = json.Unmarshal(res, &metrics); err != nil {\n\t\treturn nil, errors.New(\"failed to unmarshal JSON data due to \" + err.Error())\n\t}\n\n\treturn &metrics, nil\n}","func NewMetrics() *Metrics {\n\treturn &Metrics{items: make(map[string]*metric), rm: &sync.RWMutex{}}\n}","func newMetrics() *metrics {\n\treturn new(metrics)\n}","func (m *MetricSet) Fetch(reporter mb.ReporterV2) {\n\tvar err error\n\tvar rows *sql.Rows\n\trows, err = m.db.Query(`SELECT object_name, \n counter_name, \n instance_name, \n cntr_value \nFROM sys.dm_os_performance_counters \nWHERE counter_name = 'SQL Compilations/sec' \n OR counter_name = 'SQL Re-Compilations/sec' \n OR counter_name = 'User Connections' \n OR counter_name = 'Page splits/sec' \n OR ( counter_name = 'Lock Waits/sec' \n AND instance_name = '_Total' ) \n OR counter_name = 'Page splits/sec' \n OR ( object_name = 'SQLServer:Buffer Manager' \n AND counter_name = 'Page life expectancy' ) \n OR counter_name = 'Batch Requests/sec' \n OR ( counter_name = 'Buffer cache hit ratio' \n AND object_name = 'SQLServer:Buffer Manager' ) \n OR ( counter_name = 'Target pages' \n AND object_name = 'SQLServer:Buffer Manager' ) \n OR ( counter_name = 'Database pages' \n AND object_name = 'SQLServer:Buffer Manager' ) \n OR ( counter_name = 'Checkpoint pages/sec' \n AND object_name = 'SQLServer:Buffer Manager' ) \n OR ( counter_name = 'Lock Waits/sec' \n AND instance_name = '_Total' ) \n OR ( counter_name = 'Transactions' \n AND object_name = 'SQLServer:General Statistics' ) \n OR ( counter_name = 'Logins/sec' \n AND object_name = 'SQLServer:General Statistics' ) \n OR ( counter_name = 'Logouts/sec' \n AND object_name = 'SQLServer:General Statistics' ) \n OR ( counter_name = 'Connection Reset/sec' \n AND object_name = 'SQLServer:General Statistics' ) \n OR ( counter_name = 'Active Temp Tables' \n AND object_name = 'SQLServer:General Statistics' )`)\n\tif err != nil {\n\t\treporter.Error(errors.Wrapf(err, \"error closing rows\"))\n\t\treturn\n\t}\n\tdefer func() {\n\t\tif err := rows.Close(); err != nil {\n\t\t\tm.log.Error(\"error closing rows: %s\", err.Error())\n\t\t}\n\t}()\n\n\tmapStr := common.MapStr{}\n\tfor rows.Next() {\n\t\tvar row performanceCounter\n\t\tif err = rows.Scan(&row.objectName, &row.counterName, &row.instanceName, &row.counterValue); err != nil {\n\t\t\treporter.Error(errors.Wrap(err, \"error scanning rows\"))\n\t\t\tcontinue\n\t\t}\n\n\t\t//cell values contains spaces at the beginning and at the end of the 'actual' value. They must be removed.\n\t\trow.counterName = strings.TrimSpace(row.counterName)\n\t\trow.instanceName = strings.TrimSpace(row.instanceName)\n\t\trow.objectName = strings.TrimSpace(row.objectName)\n\n\t\tif row.counterName == \"Buffer cache hit ratio\" {\n\t\t\tmapStr[row.counterName] = fmt.Sprintf(\"%v\", float64(*row.counterValue)/100)\n\t\t} else {\n\t\t\tmapStr[row.counterName] = fmt.Sprintf(\"%v\", *row.counterValue)\n\t\t}\n\t}\n\n\tres, err := schema.Apply(mapStr)\n\tif err != nil {\n\t\tm.log.Error(errors.Wrap(err, \"error applying schema\"))\n\t\treturn\n\t}\n\n\tif isReported := reporter.Event(mb.Event{\n\t\tMetricSetFields: res,\n\t}); !isReported {\n\t\tm.log.Debug(\"event not reported\")\n\t}\n}","func Get(key Type) time.Duration {\n\tif GlobalStats != nil {\n\t\tmutex.RLock()\n\t\tdefer mutex.RUnlock()\n\t\treturn GlobalStats[key]\n\t}\n\treturn 0\n}","func NewMetrics() *MetricsHolder {\n\tm := &MetricsHolder{\n\t\tlines: make(map[string]*Reading),\n\t\tchannel: make(chan interface{}),\n\t}\n\tgo func() {\n\t\tfor {\n\t\t\tw, ok := <-m.channel\n\t\t\treading := w.(*Reading)\n\t\t\tif !ok {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif val, ok := m.lines[reading.Key]; ok {\n\t\t\t\tm.lines[reading.Key] = val.Accept(reading)\n\t\t\t} else {\n\t\t\t\tm.lines[reading.Key] = reading\n\t\t\t}\n\t\t}\n\t}()\n\treturn m\n}","func (q AptCheckPlugin) FetchMetrics() (map[string]interface{}, error) {\n\tres, err := q.invokeAptCheck()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn map[string]interface{}{\n\t\t\"updates\": uint64(res.NumOfUpdates),\n\t\t\"security_updates\": uint64(res.NumOfSecurityUpdates),\n\t}, nil\n}","func (m *metadataCache) get() *Metadata {\n\tm.mu.RLock()\n\tdefer m.mu.RUnlock()\n\treturn m.metadata\n}","func (m *Metrics) Data() (*Data, error) {\n\tvar (\n\t\ttotalResponseTime float64\n\t\tmaxTime float64\n\t\tminTime = math.MaxFloat64\n\t\tbufsize = len(m.requests)\n\t\tpercentiledTime = make(percentiledTimeMap)\n\t)\n\tm.m.RLock()\n\tdefer m.m.RUnlock()\n\tfor _, v := range m.requests {\n\t\ttotalResponseTime += v\n\n\t\tif minTime > v {\n\t\t\tminTime = v\n\t\t}\n\t\tif maxTime < v {\n\t\t\tmaxTime = v\n\t\t}\n\t}\n\n\tfor _, p := range percents {\n\t\tvar err error\n\t\tpercentiledTime[p], err = m.requests.Percentile(float64(p))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tstatusCount := make(statusCountMap)\n\tfor _, status := range httpStatuses {\n\t\tstatusCount[status] = atomic.LoadInt64(&m.statusCount[status])\n\t}\n\n\treturn &Data{\n\t\tRequest: RequestData{\n\t\t\tCount: atomic.LoadInt64(&m.count),\n\t\t\tStatusCount: statusCount,\n\t\t},\n\t\tResponse: ResponseData{\n\t\t\tMaxTime: maxTime,\n\t\t\tMinTime: minTime,\n\t\t\tAverageTime: totalResponseTime / float64(bufsize),\n\t\t\tPercentiledTime: percentiledTime,\n\t\t},\n\t}, nil\n}","func (u RackStatsPlugin) FetchMetrics() (stats map[string]interface{}, err error) {\n\tstats, err = u.parseStats()\n\treturn stats, err\n}","func (c SslCertPlugin) FetchMetrics() (map[string]interface{}, error) {\n\tdays, err := getSslCertMetrics(c.Path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresult := make(map[string]interface{})\n\tresult[\"days\"] = days\n\treturn result, nil\n}","func (h CRConfigHistoryThreadsafe) Get() []CRConfigStat {\n\th.m.RLock()\n\tdefer h.m.RUnlock()\n\tif *h.length < *h.limit {\n\t\treturn CopyCRConfigStat((*h.hist)[:*h.length])\n\t}\n\tnewStats := make([]CRConfigStat, *h.limit)\n\tcopy(newStats, (*h.hist)[*h.pos:])\n\tcopy(newStats[*h.length-*h.pos:], (*h.hist)[:*h.pos])\n\treturn newStats\n}","func (c *Cache) Metrics() CacheMetrics {\n\tif c == nil {\n\t\treturn CacheMetrics{}\n\t}\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\treturn c.m.CacheMetrics\n}","func fetchFloat64Metric(service *monitoring.Service, projectID string, resource *monitoring.MonitoredResource, metric *monitoring.Metric) (float64, error) {\n\tvar value float64\n\tbackoffPolicy := backoff.NewExponentialBackOff()\n\tbackoffPolicy.InitialInterval = 10 * time.Second\n\terr := backoff.Retry(\n\t\tfunc() error {\n\t\t\trequest := service.Projects.TimeSeries.\n\t\t\t\tList(fmt.Sprintf(\"projects/%s\", projectID)).\n\t\t\t\tFilter(fmt.Sprintf(\"resource.type=\\\"%s\\\" metric.type=\\\"%s\\\" %s %s\", resource.Type, metric.Type,\n\t\t\t\t\tbuildFilter(\"resource\", resource.Labels), buildFilter(\"metric\", metric.Labels))).\n\t\t\t\tAggregationAlignmentPeriod(\"300s\").\n\t\t\t\tAggregationPerSeriesAligner(\"ALIGN_NEXT_OLDER\").\n\t\t\t\tIntervalEndTime(time.Now().Format(time.RFC3339))\n\t\t\tlog.Printf(\"ListTimeSeriesRequest: %v\", request)\n\t\t\tresponse, err := request.Do()\n\t\t\tif err != nil {\n\t\t\t\t// TODO(jkohen): switch to gRPC and use error utils to get the response.\n\t\t\t\tif strings.Contains(err.Error(), \"Error 400\") {\n\t\t\t\t\t// The metric doesn't exist, but it may still show up.\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\treturn backoff.Permanent(err)\n\t\t\t}\n\t\t\tlog.Printf(\"ListTimeSeriesResponse: %v\", response)\n\t\t\tif len(response.TimeSeries) > 1 {\n\t\t\t\treturn backoff.Permanent(fmt.Errorf(\"Expected 1 time series, got %v\", response.TimeSeries))\n\t\t\t}\n\t\t\tif len(response.TimeSeries) == 0 {\n\t\t\t\treturn fmt.Errorf(\"Waiting for 1 time series that matches the request, got %v\", response)\n\t\t\t}\n\t\t\ttimeSeries := response.TimeSeries[0]\n\t\t\tif len(timeSeries.Points) != 1 {\n\t\t\t\treturn fmt.Errorf(\"Expected 1 point, got %v\", timeSeries)\n\t\t\t}\n\t\t\tvalue = valueAsFloat64(timeSeries.Points[0].Value)\n\t\t\treturn nil\n\t\t}, backoffPolicy)\n\treturn value, err\n}","func getMetric(c *gin.Context) {\n\tparams, err := parseMetricParams(c)\n\n\tif err != nil {\n\t\tc.JSON(400, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\t// TODO: Allow string value comparisons as well!\n\tdocs, err := getDataOverRange(mongoSession, biModule.Rules[params.RuleIndex],\n\t\tparams.Granularity, params.Start, params.End, params.Value)\n\tif err != nil {\n\t\tc.JSON(400, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\tc.JSON(200, docs)\n}","func (o *MetricsAllOf) GetMetrics() []Metric {\n\tif o == nil || o.Metrics == nil {\n\t\tvar ret []Metric\n\t\treturn ret\n\t}\n\treturn *o.Metrics\n}","func (d *hdbDriver) Stats() *Stats { return d.metrics.stats() }","func RegistryGet(humanName string) MX4JMetric {\n\treglock.RLock()\n\tdefer reglock.RUnlock()\n\n\treturn registry[humanName]\n}","func (c *memoryExactMatcher) get(key string) (*event.SloClassification, error) {\n\ttimer := prometheus.NewTimer(matcherOperationDurationSeconds.WithLabelValues(\"get\", exactMatcherType))\n\tdefer timer.ObserveDuration()\n\tc.mtx.RLock()\n\tdefer c.mtx.RUnlock()\n\n\tvalue := c.exactMatches[key]\n\treturn value, nil\n}","func GetStats(p *config.ProxyMonitorMetric, cfg *config.CCConfig, timeout time.Duration) *Stats {\n\tbytes := config.Encode(p)\n\tfmt.Println(string(bytes))\n\tvar ch = make(chan struct{})\n\tvar host = p.IP + \":\" + p.AdminPort\n\tfmt.Println(host)\n\tstats := &Stats{}\n\n\tgo func(host string) {\n\t\tdefer close(ch)\n\t\tstats.Host = host\n\t\terr := pingCheck(host, cfg.CCProxyServer.User, cfg.CCProxyServer.Password)\n\t\tif err != nil {\n\t\t\tstats.Error = err.Error()\n\t\t\tstats.Closed = true\n\t\t} else {\n\t\t\tstats.Closed = false\n\t\t}\n\t}(host)\n\n\tselect {\n\tcase <-ch:\n\t\treturn stats\n\tcase <-time.After(timeout):\n\t\treturn &Stats{Host: host, Timeout: true}\n\t}\n}","func (m VarnishPlugin) FetchMetrics() (map[string]interface{}, error) {\n\tvar out []byte\n\tvar err error\n\n\tif m.VarnishName == \"\" {\n\t\tout, err = exec.Command(m.VarnishStatPath, \"-1\").CombinedOutput()\n\t} else {\n\t\tout, err = exec.Command(m.VarnishStatPath, \"-1\", \"-n\", m.VarnishName).CombinedOutput()\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %s\", err, out)\n\t}\n\n\tlineexp := regexp.MustCompile(`^([^ ]+) +(\\d+)`)\n\tsmaexp := regexp.MustCompile(`^SMA\\.([^\\.]+)\\.(.+)$`)\n\n\tstat := map[string]interface{}{\n\t\t\"requests\": float64(0),\n\t}\n\n\tvar tmpv float64\n\tfor _, line := range strings.Split(string(out), \"\\n\") {\n\t\tmatch := lineexp.FindStringSubmatch(line)\n\t\tif match == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\ttmpv, err = strconv.ParseFloat(match[2], 64)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch match[1] {\n\t\tcase \"cache_hit\", \"MAIN.cache_hit\":\n\t\t\tstat[\"cache_hits\"] = tmpv\n\t\t\tstat[\"requests\"] = stat[\"requests\"].(float64) + tmpv\n\t\tcase \"cache_miss\", \"MAIN.cache_miss\":\n\t\t\tstat[\"requests\"] = stat[\"requests\"].(float64) + tmpv\n\t\tcase \"cache_hitpass\", \"MAIN.cache_hitpass\":\n\t\t\tstat[\"requests\"] = stat[\"requests\"].(float64) + tmpv\n\t\tcase \"MAIN.backend_req\":\n\t\t\tstat[\"backend_req\"] = tmpv\n\t\tcase \"MAIN.backend_conn\":\n\t\t\tstat[\"backend_conn\"] = tmpv\n\t\tcase \"MAIN.backend_fail\":\n\t\t\tstat[\"backend_fail\"] = tmpv\n\t\tcase \"MAIN.backend_reuse\":\n\t\t\tstat[\"backend_reuse\"] = tmpv\n\t\tcase \"MAIN.backend_recycle\":\n\t\t\tstat[\"backend_recycle\"] = tmpv\n\t\tcase \"MAIN.n_object\":\n\t\t\tstat[\"n_object\"] = tmpv\n\t\tcase \"MAIN.n_objectcore\":\n\t\t\tstat[\"n_objectcore\"] = tmpv\n\t\tcase \"MAIN.n_expired\":\n\t\t\tstat[\"n_expired\"] = tmpv\n\t\tcase \"MAIN.n_objecthead\":\n\t\t\tstat[\"n_objecthead\"] = tmpv\n\t\tcase \"MAIN.busy_sleep\":\n\t\t\tstat[\"busy_sleep\"] = tmpv\n\t\tcase \"MAIN.busy_wakeup\":\n\t\t\tstat[\"busy_wakeup\"] = tmpv\n\t\tdefault:\n\t\t\tsmamatch := smaexp.FindStringSubmatch(match[1])\n\t\t\tif smamatch == nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif smamatch[2] == \"g_alloc\" {\n\t\t\t\tstat[\"varnish.sma.g_alloc.\"+smamatch[1]+\".g_alloc\"] = tmpv\n\t\t\t} else if smamatch[2] == \"g_bytes\" {\n\t\t\t\tstat[\"varnish.sma.memory.\"+smamatch[1]+\".allocated\"] = tmpv\n\t\t\t} else if smamatch[2] == \"g_space\" {\n\t\t\t\tstat[\"varnish.sma.memory.\"+smamatch[1]+\".available\"] = tmpv\n\t\t\t}\n\t\t}\n\t}\n\n\treturn stat, err\n}","func (m *MeterSnapshot) Snapshot() metrics.Meter { return m }","func (h *Handler) GetAll(c echo.Context) error {\n\tid := c.Param(\"id\")\n\tdb := h.DB.Clone()\n\tdefer db.Close()\n\n\tvar results []*particleio.Result\n\tif err := db.DB(\"oxylus\").C(\"metrics\").Find(bson.M{\"uuid\": id}).Sort(\"time\").All(&results); err != nil {\n\t\tlog.Println(err)\n\t}\n\treturn c.JSON(http.StatusOK, results)\n}","func GetMetrics() []prometheus.Collector {\n\treturn []prometheus.Collector{\n\t\treqCounter,\n\t\treqDuration,\n\t\tconnDuration,\n\t}\n}","func (r *GatewayConnectionStatsRegistry) Get(ctx context.Context, ids ttnpb.GatewayIdentifiers) (*ttnpb.GatewayConnectionStats, error) {\n\tuid := unique.ID(ctx, ids)\n\tresult := &ttnpb.GatewayConnectionStats{}\n\tstats := &ttnpb.GatewayConnectionStats{}\n\n\tretrieved, err := r.Redis.MGet(r.key(upKey, uid), r.key(downKey, uid), r.key(statusKey, uid)).Result()\n\tif err != nil {\n\t\treturn nil, ttnredis.ConvertError(err)\n\t}\n\n\tif retrieved[0] == nil && retrieved[1] == nil && retrieved[2] == nil {\n\t\treturn nil, errNotFound\n\t}\n\n\t// Retrieve uplink stats.\n\tif retrieved[0] != nil {\n\t\tif err = ttnredis.UnmarshalProto(retrieved[0].(string), stats); err != nil {\n\t\t\treturn nil, errInvalidStats.WithAttributes(\"type\", \"uplink\").WithCause(err)\n\t\t}\n\t\tresult.LastUplinkReceivedAt = stats.LastUplinkReceivedAt\n\t\tresult.UplinkCount = stats.UplinkCount\n\t}\n\n\t// Retrieve downlink stats.\n\tif retrieved[1] != nil {\n\t\tif err = ttnredis.UnmarshalProto(retrieved[1].(string), stats); err != nil {\n\t\t\treturn nil, errInvalidStats.WithAttributes(\"type\", \"downlink\").WithCause(err)\n\t\t}\n\t\tresult.LastDownlinkReceivedAt = stats.LastDownlinkReceivedAt\n\t\tresult.DownlinkCount = stats.DownlinkCount\n\t\tresult.RoundTripTimes = stats.RoundTripTimes\n\t}\n\n\t// Retrieve gateway status.\n\tif retrieved[2] != nil {\n\t\tif err = ttnredis.UnmarshalProto(retrieved[2].(string), stats); err != nil {\n\t\t\treturn nil, errInvalidStats.WithAttributes(\"type\", \"status\").WithCause(err)\n\t\t}\n\t\tresult.ConnectedAt = stats.ConnectedAt\n\t\tresult.Protocol = stats.Protocol\n\t\tresult.LastStatus = stats.LastStatus\n\t\tresult.LastStatusReceivedAt = stats.LastStatusReceivedAt\n\t}\n\n\treturn result, nil\n}","func (e *Exporter) GetMetricsList() map[string]*QueryInstance {\n\tif e.allMetricMap == nil {\n\t\treturn nil\n\t}\n\treturn e.allMetricMap\n}","func (Metrics) MetricStruct() {}","func (c *HTTPClient) Metrics(timeout time.Duration) ([]string, error) {\n // temporary struct for parsing JSON response\n var respData struct {\n Names []string `json:\"results\"`\n }\n\n err := c.backend.Call(\"GET\", c.url+\"/api/v1/metricnames\", nil,\n timeout, http.StatusOK, &respData)\n if err != nil {\n return nil, err\n }\n\n glog.V(3).Infof(\"metric names: %+v\", respData.Names)\n return respData.Names, nil\n}","func instrumentGet(inner func()) {\n\tTotalRequests.Add(1)\n\tPendingRequests.Add(1)\n\tdefer PendingRequests.Add(-1)\n\n\tstart := time.Now()\n\n\tinner()\n\n\t// Capture the histogram over 18 geometric buckets \n\tdelta := time.Since(start)\n\tswitch {\n\tcase delta < time.Millisecond:\n\t\tLatencies.Add(\"0ms\", 1)\n\tcase delta > 32768*time.Millisecond:\n\t\tLatencies.Add(\">32s\", 1)\n\tdefault:\n\t\tfor i := time.Millisecond; i < 32768*time.Millisecond; i *= 2 {\n\t\t\tif delta >= i && delta < i*2 {\n\t\t\t\tLatencies.Add(i.String(), 1)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}","func NewMetrics(scope tally.Scope) *Metrics {\n\tsuccessScope := scope.Tagged(map[string]string{\"result\": \"success\"})\n\tfailScope := scope.Tagged(map[string]string{\"result\": \"fail\"})\n\ttimeoutScope := scope.Tagged(map[string]string{\"result\": \"timeout\"})\n\tapiScope := scope.SubScope(\"api\")\n\tserverScope := scope.SubScope(\"server\")\n\tplacement := scope.SubScope(\"placement\")\n\trecovery := scope.SubScope(\"recovery\")\n\n\treturn &Metrics{\n\t\tAPIEnqueueGangs: apiScope.Counter(\"enqueue_gangs\"),\n\t\tEnqueueGangSuccess: successScope.Counter(\"enqueue_gang\"),\n\t\tEnqueueGangFail: failScope.Counter(\"enqueue_gang\"),\n\n\t\tAPIDequeueGangs: apiScope.Counter(\"dequeue_gangs\"),\n\t\tDequeueGangSuccess: successScope.Counter(\"dequeue_gangs\"),\n\t\tDequeueGangTimeout: timeoutScope.Counter(\"dequeue_gangs\"),\n\n\t\tAPIGetPreemptibleTasks: apiScope.Counter(\"get_preemptible_tasks\"),\n\t\tGetPreemptibleTasksSuccess: successScope.Counter(\"get_preemptible_tasks\"),\n\t\tGetPreemptibleTasksTimeout: timeoutScope.Counter(\"get_preemptible_tasks\"),\n\n\t\tAPISetPlacements: apiScope.Counter(\"set_placements\"),\n\t\tSetPlacementSuccess: successScope.Counter(\"set_placements\"),\n\t\tSetPlacementFail: failScope.Counter(\"set_placements\"),\n\n\t\tAPIGetPlacements: apiScope.Counter(\"get_placements\"),\n\t\tGetPlacementSuccess: successScope.Counter(\"get_placements\"),\n\t\tGetPlacementFail: failScope.Counter(\"get_placements\"),\n\n\t\tAPILaunchedTasks: apiScope.Counter(\"launched_tasks\"),\n\n\t\tRecoverySuccess: successScope.Counter(\"recovery\"),\n\t\tRecoveryFail: failScope.Counter(\"recovery\"),\n\t\tRecoveryRunningSuccessCount: successScope.Counter(\"task_count\"),\n\t\tRecoveryRunningFailCount: failScope.Counter(\"task_count\"),\n\t\tRecoveryEnqueueFailedCount: failScope.Counter(\"enqueue_task_count\"),\n\t\tRecoveryEnqueueSuccessCount: successScope.Counter(\"enqueue_task_count\"),\n\t\tRecoveryTimer: recovery.Timer(\"running_tasks\"),\n\n\t\tPlacementQueueLen: placement.Gauge(\"placement_queue_length\"),\n\t\tPlacementFailed: placement.Counter(\"fail\"),\n\n\t\tElected: serverScope.Gauge(\"elected\"),\n\t}\n}","func (r *GoMetricsRegistry) GetAll() map[string]map[string]interface{} {\n\treturn r.shadow.GetAll()\n}","func NewMetrics(app, metricsPrefix, version, hash, date string) *Metrics {\n\tlabels := map[string]string{\n\t\t\"app\": app,\n\t\t\"version\": version,\n\t\t\"hash\": hash,\n\t\t\"buildTime\": date,\n\t}\n\n\tif metricsPrefix != \"\" {\n\t\tmetricsPrefix += \"_\"\n\t}\n\n\tpm := &Metrics{\n\t\tresponseTime: prometheus.NewHistogramVec(\n\t\t\tprometheus.HistogramOpts{\n\t\t\t\tName: metricsPrefix + \"response_time_seconds\",\n\t\t\t\tHelp: \"Description\",\n\t\t\t\tConstLabels: labels,\n\t\t\t},\n\t\t\t[]string{\"endpoint\"},\n\t\t),\n\t\ttotalRequests: prometheus.NewCounterVec(prometheus.CounterOpts{\n\t\t\tName: metricsPrefix + \"requests_total\",\n\t\t\tHelp: \"number of requests\",\n\t\t\tConstLabels: labels,\n\t\t}, []string{\"code\", \"method\", \"endpoint\"}),\n\t\tduration: prometheus.NewHistogramVec(prometheus.HistogramOpts{\n\t\t\tName: metricsPrefix + \"requests_duration_seconds\",\n\t\t\tHelp: \"duration of a requests in seconds\",\n\t\t\tConstLabels: labels,\n\t\t}, []string{\"code\", \"method\", \"endpoint\"}),\n\t\tresponseSize: prometheus.NewHistogramVec(prometheus.HistogramOpts{\n\t\t\tName: metricsPrefix + \"response_size_bytes\",\n\t\t\tHelp: \"size of the responses in bytes\",\n\t\t\tConstLabels: labels,\n\t\t}, []string{\"code\", \"method\"}),\n\t\trequestSize: prometheus.NewHistogramVec(prometheus.HistogramOpts{\n\t\t\tName: metricsPrefix + \"requests_size_bytes\",\n\t\t\tHelp: \"size of the requests in bytes\",\n\t\t\tConstLabels: labels,\n\t\t}, []string{\"code\", \"method\"}),\n\t\thandlerStatuses: prometheus.NewCounterVec(prometheus.CounterOpts{\n\t\t\tName: metricsPrefix + \"requests_statuses_total\",\n\t\t\tHelp: \"count number of responses per status\",\n\t\t\tConstLabels: labels,\n\t\t}, []string{\"method\", \"status_bucket\"}),\n\t}\n\n\terr := prometheus.Register(pm)\n\tif e := new(prometheus.AlreadyRegisteredError); errors.As(err, e) {\n\t\treturn pm\n\t} else if err != nil {\n\t\tpanic(err)\n\t}\n\n\tgrpcPrometheus.EnableHandlingTimeHistogram()\n\n\treturn pm\n}","func (p HAProxyPlugin) FetchMetrics() (map[string]float64, error) {\n\tvar metrics map[string]float64\n\tvar err error\n\tif p.Socket == \"\" {\n\t\tmetrics, err = p.fetchMetricsFromTCP()\n\t} else {\n\t\tmetrics, err = p.fetchMetricsFromSocket()\n\t}\n\treturn metrics, err\n}","func (tc *sklImpl) Metrics() Metrics {\n\treturn tc.metrics\n}","func (p *StatsDParser) GetMetrics() pdata.Metrics {\n\tmetrics := pdata.NewMetrics()\n\trm := metrics.ResourceMetrics().AppendEmpty()\n\n\tfor _, metric := range p.gauges {\n\t\trm.InstrumentationLibraryMetrics().Append(metric)\n\t}\n\n\tfor _, metric := range p.counters {\n\t\trm.InstrumentationLibraryMetrics().Append(metric)\n\t}\n\n\tfor _, metric := range p.timersAndDistributions {\n\t\trm.InstrumentationLibraryMetrics().Append(metric)\n\t}\n\n\tfor _, summaryMetric := range p.summaries {\n\t\tmetrics.ResourceMetrics().At(0).InstrumentationLibraryMetrics().Append(buildSummaryMetric(summaryMetric))\n\t}\n\n\tp.gauges = make(map[statsDMetricdescription]pdata.InstrumentationLibraryMetrics)\n\tp.counters = make(map[statsDMetricdescription]pdata.InstrumentationLibraryMetrics)\n\tp.timersAndDistributions = make([]pdata.InstrumentationLibraryMetrics, 0)\n\tp.summaries = make(map[statsDMetricdescription]summaryMetric)\n\treturn metrics\n}","func (s *CacheService) Get(base string) *RatesStore {\n\t// Is our cache expired?\n\tif s.IsExpired(base) {\n\t\treturn nil\n\t}\n\n\t// Use stored results.\n\treturn cache[base]\n}","func GetProxyMetrics(proxyName string) *ServerMetric {\n\tsmMutex.RLock()\n\tdefer smMutex.RUnlock()\n\tmetric, ok := ServerMetricInfoMap[proxyName]\n\tif ok {\n\t\tmetric.mutex.RLock()\n\t\ttmpMetric := metric.clone()\n\t\tmetric.mutex.RUnlock()\n\t\treturn tmpMetric\n\t} else {\n\t\treturn nil\n\t}\n}","func GetStats(args *Args, format string) string {\n\tcfg := config.GetConfig(args.ConfigFile)\n\t// init statistic for record\n\tstatistic.InitStatistic(cfg.Statistic)\n\n\tallQueueStatistic := []*statistic.QueueStatistic{}\n\n\tfor _, cc := range cfg.Redis {\n\t\tfor _, queueConfig := range cc.Queues {\n\t\t\ts := &statistic.QueueStatistic{\n\t\t\t\tQueueName: queueConfig.QueueName,\n\t\t\t\tSourceType: \"Redis\",\n\t\t\t\tIsEnabled: queueConfig.IsEnabled,\n\t\t\t}\n\n\t\t\tqi := &redis.QueueInstance{\n\t\t\t\tSource: cc.Config,\n\t\t\t\tQueue: queueConfig,\n\t\t\t}\n\n\t\t\tif queueConfig.IsDelayQueue {\n\t\t\t\ts.Normal, _ = qi.DelayLength(queueConfig.QueueName)\n\t\t\t} else {\n\t\t\t\ts.Normal, _ = qi.Length(queueConfig.QueueName)\n\t\t\t}\n\n\t\t\tif len(queueConfig.DelayOnFailure) > 0 {\n\t\t\t\tqueueName := fmt.Sprintf(\"%s:delayed\", queueConfig.QueueName)\n\t\t\t\ts.Delayed, _ = qi.DelayLength(queueName)\n\t\t\t}\n\n\t\t\ts.Success, _ = statistic.GetCounter(fmt.Sprintf(\"%s:success\", queueConfig.QueueName))\n\t\t\ts.Failure, _ = statistic.GetCounter(fmt.Sprintf(\"%s:failure\", queueConfig.QueueName))\n\n\t\t\ts.Total = s.Normal + s.Delayed + s.Success + s.Failure\n\n\t\t\tallQueueStatistic = append(allQueueStatistic, s)\n\t\t}\n\t}\n\n\tfor _, cc := range cfg.RabbitMQ {\n\t\tfor _, queueConfig := range cc.Queues {\n\t\t\ts := &statistic.QueueStatistic{\n\t\t\t\tQueueName: queueConfig.QueueName,\n\t\t\t\tSourceType: \"RabbitMQ\",\n\t\t\t\tIsEnabled: queueConfig.IsEnabled,\n\t\t\t}\n\n\t\t\t// qi := &rabbitmq.QueueInstance{\n\t\t\t// \tSource: cc.Config,\n\t\t\t// \tQueue: queueConfig,\n\t\t\t// }\n\t\t\t// todo get queue length\n\n\t\t\ts.Normal = 0\n\t\t\ts.Delayed = 0\n\n\t\t\ts.Success, _ = statistic.GetCounter(fmt.Sprintf(\"%s:success\", queueConfig.QueueName))\n\t\t\ts.Failure, _ = statistic.GetCounter(fmt.Sprintf(\"%s:failure\", queueConfig.QueueName))\n\n\t\t\ts.Total = s.Normal + s.Delayed + s.Success + s.Failure\n\n\t\t\tallQueueStatistic = append(allQueueStatistic, s)\n\t\t}\n\t}\n\n\tif \"json\" == format {\n\t\toutput, err := json.Marshal(allQueueStatistic)\n\n\t\tif nil != err {\n\t\t\treturn \"\"\n\t\t}\n\n\t\treturn string(output)\n\t}\n\n\toutput := fmt.Sprintf(\"%s %s statistics information\\n\\n\", constant.APPNAME, constant.APPVERSION)\n\tfor _, s := range allQueueStatistic {\n\t\tstatus := \"disable\"\n\t\tif s.IsEnabled {\n\t\t\tstatus = \"enable\"\n\t\t}\n\t\toutput += fmt.Sprintf(\" > Type: %-8s Status: %-8s Name: %s\\n%10d Total\\n%10d Normal\\n%10d Delayed\\n%10d Success\\n%10d Failure\\n\\n\", s.SourceType, status, s.QueueName, s.Total, s.Normal, s.Delayed, s.Success, s.Failure)\n\t}\n\n\tif \"html\" == format {\n\t\tstrings.Replace(output, \"\\n\", \"
\", -1)\n\t}\n\n\treturn output\n}","func (m *podMetrics) Get(ctx context.Context, name string, opts *metav1.GetOptions) (runtime.Object, error) {\n\tnamespace := genericapirequest.NamespaceValue(ctx)\n\n\tpod, err := m.podLister.ByNamespace(namespace).Get(name)\n\tif err != nil {\n\t\tif errors.IsNotFound(err) {\n\t\t\t// return not-found errors directly\n\t\t\treturn &metrics.PodMetrics{}, err\n\t\t}\n\t\tklog.ErrorS(err, \"Failed getting pod\", \"pod\", klog.KRef(namespace, name))\n\t\treturn &metrics.PodMetrics{}, fmt.Errorf(\"failed getting pod: %w\", err)\n\t}\n\tif pod == nil {\n\t\treturn &metrics.PodMetrics{}, errors.NewNotFound(corev1.Resource(\"pods\"), fmt.Sprintf(\"%s/%s\", namespace, name))\n\t}\n\n\tms, err := m.getMetrics(pod)\n\tif err != nil {\n\t\tklog.ErrorS(err, \"Failed reading pod metrics\", \"pod\", klog.KRef(namespace, name))\n\t\treturn nil, fmt.Errorf(\"failed pod metrics: %w\", err)\n\t}\n\tif len(ms) == 0 {\n\t\treturn nil, errors.NewNotFound(m.groupResource, fmt.Sprintf(\"%s/%s\", namespace, name))\n\t}\n\treturn &ms[0], nil\n}","func (core *Core) FetchMetricData() (*registry.MetricsData, error) {\n\tresp, err := http.Get(\"http://\" + core.master + \"/master/state.json\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdata := new(registry.MetricsData)\n\tif err = json.NewDecoder(resp.Body).Decode(data); err != nil {\n\t\treturn nil, err\n\t}\n\tresp.Body.Close()\n\treturn data, nil\n}","func GetMetrics(ps datatypes.PerformanceSignature, ts []datatypes.Timestamps) (datatypes.ComparisonMetrics, error) {\n\tmetricString := createMetricString(ps.PSMetrics)\n\tlogging.LogDebug(datatypes.Logging{Message: fmt.Sprintf(\"Escaped safe metric names are: %v\", metricString)})\n\n\t// Get the metrics from the most recent Deployment Event\n\tmetricResponse, err := queryMetrics(ps.DTServer, ps.DTEnv, metricString, ts[0], ps)\n\tif err != nil {\n\t\treturn datatypes.ComparisonMetrics{}, fmt.Errorf(\"error querying current metrics from Dynatrace: %v\", err)\n\t}\n\n\t// If there were two Deployment Events, get the second set of metrics\n\tif len(ts) == 2 {\n\t\tpreviousMetricResponse, err := queryMetrics(ps.DTServer, ps.DTEnv, metricString, ts[1], ps)\n\t\tif err != nil {\n\t\t\treturn datatypes.ComparisonMetrics{}, fmt.Errorf(\"error querying previous metrics from Dynatrace: %v\", err)\n\t\t}\n\t\tvar bothMetricSets = datatypes.ComparisonMetrics{\n\t\t\tCurrentMetrics: metricResponse,\n\t\t\tPreviousMetrics: previousMetricResponse,\n\t\t}\n\n\t\treturn bothMetricSets, nil\n\t}\n\n\tvar metrics = datatypes.ComparisonMetrics{\n\t\tCurrentMetrics: metricResponse,\n\t}\n\n\treturn metrics, nil\n}","func (b *gsDBBackup) getBackupMetrics(now time.Time) (time.Time, int64, error) {\n\tlastTime := time.Time{}\n\tvar count int64 = 0\n\tcountAfter := now.Add(-24 * time.Hour)\n\terr := gs.AllFilesInDir(b.gsClient, b.gsBucket, DB_BACKUP_DIR, func(item *storage.ObjectAttrs) {\n\t\tif item.Updated.After(lastTime) {\n\t\t\tlastTime = item.Updated\n\t\t}\n\t\tif item.Updated.After(countAfter) {\n\t\t\tcount++\n\t\t}\n\t})\n\treturn lastTime, count, err\n}","func (c *ClusterScalingScheduleCollector) GetMetrics() ([]CollectedMetric, error) {\n\tclusterScalingScheduleInterface, exists, err := c.store.GetByKey(c.objectReference.Name)\n\tif !exists {\n\t\treturn nil, ErrClusterScalingScheduleNotFound\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unexpected error retrieving the ClusterScalingSchedule: %s\", err.Error())\n\t}\n\n\t// The [cache.Store][0] returns the v1.ClusterScalingSchedule items as\n\t// a v1.ScalingSchedule when it first lists it. Once the objects are\n\t// updated/patched it asserts it correctly to the\n\t// v1.ClusterScalingSchedule type. It means we have to handle both\n\t// cases.\n\t// TODO(jonathanbeber): Identify why it happens and fix in the upstream.\n\t//\n\t// [0]: https://github.com/kubernetes/client-go/blob/v0.21.1/tools/cache/Store.go#L132-L140\n\tvar clusterScalingSchedule v1.ClusterScalingSchedule\n\tscalingSchedule, ok := clusterScalingScheduleInterface.(*v1.ScalingSchedule)\n\tif !ok {\n\t\tcss, ok := clusterScalingScheduleInterface.(*v1.ClusterScalingSchedule)\n\t\tif !ok {\n\t\t\treturn nil, ErrNotClusterScalingScheduleFound\n\t\t}\n\t\tclusterScalingSchedule = *css\n\t} else {\n\t\tclusterScalingSchedule = v1.ClusterScalingSchedule(*scalingSchedule)\n\t}\n\n\treturn calculateMetrics(clusterScalingSchedule.Spec, c.defaultScalingWindow, c.defaultTimeZone, c.rampSteps, c.now(), c.objectReference, c.metric)\n}","func metricsUpdate() {\n metricsXml()\n}","func (sr *scrutinyRepository) GetSummary(ctx context.Context) (map[string]*models.DeviceSummary, error) {\n\tdevices, err := sr.GetDevices(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tsummaries := map[string]*models.DeviceSummary{}\n\n\tfor _, device := range devices {\n\t\tsummaries[device.WWN] = &models.DeviceSummary{Device: device}\n\t}\n\n\t// Get parser flux query result\n\t//appConfig.GetString(\"web.influxdb.bucket\")\n\tqueryStr := fmt.Sprintf(`\n \timport \"influxdata/influxdb/schema\"\n \tbucketBaseName = \"%s\"\n\n\tdailyData = from(bucket: bucketBaseName)\n\t|> range(start: -10y, stop: now())\n\t|> filter(fn: (r) => r[\"_measurement\"] == \"smart\" )\n\t|> filter(fn: (r) => r[\"_field\"] == \"temp\" or r[\"_field\"] == \"power_on_hours\" or r[\"_field\"] == \"date\")\n\t|> last()\n\t|> schema.fieldsAsCols()\n\t|> group(columns: [\"device_wwn\"])\n\t\n\tweeklyData = from(bucket: bucketBaseName + \"_weekly\")\n\t|> range(start: -10y, stop: now())\n\t|> filter(fn: (r) => r[\"_measurement\"] == \"smart\" )\n\t|> filter(fn: (r) => r[\"_field\"] == \"temp\" or r[\"_field\"] == \"power_on_hours\" or r[\"_field\"] == \"date\")\n\t|> last()\n\t|> schema.fieldsAsCols()\n\t|> group(columns: [\"device_wwn\"])\n\t\n\tmonthlyData = from(bucket: bucketBaseName + \"_monthly\")\n\t|> range(start: -10y, stop: now())\n\t|> filter(fn: (r) => r[\"_measurement\"] == \"smart\" )\n\t|> filter(fn: (r) => r[\"_field\"] == \"temp\" or r[\"_field\"] == \"power_on_hours\" or r[\"_field\"] == \"date\")\n\t|> last()\n\t|> schema.fieldsAsCols()\n\t|> group(columns: [\"device_wwn\"])\n\t\n\tyearlyData = from(bucket: bucketBaseName + \"_yearly\")\n\t|> range(start: -10y, stop: now())\n\t|> filter(fn: (r) => r[\"_measurement\"] == \"smart\" )\n\t|> filter(fn: (r) => r[\"_field\"] == \"temp\" or r[\"_field\"] == \"power_on_hours\" or r[\"_field\"] == \"date\")\n\t|> last()\n\t|> schema.fieldsAsCols()\n\t|> group(columns: [\"device_wwn\"])\n\t\n\tunion(tables: [dailyData, weeklyData, monthlyData, yearlyData])\n\t|> sort(columns: [\"_time\"], desc: false)\n\t|> group(columns: [\"device_wwn\"])\n\t|> last(column: \"device_wwn\")\n\t|> yield(name: \"last\")\n\t\t`,\n\t\tsr.appConfig.GetString(\"web.influxdb.bucket\"),\n\t)\n\n\tresult, err := sr.influxQueryApi.Query(ctx, queryStr)\n\tif err == nil {\n\t\t// Use Next() to iterate over query result lines\n\t\tfor result.Next() {\n\t\t\t// Observe when there is new grouping key producing new table\n\t\t\tif result.TableChanged() {\n\t\t\t\t//fmt.Printf(\"table: %s\\n\", result.TableMetadata().String())\n\t\t\t}\n\t\t\t// read result\n\n\t\t\t//get summary data from Influxdb.\n\t\t\t//result.Record().Values()\n\t\t\tif deviceWWN, ok := result.Record().Values()[\"device_wwn\"]; ok {\n\n\t\t\t\t//ensure summaries is intialized for this wwn\n\t\t\t\tif _, exists := summaries[deviceWWN.(string)]; !exists {\n\t\t\t\t\tsummaries[deviceWWN.(string)] = &models.DeviceSummary{}\n\t\t\t\t}\n\n\t\t\t\tsummaries[deviceWWN.(string)].SmartResults = &models.SmartSummary{\n\t\t\t\t\tTemp: result.Record().Values()[\"temp\"].(int64),\n\t\t\t\t\tPowerOnHours: result.Record().Values()[\"power_on_hours\"].(int64),\n\t\t\t\t\tCollectorDate: result.Record().Values()[\"_time\"].(time.Time),\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif result.Err() != nil {\n\t\t\tfmt.Printf(\"Query error: %s\\n\", result.Err().Error())\n\t\t}\n\t} else {\n\t\treturn nil, err\n\t}\n\n\tdeviceTempHistory, err := sr.GetSmartTemperatureHistory(ctx, DURATION_KEY_FOREVER)\n\tif err != nil {\n\t\tsr.logger.Printf(\"========================>>>>>>>>======================\")\n\t\tsr.logger.Printf(\"========================>>>>>>>>======================\")\n\t\tsr.logger.Printf(\"========================>>>>>>>>======================\")\n\t\tsr.logger.Printf(\"========================>>>>>>>>======================\")\n\t\tsr.logger.Printf(\"========================>>>>>>>>======================\")\n\t\tsr.logger.Printf(\"Error: %v\", err)\n\t}\n\tfor wwn, tempHistory := range deviceTempHistory {\n\t\tsummaries[wwn].TempHistory = tempHistory\n\t}\n\n\treturn summaries, nil\n}","func ServerMetrics() (*Metrics, error) {\n\t// Fetch total artists\n\tartists, err := data.DB.CountArtists()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Fetch total albums\n\talbums, err := data.DB.CountAlbums()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Fetch total songs\n\tsongs, err := data.DB.CountSongs()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Fetch total folders\n\tfolders, err := data.DB.CountFolders()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Combine all metrics\n\treturn &Metrics{\n\t\tArtists: artists,\n\t\tAlbums: albums,\n\t\tSongs: songs,\n\t\tFolders: folders,\n\t}, nil\n}","func (c *summaryCache) get() map[string]*eventsStatementsSummaryByDigest {\n\tc.rw.RLock()\n\tdefer c.rw.RUnlock()\n\n\tres := make(map[string]*eventsStatementsSummaryByDigest, len(c.items))\n\tfor k, v := range c.items {\n\t\tres[k] = v\n\t}\n\treturn res\n}","func Read(\n\tctx context.Context,\n\tendpoint *url.URL,\n\ttp auth.TokenProvider,\n\tlabels []prompb.Label,\n\tago, latency time.Duration,\n\tm instr.Metrics,\n\tl log.Logger,\n\ttls options.TLS,\n) (int, error) {\n\tvar (\n\t\trt http.RoundTripper\n\t\terr error\n\t)\n\n\tif endpoint.Scheme == transport.HTTPS {\n\t\trt, err = transport.NewTLSTransport(l, tls)\n\t\tif err != nil {\n\t\t\treturn 0, errors.Wrap(err, \"create round tripper\")\n\t\t}\n\n\t\trt = auth.NewBearerTokenRoundTripper(l, tp, rt)\n\t} else {\n\t\trt = auth.NewBearerTokenRoundTripper(l, tp, nil)\n\t}\n\n\tclient, err := promapi.NewClient(promapi.Config{\n\t\tAddress: endpoint.String(),\n\t\tRoundTripper: rt,\n\t})\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tlabelSelectors := make([]string, len(labels))\n\tfor i, label := range labels {\n\t\tlabelSelectors[i] = fmt.Sprintf(`%s=\"%s\"`, label.Name, label.Value)\n\t}\n\n\tquery := fmt.Sprintf(\"{%s}\", strings.Join(labelSelectors, \",\"))\n\tts := time.Now().Add(ago)\n\n\tvalue, httpCode, _, err := api.Query(ctx, client, query, ts, false)\n\tif err != nil {\n\t\treturn httpCode, errors.Wrap(err, \"query request failed\")\n\t}\n\n\tvec := value.(model.Vector)\n\tif len(vec) != 1 {\n\t\treturn httpCode, errors.Errorf(\"expected one metric, got %d\", len(vec))\n\t}\n\n\tt := time.Unix(int64(vec[0].Value/1000), 0)\n\n\tdiffSeconds := time.Since(t).Seconds()\n\n\tm.MetricValueDifference.Observe(diffSeconds)\n\n\tif diffSeconds > latency.Seconds() {\n\t\treturn httpCode, errors.Errorf(\"metric value is too old: %2.fs\", diffSeconds)\n\t}\n\n\treturn httpCode, nil\n}","func getMetrics(_ string) []string {\n\tvar (\n\t\terr error\n\t\tsession *Session\n\t\tclient orchestrator.OrchestratorClient\n\t\tres *orchestrator.ListMetricsResponse\n\t)\n\n\tif session, err = ContinueSession(); err != nil {\n\t\tfmt.Printf(\"Error while retrieving the session. Please re-authenticate.\\n\")\n\t\treturn nil\n\t}\n\n\tclient = orchestrator.NewOrchestratorClient(session)\n\n\tif res, err = client.ListMetrics(context.Background(), &orchestrator.ListMetricsRequest{}); err != nil {\n\t\treturn []string{}\n\t}\n\n\tvar metrics []string\n\tfor _, v := range res.Metrics {\n\t\tmetrics = append(metrics, fmt.Sprintf(\"%s\\t%s: %s\", v.Id, v.Name, v.Description))\n\t}\n\n\treturn metrics\n}","func (m Metrics) MetricStruct() {}","func (h *StatsHandlers) getStats(c *gin.Context) {\n\tdb, ok := c.MustGet(\"databaseConn\").(*gorm.DB)\n\tif !ok {\n\t\treturn\n\t}\n\n\tvar stats []models.Stats\n\tdb.Limit(60 * 5).Order(\"created_date desc\").Find(&stats)\n\n\tSuccess(c, \"stats\", gin.H{\n\t\t\"title\": \"Stats\",\n\t\t\"stats\": stats})\n\n}"],"string":"[\n \"func (h *singleLhcNodeHarness) getMetrics() *metrics {\\n\\treturn &metrics{\\n\\t\\ttimeSinceLastCommitMillis: h.metricRegistry.Get(\\\"ConsensusAlgo.LeanHelix.TimeSinceLastCommit.Millis\\\").(*metric.Histogram),\\n\\t\\ttimeSinceLastElectionMillis: h.metricRegistry.Get(\\\"ConsensusAlgo.LeanHelix.TimeSinceLastElection.Millis\\\").(*metric.Histogram),\\n\\t\\tcurrentElectionCount: h.metricRegistry.Get(\\\"ConsensusAlgo.LeanHelix.CurrentElection.Number\\\").(*metric.Gauge),\\n\\t\\tcurrentLeaderMemberId: h.metricRegistry.Get(\\\"ConsensusAlgo.LeanHelix.CurrentLeaderMemberId.Number\\\").(*metric.Text),\\n\\t\\tlastCommittedTime: h.metricRegistry.Get(\\\"ConsensusAlgo.LeanHelix.LastCommitted.TimeNano\\\").(*metric.Gauge),\\n\\t}\\n}\",\n \"func (s SolrPlugin) FetchMetrics() (map[string]interface{}, error) {\\n\\tstat := make(map[string]interface{})\\n\\tfor core, stats := range s.Stats {\\n\\t\\tfor k, v := range stats {\\n\\t\\t\\tstat[core+\\\"_\\\"+k] = v\\n\\t\\t}\\n\\t}\\n\\treturn stat, nil\\n}\",\n \"func (e Entry) GetMetrics(timeout time.Duration, h heimdall.Doer, debug bool) (Metrics, error) {\\n\\tvar m Metrics\\n\\n\\t// Let's set the stuff we know already.\\n\\tm.Address = e.Address\\n\\tm.Regexp = e.Regexp\\n\\tm.CapturedAt = time.Now().UTC()\\n\\n\\t// Set a timeout.\\n\\tctx, cancel := context.WithTimeout(context.Background(), timeout)\\n\\tdefer cancel()\\n\\n\\t// Setup the request.\\n\\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, e.Address, nil)\\n\\tif err != nil {\\n\\t\\treturn m, err\\n\\t}\\n\\n\\tif debug {\\n\\t\\tfmt.Printf(\\\"%#v\\\\n\\\", req)\\n\\t}\\n\\n\\t// Let's do the request.\\n\\tstart := time.Now()\\n\\tres, err := h.Do(req)\\n\\tif err != nil {\\n\\t\\treturn m, err\\n\\t}\\n\\n\\t// We don't need the body unless we've got a regexp.\\n\\tif e.Regexp != \\\"\\\" {\\n\\t\\tbody, err := ioutil.ReadAll(res.Body)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn m, err\\n\\t\\t}\\n\\t\\t// Do the regexp here and assign the value.\\n\\t\\tmatch, _ := regexp.MatchString(e.Regexp, string(body))\\n\\t\\tm.RegexpStatus = match\\n\\t}\\n\\ttook := time.Since(start)\\n\\n\\t// Set the last few values\\n\\tm.StatusCode = res.StatusCode\\n\\tm.ResponseTime = took\\n\\n\\tif debug {\\n\\t\\tfmt.Printf(\\\"Result: %#v\\\\n\\\", res)\\n\\t\\tfmt.Printf(\\\"Time Taken: %s\\\\n\\\", took)\\n\\t\\tfmt.Printf(\\\"Metrics: %#v\\\\n\\\", m)\\n\\t}\\n\\n\\tif ctx.Err() != nil {\\n\\t\\treturn m, errors.New(\\\"context deadline exceeded\\\")\\n\\t}\\n\\treturn m, nil\\n}\",\n \"func (ms *metricsStore) getMetricData(currentTime time.Time) pmetric.Metrics {\\n\\tms.RLock()\\n\\tdefer ms.RUnlock()\\n\\n\\tout := pmetric.NewMetrics()\\n\\tfor _, mds := range ms.metricsCache {\\n\\t\\tfor i := range mds {\\n\\t\\t\\t// Set datapoint timestamp to be time of retrieval from cache.\\n\\t\\t\\tapplyCurrentTime(mds[i].Metrics, currentTime)\\n\\t\\t\\tinternaldata.OCToMetrics(mds[i].Node, mds[i].Resource, mds[i].Metrics).ResourceMetrics().MoveAndAppendTo(out.ResourceMetrics())\\n\\t\\t}\\n\\t}\\n\\n\\treturn out\\n}\",\n \"func (m Plugin) FetchMetrics() (map[string]float64, error) {\\n\\tresp, err := http.Get(fmt.Sprintf(\\\"http://%s/stats\\\", m.Target))\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tdefer resp.Body.Close()\\n\\tstats := struct {\\n\\t\\tConnections float64 `json:\\\"connections\\\"`\\n\\t\\tTotalConnections float64 `json:\\\"total_connections\\\"`\\n\\t\\tTotalMessages float64 `json:\\\"total_messages\\\"`\\n\\t\\tConnectErrors float64 `json:\\\"connect_errors\\\"`\\n\\t\\tMessageErrors float64 `json:\\\"message_errors\\\"`\\n\\t\\tClosingConnections float64 `json:\\\"closing_connections\\\"`\\n\\t}{}\\n\\tif err := json.NewDecoder(resp.Body).Decode(&stats); err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tret := make(map[string]float64, 6)\\n\\tret[\\\"conn_current\\\"] = stats.Connections\\n\\tret[\\\"conn_total\\\"] = stats.TotalConnections\\n\\tret[\\\"conn_errors\\\"] = stats.ConnectErrors\\n\\tret[\\\"conn_closing\\\"] = stats.ClosingConnections\\n\\tret[\\\"messages_total\\\"] = stats.TotalMessages\\n\\tret[\\\"messages_errors\\\"] = stats.MessageErrors\\n\\n\\treturn ret, nil\\n}\",\n \"func (m RedisPlugin) FetchMetrics() (map[string]interface{}, error) {\\n\\n\\tpubClient := redis.NewClient(&m.PubRedisOpt)\\n\\tsubClient := redis.NewClient(&m.SubRedisOpt)\\n\\n\\tsubscribe, err := subClient.Subscribe(m.ChannelName)\\n\\tif err != nil {\\n\\t\\tlogger.Errorf(\\\"Failed to subscribe. %s\\\", err)\\n\\t\\treturn nil, err\\n\\t}\\n\\tdefer subscribe.Close()\\n\\tif _, err := pubClient.Publish(m.ChannelName, m.Message).Result(); err != nil {\\n\\t\\tlogger.Errorf(\\\"Failed to publish. %s\\\", err)\\n\\t\\treturn nil, err\\n\\t}\\n\\tstart := time.Now()\\n\\tif _, err := subscribe.ReceiveMessage(); err != nil {\\n\\t\\tlogger.Infof(\\\"Failed to calculate capacity. (The cause may be that AWS Elasticache Redis has no `CONFIG` command.) Skip these metrics. %s\\\", err)\\n\\t\\treturn nil, err\\n\\t}\\n\\tduration := time.Now().Sub(start)\\n\\n\\treturn map[string]interface{}{m.metricName(): float64(duration) / float64(time.Microsecond)}, nil\\n\\n}\",\n \"func (s *Postgres) Get(filter Filter) ([]Metric, error) {\\n\\tmetrics := make([]Metric, 0)\\n\\n\\terr := s.db.Model(&metrics).\\n\\t\\tWhere(\\\"created_at >= ?\\\", filter.Since).\\n\\t\\tWhere(\\\"name = ?\\\", filter.Name).\\n\\t\\tSelect(&metrics)\\n\\n\\tif err != nil {\\n\\t\\treturn nil, errors.Wrapf(err, \\\"failed to get metrics %s\\\", filter)\\n\\t}\\n\\treturn metrics, nil\\n}\",\n \"func (p ECachePlugin) FetchMetrics() (map[string]float64, error) {\\n\\tsess, err := session.NewSession()\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tconfig := aws.NewConfig()\\n\\tif p.AccessKeyID != \\\"\\\" && p.SecretAccessKey != \\\"\\\" {\\n\\t\\tconfig = config.WithCredentials(credentials.NewStaticCredentials(p.AccessKeyID, p.SecretAccessKey, \\\"\\\"))\\n\\t}\\n\\tif p.Region != \\\"\\\" {\\n\\t\\tconfig = config.WithRegion(p.Region)\\n\\t}\\n\\n\\tcloudWatch := cloudwatch.New(sess, config)\\n\\n\\tstat := make(map[string]float64)\\n\\n\\tperInstances := []*cloudwatch.Dimension{\\n\\t\\t{\\n\\t\\t\\tName: aws.String(\\\"CacheClusterId\\\"),\\n\\t\\t\\tValue: aws.String(p.CacheClusterID),\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tName: aws.String(\\\"CacheNodeId\\\"),\\n\\t\\t\\tValue: aws.String(p.CacheNodeID),\\n\\t\\t},\\n\\t}\\n\\n\\tfor _, met := range p.CacheMetrics {\\n\\t\\tv, err := getLastPoint(cloudWatch, perInstances, met)\\n\\t\\tif err == nil {\\n\\t\\t\\tstat[met] = v\\n\\t\\t} else {\\n\\t\\t\\tlog.Printf(\\\"%s: %s\\\", met, err)\\n\\t\\t}\\n\\t}\\n\\n\\treturn stat, nil\\n}\",\n \"func getMetrics() []Metric {\\n\\tms := make([]Metric, 0)\\n\\treturn append(ms, &SimpleEapMetric{})\\n}\",\n \"func (h *History) Compute() *Metrics {\\n h.RLock()\\n defer h.RUnlock()\\n return h.compute()\\n}\",\n \"func (c Configuration) metrics() (*pkg.Metrics, error) {\\n\\tMetricsInitialised.Once.Do(func() {\\n\\t\\tlogger := zerolog.New(os.Stderr).Level(zerolog.DebugLevel)\\n\\t\\tmetrics := &pkg.Metrics{\\n\\t\\t\\tGraphiteHost: c.MetricsConfig.GraphiteHost,\\n\\t\\t\\tNamespace: c.MetricsConfig.NameSpace,\\n\\t\\t\\tGraphiteMode: c.MetricsConfig.GraphiteMode,\\n\\t\\t\\tMetricsInterval: c.MetricsConfig.CollectionInterval,\\n\\t\\t\\tLogger: logger,\\n\\t\\t}\\n\\n\\t\\thostname, err := os.Hostname()\\n\\t\\tif err != nil {\\n\\t\\t\\tMetricsInitialised.metrics, MetricsInitialised.err = nil, err\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tmetrics.Hostname = hostname\\n\\n\\t\\t// determine server Role name\\n\\t\\tif c.MetricsConfig.HostRolePath != \\\"\\\" {\\n\\t\\t\\tfile, err := os.Open(c.MetricsConfig.HostRolePath)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tMetricsInitialised.metrics, MetricsInitialised.err = nil, err\\n\\t\\t\\t\\treturn\\n\\t\\t\\t}\\n\\t\\t\\tscanner := bufio.NewScanner(file)\\n\\t\\t\\tfor scanner.Scan() {\\n\\t\\t\\t\\ttokens := strings.Split(scanner.Text(), c.MetricsConfig.HostRoleToken)\\n\\t\\t\\t\\tif len(tokens) < puppetFileColumnCount {\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tif tokens[0] == c.MetricsConfig.HostRoleKey {\\n\\t\\t\\t\\t\\tmetrics.RoleName = tokens[1]\\n\\t\\t\\t\\t\\tbreak\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tif err = file.Close(); err != nil {\\n\\t\\t\\t\\tlogger.Error().Err(err)\\n\\t\\t\\t\\tMetricsInitialised.metrics, MetricsInitialised.err = nil, err\\n\\t\\t\\t\\treturn\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tmetrics.EveryHourRegister = goMetrics.NewPrefixedRegistry(metrics.Namespace)\\n\\t\\tmetrics.EveryMinuteRegister = goMetrics.NewPrefixedRegistry(metrics.Namespace)\\n\\n\\t\\tMetricsInitialised.metrics, MetricsInitialised.err = metrics, nil\\n\\t})\\n\\n\\treturn MetricsInitialised.metrics, MetricsInitialised.err\\n}\",\n \"func Metrics() (*statsd.Client, error) {\\n\\tonce.Do(func() {\\n\\t\\tmetricsClientConf := config.Metrics()\\n\\t\\tif !metricsClientConf.Enabled {\\n\\t\\t\\terr = errors.New(\\\"metrics collection has been disabled\\\")\\n\\t\\t\\tlog.Error(err)\\n\\t\\t\\tinstance = nil\\n\\t\\t} else {\\n\\t\\t\\tconn := fmt.Sprintf(\\\"%s:%d\\\", metricsClientConf.Host, metricsClientConf.Port)\\n\\t\\t\\tinstance, err = statsd.New(conn)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tlog.Info(\\\"Unable to initialize statsd client.\\\")\\n\\t\\t\\t\\tlog.Fatal(err)\\n\\t\\t\\t}\\n\\t\\t\\tinstance.Namespace = metricsClientConf.Prefix\\n\\t\\t}\\n\\t})\\n\\treturn instance, err\\n}\",\n \"func (c *Cache) Get(ctx context.Context, job, instance, metric string) (*Entry, error) {\\n\\tif md, ok := c.staticMetadata[metric]; ok {\\n\\t\\treturn md, nil\\n\\t}\\n\\tmd, ok := c.metadata[metric]\\n\\tif !ok || md.shouldRefetch() {\\n\\t\\t// If we are seeing the job for the first time, preemptively get a full\\n\\t\\t// list of all metadata for the instance.\\n\\t\\tif _, ok := c.seenJobs[job]; !ok {\\n\\t\\t\\tmds, err := c.fetchBatch(ctx, job, instance)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\treturn nil, errors.Wrapf(err, \\\"fetch metadata for job %q\\\", job)\\n\\t\\t\\t}\\n\\t\\t\\tfor _, md := range mds {\\n\\t\\t\\t\\t// Only set if we haven't seen the metric before. Changes to metadata\\n\\t\\t\\t\\t// may need special handling in Stackdriver, which we do not provide\\n\\t\\t\\t\\t// yet anyway.\\n\\t\\t\\t\\tif _, ok := c.metadata[md.Metric]; !ok {\\n\\t\\t\\t\\t\\tc.metadata[md.Metric] = md\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tc.seenJobs[job] = struct{}{}\\n\\t\\t} else {\\n\\t\\t\\tmd, err := c.fetchMetric(ctx, job, instance, metric)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\treturn nil, errors.Wrapf(err, \\\"fetch metric metadata \\\\\\\"%s/%s/%s\\\\\\\"\\\", job, instance, metric)\\n\\t\\t\\t}\\n\\t\\t\\tc.metadata[metric] = md\\n\\t\\t}\\n\\t\\tmd = c.metadata[metric]\\n\\t}\\n\\tif md != nil && md.found {\\n\\t\\treturn md.Entry, nil\\n\\t}\\n\\t// The metric might also be produced by a recording rule, which by convention\\n\\t// contain at least one `:` character. In that case we can generally assume that\\n\\t// it is a gauge. We leave the help text empty.\\n\\tif strings.Contains(metric, \\\":\\\") {\\n\\t\\tentry := &Entry{Metric: metric, MetricType: textparse.MetricTypeGauge}\\n\\t\\treturn entry, nil\\n\\t}\\n\\treturn nil, nil\\n}\",\n \"func (c *Client) getStatistics() *AllStats {\\n\\n\\tvar status Status\\n\\tstatusURL := fmt.Sprintf(statusURLPattern, c.protocol, c.hostname, c.port)\\n\\tbody := c.MakeRequest(statusURL)\\n\\terr := json.Unmarshal(body, &status)\\n\\tif err != nil {\\n\\t\\tlog.Println(\\\"Unable to unmarshal Adguard log statistics to log statistics struct model\\\", err)\\n\\t}\\n\\n\\tvar stats Stats\\n\\tstatsURL := fmt.Sprintf(statsURLPattern, c.protocol, c.hostname, c.port)\\n\\tbody = c.MakeRequest(statsURL)\\n\\terr = json.Unmarshal(body, &stats)\\n\\tif err != nil {\\n\\t\\tlog.Println(\\\"Unable to unmarshal Adguard statistics to statistics struct model\\\", err)\\n\\t}\\n\\n\\tvar logstats LogStats\\n\\tlogstatsURL := fmt.Sprintf(logstatsURLPattern, c.protocol, c.hostname, c.port, c.logLimit)\\n\\tbody = c.MakeRequest(logstatsURL)\\n\\terr = json.Unmarshal(body, &logstats)\\n\\tif err != nil {\\n\\t\\tlog.Println(\\\"Unable to unmarshal Adguard log statistics to log statistics struct model\\\", err)\\n\\t}\\n\\n\\tvar allstats AllStats\\n\\tallstats.status = &status\\n\\tallstats.stats = &stats\\n\\tallstats.logStats = &logstats\\n\\n\\treturn &allstats\\n}\",\n \"func (c *MetricsCollector) Metrics() *InvocationMetrics {\\n\\tc.Lock()\\n\\tdefer c.Unlock()\\n\\treturn c.metrics\\n}\",\n \"func (u UptimePlugin) FetchMetrics() (map[string]float64, error) {\\n\\tut, err := uptime.Get()\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"Failed to fetch uptime metrics: %s\\\", err)\\n\\t}\\n\\treturn map[string]float64{\\\"seconds\\\": ut.Seconds()}, nil\\n}\",\n \"func GetAll() map[Type]time.Duration {\\n\\tmutex.RLock()\\n\\tdefer mutex.RUnlock()\\n\\treturn GlobalStats\\n}\",\n \"func (m *Manager) Get(base int64) *TimestampBuffering {\\n\\t// m.mutex.Lock()\\n\\t// defer m.mutex.Unlock()\\n\\n\\t// get now\\n\\tindex := m.GetCurrentIndex(base)\\n\\tfmt.Printf(\\\"get current index :%d\\\\n\\\",index)\\n\\n\\n\\treturn m.targets[index]\\n\\n\\t// return nil\\n}\",\n \"func (p S3RequestsPlugin) FetchMetrics() (map[string]float64, error) {\\n\\tstats := make(map[string]float64)\\n\\n\\tfor _, met := range s3RequestMetricsGroup {\\n\\t\\tv, err := getLastPointFromCloudWatch(p.CloudWatch, p.BucketName, p.FilterID, met)\\n\\t\\tif err != nil {\\n\\t\\t\\tlog.Printf(\\\"%s: %s\\\", met, err)\\n\\t\\t} else if v != nil {\\n\\t\\t\\tstats = mergeStatsFromDatapoint(stats, v, met)\\n\\t\\t}\\n\\t}\\n\\treturn stats, nil\\n}\",\n \"func (engine *DockerStatsEngine) GetInstanceMetrics() (*ecstcs.MetricsMetadata, []*ecstcs.TaskMetric, error) {\\n\\tvar taskMetrics []*ecstcs.TaskMetric\\n\\tidle := engine.isIdle()\\n\\tmetricsMetadata := &ecstcs.MetricsMetadata{\\n\\t\\tCluster: aws.String(engine.cluster),\\n\\t\\tContainerInstance: aws.String(engine.containerInstanceArn),\\n\\t\\tIdle: aws.Bool(idle),\\n\\t\\tMessageId: aws.String(uuid.NewRandom().String()),\\n\\t}\\n\\n\\tif idle {\\n\\t\\tlog.Debug(\\\"Instance is idle. No task metrics to report\\\")\\n\\t\\tfin := true\\n\\t\\tmetricsMetadata.Fin = &fin\\n\\t\\treturn metricsMetadata, taskMetrics, nil\\n\\t}\\n\\n\\tfor taskArn := range engine.tasksToContainers {\\n\\t\\tcontainerMetrics, err := engine.getContainerMetricsForTask(taskArn)\\n\\t\\tif err != nil {\\n\\t\\t\\tlog.Debug(\\\"Error getting container metrics for task\\\", \\\"err\\\", err, \\\"task\\\", taskArn)\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\n\\t\\tif len(containerMetrics) == 0 {\\n\\t\\t\\tlog.Debug(\\\"Empty containerMetrics for task, ignoring\\\", \\\"task\\\", taskArn)\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\n\\t\\ttaskDef, exists := engine.tasksToDefinitions[taskArn]\\n\\t\\tif !exists {\\n\\t\\t\\tlog.Debug(\\\"Could not map task to definition\\\", \\\"task\\\", taskArn)\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\n\\t\\tmetricTaskArn := taskArn\\n\\t\\ttaskMetric := &ecstcs.TaskMetric{\\n\\t\\t\\tTaskArn: &metricTaskArn,\\n\\t\\t\\tTaskDefinitionFamily: &taskDef.family,\\n\\t\\t\\tTaskDefinitionVersion: &taskDef.version,\\n\\t\\t\\tContainerMetrics: containerMetrics,\\n\\t\\t}\\n\\t\\ttaskMetrics = append(taskMetrics, taskMetric)\\n\\t}\\n\\n\\tif len(taskMetrics) == 0 {\\n\\t\\t// Not idle. Expect taskMetrics to be there.\\n\\t\\treturn nil, nil, fmt.Errorf(\\\"No task metrics to report\\\")\\n\\t}\\n\\n\\t// Reset current stats. Retaining older stats results in incorrect utilization stats\\n\\t// until they are removed from the queue.\\n\\tengine.resetStats()\\n\\treturn metricsMetadata, taskMetrics, nil\\n}\",\n \"func (db *DB) Metrics() *Metrics {\\n\\treturn db.metrics\\n}\",\n \"func Latest() StatusData {\\n\\tlog.Println(\\\"LatestStatusData\\\")\\n\\tr := rp.Get()\\n\\tdefer r.Close()\\n\\n\\tresult := StatusData{Success: true, Timestamp: time.Now(), Realtime: make(map[string]int), Total: make(map[string]int)}\\n\\n\\tr.Send(\\\"SMEMBERS\\\", \\\"domains\\\")\\n\\tr.Flush()\\n\\tresult.Domains, _ = redis.Strings(redis.MultiBulk(r.Receive()))\\n\\n\\tfor _, d := range result.Domains {\\n\\t\\tvar key = d + \\\"_\\\" + result.Timestamp.Format(\\\"20060102\\\")\\n\\t\\tval, _ := redis.Int(r.Do(\\\"GET\\\", key))\\n\\t\\tif val > 0 {\\n\\t\\t\\tresult.Total[d] = val\\n\\t\\t}\\n\\t}\\n\\n\\treply, err := redis.Values(r.Do(\\\"SCAN\\\", 0, \\\"MATCH\\\", \\\"*:*\\\", \\\"COUNT\\\", 1000000))\\n\\tif err != nil {\\n\\t\\tlog.Println(\\\"redis.Values\\\", err)\\n\\t}\\n\\tif _, err := redis.Scan(reply, nil, &result.Idents); err != nil {\\n\\t\\tlog.Println(\\\"redis.Scan\\\", err)\\n\\t}\\n\\tresult.Current = len(result.Idents)\\n\\n\\tfor _, ident := range result.Idents {\\n\\t\\ttmp := strings.Split(ident, \\\":\\\")\\n\\t\\tif val, ok := result.Realtime[tmp[0]]; ok {\\n\\t\\t\\tresult.Realtime[tmp[0]] = val + 1\\n\\t\\t} else {\\n\\t\\t\\tresult.Realtime[tmp[0]] = 1\\n\\t\\t}\\n\\t}\\n\\n\\treturn result\\n}\",\n \"func (api *API) Get(k string) (MetricItem, bool) {\\n\\treturn api.metricItens.Get(k)\\n}\",\n \"func (p CognitoIdpPlugin) FetchMetrics() (map[string]interface{}, error) {\\n\\tstat := make(map[string]interface{})\\n\\n\\tfor _, met := range [...]metrics{\\n\\t\\t{CloudWatchName: \\\"SignUpSuccesses\\\", MackerelName: \\\"SignUpSuccesses\\\", Type: metricsTypeSum},\\n\\t\\t{CloudWatchName: \\\"SignUpSuccesses\\\", MackerelName: \\\"SignUpParcentageOfSuccessful\\\", Type: metricsTypeAverage},\\n\\t\\t{CloudWatchName: \\\"SignUpSuccesses\\\", MackerelName: \\\"SignUpSampleCount\\\", Type: metricsTypeSampleCount},\\n\\t\\t{CloudWatchName: \\\"SignUpThrottles\\\", MackerelName: \\\"SignUpThrottles\\\", Type: metricsTypeSum},\\n\\t\\t{CloudWatchName: \\\"SignInSuccesses\\\", MackerelName: \\\"SignInSuccesses\\\", Type: metricsTypeSum},\\n\\t\\t{CloudWatchName: \\\"SignInSuccesses\\\", MackerelName: \\\"SignInParcentageOfSuccessful\\\", Type: metricsTypeAverage},\\n\\t\\t{CloudWatchName: \\\"SignInSuccesses\\\", MackerelName: \\\"SignInSampleCount\\\", Type: metricsTypeSampleCount},\\n\\t\\t{CloudWatchName: \\\"SignInThrottles\\\", MackerelName: \\\"SignInThrottles\\\", Type: metricsTypeSum},\\n\\t\\t{CloudWatchName: \\\"TokenRefreshSuccesses\\\", MackerelName: \\\"TokenRefreshSuccesses\\\", Type: metricsTypeSum},\\n\\t\\t{CloudWatchName: \\\"TokenRefreshSuccesses\\\", MackerelName: \\\"TokenRefreshParcentageOfSuccessful\\\", Type: metricsTypeAverage},\\n\\t\\t{CloudWatchName: \\\"TokenRefreshSuccesses\\\", MackerelName: \\\"TokenRefreshSampleCount\\\", Type: metricsTypeSampleCount},\\n\\t\\t{CloudWatchName: \\\"TokenRefreshThrottles\\\", MackerelName: \\\"TokenRefreshThrottles\\\", Type: metricsTypeSum},\\n\\t\\t{CloudWatchName: \\\"FederationSuccesses\\\", MackerelName: \\\"FederationSuccesses\\\", Type: metricsTypeSum},\\n\\t\\t{CloudWatchName: \\\"FederationSuccesses\\\", MackerelName: \\\"FederationParcentageOfSuccessful\\\", Type: metricsTypeAverage},\\n\\t\\t{CloudWatchName: \\\"FederationSuccesses\\\", MackerelName: \\\"FederationSampleCount\\\", Type: metricsTypeSampleCount},\\n\\t\\t{CloudWatchName: \\\"FederationThrottles\\\", MackerelName: \\\"FederationThrottles\\\", Type: metricsTypeSum},\\n\\t} {\\n\\t\\tv, err := p.getLastPoint(met)\\n\\t\\tif err == nil {\\n\\t\\t\\tstat[met.MackerelName] = v\\n\\t\\t} else {\\n\\t\\t\\tlog.Printf(\\\"%s: %s\\\", met, err)\\n\\t\\t}\\n\\t}\\n\\treturn stat, nil\\n}\",\n \"func (s *Stats) Get() Stats {\\n\\n\\tout := Stats{\\n\\t\\tEventsTotal: atomic.LoadUint64(&s.EventsTotal),\\n\\t\\tEventsUpdate: atomic.LoadUint64(&s.EventsUpdate),\\n\\t\\tEventsDestroy: atomic.LoadUint64(&s.EventsDestroy),\\n\\t}\\n\\n\\t// Get Update source stats if present.\\n\\tif s.UpdateSourceStats != nil {\\n\\t\\ts := s.UpdateSourceStats.Get()\\n\\t\\tout.UpdateSourceStats = &s\\n\\t}\\n\\n\\t// Get Destroy source stats if present.\\n\\tif s.DestroySourceStats != nil {\\n\\t\\ts := s.DestroySourceStats.Get()\\n\\t\\tout.DestroySourceStats = &s\\n\\t}\\n\\n\\treturn out\\n}\",\n \"func (m *MetricsCacheType) GetMetrics() ([]string, bool) {\\n\\tif m.IsAvailable() && !m.TimedOut() {\\n\\t\\treturn m.metrics, true\\n\\t}\\n\\n\\tif !m.updating {\\n\\t\\tgo m.RefreshCache()\\n\\t}\\n\\treturn nil, false\\n}\",\n \"func (c *ResourceCollector) Get(ch chan<- prometheus.Metric) (float64, error) {\\n\\n\\tjsonResources, err := getResourceStats()\\n\\tif err != nil {\\n\\t\\ttotalResourceErrors++\\n\\t\\treturn totalResourceErrors, fmt.Errorf(\\\"cannot get resources: %s\\\", err)\\n\\t}\\n\\tif err := processResourceStats(ch, jsonResources); err != nil {\\n\\t\\ttotalResourceErrors++\\n\\t\\treturn totalResourceErrors, err\\n\\t}\\n\\treturn totalResourceErrors, nil\\n\\n}\",\n \"func (c *PromMetricsClient) GetMetrics() ([]*Metric, error) {\\n\\tres, err := http.Get(c.URL)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tif res.StatusCode != 200 {\\n\\t\\treturn nil, ErrUnexpectedHTTPStatusCode\\n\\t}\\n\\n\\tdefer res.Body.Close()\\n\\treturn Parse(res.Body)\\n}\",\n \"func (c *CAdvisor) GetMetrics() (*Metrics, error) {\\n\\tlog.Printf(\\\"[DEBUG] [cadvisor] Get metrics\\\")\\n\\tnodeSpec, err := c.Client.MachineInfo()\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tlog.Printf(\\\"[DEBUG] [cadvisor] Receive machine info : %#v\\\",\\n\\t\\tnodeSpec)\\n\\tnodeInfo, err := c.Client.ContainerInfo(\\\"/\\\", c.Query)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tlog.Printf(\\\"[DEBUG] [cadvisor] Receive container info : %#v\\\",\\n\\t\\tnodeInfo)\\n\\tcontainersInfo, err := c.Client.AllDockerContainers(c.Query)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tlog.Printf(\\\"[DEBUG] [cadvisor] Receive all docker containers : %#v\\\",\\n\\t\\tcontainersInfo)\\n\\tmetrics := &Metrics{\\n\\t\\tNodeSpec: nodeSpec,\\n\\t\\tNodeInfo: nodeInfo,\\n\\t\\tContainersInfo: containersInfo,\\n\\t}\\n\\t//log.Printf(\\\"[INFO] [cadvisor] Metrics: %#v\\\", metrics)\\n\\treturn metrics, nil\\n}\",\n \"func (p RekognitionPlugin) FetchMetrics() (map[string]float64, error) {\\n\\tstat := make(map[string]float64)\\n\\n\\tfor _, met := range [...]string{\\n\\t\\t\\\"SuccessfulRequestCount\\\",\\n\\t\\t\\\"ThrottledCount\\\",\\n\\t\\t\\\"ResponseTime\\\",\\n\\t\\t\\\"DetectedFaceCount\\\",\\n\\t\\t\\\"DetectedLabelCount\\\",\\n\\t\\t\\\"ServerErrorCount\\\",\\n\\t\\t\\\"UserErrorCount\\\",\\n\\t} {\\n\\t\\tv, err := p.getLastPoint(met)\\n\\t\\tif err == nil {\\n\\t\\t\\tstat[met] = v\\n\\t\\t} else {\\n\\t\\t\\tlog.Printf(\\\"%s: %s\\\", met, err)\\n\\t\\t}\\n\\t}\\n\\n\\treturn stat, nil\\n}\",\n \"func (mw *Stats) Data() *Data {\\n\\tmw.mu.RLock()\\n\\n\\tresponseCounts := make(map[string]int, len(mw.ResponseCounts))\\n\\ttotalResponseCounts := make(map[string]int, len(mw.TotalResponseCounts))\\n\\ttotalMetricsCounts := make(map[string]int, len(mw.MetricsCounts))\\n\\tmetricsCounts := make(map[string]float64, len(mw.MetricsCounts))\\n\\n\\tnow := time.Now()\\n\\n\\tuptime := now.Sub(mw.Uptime)\\n\\n\\tcount := 0\\n\\tfor code, current := range mw.ResponseCounts {\\n\\t\\tresponseCounts[code] = current\\n\\t\\tcount += current\\n\\t}\\n\\n\\ttotalCount := 0\\n\\tfor code, count := range mw.TotalResponseCounts {\\n\\t\\ttotalResponseCounts[code] = count\\n\\t\\ttotalCount += count\\n\\t}\\n\\n\\ttotalResponseTime := mw.TotalResponseTime.Sub(time.Time{})\\n\\ttotalResponseSize := mw.TotalResponseSize\\n\\n\\taverageResponseTime := time.Duration(0)\\n\\taverageResponseSize := int64(0)\\n\\tif totalCount > 0 {\\n\\t\\tavgNs := int64(totalResponseTime) / int64(totalCount)\\n\\t\\taverageResponseTime = time.Duration(avgNs)\\n\\t\\taverageResponseSize = int64(totalResponseSize) / int64(totalCount)\\n\\t}\\n\\n\\tfor key, count := range mw.MetricsCounts {\\n\\t\\ttotalMetric := mw.MetricsTimers[key].Sub(time.Time{})\\n\\t\\tavgNs := int64(totalMetric) / int64(count)\\n\\t\\tmetricsCounts[key] = time.Duration(avgNs).Seconds()\\n\\t\\ttotalMetricsCounts[key] = count\\n\\t}\\n\\n\\tmw.mu.RUnlock()\\n\\n\\tr := &Data{\\n\\t\\tPid: mw.Pid,\\n\\t\\tUpTime: uptime.String(),\\n\\t\\tUpTimeSec: uptime.Seconds(),\\n\\t\\tTime: now.String(),\\n\\t\\tTimeUnix: now.Unix(),\\n\\t\\tStatusCodeCount: responseCounts,\\n\\t\\tTotalStatusCodeCount: totalResponseCounts,\\n\\t\\tCount: count,\\n\\t\\tTotalCount: totalCount,\\n\\t\\tTotalResponseTime: totalResponseTime.String(),\\n\\t\\tTotalResponseSize: totalResponseSize,\\n\\t\\tTotalResponseTimeSec: totalResponseTime.Seconds(),\\n\\t\\tTotalMetricsCounts: totalMetricsCounts,\\n\\t\\tAverageResponseSize: averageResponseSize,\\n\\t\\tAverageResponseTime: averageResponseTime.String(),\\n\\t\\tAverageResponseTimeSec: averageResponseTime.Seconds(),\\n\\t\\tAverageMetricsTimers: metricsCounts,\\n\\t}\\n\\n\\treturn r\\n}\",\n \"func (r IpvsPlugin) FetchMetrics() (map[string]float64, error) {\\n file, err := os.Open(r.Target)\\n if err != nil {\\n return nil, err\\n }\\n defer file.Close()\\n\\n return Parse(file)\\n}\",\n \"func (s *Store) Metrics() *StoreMetrics {\\n\\treturn s.metrics\\n}\",\n \"func (s *inMemoryStore) Get(ctx context.Context, h types.Metric, resetTime time.Time, fieldVals []any) any {\\n\\tif resetTime.IsZero() {\\n\\t\\tresetTime = clock.Now(ctx)\\n\\t}\\n\\n\\tm := s.getOrCreateData(h)\\n\\tt := s.findTarget(ctx, m)\\n\\tm.lock.Lock()\\n\\tdefer m.lock.Unlock()\\n\\treturn m.get(fieldVals, t, resetTime).Value\\n}\",\n \"func (c *MetricCollector) Get(ctx context.Context, namespace, name string) (*Metric, error) {\\n\\tc.collectionsMutex.RLock()\\n\\tdefer c.collectionsMutex.RUnlock()\\n\\n\\tkey := NewMetricKey(namespace, name)\\n\\tcollector, ok := c.collections[key]\\n\\tif !ok {\\n\\t\\treturn nil, k8serrors.NewNotFound(kpa.Resource(\\\"Deciders\\\"), key)\\n\\t}\\n\\n\\treturn collector.metric.DeepCopy(), nil\\n}\",\n \"func (sink *influxdbSink) GetMetric(metricName string, metricKeys []core.HistoricalKey, start, end time.Time) (map[core.HistoricalKey][]core.TimestampedMetricValue, error) {\\n\\tfor _, key := range metricKeys {\\n\\t\\tif err := sink.checkSanitizedKey(&key); err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t}\\n\\n\\tif err := sink.checkSanitizedMetricName(metricName); err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tquery := sink.composeRawQuery(metricName, nil, metricKeys, start, end)\\n\\n\\tsink.RLock()\\n\\tdefer sink.RUnlock()\\n\\n\\tresp, err := sink.runQuery(query)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tres := make(map[core.HistoricalKey][]core.TimestampedMetricValue, len(metricKeys))\\n\\tfor i, key := range metricKeys {\\n\\t\\tif len(resp[i].Series) < 1 {\\n\\t\\t\\treturn nil, fmt.Errorf(\\\"No results for metric %q describing %q\\\", metricName, key.String())\\n\\t\\t}\\n\\n\\t\\tvals, err := sink.parseRawQueryRow(resp[i].Series[0])\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t\\tres[key] = vals\\n\\t}\\n\\n\\treturn res, nil\\n}\",\n \"func setupMetrics() Metrics {\\n\\tm := Metrics{}\\n\\tm.LastBackupDuration = prometheus.NewGauge(prometheus.GaugeOpts{\\n\\t\\tNamespace: \\\"clickhouse_backup\\\",\\n\\t\\tName: \\\"last_backup_duration\\\",\\n\\t\\tHelp: \\\"Backup duration in nanoseconds.\\\",\\n\\t})\\n\\tm.LastBackupSuccess = prometheus.NewGauge(prometheus.GaugeOpts{\\n\\t\\tNamespace: \\\"clickhouse_backup\\\",\\n\\t\\tName: \\\"last_backup_success\\\",\\n\\t\\tHelp: \\\"Last backup success boolean: 0=failed, 1=success, 2=unknown.\\\",\\n\\t})\\n\\tm.LastBackupStart = prometheus.NewGauge(prometheus.GaugeOpts{\\n\\t\\tNamespace: \\\"clickhouse_backup\\\",\\n\\t\\tName: \\\"last_backup_start\\\",\\n\\t\\tHelp: \\\"Last backup start timestamp.\\\",\\n\\t})\\n\\tm.LastBackupEnd = prometheus.NewGauge(prometheus.GaugeOpts{\\n\\t\\tNamespace: \\\"clickhouse_backup\\\",\\n\\t\\tName: \\\"last_backup_end\\\",\\n\\t\\tHelp: \\\"Last backup end timestamp.\\\",\\n\\t})\\n\\tm.SuccessfulBackups = prometheus.NewCounter(prometheus.CounterOpts{\\n\\t\\tNamespace: \\\"clickhouse_backup\\\",\\n\\t\\tName: \\\"successful_backups\\\",\\n\\t\\tHelp: \\\"Number of Successful Backups.\\\",\\n\\t})\\n\\tm.FailedBackups = prometheus.NewCounter(prometheus.CounterOpts{\\n\\t\\tNamespace: \\\"clickhouse_backup\\\",\\n\\t\\tName: \\\"failed_backups\\\",\\n\\t\\tHelp: \\\"Number of Failed Backups.\\\",\\n\\t})\\n\\tprometheus.MustRegister(\\n\\t\\tm.LastBackupDuration,\\n\\t\\tm.LastBackupStart,\\n\\t\\tm.LastBackupEnd,\\n\\t\\tm.LastBackupSuccess,\\n\\t\\tm.SuccessfulBackups,\\n\\t\\tm.FailedBackups,\\n\\t)\\n\\tm.LastBackupSuccess.Set(2) // 0=failed, 1=success, 2=unknown\\n\\treturn m\\n}\",\n \"func NewMetrics(ns string) *Metrics {\\n\\tres := &Metrics{\\n\\t\\tInfo: promauto.NewGaugeVec(\\n\\t\\t\\tprometheus.GaugeOpts{\\n\\t\\t\\t\\tNamespace: ns,\\n\\t\\t\\t\\tName: \\\"info\\\",\\n\\t\\t\\t\\tHelp: \\\"Informations about given repository, value always 1\\\",\\n\\t\\t\\t},\\n\\t\\t\\t[]string{\\\"module\\\", \\\"goversion\\\"},\\n\\t\\t),\\n\\t\\tDeprecated: promauto.NewGaugeVec(\\n\\t\\t\\tprometheus.GaugeOpts{\\n\\t\\t\\t\\tNamespace: ns,\\n\\t\\t\\t\\tName: \\\"deprecated\\\",\\n\\t\\t\\t\\tHelp: \\\"Number of days since given dependency of repository is out-of-date\\\",\\n\\t\\t\\t},\\n\\t\\t\\t[]string{\\\"module\\\", \\\"dependency\\\", \\\"type\\\", \\\"current\\\", \\\"latest\\\"},\\n\\t\\t),\\n\\t\\tReplaced: promauto.NewGaugeVec(\\n\\t\\t\\tprometheus.GaugeOpts{\\n\\t\\t\\t\\tNamespace: ns,\\n\\t\\t\\t\\tName: \\\"replaced\\\",\\n\\t\\t\\t\\tHelp: \\\"Give information about module replacements\\\",\\n\\t\\t\\t},\\n\\t\\t\\t[]string{\\\"module\\\", \\\"dependency\\\", \\\"type\\\", \\\"replacement\\\", \\\"version\\\"},\\n\\t\\t),\\n\\t\\tStatus: promauto.NewGaugeVec(\\n\\t\\t\\tprometheus.GaugeOpts{\\n\\t\\t\\t\\tNamespace: ns,\\n\\t\\t\\t\\tName: \\\"status\\\",\\n\\t\\t\\t\\tHelp: \\\"Status of last analysis of given repository, 0 for error\\\",\\n\\t\\t\\t},\\n\\t\\t\\t[]string{\\\"repository\\\"},\\n\\t\\t),\\n\\t\\tDuration: promauto.NewGauge(\\n\\t\\t\\tprometheus.GaugeOpts{\\n\\t\\t\\t\\tNamespace: ns,\\n\\t\\t\\t\\tName: \\\"duration\\\",\\n\\t\\t\\t\\tHelp: \\\"Duration of last analysis in second\\\",\\n\\t\\t\\t},\\n\\t\\t),\\n\\t\\tRegistry: prometheus.NewRegistry(),\\n\\t}\\n\\n\\tres.Registry.Register(res.Info)\\n\\tres.Registry.Register(res.Deprecated)\\n\\tres.Registry.Register(res.Replaced)\\n\\tres.Registry.Register(res.Status)\\n\\tres.Registry.Register(res.Duration)\\n\\treturn res\\n}\",\n \"func (y *YarnMetrics) getMetrics() *NMMetrics {\\n\\tjmxResp := &JmxResp{}\\n\\terr := y.requestUrl(metricsSuffix, jmxResp)\\n\\tif err != nil {\\n\\t\\tklog.V(5).Infof(\\\"request nodemanager metrics err: %v\\\", err)\\n\\t\\treturn nil\\n\\t}\\n\\tif len(jmxResp.Beans) == 0 {\\n\\t\\tklog.V(5).Infof(\\\"request nodemanager metrics, empty beans\\\")\\n\\t\\treturn nil\\n\\t}\\n\\treturn &jmxResp.Beans[0]\\n}\",\n \"func (self *Metric) GetTime() time.Time {\\n\\treturn time.Unix(self.Time, 0).UTC()\\n}\",\n \"func (h *Handler) GetMetricSum(w http.ResponseWriter, r *http.Request) {\\n\\tvar b []byte\\n\\tkey := mux.Vars(r)[\\\"key\\\"]\\n\\n\\tresp := response{}\\n\\tw.Header().Set(\\\"Content-Type\\\", \\\"application/json\\\")\\n\\tw.WriteHeader(http.StatusOK)\\n\\tcachedVal, ok := h.MetricsCache.Get(key)\\n\\tif !ok {\\n\\t\\tb, _ = json.Marshal(resp)\\n\\t\\tw.Write(b)\\n\\t\\treturn\\n\\t}\\n\\n\\tcachedList := cachedVal.(*list.List)\\n\\tnewList := list.New()\\n\\n\\tfor element := cachedList.Front(); element != nil; element = element.Next() {\\n\\t\\tdata := element.Value.(metricData)\\n\\t\\tmetricTime := data.time\\n\\t\\tvalidMetricTime := metricTime.Add(h.InstrumentationTimeInSeconds * time.Second)\\n\\n\\t\\tif validMetricTime.After(time.Now()) {\\n\\t\\t\\tresp.Value = resp.Value + data.value\\n\\t\\t\\tdata := metricData{value: data.value, time: data.time}\\n\\n\\t\\t\\tnewList.PushBack(data)\\n\\t\\t} else {\\n\\t\\t\\th.MetricsCache.Set(key, newList, cache.NoExpiration)\\n\\t\\t\\tbreak\\n\\t\\t}\\n\\t}\\n\\n\\tb, _ = json.Marshal(resp)\\n\\tw.Write(b)\\n\\n\\treturn\\n}\",\n \"func (r Virtual_Guest) GetRecentMetricData(time *uint) (resp []datatypes.Metric_Tracking_Object, err error) {\\n\\tparams := []interface{}{\\n\\t\\ttime,\\n\\t}\\n\\terr = r.Session.DoRequest(\\\"SoftLayer_Virtual_Guest\\\", \\\"getRecentMetricData\\\", params, &r.Options, &resp)\\n\\treturn\\n}\",\n \"func (c *client) getAllTicketMetrics(endpoint string, in interface{}) ([]TicketMetric, error) {\\n\\tresult := make([]TicketMetric, 0)\\n\\tpayload, err := marshall(in)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\theaders := map[string]string{}\\n\\tif in != nil {\\n\\t\\theaders[\\\"Content-Type\\\"] = \\\"application/json\\\"\\n\\t}\\n\\n\\tres, err := c.request(\\\"GET\\\", endpoint, headers, bytes.NewReader(payload))\\n\\tdataPerPage := new(APIPayload)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tapiV2 := \\\"/api/v2/\\\"\\n\\tfieldName := strings.Split(endpoint[len(apiV2):], \\\".\\\")[0]\\n\\tdefer res.Body.Close()\\n\\n\\terr = unmarshall(res, dataPerPage)\\n\\n\\tapiStartIndex := strings.Index(dataPerPage.NextPage, apiV2)\\n\\tcurrentPage := endpoint\\n\\n\\tvar totalWaitTime int64\\n\\tfor currentPage != \\\"\\\" {\\n\\t\\t// if too many requests(res.StatusCode == 429), delay sending request\\n\\t\\tif res.StatusCode == 429 {\\n\\t\\t\\tafter, err := strconv.ParseInt(res.Header.Get(\\\"Retry-After\\\"), 10, 64)\\n\\t\\t\\tlog.Printf(\\\"[zd_ticket_metrics_service][getAllTicketMetrics] too many requests. Wait for %v seconds\\\\n\\\", after)\\n\\t\\t\\ttotalWaitTime += after\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\treturn nil, err\\n\\t\\t\\t}\\n\\t\\t\\ttime.Sleep(time.Duration(after) * time.Second)\\n\\t\\t} else {\\n\\t\\t\\tif fieldName == \\\"ticket_metrics\\\" {\\n\\t\\t\\t\\tresult = append(result, dataPerPage.TicketMetrics...)\\n\\t\\t\\t}\\n\\t\\t\\tcurrentPage = dataPerPage.NextPage\\n\\t\\t}\\n\\t\\tres, _ = c.request(\\\"GET\\\", dataPerPage.NextPage[apiStartIndex:], headers, bytes.NewReader(payload))\\n\\t\\tdataPerPage = new(APIPayload)\\n\\t\\terr = unmarshall(res, dataPerPage)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t}\\n\\tlog.Printf(\\\"[zd_ticket_metrics_service][getAllTicketMetrics] number of records pulled: %v\\\\n\\\", len(result))\\n\\tlog.Printf(\\\"[zd_ticket_metrics_service][getAllTicketMetrics] total waiting time due to rate limit: %v\\\\n\\\", totalWaitTime)\\n\\n\\treturn result, err\\n}\",\n \"func (m *MetricSet) Fetch() (common.MapStr, error) {\\n\\n\\thapc, err := haproxy.NewHaproxyClient(m.statsAddr)\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"HAProxy Client error: %s\\\", err)\\n\\t}\\n\\n\\tres, err := hapc.GetInfo()\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"HAProxy Client error fetching %s: %s\\\", statsMethod, err)\\n\\t}\\n\\n\\tmappedEvent, err := eventMapping(res)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn mappedEvent, nil\\n}\",\n \"func getGlobalMetrics(\\n\\tctx context.Context,\\n\\tcl kubeClient,\\n\\tnow time.Time,\\n\\tclusterName string,\\n) ([]types.MetricPoint, error) {\\n\\tvar (\\n\\t\\terr error\\n\\t\\tmultiErr prometheus.MultiError\\n\\t\\tcache kubeCache\\n\\t)\\n\\n\\t// Add resources to the cache.\\n\\tcache.pods, err = cl.GetPODs(ctx, \\\"\\\")\\n\\tmultiErr.Append(err)\\n\\n\\tcache.namespaces, err = cl.GetNamespaces(ctx)\\n\\tmultiErr.Append(err)\\n\\n\\tcache.nodes, err = cl.GetNodes(ctx)\\n\\tmultiErr.Append(err)\\n\\n\\treplicasets, err := cl.GetReplicasets(ctx)\\n\\tmultiErr.Append(err)\\n\\n\\tcache.replicasetOwnerByUID = make(map[string]metav1.OwnerReference, len(replicasets))\\n\\n\\tfor _, replicaset := range replicasets {\\n\\t\\tif len(replicaset.OwnerReferences) > 0 {\\n\\t\\t\\tcache.replicasetOwnerByUID[string(replicaset.UID)] = replicaset.OwnerReferences[0]\\n\\t\\t}\\n\\t}\\n\\n\\t// Compute cluster metrics.\\n\\tvar points []types.MetricPoint\\n\\n\\tmetricFunctions := []metricsFunc{podsCount, requestsAndLimits, namespacesCount, nodesCount, podsRestartCount}\\n\\n\\tfor _, f := range metricFunctions {\\n\\t\\tpoints = append(points, f(cache, now)...)\\n\\t}\\n\\n\\t// Add the Kubernetes cluster meta label to global metrics, this is used to\\n\\t// replace the agent ID by the Kubernetes agent ID in the relabel hook.\\n\\tfor _, point := range points {\\n\\t\\tpoint.Labels[types.LabelMetaKubernetesCluster] = clusterName\\n\\t}\\n\\n\\treturn points, multiErr.MaybeUnwrap()\\n}\",\n \"func (sm *SinkManager) LatestContainerMetrics(appID string) []*events.Envelope {\\n\\tif sink := sm.sinks.ContainerMetricsFor(appID); sink != nil {\\n\\t\\treturn sink.GetLatest()\\n\\t}\\n\\treturn []*events.Envelope{}\\n}\",\n \"func (xratesKit *XRatesKit) GetLatest(currencyCode string, coinCodes *CoinCodes) *XRates {\\n\\n\\tdata, err := xratesKit.ipfsHandler.GetLatestXRates(currencyCode, coinCodes.toStringArray())\\n\\n\\tif err != nil {\\n\\n\\t\\t// Get data from CoinPaprika\\n\\t\\tdata, err = xratesKit.coinPaprika.GetLatestXRates(currencyCode, coinCodes.toStringArray())\\n\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil\\n\\t\\t}\\n\\t}\\n\\t//---------- Cache Data -------------------\\n\\n\\txratesKit.cacheService.SetLatest(data)\\n\\n\\t//-----------------------------------------\\n\\n\\tlog.Println(data)\\n\\n\\tvar result = make([]XRate, len(data))\\n\\tfor i, xrate := range data {\\n\\t\\tresult[i] = XRate(xrate)\\n\\t}\\n\\treturn &XRates{result}\\n}\",\n \"func (s *Simulator) Stats() *Stats {\\n\\ts.mu.Lock()\\n\\tdefer s.mu.Unlock()\\n\\telapsed := time.Since(s.now).Seconds()\\n\\tpThrough := float64(s.writtenN) / elapsed\\n\\trespMean := 0\\n\\tif len(s.latencyHistory) > 0 {\\n\\t\\trespMean = int(s.totalLatency) / len(s.latencyHistory) / int(time.Millisecond)\\n\\t}\\n\\tstats := &Stats{\\n\\t\\tTime: time.Unix(0, int64(time.Since(s.now))),\\n\\t\\tTags: s.ReportTags,\\n\\t\\tFields: models.Fields(map[string]interface{}{\\n\\t\\t\\t\\\"T\\\": int(elapsed),\\n\\t\\t\\t\\\"points_written\\\": s.writtenN,\\n\\t\\t\\t\\\"values_written\\\": s.writtenN * s.FieldsPerPoint,\\n\\t\\t\\t\\\"points_ps\\\": pThrough,\\n\\t\\t\\t\\\"values_ps\\\": pThrough * float64(s.FieldsPerPoint),\\n\\t\\t\\t\\\"write_error\\\": s.currentErrors,\\n\\t\\t\\t\\\"resp_wma\\\": int(s.wmaLatency),\\n\\t\\t\\t\\\"resp_mean\\\": respMean,\\n\\t\\t\\t\\\"resp_90\\\": int(s.quartileResponse(0.9) / time.Millisecond),\\n\\t\\t\\t\\\"resp_95\\\": int(s.quartileResponse(0.95) / time.Millisecond),\\n\\t\\t\\t\\\"resp_99\\\": int(s.quartileResponse(0.99) / time.Millisecond),\\n\\t\\t}),\\n\\t}\\n\\n\\tvar isCreating bool\\n\\tif s.writtenN < s.SeriesN() {\\n\\t\\tisCreating = true\\n\\t}\\n\\tstats.Tags[\\\"creating_series\\\"] = fmt.Sprint(isCreating)\\n\\n\\t// Reset error count for next reporting.\\n\\ts.currentErrors = 0\\n\\n\\t// Add runtime stats for the remote instance.\\n\\tvar vars Vars\\n\\tresp, err := http.Get(strings.TrimSuffix(s.Host, \\\"/\\\") + \\\"/debug/vars\\\")\\n\\tif err != nil {\\n\\t\\t// Don't log error as it can get spammy.\\n\\t\\treturn stats\\n\\t}\\n\\tdefer resp.Body.Close()\\n\\n\\tif err := json.NewDecoder(resp.Body).Decode(&vars); err != nil {\\n\\t\\tfmt.Fprintln(s.Stderr, err)\\n\\t\\treturn stats\\n\\t}\\n\\n\\tstats.Fields[\\\"heap_alloc\\\"] = vars.Memstats.HeapAlloc\\n\\tstats.Fields[\\\"heap_in_use\\\"] = vars.Memstats.HeapInUse\\n\\tstats.Fields[\\\"heap_objects\\\"] = vars.Memstats.HeapObjects\\n\\treturn stats\\n}\",\n \"func (m *MetricSet) Fetch(r mb.ReporterV2) {\\n\\tvar uptime sigar.Uptime\\n\\tif err := uptime.Get(); err != nil {\\n\\t\\tr.Error(errors.Wrap(err, \\\"failed to get uptime\\\"))\\n\\t\\treturn\\n\\t}\\n\\n\\tr.Event(mb.Event{\\n\\t\\tMetricSetFields: common.MapStr{\\n\\t\\t\\t\\\"duration\\\": common.MapStr{\\n\\t\\t\\t\\t\\\"ms\\\": int64(uptime.Length * 1000),\\n\\t\\t\\t},\\n\\t\\t},\\n\\t})\\n}\",\n \"func Metrics(cl client.Client) (*v1.Metrics, error) {\\n\\n\\t// Get metrics\\n\\treq, err := http.NewRequest(\\\"GET\\\", cl.MetronomeUrl()+\\\"/v1/metrics\\\", nil)\\n\\tres, err := cl.DoRequest(req)\\n\\tif err != nil {\\n\\t\\treturn nil, errors.New(\\\"failed to fetch metrics due to \\\" + err.Error())\\n\\t}\\n\\n\\t// Parse metrics\\n\\tvar metrics v1.Metrics\\n\\tif err = json.Unmarshal(res, &metrics); err != nil {\\n\\t\\treturn nil, errors.New(\\\"failed to unmarshal JSON data due to \\\" + err.Error())\\n\\t}\\n\\n\\treturn &metrics, nil\\n}\",\n \"func NewMetrics() *Metrics {\\n\\treturn &Metrics{items: make(map[string]*metric), rm: &sync.RWMutex{}}\\n}\",\n \"func newMetrics() *metrics {\\n\\treturn new(metrics)\\n}\",\n \"func (m *MetricSet) Fetch(reporter mb.ReporterV2) {\\n\\tvar err error\\n\\tvar rows *sql.Rows\\n\\trows, err = m.db.Query(`SELECT object_name, \\n counter_name, \\n instance_name, \\n cntr_value \\nFROM sys.dm_os_performance_counters \\nWHERE counter_name = 'SQL Compilations/sec' \\n OR counter_name = 'SQL Re-Compilations/sec' \\n OR counter_name = 'User Connections' \\n OR counter_name = 'Page splits/sec' \\n OR ( counter_name = 'Lock Waits/sec' \\n AND instance_name = '_Total' ) \\n OR counter_name = 'Page splits/sec' \\n OR ( object_name = 'SQLServer:Buffer Manager' \\n AND counter_name = 'Page life expectancy' ) \\n OR counter_name = 'Batch Requests/sec' \\n OR ( counter_name = 'Buffer cache hit ratio' \\n AND object_name = 'SQLServer:Buffer Manager' ) \\n OR ( counter_name = 'Target pages' \\n AND object_name = 'SQLServer:Buffer Manager' ) \\n OR ( counter_name = 'Database pages' \\n AND object_name = 'SQLServer:Buffer Manager' ) \\n OR ( counter_name = 'Checkpoint pages/sec' \\n AND object_name = 'SQLServer:Buffer Manager' ) \\n OR ( counter_name = 'Lock Waits/sec' \\n AND instance_name = '_Total' ) \\n OR ( counter_name = 'Transactions' \\n AND object_name = 'SQLServer:General Statistics' ) \\n OR ( counter_name = 'Logins/sec' \\n AND object_name = 'SQLServer:General Statistics' ) \\n OR ( counter_name = 'Logouts/sec' \\n AND object_name = 'SQLServer:General Statistics' ) \\n OR ( counter_name = 'Connection Reset/sec' \\n AND object_name = 'SQLServer:General Statistics' ) \\n OR ( counter_name = 'Active Temp Tables' \\n AND object_name = 'SQLServer:General Statistics' )`)\\n\\tif err != nil {\\n\\t\\treporter.Error(errors.Wrapf(err, \\\"error closing rows\\\"))\\n\\t\\treturn\\n\\t}\\n\\tdefer func() {\\n\\t\\tif err := rows.Close(); err != nil {\\n\\t\\t\\tm.log.Error(\\\"error closing rows: %s\\\", err.Error())\\n\\t\\t}\\n\\t}()\\n\\n\\tmapStr := common.MapStr{}\\n\\tfor rows.Next() {\\n\\t\\tvar row performanceCounter\\n\\t\\tif err = rows.Scan(&row.objectName, &row.counterName, &row.instanceName, &row.counterValue); err != nil {\\n\\t\\t\\treporter.Error(errors.Wrap(err, \\\"error scanning rows\\\"))\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\n\\t\\t//cell values contains spaces at the beginning and at the end of the 'actual' value. They must be removed.\\n\\t\\trow.counterName = strings.TrimSpace(row.counterName)\\n\\t\\trow.instanceName = strings.TrimSpace(row.instanceName)\\n\\t\\trow.objectName = strings.TrimSpace(row.objectName)\\n\\n\\t\\tif row.counterName == \\\"Buffer cache hit ratio\\\" {\\n\\t\\t\\tmapStr[row.counterName] = fmt.Sprintf(\\\"%v\\\", float64(*row.counterValue)/100)\\n\\t\\t} else {\\n\\t\\t\\tmapStr[row.counterName] = fmt.Sprintf(\\\"%v\\\", *row.counterValue)\\n\\t\\t}\\n\\t}\\n\\n\\tres, err := schema.Apply(mapStr)\\n\\tif err != nil {\\n\\t\\tm.log.Error(errors.Wrap(err, \\\"error applying schema\\\"))\\n\\t\\treturn\\n\\t}\\n\\n\\tif isReported := reporter.Event(mb.Event{\\n\\t\\tMetricSetFields: res,\\n\\t}); !isReported {\\n\\t\\tm.log.Debug(\\\"event not reported\\\")\\n\\t}\\n}\",\n \"func Get(key Type) time.Duration {\\n\\tif GlobalStats != nil {\\n\\t\\tmutex.RLock()\\n\\t\\tdefer mutex.RUnlock()\\n\\t\\treturn GlobalStats[key]\\n\\t}\\n\\treturn 0\\n}\",\n \"func NewMetrics() *MetricsHolder {\\n\\tm := &MetricsHolder{\\n\\t\\tlines: make(map[string]*Reading),\\n\\t\\tchannel: make(chan interface{}),\\n\\t}\\n\\tgo func() {\\n\\t\\tfor {\\n\\t\\t\\tw, ok := <-m.channel\\n\\t\\t\\treading := w.(*Reading)\\n\\t\\t\\tif !ok {\\n\\t\\t\\t\\tbreak\\n\\t\\t\\t}\\n\\t\\t\\tif val, ok := m.lines[reading.Key]; ok {\\n\\t\\t\\t\\tm.lines[reading.Key] = val.Accept(reading)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tm.lines[reading.Key] = reading\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}()\\n\\treturn m\\n}\",\n \"func (q AptCheckPlugin) FetchMetrics() (map[string]interface{}, error) {\\n\\tres, err := q.invokeAptCheck()\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\treturn map[string]interface{}{\\n\\t\\t\\\"updates\\\": uint64(res.NumOfUpdates),\\n\\t\\t\\\"security_updates\\\": uint64(res.NumOfSecurityUpdates),\\n\\t}, nil\\n}\",\n \"func (m *metadataCache) get() *Metadata {\\n\\tm.mu.RLock()\\n\\tdefer m.mu.RUnlock()\\n\\treturn m.metadata\\n}\",\n \"func (m *Metrics) Data() (*Data, error) {\\n\\tvar (\\n\\t\\ttotalResponseTime float64\\n\\t\\tmaxTime float64\\n\\t\\tminTime = math.MaxFloat64\\n\\t\\tbufsize = len(m.requests)\\n\\t\\tpercentiledTime = make(percentiledTimeMap)\\n\\t)\\n\\tm.m.RLock()\\n\\tdefer m.m.RUnlock()\\n\\tfor _, v := range m.requests {\\n\\t\\ttotalResponseTime += v\\n\\n\\t\\tif minTime > v {\\n\\t\\t\\tminTime = v\\n\\t\\t}\\n\\t\\tif maxTime < v {\\n\\t\\t\\tmaxTime = v\\n\\t\\t}\\n\\t}\\n\\n\\tfor _, p := range percents {\\n\\t\\tvar err error\\n\\t\\tpercentiledTime[p], err = m.requests.Percentile(float64(p))\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t}\\n\\n\\tstatusCount := make(statusCountMap)\\n\\tfor _, status := range httpStatuses {\\n\\t\\tstatusCount[status] = atomic.LoadInt64(&m.statusCount[status])\\n\\t}\\n\\n\\treturn &Data{\\n\\t\\tRequest: RequestData{\\n\\t\\t\\tCount: atomic.LoadInt64(&m.count),\\n\\t\\t\\tStatusCount: statusCount,\\n\\t\\t},\\n\\t\\tResponse: ResponseData{\\n\\t\\t\\tMaxTime: maxTime,\\n\\t\\t\\tMinTime: minTime,\\n\\t\\t\\tAverageTime: totalResponseTime / float64(bufsize),\\n\\t\\t\\tPercentiledTime: percentiledTime,\\n\\t\\t},\\n\\t}, nil\\n}\",\n \"func (u RackStatsPlugin) FetchMetrics() (stats map[string]interface{}, err error) {\\n\\tstats, err = u.parseStats()\\n\\treturn stats, err\\n}\",\n \"func (c SslCertPlugin) FetchMetrics() (map[string]interface{}, error) {\\n\\tdays, err := getSslCertMetrics(c.Path)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tresult := make(map[string]interface{})\\n\\tresult[\\\"days\\\"] = days\\n\\treturn result, nil\\n}\",\n \"func (h CRConfigHistoryThreadsafe) Get() []CRConfigStat {\\n\\th.m.RLock()\\n\\tdefer h.m.RUnlock()\\n\\tif *h.length < *h.limit {\\n\\t\\treturn CopyCRConfigStat((*h.hist)[:*h.length])\\n\\t}\\n\\tnewStats := make([]CRConfigStat, *h.limit)\\n\\tcopy(newStats, (*h.hist)[*h.pos:])\\n\\tcopy(newStats[*h.length-*h.pos:], (*h.hist)[:*h.pos])\\n\\treturn newStats\\n}\",\n \"func (c *Cache) Metrics() CacheMetrics {\\n\\tif c == nil {\\n\\t\\treturn CacheMetrics{}\\n\\t}\\n\\tc.mu.Lock()\\n\\tdefer c.mu.Unlock()\\n\\treturn c.m.CacheMetrics\\n}\",\n \"func fetchFloat64Metric(service *monitoring.Service, projectID string, resource *monitoring.MonitoredResource, metric *monitoring.Metric) (float64, error) {\\n\\tvar value float64\\n\\tbackoffPolicy := backoff.NewExponentialBackOff()\\n\\tbackoffPolicy.InitialInterval = 10 * time.Second\\n\\terr := backoff.Retry(\\n\\t\\tfunc() error {\\n\\t\\t\\trequest := service.Projects.TimeSeries.\\n\\t\\t\\t\\tList(fmt.Sprintf(\\\"projects/%s\\\", projectID)).\\n\\t\\t\\t\\tFilter(fmt.Sprintf(\\\"resource.type=\\\\\\\"%s\\\\\\\" metric.type=\\\\\\\"%s\\\\\\\" %s %s\\\", resource.Type, metric.Type,\\n\\t\\t\\t\\t\\tbuildFilter(\\\"resource\\\", resource.Labels), buildFilter(\\\"metric\\\", metric.Labels))).\\n\\t\\t\\t\\tAggregationAlignmentPeriod(\\\"300s\\\").\\n\\t\\t\\t\\tAggregationPerSeriesAligner(\\\"ALIGN_NEXT_OLDER\\\").\\n\\t\\t\\t\\tIntervalEndTime(time.Now().Format(time.RFC3339))\\n\\t\\t\\tlog.Printf(\\\"ListTimeSeriesRequest: %v\\\", request)\\n\\t\\t\\tresponse, err := request.Do()\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t// TODO(jkohen): switch to gRPC and use error utils to get the response.\\n\\t\\t\\t\\tif strings.Contains(err.Error(), \\\"Error 400\\\") {\\n\\t\\t\\t\\t\\t// The metric doesn't exist, but it may still show up.\\n\\t\\t\\t\\t\\treturn err\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\treturn backoff.Permanent(err)\\n\\t\\t\\t}\\n\\t\\t\\tlog.Printf(\\\"ListTimeSeriesResponse: %v\\\", response)\\n\\t\\t\\tif len(response.TimeSeries) > 1 {\\n\\t\\t\\t\\treturn backoff.Permanent(fmt.Errorf(\\\"Expected 1 time series, got %v\\\", response.TimeSeries))\\n\\t\\t\\t}\\n\\t\\t\\tif len(response.TimeSeries) == 0 {\\n\\t\\t\\t\\treturn fmt.Errorf(\\\"Waiting for 1 time series that matches the request, got %v\\\", response)\\n\\t\\t\\t}\\n\\t\\t\\ttimeSeries := response.TimeSeries[0]\\n\\t\\t\\tif len(timeSeries.Points) != 1 {\\n\\t\\t\\t\\treturn fmt.Errorf(\\\"Expected 1 point, got %v\\\", timeSeries)\\n\\t\\t\\t}\\n\\t\\t\\tvalue = valueAsFloat64(timeSeries.Points[0].Value)\\n\\t\\t\\treturn nil\\n\\t\\t}, backoffPolicy)\\n\\treturn value, err\\n}\",\n \"func getMetric(c *gin.Context) {\\n\\tparams, err := parseMetricParams(c)\\n\\n\\tif err != nil {\\n\\t\\tc.JSON(400, gin.H{\\n\\t\\t\\t\\\"error\\\": err.Error(),\\n\\t\\t})\\n\\t\\treturn\\n\\t}\\n\\n\\t// TODO: Allow string value comparisons as well!\\n\\tdocs, err := getDataOverRange(mongoSession, biModule.Rules[params.RuleIndex],\\n\\t\\tparams.Granularity, params.Start, params.End, params.Value)\\n\\tif err != nil {\\n\\t\\tc.JSON(400, gin.H{\\n\\t\\t\\t\\\"error\\\": err.Error(),\\n\\t\\t})\\n\\t\\treturn\\n\\t}\\n\\tc.JSON(200, docs)\\n}\",\n \"func (o *MetricsAllOf) GetMetrics() []Metric {\\n\\tif o == nil || o.Metrics == nil {\\n\\t\\tvar ret []Metric\\n\\t\\treturn ret\\n\\t}\\n\\treturn *o.Metrics\\n}\",\n \"func (d *hdbDriver) Stats() *Stats { return d.metrics.stats() }\",\n \"func RegistryGet(humanName string) MX4JMetric {\\n\\treglock.RLock()\\n\\tdefer reglock.RUnlock()\\n\\n\\treturn registry[humanName]\\n}\",\n \"func (c *memoryExactMatcher) get(key string) (*event.SloClassification, error) {\\n\\ttimer := prometheus.NewTimer(matcherOperationDurationSeconds.WithLabelValues(\\\"get\\\", exactMatcherType))\\n\\tdefer timer.ObserveDuration()\\n\\tc.mtx.RLock()\\n\\tdefer c.mtx.RUnlock()\\n\\n\\tvalue := c.exactMatches[key]\\n\\treturn value, nil\\n}\",\n \"func GetStats(p *config.ProxyMonitorMetric, cfg *config.CCConfig, timeout time.Duration) *Stats {\\n\\tbytes := config.Encode(p)\\n\\tfmt.Println(string(bytes))\\n\\tvar ch = make(chan struct{})\\n\\tvar host = p.IP + \\\":\\\" + p.AdminPort\\n\\tfmt.Println(host)\\n\\tstats := &Stats{}\\n\\n\\tgo func(host string) {\\n\\t\\tdefer close(ch)\\n\\t\\tstats.Host = host\\n\\t\\terr := pingCheck(host, cfg.CCProxyServer.User, cfg.CCProxyServer.Password)\\n\\t\\tif err != nil {\\n\\t\\t\\tstats.Error = err.Error()\\n\\t\\t\\tstats.Closed = true\\n\\t\\t} else {\\n\\t\\t\\tstats.Closed = false\\n\\t\\t}\\n\\t}(host)\\n\\n\\tselect {\\n\\tcase <-ch:\\n\\t\\treturn stats\\n\\tcase <-time.After(timeout):\\n\\t\\treturn &Stats{Host: host, Timeout: true}\\n\\t}\\n}\",\n \"func (m VarnishPlugin) FetchMetrics() (map[string]interface{}, error) {\\n\\tvar out []byte\\n\\tvar err error\\n\\n\\tif m.VarnishName == \\\"\\\" {\\n\\t\\tout, err = exec.Command(m.VarnishStatPath, \\\"-1\\\").CombinedOutput()\\n\\t} else {\\n\\t\\tout, err = exec.Command(m.VarnishStatPath, \\\"-1\\\", \\\"-n\\\", m.VarnishName).CombinedOutput()\\n\\t}\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"%s: %s\\\", err, out)\\n\\t}\\n\\n\\tlineexp := regexp.MustCompile(`^([^ ]+) +(\\\\d+)`)\\n\\tsmaexp := regexp.MustCompile(`^SMA\\\\.([^\\\\.]+)\\\\.(.+)$`)\\n\\n\\tstat := map[string]interface{}{\\n\\t\\t\\\"requests\\\": float64(0),\\n\\t}\\n\\n\\tvar tmpv float64\\n\\tfor _, line := range strings.Split(string(out), \\\"\\\\n\\\") {\\n\\t\\tmatch := lineexp.FindStringSubmatch(line)\\n\\t\\tif match == nil {\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\n\\t\\ttmpv, err = strconv.ParseFloat(match[2], 64)\\n\\t\\tif err != nil {\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\n\\t\\tswitch match[1] {\\n\\t\\tcase \\\"cache_hit\\\", \\\"MAIN.cache_hit\\\":\\n\\t\\t\\tstat[\\\"cache_hits\\\"] = tmpv\\n\\t\\t\\tstat[\\\"requests\\\"] = stat[\\\"requests\\\"].(float64) + tmpv\\n\\t\\tcase \\\"cache_miss\\\", \\\"MAIN.cache_miss\\\":\\n\\t\\t\\tstat[\\\"requests\\\"] = stat[\\\"requests\\\"].(float64) + tmpv\\n\\t\\tcase \\\"cache_hitpass\\\", \\\"MAIN.cache_hitpass\\\":\\n\\t\\t\\tstat[\\\"requests\\\"] = stat[\\\"requests\\\"].(float64) + tmpv\\n\\t\\tcase \\\"MAIN.backend_req\\\":\\n\\t\\t\\tstat[\\\"backend_req\\\"] = tmpv\\n\\t\\tcase \\\"MAIN.backend_conn\\\":\\n\\t\\t\\tstat[\\\"backend_conn\\\"] = tmpv\\n\\t\\tcase \\\"MAIN.backend_fail\\\":\\n\\t\\t\\tstat[\\\"backend_fail\\\"] = tmpv\\n\\t\\tcase \\\"MAIN.backend_reuse\\\":\\n\\t\\t\\tstat[\\\"backend_reuse\\\"] = tmpv\\n\\t\\tcase \\\"MAIN.backend_recycle\\\":\\n\\t\\t\\tstat[\\\"backend_recycle\\\"] = tmpv\\n\\t\\tcase \\\"MAIN.n_object\\\":\\n\\t\\t\\tstat[\\\"n_object\\\"] = tmpv\\n\\t\\tcase \\\"MAIN.n_objectcore\\\":\\n\\t\\t\\tstat[\\\"n_objectcore\\\"] = tmpv\\n\\t\\tcase \\\"MAIN.n_expired\\\":\\n\\t\\t\\tstat[\\\"n_expired\\\"] = tmpv\\n\\t\\tcase \\\"MAIN.n_objecthead\\\":\\n\\t\\t\\tstat[\\\"n_objecthead\\\"] = tmpv\\n\\t\\tcase \\\"MAIN.busy_sleep\\\":\\n\\t\\t\\tstat[\\\"busy_sleep\\\"] = tmpv\\n\\t\\tcase \\\"MAIN.busy_wakeup\\\":\\n\\t\\t\\tstat[\\\"busy_wakeup\\\"] = tmpv\\n\\t\\tdefault:\\n\\t\\t\\tsmamatch := smaexp.FindStringSubmatch(match[1])\\n\\t\\t\\tif smamatch == nil {\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\n\\t\\t\\tif smamatch[2] == \\\"g_alloc\\\" {\\n\\t\\t\\t\\tstat[\\\"varnish.sma.g_alloc.\\\"+smamatch[1]+\\\".g_alloc\\\"] = tmpv\\n\\t\\t\\t} else if smamatch[2] == \\\"g_bytes\\\" {\\n\\t\\t\\t\\tstat[\\\"varnish.sma.memory.\\\"+smamatch[1]+\\\".allocated\\\"] = tmpv\\n\\t\\t\\t} else if smamatch[2] == \\\"g_space\\\" {\\n\\t\\t\\t\\tstat[\\\"varnish.sma.memory.\\\"+smamatch[1]+\\\".available\\\"] = tmpv\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\treturn stat, err\\n}\",\n \"func (m *MeterSnapshot) Snapshot() metrics.Meter { return m }\",\n \"func (h *Handler) GetAll(c echo.Context) error {\\n\\tid := c.Param(\\\"id\\\")\\n\\tdb := h.DB.Clone()\\n\\tdefer db.Close()\\n\\n\\tvar results []*particleio.Result\\n\\tif err := db.DB(\\\"oxylus\\\").C(\\\"metrics\\\").Find(bson.M{\\\"uuid\\\": id}).Sort(\\\"time\\\").All(&results); err != nil {\\n\\t\\tlog.Println(err)\\n\\t}\\n\\treturn c.JSON(http.StatusOK, results)\\n}\",\n \"func GetMetrics() []prometheus.Collector {\\n\\treturn []prometheus.Collector{\\n\\t\\treqCounter,\\n\\t\\treqDuration,\\n\\t\\tconnDuration,\\n\\t}\\n}\",\n \"func (r *GatewayConnectionStatsRegistry) Get(ctx context.Context, ids ttnpb.GatewayIdentifiers) (*ttnpb.GatewayConnectionStats, error) {\\n\\tuid := unique.ID(ctx, ids)\\n\\tresult := &ttnpb.GatewayConnectionStats{}\\n\\tstats := &ttnpb.GatewayConnectionStats{}\\n\\n\\tretrieved, err := r.Redis.MGet(r.key(upKey, uid), r.key(downKey, uid), r.key(statusKey, uid)).Result()\\n\\tif err != nil {\\n\\t\\treturn nil, ttnredis.ConvertError(err)\\n\\t}\\n\\n\\tif retrieved[0] == nil && retrieved[1] == nil && retrieved[2] == nil {\\n\\t\\treturn nil, errNotFound\\n\\t}\\n\\n\\t// Retrieve uplink stats.\\n\\tif retrieved[0] != nil {\\n\\t\\tif err = ttnredis.UnmarshalProto(retrieved[0].(string), stats); err != nil {\\n\\t\\t\\treturn nil, errInvalidStats.WithAttributes(\\\"type\\\", \\\"uplink\\\").WithCause(err)\\n\\t\\t}\\n\\t\\tresult.LastUplinkReceivedAt = stats.LastUplinkReceivedAt\\n\\t\\tresult.UplinkCount = stats.UplinkCount\\n\\t}\\n\\n\\t// Retrieve downlink stats.\\n\\tif retrieved[1] != nil {\\n\\t\\tif err = ttnredis.UnmarshalProto(retrieved[1].(string), stats); err != nil {\\n\\t\\t\\treturn nil, errInvalidStats.WithAttributes(\\\"type\\\", \\\"downlink\\\").WithCause(err)\\n\\t\\t}\\n\\t\\tresult.LastDownlinkReceivedAt = stats.LastDownlinkReceivedAt\\n\\t\\tresult.DownlinkCount = stats.DownlinkCount\\n\\t\\tresult.RoundTripTimes = stats.RoundTripTimes\\n\\t}\\n\\n\\t// Retrieve gateway status.\\n\\tif retrieved[2] != nil {\\n\\t\\tif err = ttnredis.UnmarshalProto(retrieved[2].(string), stats); err != nil {\\n\\t\\t\\treturn nil, errInvalidStats.WithAttributes(\\\"type\\\", \\\"status\\\").WithCause(err)\\n\\t\\t}\\n\\t\\tresult.ConnectedAt = stats.ConnectedAt\\n\\t\\tresult.Protocol = stats.Protocol\\n\\t\\tresult.LastStatus = stats.LastStatus\\n\\t\\tresult.LastStatusReceivedAt = stats.LastStatusReceivedAt\\n\\t}\\n\\n\\treturn result, nil\\n}\",\n \"func (e *Exporter) GetMetricsList() map[string]*QueryInstance {\\n\\tif e.allMetricMap == nil {\\n\\t\\treturn nil\\n\\t}\\n\\treturn e.allMetricMap\\n}\",\n \"func (Metrics) MetricStruct() {}\",\n \"func (c *HTTPClient) Metrics(timeout time.Duration) ([]string, error) {\\n // temporary struct for parsing JSON response\\n var respData struct {\\n Names []string `json:\\\"results\\\"`\\n }\\n\\n err := c.backend.Call(\\\"GET\\\", c.url+\\\"/api/v1/metricnames\\\", nil,\\n timeout, http.StatusOK, &respData)\\n if err != nil {\\n return nil, err\\n }\\n\\n glog.V(3).Infof(\\\"metric names: %+v\\\", respData.Names)\\n return respData.Names, nil\\n}\",\n \"func instrumentGet(inner func()) {\\n\\tTotalRequests.Add(1)\\n\\tPendingRequests.Add(1)\\n\\tdefer PendingRequests.Add(-1)\\n\\n\\tstart := time.Now()\\n\\n\\tinner()\\n\\n\\t// Capture the histogram over 18 geometric buckets \\n\\tdelta := time.Since(start)\\n\\tswitch {\\n\\tcase delta < time.Millisecond:\\n\\t\\tLatencies.Add(\\\"0ms\\\", 1)\\n\\tcase delta > 32768*time.Millisecond:\\n\\t\\tLatencies.Add(\\\">32s\\\", 1)\\n\\tdefault:\\n\\t\\tfor i := time.Millisecond; i < 32768*time.Millisecond; i *= 2 {\\n\\t\\t\\tif delta >= i && delta < i*2 {\\n\\t\\t\\t\\tLatencies.Add(i.String(), 1)\\n\\t\\t\\t\\tbreak\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n}\",\n \"func NewMetrics(scope tally.Scope) *Metrics {\\n\\tsuccessScope := scope.Tagged(map[string]string{\\\"result\\\": \\\"success\\\"})\\n\\tfailScope := scope.Tagged(map[string]string{\\\"result\\\": \\\"fail\\\"})\\n\\ttimeoutScope := scope.Tagged(map[string]string{\\\"result\\\": \\\"timeout\\\"})\\n\\tapiScope := scope.SubScope(\\\"api\\\")\\n\\tserverScope := scope.SubScope(\\\"server\\\")\\n\\tplacement := scope.SubScope(\\\"placement\\\")\\n\\trecovery := scope.SubScope(\\\"recovery\\\")\\n\\n\\treturn &Metrics{\\n\\t\\tAPIEnqueueGangs: apiScope.Counter(\\\"enqueue_gangs\\\"),\\n\\t\\tEnqueueGangSuccess: successScope.Counter(\\\"enqueue_gang\\\"),\\n\\t\\tEnqueueGangFail: failScope.Counter(\\\"enqueue_gang\\\"),\\n\\n\\t\\tAPIDequeueGangs: apiScope.Counter(\\\"dequeue_gangs\\\"),\\n\\t\\tDequeueGangSuccess: successScope.Counter(\\\"dequeue_gangs\\\"),\\n\\t\\tDequeueGangTimeout: timeoutScope.Counter(\\\"dequeue_gangs\\\"),\\n\\n\\t\\tAPIGetPreemptibleTasks: apiScope.Counter(\\\"get_preemptible_tasks\\\"),\\n\\t\\tGetPreemptibleTasksSuccess: successScope.Counter(\\\"get_preemptible_tasks\\\"),\\n\\t\\tGetPreemptibleTasksTimeout: timeoutScope.Counter(\\\"get_preemptible_tasks\\\"),\\n\\n\\t\\tAPISetPlacements: apiScope.Counter(\\\"set_placements\\\"),\\n\\t\\tSetPlacementSuccess: successScope.Counter(\\\"set_placements\\\"),\\n\\t\\tSetPlacementFail: failScope.Counter(\\\"set_placements\\\"),\\n\\n\\t\\tAPIGetPlacements: apiScope.Counter(\\\"get_placements\\\"),\\n\\t\\tGetPlacementSuccess: successScope.Counter(\\\"get_placements\\\"),\\n\\t\\tGetPlacementFail: failScope.Counter(\\\"get_placements\\\"),\\n\\n\\t\\tAPILaunchedTasks: apiScope.Counter(\\\"launched_tasks\\\"),\\n\\n\\t\\tRecoverySuccess: successScope.Counter(\\\"recovery\\\"),\\n\\t\\tRecoveryFail: failScope.Counter(\\\"recovery\\\"),\\n\\t\\tRecoveryRunningSuccessCount: successScope.Counter(\\\"task_count\\\"),\\n\\t\\tRecoveryRunningFailCount: failScope.Counter(\\\"task_count\\\"),\\n\\t\\tRecoveryEnqueueFailedCount: failScope.Counter(\\\"enqueue_task_count\\\"),\\n\\t\\tRecoveryEnqueueSuccessCount: successScope.Counter(\\\"enqueue_task_count\\\"),\\n\\t\\tRecoveryTimer: recovery.Timer(\\\"running_tasks\\\"),\\n\\n\\t\\tPlacementQueueLen: placement.Gauge(\\\"placement_queue_length\\\"),\\n\\t\\tPlacementFailed: placement.Counter(\\\"fail\\\"),\\n\\n\\t\\tElected: serverScope.Gauge(\\\"elected\\\"),\\n\\t}\\n}\",\n \"func (r *GoMetricsRegistry) GetAll() map[string]map[string]interface{} {\\n\\treturn r.shadow.GetAll()\\n}\",\n \"func NewMetrics(app, metricsPrefix, version, hash, date string) *Metrics {\\n\\tlabels := map[string]string{\\n\\t\\t\\\"app\\\": app,\\n\\t\\t\\\"version\\\": version,\\n\\t\\t\\\"hash\\\": hash,\\n\\t\\t\\\"buildTime\\\": date,\\n\\t}\\n\\n\\tif metricsPrefix != \\\"\\\" {\\n\\t\\tmetricsPrefix += \\\"_\\\"\\n\\t}\\n\\n\\tpm := &Metrics{\\n\\t\\tresponseTime: prometheus.NewHistogramVec(\\n\\t\\t\\tprometheus.HistogramOpts{\\n\\t\\t\\t\\tName: metricsPrefix + \\\"response_time_seconds\\\",\\n\\t\\t\\t\\tHelp: \\\"Description\\\",\\n\\t\\t\\t\\tConstLabels: labels,\\n\\t\\t\\t},\\n\\t\\t\\t[]string{\\\"endpoint\\\"},\\n\\t\\t),\\n\\t\\ttotalRequests: prometheus.NewCounterVec(prometheus.CounterOpts{\\n\\t\\t\\tName: metricsPrefix + \\\"requests_total\\\",\\n\\t\\t\\tHelp: \\\"number of requests\\\",\\n\\t\\t\\tConstLabels: labels,\\n\\t\\t}, []string{\\\"code\\\", \\\"method\\\", \\\"endpoint\\\"}),\\n\\t\\tduration: prometheus.NewHistogramVec(prometheus.HistogramOpts{\\n\\t\\t\\tName: metricsPrefix + \\\"requests_duration_seconds\\\",\\n\\t\\t\\tHelp: \\\"duration of a requests in seconds\\\",\\n\\t\\t\\tConstLabels: labels,\\n\\t\\t}, []string{\\\"code\\\", \\\"method\\\", \\\"endpoint\\\"}),\\n\\t\\tresponseSize: prometheus.NewHistogramVec(prometheus.HistogramOpts{\\n\\t\\t\\tName: metricsPrefix + \\\"response_size_bytes\\\",\\n\\t\\t\\tHelp: \\\"size of the responses in bytes\\\",\\n\\t\\t\\tConstLabels: labels,\\n\\t\\t}, []string{\\\"code\\\", \\\"method\\\"}),\\n\\t\\trequestSize: prometheus.NewHistogramVec(prometheus.HistogramOpts{\\n\\t\\t\\tName: metricsPrefix + \\\"requests_size_bytes\\\",\\n\\t\\t\\tHelp: \\\"size of the requests in bytes\\\",\\n\\t\\t\\tConstLabels: labels,\\n\\t\\t}, []string{\\\"code\\\", \\\"method\\\"}),\\n\\t\\thandlerStatuses: prometheus.NewCounterVec(prometheus.CounterOpts{\\n\\t\\t\\tName: metricsPrefix + \\\"requests_statuses_total\\\",\\n\\t\\t\\tHelp: \\\"count number of responses per status\\\",\\n\\t\\t\\tConstLabels: labels,\\n\\t\\t}, []string{\\\"method\\\", \\\"status_bucket\\\"}),\\n\\t}\\n\\n\\terr := prometheus.Register(pm)\\n\\tif e := new(prometheus.AlreadyRegisteredError); errors.As(err, e) {\\n\\t\\treturn pm\\n\\t} else if err != nil {\\n\\t\\tpanic(err)\\n\\t}\\n\\n\\tgrpcPrometheus.EnableHandlingTimeHistogram()\\n\\n\\treturn pm\\n}\",\n \"func (p HAProxyPlugin) FetchMetrics() (map[string]float64, error) {\\n\\tvar metrics map[string]float64\\n\\tvar err error\\n\\tif p.Socket == \\\"\\\" {\\n\\t\\tmetrics, err = p.fetchMetricsFromTCP()\\n\\t} else {\\n\\t\\tmetrics, err = p.fetchMetricsFromSocket()\\n\\t}\\n\\treturn metrics, err\\n}\",\n \"func (tc *sklImpl) Metrics() Metrics {\\n\\treturn tc.metrics\\n}\",\n \"func (p *StatsDParser) GetMetrics() pdata.Metrics {\\n\\tmetrics := pdata.NewMetrics()\\n\\trm := metrics.ResourceMetrics().AppendEmpty()\\n\\n\\tfor _, metric := range p.gauges {\\n\\t\\trm.InstrumentationLibraryMetrics().Append(metric)\\n\\t}\\n\\n\\tfor _, metric := range p.counters {\\n\\t\\trm.InstrumentationLibraryMetrics().Append(metric)\\n\\t}\\n\\n\\tfor _, metric := range p.timersAndDistributions {\\n\\t\\trm.InstrumentationLibraryMetrics().Append(metric)\\n\\t}\\n\\n\\tfor _, summaryMetric := range p.summaries {\\n\\t\\tmetrics.ResourceMetrics().At(0).InstrumentationLibraryMetrics().Append(buildSummaryMetric(summaryMetric))\\n\\t}\\n\\n\\tp.gauges = make(map[statsDMetricdescription]pdata.InstrumentationLibraryMetrics)\\n\\tp.counters = make(map[statsDMetricdescription]pdata.InstrumentationLibraryMetrics)\\n\\tp.timersAndDistributions = make([]pdata.InstrumentationLibraryMetrics, 0)\\n\\tp.summaries = make(map[statsDMetricdescription]summaryMetric)\\n\\treturn metrics\\n}\",\n \"func (s *CacheService) Get(base string) *RatesStore {\\n\\t// Is our cache expired?\\n\\tif s.IsExpired(base) {\\n\\t\\treturn nil\\n\\t}\\n\\n\\t// Use stored results.\\n\\treturn cache[base]\\n}\",\n \"func GetProxyMetrics(proxyName string) *ServerMetric {\\n\\tsmMutex.RLock()\\n\\tdefer smMutex.RUnlock()\\n\\tmetric, ok := ServerMetricInfoMap[proxyName]\\n\\tif ok {\\n\\t\\tmetric.mutex.RLock()\\n\\t\\ttmpMetric := metric.clone()\\n\\t\\tmetric.mutex.RUnlock()\\n\\t\\treturn tmpMetric\\n\\t} else {\\n\\t\\treturn nil\\n\\t}\\n}\",\n \"func GetStats(args *Args, format string) string {\\n\\tcfg := config.GetConfig(args.ConfigFile)\\n\\t// init statistic for record\\n\\tstatistic.InitStatistic(cfg.Statistic)\\n\\n\\tallQueueStatistic := []*statistic.QueueStatistic{}\\n\\n\\tfor _, cc := range cfg.Redis {\\n\\t\\tfor _, queueConfig := range cc.Queues {\\n\\t\\t\\ts := &statistic.QueueStatistic{\\n\\t\\t\\t\\tQueueName: queueConfig.QueueName,\\n\\t\\t\\t\\tSourceType: \\\"Redis\\\",\\n\\t\\t\\t\\tIsEnabled: queueConfig.IsEnabled,\\n\\t\\t\\t}\\n\\n\\t\\t\\tqi := &redis.QueueInstance{\\n\\t\\t\\t\\tSource: cc.Config,\\n\\t\\t\\t\\tQueue: queueConfig,\\n\\t\\t\\t}\\n\\n\\t\\t\\tif queueConfig.IsDelayQueue {\\n\\t\\t\\t\\ts.Normal, _ = qi.DelayLength(queueConfig.QueueName)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\ts.Normal, _ = qi.Length(queueConfig.QueueName)\\n\\t\\t\\t}\\n\\n\\t\\t\\tif len(queueConfig.DelayOnFailure) > 0 {\\n\\t\\t\\t\\tqueueName := fmt.Sprintf(\\\"%s:delayed\\\", queueConfig.QueueName)\\n\\t\\t\\t\\ts.Delayed, _ = qi.DelayLength(queueName)\\n\\t\\t\\t}\\n\\n\\t\\t\\ts.Success, _ = statistic.GetCounter(fmt.Sprintf(\\\"%s:success\\\", queueConfig.QueueName))\\n\\t\\t\\ts.Failure, _ = statistic.GetCounter(fmt.Sprintf(\\\"%s:failure\\\", queueConfig.QueueName))\\n\\n\\t\\t\\ts.Total = s.Normal + s.Delayed + s.Success + s.Failure\\n\\n\\t\\t\\tallQueueStatistic = append(allQueueStatistic, s)\\n\\t\\t}\\n\\t}\\n\\n\\tfor _, cc := range cfg.RabbitMQ {\\n\\t\\tfor _, queueConfig := range cc.Queues {\\n\\t\\t\\ts := &statistic.QueueStatistic{\\n\\t\\t\\t\\tQueueName: queueConfig.QueueName,\\n\\t\\t\\t\\tSourceType: \\\"RabbitMQ\\\",\\n\\t\\t\\t\\tIsEnabled: queueConfig.IsEnabled,\\n\\t\\t\\t}\\n\\n\\t\\t\\t// qi := &rabbitmq.QueueInstance{\\n\\t\\t\\t// \\tSource: cc.Config,\\n\\t\\t\\t// \\tQueue: queueConfig,\\n\\t\\t\\t// }\\n\\t\\t\\t// todo get queue length\\n\\n\\t\\t\\ts.Normal = 0\\n\\t\\t\\ts.Delayed = 0\\n\\n\\t\\t\\ts.Success, _ = statistic.GetCounter(fmt.Sprintf(\\\"%s:success\\\", queueConfig.QueueName))\\n\\t\\t\\ts.Failure, _ = statistic.GetCounter(fmt.Sprintf(\\\"%s:failure\\\", queueConfig.QueueName))\\n\\n\\t\\t\\ts.Total = s.Normal + s.Delayed + s.Success + s.Failure\\n\\n\\t\\t\\tallQueueStatistic = append(allQueueStatistic, s)\\n\\t\\t}\\n\\t}\\n\\n\\tif \\\"json\\\" == format {\\n\\t\\toutput, err := json.Marshal(allQueueStatistic)\\n\\n\\t\\tif nil != err {\\n\\t\\t\\treturn \\\"\\\"\\n\\t\\t}\\n\\n\\t\\treturn string(output)\\n\\t}\\n\\n\\toutput := fmt.Sprintf(\\\"%s %s statistics information\\\\n\\\\n\\\", constant.APPNAME, constant.APPVERSION)\\n\\tfor _, s := range allQueueStatistic {\\n\\t\\tstatus := \\\"disable\\\"\\n\\t\\tif s.IsEnabled {\\n\\t\\t\\tstatus = \\\"enable\\\"\\n\\t\\t}\\n\\t\\toutput += fmt.Sprintf(\\\" > Type: %-8s Status: %-8s Name: %s\\\\n%10d Total\\\\n%10d Normal\\\\n%10d Delayed\\\\n%10d Success\\\\n%10d Failure\\\\n\\\\n\\\", s.SourceType, status, s.QueueName, s.Total, s.Normal, s.Delayed, s.Success, s.Failure)\\n\\t}\\n\\n\\tif \\\"html\\\" == format {\\n\\t\\tstrings.Replace(output, \\\"\\\\n\\\", \\\"
\\\", -1)\\n\\t}\\n\\n\\treturn output\\n}\",\n \"func (m *podMetrics) Get(ctx context.Context, name string, opts *metav1.GetOptions) (runtime.Object, error) {\\n\\tnamespace := genericapirequest.NamespaceValue(ctx)\\n\\n\\tpod, err := m.podLister.ByNamespace(namespace).Get(name)\\n\\tif err != nil {\\n\\t\\tif errors.IsNotFound(err) {\\n\\t\\t\\t// return not-found errors directly\\n\\t\\t\\treturn &metrics.PodMetrics{}, err\\n\\t\\t}\\n\\t\\tklog.ErrorS(err, \\\"Failed getting pod\\\", \\\"pod\\\", klog.KRef(namespace, name))\\n\\t\\treturn &metrics.PodMetrics{}, fmt.Errorf(\\\"failed getting pod: %w\\\", err)\\n\\t}\\n\\tif pod == nil {\\n\\t\\treturn &metrics.PodMetrics{}, errors.NewNotFound(corev1.Resource(\\\"pods\\\"), fmt.Sprintf(\\\"%s/%s\\\", namespace, name))\\n\\t}\\n\\n\\tms, err := m.getMetrics(pod)\\n\\tif err != nil {\\n\\t\\tklog.ErrorS(err, \\\"Failed reading pod metrics\\\", \\\"pod\\\", klog.KRef(namespace, name))\\n\\t\\treturn nil, fmt.Errorf(\\\"failed pod metrics: %w\\\", err)\\n\\t}\\n\\tif len(ms) == 0 {\\n\\t\\treturn nil, errors.NewNotFound(m.groupResource, fmt.Sprintf(\\\"%s/%s\\\", namespace, name))\\n\\t}\\n\\treturn &ms[0], nil\\n}\",\n \"func (core *Core) FetchMetricData() (*registry.MetricsData, error) {\\n\\tresp, err := http.Get(\\\"http://\\\" + core.master + \\\"/master/state.json\\\")\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tdata := new(registry.MetricsData)\\n\\tif err = json.NewDecoder(resp.Body).Decode(data); err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tresp.Body.Close()\\n\\treturn data, nil\\n}\",\n \"func GetMetrics(ps datatypes.PerformanceSignature, ts []datatypes.Timestamps) (datatypes.ComparisonMetrics, error) {\\n\\tmetricString := createMetricString(ps.PSMetrics)\\n\\tlogging.LogDebug(datatypes.Logging{Message: fmt.Sprintf(\\\"Escaped safe metric names are: %v\\\", metricString)})\\n\\n\\t// Get the metrics from the most recent Deployment Event\\n\\tmetricResponse, err := queryMetrics(ps.DTServer, ps.DTEnv, metricString, ts[0], ps)\\n\\tif err != nil {\\n\\t\\treturn datatypes.ComparisonMetrics{}, fmt.Errorf(\\\"error querying current metrics from Dynatrace: %v\\\", err)\\n\\t}\\n\\n\\t// If there were two Deployment Events, get the second set of metrics\\n\\tif len(ts) == 2 {\\n\\t\\tpreviousMetricResponse, err := queryMetrics(ps.DTServer, ps.DTEnv, metricString, ts[1], ps)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn datatypes.ComparisonMetrics{}, fmt.Errorf(\\\"error querying previous metrics from Dynatrace: %v\\\", err)\\n\\t\\t}\\n\\t\\tvar bothMetricSets = datatypes.ComparisonMetrics{\\n\\t\\t\\tCurrentMetrics: metricResponse,\\n\\t\\t\\tPreviousMetrics: previousMetricResponse,\\n\\t\\t}\\n\\n\\t\\treturn bothMetricSets, nil\\n\\t}\\n\\n\\tvar metrics = datatypes.ComparisonMetrics{\\n\\t\\tCurrentMetrics: metricResponse,\\n\\t}\\n\\n\\treturn metrics, nil\\n}\",\n \"func (b *gsDBBackup) getBackupMetrics(now time.Time) (time.Time, int64, error) {\\n\\tlastTime := time.Time{}\\n\\tvar count int64 = 0\\n\\tcountAfter := now.Add(-24 * time.Hour)\\n\\terr := gs.AllFilesInDir(b.gsClient, b.gsBucket, DB_BACKUP_DIR, func(item *storage.ObjectAttrs) {\\n\\t\\tif item.Updated.After(lastTime) {\\n\\t\\t\\tlastTime = item.Updated\\n\\t\\t}\\n\\t\\tif item.Updated.After(countAfter) {\\n\\t\\t\\tcount++\\n\\t\\t}\\n\\t})\\n\\treturn lastTime, count, err\\n}\",\n \"func (c *ClusterScalingScheduleCollector) GetMetrics() ([]CollectedMetric, error) {\\n\\tclusterScalingScheduleInterface, exists, err := c.store.GetByKey(c.objectReference.Name)\\n\\tif !exists {\\n\\t\\treturn nil, ErrClusterScalingScheduleNotFound\\n\\t}\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"unexpected error retrieving the ClusterScalingSchedule: %s\\\", err.Error())\\n\\t}\\n\\n\\t// The [cache.Store][0] returns the v1.ClusterScalingSchedule items as\\n\\t// a v1.ScalingSchedule when it first lists it. Once the objects are\\n\\t// updated/patched it asserts it correctly to the\\n\\t// v1.ClusterScalingSchedule type. It means we have to handle both\\n\\t// cases.\\n\\t// TODO(jonathanbeber): Identify why it happens and fix in the upstream.\\n\\t//\\n\\t// [0]: https://github.com/kubernetes/client-go/blob/v0.21.1/tools/cache/Store.go#L132-L140\\n\\tvar clusterScalingSchedule v1.ClusterScalingSchedule\\n\\tscalingSchedule, ok := clusterScalingScheduleInterface.(*v1.ScalingSchedule)\\n\\tif !ok {\\n\\t\\tcss, ok := clusterScalingScheduleInterface.(*v1.ClusterScalingSchedule)\\n\\t\\tif !ok {\\n\\t\\t\\treturn nil, ErrNotClusterScalingScheduleFound\\n\\t\\t}\\n\\t\\tclusterScalingSchedule = *css\\n\\t} else {\\n\\t\\tclusterScalingSchedule = v1.ClusterScalingSchedule(*scalingSchedule)\\n\\t}\\n\\n\\treturn calculateMetrics(clusterScalingSchedule.Spec, c.defaultScalingWindow, c.defaultTimeZone, c.rampSteps, c.now(), c.objectReference, c.metric)\\n}\",\n \"func metricsUpdate() {\\n metricsXml()\\n}\",\n \"func (sr *scrutinyRepository) GetSummary(ctx context.Context) (map[string]*models.DeviceSummary, error) {\\n\\tdevices, err := sr.GetDevices(ctx)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tsummaries := map[string]*models.DeviceSummary{}\\n\\n\\tfor _, device := range devices {\\n\\t\\tsummaries[device.WWN] = &models.DeviceSummary{Device: device}\\n\\t}\\n\\n\\t// Get parser flux query result\\n\\t//appConfig.GetString(\\\"web.influxdb.bucket\\\")\\n\\tqueryStr := fmt.Sprintf(`\\n \\timport \\\"influxdata/influxdb/schema\\\"\\n \\tbucketBaseName = \\\"%s\\\"\\n\\n\\tdailyData = from(bucket: bucketBaseName)\\n\\t|> range(start: -10y, stop: now())\\n\\t|> filter(fn: (r) => r[\\\"_measurement\\\"] == \\\"smart\\\" )\\n\\t|> filter(fn: (r) => r[\\\"_field\\\"] == \\\"temp\\\" or r[\\\"_field\\\"] == \\\"power_on_hours\\\" or r[\\\"_field\\\"] == \\\"date\\\")\\n\\t|> last()\\n\\t|> schema.fieldsAsCols()\\n\\t|> group(columns: [\\\"device_wwn\\\"])\\n\\t\\n\\tweeklyData = from(bucket: bucketBaseName + \\\"_weekly\\\")\\n\\t|> range(start: -10y, stop: now())\\n\\t|> filter(fn: (r) => r[\\\"_measurement\\\"] == \\\"smart\\\" )\\n\\t|> filter(fn: (r) => r[\\\"_field\\\"] == \\\"temp\\\" or r[\\\"_field\\\"] == \\\"power_on_hours\\\" or r[\\\"_field\\\"] == \\\"date\\\")\\n\\t|> last()\\n\\t|> schema.fieldsAsCols()\\n\\t|> group(columns: [\\\"device_wwn\\\"])\\n\\t\\n\\tmonthlyData = from(bucket: bucketBaseName + \\\"_monthly\\\")\\n\\t|> range(start: -10y, stop: now())\\n\\t|> filter(fn: (r) => r[\\\"_measurement\\\"] == \\\"smart\\\" )\\n\\t|> filter(fn: (r) => r[\\\"_field\\\"] == \\\"temp\\\" or r[\\\"_field\\\"] == \\\"power_on_hours\\\" or r[\\\"_field\\\"] == \\\"date\\\")\\n\\t|> last()\\n\\t|> schema.fieldsAsCols()\\n\\t|> group(columns: [\\\"device_wwn\\\"])\\n\\t\\n\\tyearlyData = from(bucket: bucketBaseName + \\\"_yearly\\\")\\n\\t|> range(start: -10y, stop: now())\\n\\t|> filter(fn: (r) => r[\\\"_measurement\\\"] == \\\"smart\\\" )\\n\\t|> filter(fn: (r) => r[\\\"_field\\\"] == \\\"temp\\\" or r[\\\"_field\\\"] == \\\"power_on_hours\\\" or r[\\\"_field\\\"] == \\\"date\\\")\\n\\t|> last()\\n\\t|> schema.fieldsAsCols()\\n\\t|> group(columns: [\\\"device_wwn\\\"])\\n\\t\\n\\tunion(tables: [dailyData, weeklyData, monthlyData, yearlyData])\\n\\t|> sort(columns: [\\\"_time\\\"], desc: false)\\n\\t|> group(columns: [\\\"device_wwn\\\"])\\n\\t|> last(column: \\\"device_wwn\\\")\\n\\t|> yield(name: \\\"last\\\")\\n\\t\\t`,\\n\\t\\tsr.appConfig.GetString(\\\"web.influxdb.bucket\\\"),\\n\\t)\\n\\n\\tresult, err := sr.influxQueryApi.Query(ctx, queryStr)\\n\\tif err == nil {\\n\\t\\t// Use Next() to iterate over query result lines\\n\\t\\tfor result.Next() {\\n\\t\\t\\t// Observe when there is new grouping key producing new table\\n\\t\\t\\tif result.TableChanged() {\\n\\t\\t\\t\\t//fmt.Printf(\\\"table: %s\\\\n\\\", result.TableMetadata().String())\\n\\t\\t\\t}\\n\\t\\t\\t// read result\\n\\n\\t\\t\\t//get summary data from Influxdb.\\n\\t\\t\\t//result.Record().Values()\\n\\t\\t\\tif deviceWWN, ok := result.Record().Values()[\\\"device_wwn\\\"]; ok {\\n\\n\\t\\t\\t\\t//ensure summaries is intialized for this wwn\\n\\t\\t\\t\\tif _, exists := summaries[deviceWWN.(string)]; !exists {\\n\\t\\t\\t\\t\\tsummaries[deviceWWN.(string)] = &models.DeviceSummary{}\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\tsummaries[deviceWWN.(string)].SmartResults = &models.SmartSummary{\\n\\t\\t\\t\\t\\tTemp: result.Record().Values()[\\\"temp\\\"].(int64),\\n\\t\\t\\t\\t\\tPowerOnHours: result.Record().Values()[\\\"power_on_hours\\\"].(int64),\\n\\t\\t\\t\\t\\tCollectorDate: result.Record().Values()[\\\"_time\\\"].(time.Time),\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tif result.Err() != nil {\\n\\t\\t\\tfmt.Printf(\\\"Query error: %s\\\\n\\\", result.Err().Error())\\n\\t\\t}\\n\\t} else {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tdeviceTempHistory, err := sr.GetSmartTemperatureHistory(ctx, DURATION_KEY_FOREVER)\\n\\tif err != nil {\\n\\t\\tsr.logger.Printf(\\\"========================>>>>>>>>======================\\\")\\n\\t\\tsr.logger.Printf(\\\"========================>>>>>>>>======================\\\")\\n\\t\\tsr.logger.Printf(\\\"========================>>>>>>>>======================\\\")\\n\\t\\tsr.logger.Printf(\\\"========================>>>>>>>>======================\\\")\\n\\t\\tsr.logger.Printf(\\\"========================>>>>>>>>======================\\\")\\n\\t\\tsr.logger.Printf(\\\"Error: %v\\\", err)\\n\\t}\\n\\tfor wwn, tempHistory := range deviceTempHistory {\\n\\t\\tsummaries[wwn].TempHistory = tempHistory\\n\\t}\\n\\n\\treturn summaries, nil\\n}\",\n \"func ServerMetrics() (*Metrics, error) {\\n\\t// Fetch total artists\\n\\tartists, err := data.DB.CountArtists()\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\t// Fetch total albums\\n\\talbums, err := data.DB.CountAlbums()\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\t// Fetch total songs\\n\\tsongs, err := data.DB.CountSongs()\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\t// Fetch total folders\\n\\tfolders, err := data.DB.CountFolders()\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\t// Combine all metrics\\n\\treturn &Metrics{\\n\\t\\tArtists: artists,\\n\\t\\tAlbums: albums,\\n\\t\\tSongs: songs,\\n\\t\\tFolders: folders,\\n\\t}, nil\\n}\",\n \"func (c *summaryCache) get() map[string]*eventsStatementsSummaryByDigest {\\n\\tc.rw.RLock()\\n\\tdefer c.rw.RUnlock()\\n\\n\\tres := make(map[string]*eventsStatementsSummaryByDigest, len(c.items))\\n\\tfor k, v := range c.items {\\n\\t\\tres[k] = v\\n\\t}\\n\\treturn res\\n}\",\n \"func Read(\\n\\tctx context.Context,\\n\\tendpoint *url.URL,\\n\\ttp auth.TokenProvider,\\n\\tlabels []prompb.Label,\\n\\tago, latency time.Duration,\\n\\tm instr.Metrics,\\n\\tl log.Logger,\\n\\ttls options.TLS,\\n) (int, error) {\\n\\tvar (\\n\\t\\trt http.RoundTripper\\n\\t\\terr error\\n\\t)\\n\\n\\tif endpoint.Scheme == transport.HTTPS {\\n\\t\\trt, err = transport.NewTLSTransport(l, tls)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn 0, errors.Wrap(err, \\\"create round tripper\\\")\\n\\t\\t}\\n\\n\\t\\trt = auth.NewBearerTokenRoundTripper(l, tp, rt)\\n\\t} else {\\n\\t\\trt = auth.NewBearerTokenRoundTripper(l, tp, nil)\\n\\t}\\n\\n\\tclient, err := promapi.NewClient(promapi.Config{\\n\\t\\tAddress: endpoint.String(),\\n\\t\\tRoundTripper: rt,\\n\\t})\\n\\tif err != nil {\\n\\t\\treturn 0, err\\n\\t}\\n\\n\\tlabelSelectors := make([]string, len(labels))\\n\\tfor i, label := range labels {\\n\\t\\tlabelSelectors[i] = fmt.Sprintf(`%s=\\\"%s\\\"`, label.Name, label.Value)\\n\\t}\\n\\n\\tquery := fmt.Sprintf(\\\"{%s}\\\", strings.Join(labelSelectors, \\\",\\\"))\\n\\tts := time.Now().Add(ago)\\n\\n\\tvalue, httpCode, _, err := api.Query(ctx, client, query, ts, false)\\n\\tif err != nil {\\n\\t\\treturn httpCode, errors.Wrap(err, \\\"query request failed\\\")\\n\\t}\\n\\n\\tvec := value.(model.Vector)\\n\\tif len(vec) != 1 {\\n\\t\\treturn httpCode, errors.Errorf(\\\"expected one metric, got %d\\\", len(vec))\\n\\t}\\n\\n\\tt := time.Unix(int64(vec[0].Value/1000), 0)\\n\\n\\tdiffSeconds := time.Since(t).Seconds()\\n\\n\\tm.MetricValueDifference.Observe(diffSeconds)\\n\\n\\tif diffSeconds > latency.Seconds() {\\n\\t\\treturn httpCode, errors.Errorf(\\\"metric value is too old: %2.fs\\\", diffSeconds)\\n\\t}\\n\\n\\treturn httpCode, nil\\n}\",\n \"func getMetrics(_ string) []string {\\n\\tvar (\\n\\t\\terr error\\n\\t\\tsession *Session\\n\\t\\tclient orchestrator.OrchestratorClient\\n\\t\\tres *orchestrator.ListMetricsResponse\\n\\t)\\n\\n\\tif session, err = ContinueSession(); err != nil {\\n\\t\\tfmt.Printf(\\\"Error while retrieving the session. Please re-authenticate.\\\\n\\\")\\n\\t\\treturn nil\\n\\t}\\n\\n\\tclient = orchestrator.NewOrchestratorClient(session)\\n\\n\\tif res, err = client.ListMetrics(context.Background(), &orchestrator.ListMetricsRequest{}); err != nil {\\n\\t\\treturn []string{}\\n\\t}\\n\\n\\tvar metrics []string\\n\\tfor _, v := range res.Metrics {\\n\\t\\tmetrics = append(metrics, fmt.Sprintf(\\\"%s\\\\t%s: %s\\\", v.Id, v.Name, v.Description))\\n\\t}\\n\\n\\treturn metrics\\n}\",\n \"func (m Metrics) MetricStruct() {}\",\n \"func (h *StatsHandlers) getStats(c *gin.Context) {\\n\\tdb, ok := c.MustGet(\\\"databaseConn\\\").(*gorm.DB)\\n\\tif !ok {\\n\\t\\treturn\\n\\t}\\n\\n\\tvar stats []models.Stats\\n\\tdb.Limit(60 * 5).Order(\\\"created_date desc\\\").Find(&stats)\\n\\n\\tSuccess(c, \\\"stats\\\", gin.H{\\n\\t\\t\\\"title\\\": \\\"Stats\\\",\\n\\t\\t\\\"stats\\\": stats})\\n\\n}\"\n]"},"negative_scores":{"kind":"list like","value":["0.63227373","0.5876255","0.58494925","0.58435","0.5822314","0.5772896","0.5730107","0.56519294","0.56305707","0.56088465","0.5589029","0.5588156","0.5586257","0.55593395","0.55461884","0.54866064","0.54594845","0.54443604","0.5433243","0.5426571","0.5410528","0.53490496","0.5344679","0.531531","0.53000236","0.5287589","0.5275283","0.5272943","0.5268425","0.5245843","0.52366763","0.52324414","0.52313375","0.5229259","0.5218071","0.5212275","0.52122647","0.52095604","0.5207078","0.52051544","0.51929003","0.5191632","0.51883733","0.51880074","0.5172249","0.51608557","0.5158026","0.51496845","0.51483816","0.51467407","0.5137313","0.5135146","0.5127221","0.5125391","0.5125155","0.5119823","0.51148677","0.51023525","0.5099337","0.50983155","0.5093375","0.5083848","0.50821453","0.5075079","0.506536","0.50622094","0.50608796","0.50552535","0.5049605","0.5047184","0.50314313","0.5027024","0.50252265","0.5023107","0.50154036","0.5012451","0.5011658","0.5009043","0.50062954","0.50032693","0.50012875","0.49996588","0.49896225","0.49834898","0.49812722","0.4980547","0.49801648","0.49771622","0.49642426","0.4962569","0.4957777","0.4957008","0.49491656","0.49477345","0.4946963","0.49464607","0.49455923","0.49450934","0.49370977","0.49330106"],"string":"[\n \"0.63227373\",\n \"0.5876255\",\n \"0.58494925\",\n \"0.58435\",\n \"0.5822314\",\n \"0.5772896\",\n \"0.5730107\",\n \"0.56519294\",\n \"0.56305707\",\n \"0.56088465\",\n \"0.5589029\",\n \"0.5588156\",\n \"0.5586257\",\n \"0.55593395\",\n \"0.55461884\",\n \"0.54866064\",\n \"0.54594845\",\n \"0.54443604\",\n \"0.5433243\",\n \"0.5426571\",\n \"0.5410528\",\n \"0.53490496\",\n \"0.5344679\",\n \"0.531531\",\n \"0.53000236\",\n \"0.5287589\",\n \"0.5275283\",\n \"0.5272943\",\n \"0.5268425\",\n \"0.5245843\",\n \"0.52366763\",\n \"0.52324414\",\n \"0.52313375\",\n \"0.5229259\",\n \"0.5218071\",\n \"0.5212275\",\n \"0.52122647\",\n \"0.52095604\",\n \"0.5207078\",\n \"0.52051544\",\n \"0.51929003\",\n \"0.5191632\",\n \"0.51883733\",\n \"0.51880074\",\n \"0.5172249\",\n \"0.51608557\",\n \"0.5158026\",\n \"0.51496845\",\n \"0.51483816\",\n \"0.51467407\",\n \"0.5137313\",\n \"0.5135146\",\n \"0.5127221\",\n \"0.5125391\",\n \"0.5125155\",\n \"0.5119823\",\n \"0.51148677\",\n \"0.51023525\",\n \"0.5099337\",\n \"0.50983155\",\n \"0.5093375\",\n \"0.5083848\",\n \"0.50821453\",\n \"0.5075079\",\n \"0.506536\",\n \"0.50622094\",\n \"0.50608796\",\n \"0.50552535\",\n \"0.5049605\",\n \"0.5047184\",\n \"0.50314313\",\n \"0.5027024\",\n \"0.50252265\",\n \"0.5023107\",\n \"0.50154036\",\n \"0.5012451\",\n \"0.5011658\",\n \"0.5009043\",\n \"0.50062954\",\n \"0.50032693\",\n \"0.50012875\",\n \"0.49996588\",\n \"0.49896225\",\n \"0.49834898\",\n \"0.49812722\",\n \"0.4980547\",\n \"0.49801648\",\n \"0.49771622\",\n \"0.49642426\",\n \"0.4962569\",\n \"0.4957777\",\n \"0.4957008\",\n \"0.49491656\",\n \"0.49477345\",\n \"0.4946963\",\n \"0.49464607\",\n \"0.49455923\",\n \"0.49450934\",\n \"0.49370977\",\n \"0.49330106\"\n]"},"document_score":{"kind":"string","value":"0.62895125"},"document_rank":{"kind":"string","value":"1"}}},{"rowIdx":105058,"cells":{"query":{"kind":"string","value":"Collect will process darkstats metrics locally and fill singleton with latest data"},"document":{"kind":"string","value":"func Collect(ctx context.Context) error {\n\tif !singleton.enabled {\n\t\treturn nil\n\t}\n\n\tif singleton.darkstatAddr == \"\" {\n\t\treturn fmt.Errorf(\"Darkstat address is empty\")\n\t}\n\n\tstartTime := time.Now()\n\n\tinventoryHosts := inventory.Get()\n\n\tlocalAddr, err := network.DefaultLocalAddr()\n\tif err != nil {\n\t\treturn err\n\t}\n\t// To label source traffic that we need to build dependency graph\n\tlocalHostgroup := localAddr.String()\n\tlocalDomain := localAddr.String()\n\tlocalInventory, ok := inventoryHosts[localAddr.String()]\n\tif ok {\n\t\tlocalHostgroup = localInventory.Hostgroup\n\t\tlocalDomain = localInventory.Domain\n\t}\n\tlog.Debugf(\"Local address don't exist in inventory: %v\", localAddr.String())\n\n\t// Scrape darkstat prometheus endpoint for host_bytes_total\n\tvar darkstatHostBytesTotal *prom2json.Family\n\tdarkstatScrape, err := prometheus.Scrape(singleton.darkstatAddr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, v := range darkstatScrape {\n\t\tif v.Name == \"host_bytes_total\" {\n\t\t\tdarkstatHostBytesTotal = v\n\t\t\tbreak\n\t\t}\n\t}\n\tif darkstatHostBytesTotal == nil {\n\t\treturn fmt.Errorf(\"Metric host_bytes_total doesn't exist\")\n\t}\n\n\t// Extract relevant data out of host_bytes_total\n\tvar hosts []Metric\n\tfor _, m := range darkstatHostBytesTotal.Metrics {\n\t\tmetric := m.(prom2json.Metric)\n\n\t\tip := net.ParseIP(metric.Labels[\"ip\"])\n\n\t\t// Skip its own IP as we don't need it\n\t\tif ip.Equal(localAddr) {\n\t\t\tcontinue\n\t\t}\n\n\t\tinventoryHostInfo := inventoryHosts[metric.Labels[\"ip\"]]\n\n\t\tbandwidth, err := strconv.ParseFloat(metric.Value, 64)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Failed to parse 'host_bytes_total' value: %v\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\tdirection := \"\"\n\t\t// Reversed from netfilter perspective\n\t\tswitch metric.Labels[\"dir\"] {\n\t\tcase \"out\":\n\t\t\tdirection = \"ingress\"\n\t\tcase \"in\":\n\t\t\tdirection = \"egress\"\n\t\t}\n\n\t\thosts = append(hosts, Metric{\n\t\t\tLocalHostgroup: localHostgroup,\n\t\t\tRemoteHostgroup: inventoryHostInfo.Hostgroup,\n\t\t\tRemoteIPAddr: metric.Labels[\"ip\"],\n\t\t\tLocalDomain: localDomain,\n\t\t\tRemoteDomain: inventoryHostInfo.Domain,\n\t\t\tDirection: direction,\n\t\t\tBandwidth: bandwidth,\n\t\t})\n\t}\n\n\tsingleton.mu.Lock()\n\tsingleton.hosts = hosts\n\tsingleton.mu.Unlock()\n\n\tlog.Debugf(\"taskdarkstat.Collect retrieved %v downstreams metrics\", len(hosts))\n\tlog.Debugf(\"taskdarkstat.Collect process took %v\", time.Since(startTime))\n\treturn nil\n}"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\te.mutex.Lock() // To protect metrics from concurrent collects.\n\tdefer e.mutex.Unlock()\n\n\tif err := e.scrape(); err != nil {\n\t\tlog.Error(err)\n\t\tnomad_up.Set(0)\n\t\tch <- nomad_up\n\t\treturn\n\t}\n\n\tch <- nomad_up\n\tch <- metric_uptime\n\tch <- metric_request_response_time_total\n\tch <- metric_request_response_time_avg\n\n\tfor _, metric := range metric_request_status_count_current {\n\t\tch <- metric\n\t}\n\tfor _, metric := range metric_request_status_count_total {\n\t\tch <- metric\n\t}\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\te.mutex.Lock() // To protect metrics from concurrent collects.\n\tdefer e.mutex.Unlock()\n\tif err := e.scrape(ch); err != nil {\n\t\tlog.Printf(\"Error scraping nightscout url: %s\", err)\n\t}\n\n\te.statusNightscout.Collect(ch)\n\n\treturn\n}","func (c *Collector) Collect(ch chan<- prometheus.Metric) {\n\tip := os.Getenv(\"DYNO_INSTANCE\")\n\tif ip == \"\" {\n\t\tlogg.Error(\"could not get ip address from env variable: DYNO_INSTANCE\")\n\t}\n\n\ttoken := os.Getenv(\"DYNO_TOKEN\")\n\tif token == \"\" {\n\t\tlogg.Error(\"could not get token from env variable: DYNO_TOKEN\")\n\t}\n\n\tvar rack, dc string\n\tir, err := c.dyno.Info()\n\tif err != nil {\n\t\tlogg.Error(err.Error())\n\t} else {\n\t\track = ir.Rack\n\t\tdc = ir.DC\n\n\t\tch <- c.uptime.mustNewConstMetric(float64(ir.Uptime), rack, dc, token, ip)\n\t\tch <- c.clientConnections.mustNewConstMetric(float64(ir.Pool.ClientConnections), rack, dc, token, ip)\n\t\tch <- c.clientReadRequests.mustNewConstMetric(float64(ir.Pool.ClientReadRequests), rack, dc, token, ip)\n\t\tch <- c.clientWriteRequests.mustNewConstMetric(float64(ir.Pool.ClientWriteRequests), rack, dc, token, ip)\n\t\tch <- c.clientDroppedRequests.mustNewConstMetric(float64(ir.Pool.ClientDroppedRequests), rack, dc, token, ip)\n\t}\n\n\tstateVal := 1 // until proven otherwise\n\tstateStr := \"unknown\" // always have a value for the state label\n\n\tstate, err := c.dyno.GetState()\n\tif err != nil {\n\t\tstateVal = 0\n\t\tlogg.Error(err.Error())\n\t} else {\n\t\tstateStr = string(state)\n\t}\n\n\tif state != Normal {\n\t\tstateVal = 0\n\t}\n\tch <- c.state.mustNewConstMetric(float64(stateVal), stateStr, rack, dc, token, ip)\n\n\tsize, err := c.dyno.Backend.DBSize()\n\tif err != nil {\n\t\tlogg.Error(err.Error())\n\t} else {\n\t\tch <- c.dbSize.mustNewConstMetric(float64(size), rack, dc, token, ip)\n\t}\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\te.mutex.Lock() // To protect metrics from concurrent collects.\n\tdefer e.mutex.Unlock()\n\n\t// Reset metrics.\n\tfor _, vec := range e.gauges {\n\t\tvec.Reset()\n\t}\n\n\tfor _, vec := range e.counters {\n\t\tvec.Reset()\n\t}\n\n\tresp, err := e.client.Get(e.URI)\n\tif err != nil {\n\t\te.up.Set(0)\n\t\tlog.Printf(\"Error while querying Elasticsearch: %v\", err)\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\n\tif err != nil {\n\t\tlog.Printf(\"Failed to read ES response body: %v\", err)\n\t\te.up.Set(0)\n\t\treturn\n\t}\n\n\te.up.Set(1)\n\n\tvar all_stats NodeStatsResponse\n\terr = json.Unmarshal(body, &all_stats)\n\n\tif err != nil {\n\t\tlog.Printf(\"Failed to unmarshal JSON into struct: %v\", err)\n\t\treturn\n\t}\n\n\t// Regardless of whether we're querying the local host or the whole\n\t// cluster, here we can just iterate through all nodes found.\n\n\tfor node, stats := range all_stats.Nodes {\n\t\tlog.Printf(\"Processing node %v\", node)\n\t\t// GC Stats\n\t\tfor collector, gcstats := range stats.JVM.GC.Collectors {\n\t\t\te.counters[\"jvm_gc_collection_count\"].WithLabelValues(all_stats.ClusterName, stats.Name, collector).Set(float64(gcstats.CollectionCount))\n\t\t\te.counters[\"jvm_gc_collection_time_in_millis\"].WithLabelValues(all_stats.ClusterName, stats.Name, collector).Set(float64(gcstats.CollectionTime))\n\t\t}\n\n\t\t// Breaker stats\n\t\tfor breaker, bstats := range stats.Breakers {\n\t\t\te.gauges[\"breakers_estimated_size_in_bytes\"].WithLabelValues(all_stats.ClusterName, stats.Name, breaker).Set(float64(bstats.EstimatedSize))\n\t\t\te.gauges[\"breakers_limit_size_in_bytes\"].WithLabelValues(all_stats.ClusterName, stats.Name, breaker).Set(float64(bstats.LimitSize))\n\t\t}\n\n\t\t// JVM Memory Stats\n\t\te.gauges[\"jvm_mem_heap_committed_in_bytes\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.JVM.Mem.HeapCommitted))\n\t\te.gauges[\"jvm_mem_heap_used_in_bytes\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.JVM.Mem.HeapUsed))\n\t\te.gauges[\"jvm_mem_heap_max_in_bytes\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.JVM.Mem.HeapMax))\n\t\te.gauges[\"jvm_mem_non_heap_committed_in_bytes\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.JVM.Mem.NonHeapCommitted))\n\t\te.gauges[\"jvm_mem_non_heap_used_in_bytes\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.JVM.Mem.NonHeapUsed))\n\n\t\t// Indices Stats\n\t\te.gauges[\"indices_fielddata_evictions\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.FieldData.Evictions))\n\t\te.gauges[\"indices_fielddata_memory_size_in_bytes\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.FieldData.MemorySize))\n\t\te.gauges[\"indices_filter_cache_evictions\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.FilterCache.Evictions))\n\t\te.gauges[\"indices_filter_cache_memory_size_in_bytes\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.FilterCache.MemorySize))\n\n\t\te.gauges[\"indices_docs_count\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.Docs.Count))\n\t\te.gauges[\"indices_docs_deleted\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.Docs.Deleted))\n\n\t\te.gauges[\"indices_segments_memory_in_bytes\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.Segments.Memory))\n\n\t\te.gauges[\"indices_store_size_in_bytes\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.Store.Size))\n\t\te.counters[\"indices_store_throttle_time_in_millis\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.Store.ThrottleTime))\n\n\t\te.counters[\"indices_flush_total\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.Flush.Total))\n\t\te.counters[\"indices_flush_time_in_millis\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.Flush.Time))\n\n\t\t// Transport Stats\n\t\te.counters[\"transport_rx_count\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Transport.RxCount))\n\t\te.counters[\"transport_rx_size_in_bytes\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Transport.RxSize))\n\t\te.counters[\"transport_tx_count\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Transport.TxCount))\n\t\te.counters[\"transport_tx_size_in_bytes\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Transport.TxSize))\n\t}\n\n\t// Report metrics.\n\tch <- e.up\n\n\tfor _, vec := range e.counters {\n\t\tvec.Collect(ch)\n\t}\n\n\tfor _, vec := range e.gauges {\n\t\tvec.Collect(ch)\n\t}\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\t// Protect metrics from concurrent collects.\n\te.mutex.Lock()\n\tdefer e.mutex.Unlock()\n\n\t// Scrape metrics from Tankerkoenig API.\n\tif err := e.scrape(ch); err != nil {\n\t\te.logger.Printf(\"error: cannot scrape tankerkoenig api: %v\", err)\n\t}\n\n\t// Collect metrics.\n\te.up.Collect(ch)\n\te.scrapeDuration.Collect(ch)\n\te.failedScrapes.Collect(ch)\n\te.totalScrapes.Collect(ch)\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\te.mutex.Lock() // To protect metrics from concurrent collects.\n\tdefer e.mutex.Unlock()\n\n\tup := e.scrape(ch)\n\n\tch <- prometheus.MustNewConstMetric(artifactoryUp, prometheus.GaugeValue, up)\n\tch <- e.totalScrapes\n\tch <- e.jsonParseFailures\n}","func (c *MetricsCollector) Collect(ch chan<- prometheus.Metric) {\n\tfor _, s := range c.status {\n\t\ts.RLock()\n\t\tdefer s.RUnlock()\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.verify,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(s.VerifyRestore),\n\t\t\t\"verify_restore\",\n\t\t\ts.BackupService,\n\t\t\ts.StorageService,\n\t\t)\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.verify,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(s.VerifyDiff),\n\t\t\t\"verify_diff\",\n\t\t\ts.BackupService,\n\t\t\ts.StorageService,\n\t\t)\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.verify,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(s.VerifyChecksum),\n\t\t\t\"verify_checksum\",\n\t\t\ts.BackupService,\n\t\t\ts.StorageService,\n\t\t)\n\t}\n\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\tfor _, db := range e.dbs {\n\t\t// logger.Log(\"Scraping\", db.String())\n\t\tgo e.scrapeDatabase(db)\n\t}\n\te.mutex.Lock()\n\tdefer e.mutex.Unlock()\n\te.cpuPercent.Collect(ch)\n\te.dataIO.Collect(ch)\n\te.logIO.Collect(ch)\n\te.memoryPercent.Collect(ch)\n\te.workPercent.Collect(ch)\n\te.sessionPercent.Collect(ch)\n\te.storagePercent.Collect(ch)\n\te.dbUp.Collect(ch)\n\te.up.Set(1)\n}","func (sc *SlurmCollector) Collect(ch chan<- prometheus.Metric) {\n\tsc.mutex.Lock()\n\tdefer sc.mutex.Unlock()\n\n\tlog.Debugf(\"Time since last scrape: %f seconds\", time.Since(sc.lastScrape).Seconds())\n\tif time.Since(sc.lastScrape).Seconds() > float64(sc.scrapeInterval) {\n\t\tsc.updateDynamicJobIds()\n\t\tvar err error\n\t\tsc.sshClient, err = sc.sshConfig.NewClient()\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Creating SSH client: %s\", err.Error())\n\t\t\treturn\n\t\t}\n\t\tdefer sc.sshClient.Close()\n\t\tlog.Infof(\"Collecting metrics from Slurm...\")\n\t\tsc.trackedJobs = make(map[string]bool)\n\t\tif sc.targetJobIds == \"\" {\n\t\t\t// sc.collectQueue()\n\t\t} else {\n\t\t\tsc.collectAcct()\n\t\t}\n\t\tif !sc.skipInfra {\n\t\t\tsc.collectInfo()\n\t\t}\n\t\tsc.lastScrape = time.Now()\n\t\tsc.delJobs()\n\n\t}\n\n\tsc.updateMetrics(ch)\n}","func (c *Collector) Collect(ch chan<- prometheus.Metric) {\n\tc.Lock()\n\tdefer c.Unlock()\n\n\tc.totalScrapes.Inc()\n\terr := c.getDadataBalance()\n\tif err != nil {\n\t\tc.failedBalanceScrapes.Inc()\n\t}\n\terr = c.getDadataStats()\n\tif err != nil {\n\t\tc.failedStatsScrapes.Inc()\n\t}\n\n\tch <- c.totalScrapes\n\tch <- c.failedBalanceScrapes\n\tch <- c.failedStatsScrapes\n\tch <- c.CurrentBalance\n\tch <- c.ServicesClean\n\tch <- c.ServicesMerging\n\tch <- c.ServicesSuggestions\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\te.mutex.Lock()\n\tdefer e.mutex.Unlock()\n\n\tfor _, vec := range e.gauges {\n\t\tvec.Reset()\n\t}\n\n\tdefer func() { ch <- e.up }()\n\n\t// If we fail at any point in retrieving GPU status, we fail 0\n\te.up.Set(1)\n\n\te.GetTelemetryFromNVML()\n\n\tfor _, vec := range e.gauges {\n\t\tvec.Collect(ch)\n\t}\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\tvar (\n\t\tdata *Data\n\t\terr error\n\t)\n\n\te.mutex.Lock() // To protect metrics from concurrent collects.\n\tdefer e.mutex.Unlock()\n\n\te.resetGaugeVecs() // Clean starting point\n\n\tvar endpointOfAPI []string\n\tif strings.HasSuffix(rancherURL, \"v3\") || strings.HasSuffix(rancherURL, \"v3/\") {\n\t\tendpointOfAPI = endpointsV3\n\t} else {\n\t\tendpointOfAPI = endpoints\n\t}\n\n\tcacheExpired := e.IsCacheExpired()\n\n\t// Range over the pre-configured endpoints array\n\tfor _, p := range endpointOfAPI {\n\t\tif cacheExpired {\n\t\t\tdata, err = e.gatherData(e.rancherURL, e.resourceLimit, e.accessKey, e.secretKey, p, ch)\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"Error getting JSON from URL %s\", p)\n\t\t\t\treturn\n\t\t\t}\n\t\t\te.cache[p] = data\n\t\t} else {\n\t\t\td, ok := e.cache[p]\n\t\t\tif !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdata = d\n\t\t}\n\n\t\tif err := e.processMetrics(data, p, e.hideSys, ch); err != nil {\n\t\t\tlog.Errorf(\"Error scraping rancher url: %s\", err)\n\t\t\treturn\n\t\t}\n\t\tlog.Infof(\"Metrics successfully processed for %s\", p)\n\t}\n\n\tif cacheExpired {\n\t\te.RenewCache()\n\t}\n\n\tfor _, m := range e.gaugeVecs {\n\t\tm.Collect(ch)\n\t}\n}","func (collector *OpenweatherCollector) Collect(ch chan<- prometheus.Metric) {\n\t// Get Coords\n\tlatitude, longitude := geo.Get_coords(openstreetmap.Geocoder(), collector.Location)\n\n\t// Setup HTTP Client\n\tclient := &http.Client{\n\t\tTimeout: 1 * time.Second,\n\t}\n\n\t// Grab Metrics\n\tw, err := owm.NewCurrent(collector.DegreesUnit, collector.Language, collector.ApiKey, owm.WithHttpClient(client))\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t} else {\n\t\tlog.Infof(\"Collecting metrics from openweather API successful\")\n\t}\n\n\tw.CurrentByCoordinates(&owm.Coordinates{Longitude: longitude, Latitude: latitude})\n\n\t// Get Weather description out of Weather slice to pass as label\n\tvar weather_description string\n\tfor _, n := range w.Weather {\n\t\tweather_description = n.Description\n\t}\n\n\t//Write latest value for each metric in the prometheus metric channel.\n\t//Note that you can pass CounterValue, GaugeValue, or UntypedValue types here.\n\tch <- prometheus.MustNewConstMetric(collector.temperatureMetric, prometheus.GaugeValue, w.Main.Temp, collector.Location)\n\tch <- prometheus.MustNewConstMetric(collector.humidity, prometheus.GaugeValue, float64(w.Main.Humidity), collector.Location)\n\tch <- prometheus.MustNewConstMetric(collector.feelslike, prometheus.GaugeValue, w.Main.FeelsLike, collector.Location)\n\tch <- prometheus.MustNewConstMetric(collector.pressure, prometheus.GaugeValue, w.Main.Pressure, collector.Location)\n\tch <- prometheus.MustNewConstMetric(collector.windspeed, prometheus.GaugeValue, w.Wind.Speed, collector.Location)\n\tch <- prometheus.MustNewConstMetric(collector.rain1h, prometheus.GaugeValue, w.Rain.OneH, collector.Location)\n\tch <- prometheus.MustNewConstMetric(collector.winddegree, prometheus.GaugeValue, w.Wind.Deg, collector.Location)\n\tch <- prometheus.MustNewConstMetric(collector.cloudiness, prometheus.GaugeValue, float64(w.Clouds.All), collector.Location)\n\tch <- prometheus.MustNewConstMetric(collector.sunrise, prometheus.GaugeValue, float64(w.Sys.Sunrise), collector.Location)\n\tch <- prometheus.MustNewConstMetric(collector.sunset, prometheus.GaugeValue, float64(w.Sys.Sunset), collector.Location)\n\tch <- prometheus.MustNewConstMetric(collector.snow1h, prometheus.GaugeValue, w.Snow.OneH, collector.Location)\n\tch <- prometheus.MustNewConstMetric(collector.currentconditions, prometheus.GaugeValue, 0, collector.Location, weather_description)\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\tvar up float64 = 1\n\n\tglobalMutex.Lock()\n\tdefer globalMutex.Unlock()\n\n\tif e.config.resetStats && !globalResetExecuted {\n\t\t// Its time to try to reset the stats\n\t\tif e.resetStatsSemp1() {\n\t\t\tlevel.Info(e.logger).Log(\"msg\", \"Statistics successfully reset\")\n\t\t\tglobalResetExecuted = true\n\t\t\tup = 1\n\t\t} else {\n\t\t\tup = 0\n\t\t}\n\t}\n\n\tif e.config.details {\n\t\tif up > 0 {\n\t\t\tup = e.getClientSemp1(ch)\n\t\t}\n\t\tif up > 0 {\n\t\t\tup = e.getQueueSemp1(ch)\n\t\t}\n\t\tif up > 0 && e.config.scrapeRates {\n\t\t\tup = e.getQueueRatesSemp1(ch)\n\t\t}\n\t} else { // Basic\n\t\tif up > 0 {\n\t\t\tup = e.getRedundancySemp1(ch)\n\t\t}\n\t\tif up > 0 {\n\t\t\tup = e.getSpoolSemp1(ch)\n\t\t}\n\t\tif up > 0 {\n\t\t\tup = e.getHealthSemp1(ch)\n\t\t}\n\t\tif up > 0 {\n\t\t\tup = e.getVpnSemp1(ch)\n\t\t}\n\t}\n\n\tch <- prometheus.MustNewConstMetric(solaceUp, prometheus.GaugeValue, up)\n}","func (c *OrchestratorCollector) Collect(ch chan<- prometheus.Metric) {\n\tc.mutex.Lock() // To protect metrics from concurrent collects\n\tdefer c.mutex.Unlock()\n\n\tstats, err := c.orchestratorClient.GetMetrics()\n\tif err != nil {\n\t\tc.upMetric.Set(serviceDown)\n\t\tch <- c.upMetric\n\t\tlog.Printf(\"Error getting Orchestrator stats: %v\", err)\n\t\treturn\n\t}\n\n\tc.upMetric.Set(serviceUp)\n\tch <- c.upMetric\n\n\tch <- prometheus.MustNewConstMetric(c.metrics[\"cluter_size\"],\n\t\tprometheus.GaugeValue, float64(len(stats.Status.Details.AvailableNodes)))\n\tch <- prometheus.MustNewConstMetric(c.metrics[\"is_active_node\"],\n\t\tprometheus.GaugeValue, boolToFloat64(stats.Status.Details.IsActiveNode))\n\tch <- prometheus.MustNewConstMetric(c.metrics[\"problems\"],\n\t\tprometheus.GaugeValue, float64(len(stats.Problems)))\n\tch <- prometheus.MustNewConstMetric(c.metrics[\"last_failover_id\"],\n\t\tprometheus.CounterValue, float64(stats.LastFailoverID))\n\tch <- prometheus.MustNewConstMetric(c.metrics[\"is_healthy\"],\n\t\tprometheus.GaugeValue, boolToFloat64(stats.Status.Details.Healthy))\n\tch <- prometheus.MustNewConstMetric(c.metrics[\"failed_seeds\"],\n\t\tprometheus.CounterValue, float64(stats.FailedSeeds))\n}","func (k *KACollector) Collect(ch chan<- prometheus.Metric) {\n\tk.mutex.Lock()\n\tdefer k.mutex.Unlock()\n\n\tvar err error\n\tvar kaStats []KAStats\n\n\tif k.useJSON {\n\t\tkaStats, err = k.json()\n\t\tif err != nil {\n\t\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_up\"], prometheus.GaugeValue, 0)\n\t\t\tlog.Printf(\"keepalived_exporter: %v\", err)\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tkaStats, err = k.text()\n\t\tif err != nil {\n\t\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_up\"], prometheus.GaugeValue, 0)\n\t\t\tlog.Printf(\"keepalived_exporter: %v\", err)\n\t\t\treturn\n\t\t}\n\t}\n\n\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_up\"], prometheus.GaugeValue, 1)\n\n\tfor _, st := range kaStats {\n\t\tstate := \"\"\n\t\tif _, ok := state2string[st.Data.State]; ok {\n\t\t\tstate = state2string[st.Data.State]\n\t\t}\n\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_vrrp_advert_rcvd\"], prometheus.CounterValue,\n\t\t\tfloat64(st.Stats.AdvertRcvd), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_vrrp_advert_sent\"], prometheus.CounterValue,\n\t\t\tfloat64(st.Stats.AdvertSent), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_vrrp_become_master\"], prometheus.CounterValue,\n\t\t\tfloat64(st.Stats.BecomeMaster), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_vrrp_release_master\"], prometheus.CounterValue,\n\t\t\tfloat64(st.Stats.ReleaseMaster), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_vrrp_packet_len_err\"], prometheus.CounterValue,\n\t\t\tfloat64(st.Stats.PacketLenErr), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_vrrp_advert_interval_err\"], prometheus.CounterValue,\n\t\t\tfloat64(st.Stats.AdvertIntervalErr), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_vrrp_ip_ttl_err\"], prometheus.CounterValue,\n\t\t\tfloat64(st.Stats.AdvertIntervalErr), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_vrrp_invalid_type_rcvd\"], prometheus.CounterValue,\n\t\t\tfloat64(st.Stats.InvalidTypeRcvd), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_vrrp_addr_list_err\"], prometheus.CounterValue,\n\t\t\tfloat64(st.Stats.AddrListErr), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_vrrp_invalid_authtype\"], prometheus.CounterValue,\n\t\t\tfloat64(st.Stats.InvalidAuthtype), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_vrrp_authtype_mismatch\"], prometheus.CounterValue,\n\t\t\tfloat64(st.Stats.AuthtypeMismatch), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_vrrp_auth_failure\"], prometheus.CounterValue,\n\t\t\tfloat64(st.Stats.AuthFailure), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_vrrp_pri_zero_rcvd\"], prometheus.CounterValue,\n\t\t\tfloat64(st.Stats.PriZeroRcvd), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_vrrp_pri_zero_sent\"], prometheus.CounterValue,\n\t\t\tfloat64(st.Stats.PriZeroSent), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\n\t}\n\n\tif k.handle == nil {\n\t\treturn\n\t}\n\n\tsvcs, err := k.handle.GetServices()\n\tif err != nil {\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_up\"], prometheus.GaugeValue, 0)\n\t\tlog.Printf(\"keepalived_exporter: services: %v\", err)\n\t\treturn\n\t}\n\n\tfor _, s := range svcs {\n\t\tdsts, err := k.handle.GetDestinations(s)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"keepalived_exporter: destinations: %v\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\taddr := s.Address.String() + \":\" + strconv.Itoa(int(s.Port))\n\t\tproto := strconv.Itoa(int(s.Protocol))\n\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_lvs_vip_in_packets\"], prometheus.CounterValue,\n\t\t\tfloat64(s.Stats.PacketsIn), addr, proto)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_lvs_vip_out_packets\"], prometheus.CounterValue,\n\t\t\tfloat64(s.Stats.PacketsOut), addr, proto)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_lvs_vip_in_bytes\"], prometheus.CounterValue,\n\t\t\tfloat64(s.Stats.BytesIn), addr, proto)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_lvs_vip_out_bytes\"], prometheus.CounterValue,\n\t\t\tfloat64(s.Stats.BytesOut), addr, proto)\n\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_lvs_vip_conn\"], prometheus.CounterValue,\n\t\t\tfloat64(s.Stats.Connections), addr, proto)\n\n\t\tfor _, d := range dsts {\n\t\t\taddr := d.Address.String() + \":\" + strconv.Itoa(int(d.Port))\n\n\t\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_lvs_rs_in_packets\"], prometheus.CounterValue,\n\t\t\t\tfloat64(d.Stats.PacketsIn), addr, proto)\n\t\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_lvs_rs_out_packets\"], prometheus.CounterValue,\n\t\t\t\tfloat64(d.Stats.PacketsOut), addr, proto)\n\t\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_lvs_rs_in_bytes\"], prometheus.CounterValue,\n\t\t\t\tfloat64(d.Stats.BytesIn), addr, proto)\n\t\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_lvs_rs_out_bytes\"], prometheus.CounterValue,\n\t\t\t\tfloat64(d.Stats.BytesOut), addr, proto)\n\t\t\tch <- prometheus.MustNewConstMetric(k.metrics[\"keepalived_lvs_rs_conn\"], prometheus.CounterValue,\n\t\t\t\tfloat64(d.Stats.Connections), addr, proto)\n\t\t}\n\t}\n}","func (c *solarCollector) Collect(ch chan<- prometheus.Metric) {\n\tc.mutex.Lock() // To protect metrics from concurrent collects.\n\tdefer c.mutex.Unlock()\n\tif err := c.collect(ch); err != nil {\n\t\tlog.Printf(\"Error getting solar controller data: %s\", err)\n\t\tc.scrapeFailures.Inc()\n\t\tc.scrapeFailures.Collect(ch)\n\t}\n\treturn\n}","func (c *ClusterManager) Collect(ch chan<- prometheus.Metric) {\n\toomCountByHost, ramUsageByHost := c.ReallyExpensiveAssessmentOfTheSystemState()\n\tfor host, oomCount := range oomCountByHost {\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.OOMCountDesc,\n\t\t\tprometheus.CounterValue,\n\t\t\tfloat64(oomCount),\n\t\t\thost,\n\t\t)\n\t}\n\tfor host, ramUsage := range ramUsageByHost {\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.RAMUsageDesc,\n\t\t\tprometheus.GaugeValue,\n\t\t\tramUsage,\n\t\t\thost,\n\t\t)\n\t}\n}","func (e *UwsgiExporter) Collect(ch chan<- prometheus.Metric) {\n\tstartTime := time.Now()\n\terr := e.execute(ch)\n\td := time.Since(startTime).Seconds()\n\n\tif err != nil {\n\t\tlog.Errorf(\"ERROR: scrape failed after %fs: %s\", d, err)\n\t\te.uwsgiUp.Set(0)\n\t\te.scrapeDurations.WithLabelValues(\"error\").Observe(d)\n\t} else {\n\t\tlog.Debugf(\"OK: scrape successful after %fs.\", d)\n\t\te.uwsgiUp.Set(1)\n\t\te.scrapeDurations.WithLabelValues(\"success\").Observe(d)\n\t}\n\n\te.uwsgiUp.Collect(ch)\n\te.scrapeDurations.Collect(ch)\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\tignore := strings.Split(*flagStatsIgnore, \",\")\n\tif len(ignore) == 1 && ignore[0] == \"\" {\n\t\tignore = []string{}\n\t}\n\tnicks := strings.Split(*flagStatsNicks, \",\")\n\tif len(nicks) == 1 && nicks[0] == \"\" {\n\t\tnicks = []string{}\n\t}\n\tres := e.client.Stats(irc.StatsRequest{\n\t\tLocal: *flagStatsLocal,\n\t\tTimeout: *flagStatsTimeout,\n\t\tIgnoreServers: ignore,\n\t\tNicks: nicks,\n\t})\n\n\tch <- prometheus.MustNewConstMetric(\n\t\tconnected, prometheus.GaugeValue, boolToFloat[e.client.Server != \"\"])\n\n\t_, ok := res.Servers[e.client.Server]\n\tif res.Timeout && !ok {\n\t\t// Timeout, no data at all\n\t\tif e.client.Server != \"\" {\n\t\t\tch <- prometheus.MustNewConstMetric(\n\t\t\t\tup, prometheus.GaugeValue, 0.0, e.client.Server)\n\t\t}\n\t} else {\n\t\t// Global state\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tchannels, prometheus.GaugeValue, float64(res.Channels))\n\n\t\tfor nick, nickIson := range res.Nicks {\n\t\t\tch <- prometheus.MustNewConstMetric(\n\t\t\t\tison, prometheus.GaugeValue, boolToFloat[nickIson], nick)\n\t\t}\n\n\t\t// Per server state\n\t\tfor server, stats := range res.Servers {\n\t\t\tch <- prometheus.MustNewConstMetric(\n\t\t\t\tdistance, prometheus.GaugeValue, float64(stats.Distance), server)\n\n\t\t\tif *flagStatsLocal && e.client.Server != server {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tch <- prometheus.MustNewConstMetric(\n\t\t\t\tup, prometheus.GaugeValue, boolToFloat[stats.Up], server)\n\n\t\t\tif stats.Up {\n\t\t\t\tch <- prometheus.MustNewConstMetric(\n\t\t\t\t\tusers, prometheus.GaugeValue, float64(stats.Users), server)\n\n\t\t\t\tch <- prometheus.MustNewConstMetric(\n\t\t\t\t\tlatency, prometheus.GaugeValue, float64(stats.ResponseTime.Sub(stats.RequestTime))/float64(time.Second), server)\n\t\t\t}\n\t\t}\n\t}\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\te.mutex.Lock() // To protect metrics from concurrent collects.\n\tdefer e.mutex.Unlock()\n if err := e.scrape(ch); err != nil {\n\t\tlog.Infof(\"Error scraping tinystats: %s\", err)\n\t}\n e.ipv4QueryA.Collect(ch)\n e.ipv4QueryNS.Collect(ch)\n e.ipv4QueryCNAME.Collect(ch)\n e.ipv4QuerySOA.Collect(ch)\n e.ipv4QueryPTR.Collect(ch)\n e.ipv4QueryHINFO.Collect(ch)\n e.ipv4QueryMX.Collect(ch)\n e.ipv4QueryTXT.Collect(ch)\n e.ipv4QueryRP.Collect(ch)\n e.ipv4QuerySIG.Collect(ch)\n e.ipv4QueryKEY.Collect(ch)\n e.ipv4QueryAAAA.Collect(ch)\n e.ipv4QueryAXFR.Collect(ch)\n e.ipv4QueryANY.Collect(ch)\n e.ipv4QueryTOTAL.Collect(ch)\n e.ipv4QueryOTHER.Collect(ch)\n e.ipv4QueryNOTAUTH.Collect(ch)\n e.ipv4QueryNOTIMPL.Collect(ch)\n e.ipv4QueryBADCLASS.Collect(ch)\n e.ipv4QueryNOQUERY.Collect(ch)\n\n e.ipv6QueryA.Collect(ch)\n e.ipv6QueryNS.Collect(ch)\n e.ipv6QueryCNAME.Collect(ch)\n e.ipv6QuerySOA.Collect(ch)\n e.ipv6QueryPTR.Collect(ch)\n e.ipv6QueryHINFO.Collect(ch)\n e.ipv6QueryMX.Collect(ch)\n e.ipv6QueryTXT.Collect(ch)\n e.ipv6QueryRP.Collect(ch)\n e.ipv6QuerySIG.Collect(ch)\n e.ipv6QueryKEY.Collect(ch)\n e.ipv6QueryAAAA.Collect(ch)\n e.ipv6QueryAXFR.Collect(ch)\n e.ipv6QueryANY.Collect(ch)\n e.ipv6QueryTOTAL.Collect(ch)\n e.ipv6QueryOTHER.Collect(ch)\n e.ipv6QueryNOTAUTH.Collect(ch)\n e.ipv6QueryNOTIMPL.Collect(ch)\n e.ipv6QueryBADCLASS.Collect(ch)\n e.ipv6QueryNOQUERY.Collect(ch)\n\n\treturn\n}","func (r *RGWCollector) Collect(ch chan<- prometheus.Metric, version *Version) {\n\tif !r.background {\n\t\tr.logger.WithField(\"background\", r.background).Debug(\"collecting RGW GC stats\")\n\t\terr := r.collect()\n\t\tif err != nil {\n\t\t\tr.logger.WithField(\"background\", r.background).WithError(err).Error(\"error collecting RGW GC stats\")\n\t\t}\n\t}\n\n\tfor _, metric := range r.collectorList() {\n\t\tmetric.Collect(ch)\n\t}\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\te.mutex.Lock() // To protect metrics from concurrent collects.\n\tdefer e.mutex.Unlock()\n\n\tup, result := e.scrape(ch)\n\n\tch <- e.totalScrapes\n\tch <- e.jsonParseFailures\n\tch <- prometheus.MustNewConstMetric(iqAirUp, prometheus.GaugeValue, up)\n\tch <- prometheus.MustNewConstMetric(iqAirCO2, prometheus.GaugeValue, float64(result.CO2))\n\tch <- prometheus.MustNewConstMetric(iqAirP25, prometheus.GaugeValue, float64(result.P25))\n\tch <- prometheus.MustNewConstMetric(iqAirP10, prometheus.GaugeValue, float64(result.P10))\n\tch <- prometheus.MustNewConstMetric(iqAirTemp, prometheus.GaugeValue, float64(result.Temperature))\n\tch <- prometheus.MustNewConstMetric(iqAirHumidity, prometheus.GaugeValue, float64(result.Humidity))\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\tlog.Infof(\"Syno exporter starting\")\n\tif e.Client == nil {\n\t\tlog.Errorf(\"Syno client not configured.\")\n\t\treturn\n\t}\n\terr := e.Client.Connect()\n\tif err != nil {\n\t\tlog.Errorln(\"Can't connect to Synology for SNMP: %s\", err)\n\t\treturn\n\t}\n\tdefer e.Client.SNMP.Conn.Close()\n\n\te.collectSystemMetrics(ch)\n\te.collectCPUMetrics(ch)\n\te.collectLoadMetrics(ch)\n\te.collectMemoryMetrics(ch)\n\te.collectNetworkMetrics(ch)\n\te.collectDiskMetrics(ch)\n\n\tlog.Infof(\"Syno exporter finished\")\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\n\te.mutex.Lock() // To protect metrics from concurrent collects.\n\tdefer e.mutex.Unlock()\n\n\te.zpool.getStatus()\n\te.poolUsage.Set(float64(e.zpool.capacity))\n\te.providersOnline.Set(float64(e.zpool.online))\n\te.providersFaulted.Set(float64(e.zpool.faulted))\n\n\tch <- e.poolUsage\n\tch <- e.providersOnline\n\tch <- e.providersFaulted\n}","func Collect(metrics []Metric, c CloudWatchService, namespace string) {\n\tid, err := GetInstanceID()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfor _, metric := range metrics {\n\t\tmetric.Collect(id, c, namespace)\n\t}\n}","func (p *Collector) Collect(c chan<- prometheus.Metric) {\n\tp.Sink.mu.Lock()\n\tdefer p.Sink.mu.Unlock()\n\n\texpire := p.Sink.expiration != 0\n\tnow := time.Now()\n\tfor k, v := range p.Sink.gauges {\n\t\tlast := p.Sink.updates[k]\n\t\tif expire && last.Add(p.Sink.expiration).Before(now) {\n\t\t\tdelete(p.Sink.updates, k)\n\t\t\tdelete(p.Sink.gauges, k)\n\t\t} else {\n\t\t\tv.Collect(c)\n\t\t}\n\t}\n\tfor k, v := range p.Sink.summaries {\n\t\tlast := p.Sink.updates[k]\n\t\tif expire && last.Add(p.Sink.expiration).Before(now) {\n\t\t\tdelete(p.Sink.updates, k)\n\t\t\tdelete(p.Sink.summaries, k)\n\t\t} else {\n\t\t\tv.Collect(c)\n\t\t}\n\t}\n\tfor k, v := range p.Sink.counters {\n\t\tlast := p.Sink.updates[k]\n\t\tif expire && last.Add(p.Sink.expiration).Before(now) {\n\t\t\tdelete(p.Sink.updates, k)\n\t\t\tdelete(p.Sink.counters, k)\n\t\t} else {\n\t\t\tv.Collect(c)\n\t\t}\n\t}\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\tresp, err := e.Pihole.GetMetrics()\n\tif err != nil {\n\t\tlog.Errorf(\"Pihole error: %s\", err.Error())\n\t\treturn\n\t}\n\tlog.Debugf(\"PiHole metrics: %#v\", resp)\n\tch <- prometheus.MustNewConstMetric(\n\t\tdomainsBeingBlocked, prometheus.CounterValue, float64(resp.DomainsBeingBlocked))\n\n\tch <- prometheus.MustNewConstMetric(\n\t\tdnsQueries, prometheus.CounterValue, float64(resp.DNSQueriesToday))\n\n\tch <- prometheus.MustNewConstMetric(\n\t\tadsBlocked, prometheus.CounterValue, float64(resp.AdsBlockedToday))\n\n\tch <- prometheus.MustNewConstMetric(\n\t\tadsPercentage, prometheus.CounterValue, float64(resp.AdsPercentageToday))\n\n\tfor k, v := range resp.Querytypes {\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tqueryTypes, prometheus.CounterValue, v, k)\n\t}\n\tfor k, v := range resp.TopQueries {\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\ttopQueries, prometheus.CounterValue, float64(v), k)\n\t}\n\tfor k, v := range resp.TopAds {\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\ttopAds, prometheus.CounterValue, float64(v), k)\n\n\t}\n\tfor k, v := range resp.TopSources {\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\ttopSources, prometheus.CounterValue, float64(v), k)\n\t}\n}","func (collector *MetricsCollector) Collect(ch chan<- prometheus.Metric) {\n\tfilterMetricsByKind := func(kind string, orgMetrics []constMetric) (filteredMetrics []constMetric) {\n\t\tfor _, metric := range orgMetrics {\n\t\t\tif metric.kind == kind {\n\t\t\t\tfilteredMetrics = append(filteredMetrics, metric)\n\t\t\t}\n\t\t}\n\t\treturn filteredMetrics\n\t}\n\tcollector.defMetrics.reset()\n\tfor k := range collector.metrics {\n\t\tcounters := filterMetricsByKind(config.KeyMetricTypeCounter, collector.metrics[k])\n\t\tgauges := filterMetricsByKind(config.KeyMetricTypeGauge, collector.metrics[k])\n\t\thistograms := filterMetricsByKind(config.KeyMetricTypeHistogram, collector.metrics[k])\n\t\tcollectCounters(counters, collector.defMetrics, ch)\n\t\tcollectGauges(gauges, collector.defMetrics, ch)\n\t\tcollectHistograms(histograms, collector.defMetrics, ch)\n\t\tcollector.cache.Reset()\n\t}\n\tcollector.defMetrics.collectDefaultMetrics(ch)\n}","func (collector *Collector) Collect(ch chan<- prometheus.Metric) {\n\tch <- prometheus.MustNewConstMetric(collector.incidentsCreatedCount, prometheus.CounterValue, collector.storage.GetIncidentsCreatedCount())\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\tjunosTotalScrapeCount++\n\tch <- prometheus.MustNewConstMetric(junosDesc[\"ScrapesTotal\"], prometheus.CounterValue, junosTotalScrapeCount)\n\n\twg := &sync.WaitGroup{}\n\tfor _, collector := range e.Collectors {\n\t\twg.Add(1)\n\t\tgo e.runCollector(ch, collector, wg)\n\t}\n\twg.Wait()\n}","func (c *auditdCollector) Collect(ch chan<- prometheus.Metric) {\n\n\tfor _, i := range c.metrics {\n\t\tch <- prometheus.MustNewConstMetric(i.desc, i.valType, i.eval(c.stats))\n\t}\n\n}","func (o *OSDCollector) Collect(ch chan<- prometheus.Metric, version *Version) {\n\t// Reset daemon specific metrics; daemons can leave the cluster\n\to.CrushWeight.Reset()\n\to.Depth.Reset()\n\to.Reweight.Reset()\n\to.Bytes.Reset()\n\to.UsedBytes.Reset()\n\to.AvailBytes.Reset()\n\to.Utilization.Reset()\n\to.Variance.Reset()\n\to.Pgs.Reset()\n\to.CommitLatency.Reset()\n\to.ApplyLatency.Reset()\n\to.OSDIn.Reset()\n\to.OSDUp.Reset()\n\to.OSDMetadata.Reset()\n\to.buildOSDLabelCache()\n\n\tlocalWg := &sync.WaitGroup{}\n\n\tlocalWg.Add(1)\n\tgo func() {\n\t\tdefer localWg.Done()\n\t\tif err := o.collectOSDPerf(); err != nil {\n\t\t\to.logger.WithError(err).Error(\"error collecting OSD perf metrics\")\n\t\t}\n\t}()\n\n\tlocalWg.Add(1)\n\tgo func() {\n\t\tdefer localWg.Done()\n\t\tif err := o.collectOSDMetadata(); err != nil {\n\t\t\to.logger.WithError(err).Error(\"error collecting OSD metadata metrics\")\n\t\t}\n\t}()\n\n\tlocalWg.Add(1)\n\tgo func() {\n\t\tdefer localWg.Done()\n\t\tif err := o.collectOSDDump(); err != nil {\n\t\t\to.logger.WithError(err).Error(\"error collecting OSD dump metrics\")\n\t\t}\n\t}()\n\n\tlocalWg.Add(1)\n\tgo func() {\n\t\tdefer localWg.Done()\n\t\tif err := o.collectOSDDF(); err != nil {\n\t\t\to.logger.WithError(err).Error(\"error collecting OSD df metrics\")\n\t\t}\n\t}()\n\n\tlocalWg.Add(1)\n\tgo func() {\n\t\tdefer localWg.Done()\n\t\tif err := o.collectOSDTreeDown(ch); err != nil {\n\t\t\to.logger.WithError(err).Error(\"error collecting OSD tree down metrics\")\n\t\t}\n\t}()\n\n\tlocalWg.Add(1)\n\tgo func() {\n\t\tdefer localWg.Done()\n\t\tif err := o.collectOSDScrubState(ch); err != nil {\n\t\t\to.logger.WithError(err).Error(\"error collecting OSD scrub metrics\")\n\t\t}\n\t}()\n\n\tlocalWg.Wait()\n\n\tfor _, metric := range o.collectorList() {\n\t\tmetric.Collect(ch)\n\t}\n}","func (c *metricbeatCollector) Collect(ch chan<- prometheus.Metric) {\n\n\tfor _, i := range c.metrics {\n\t\tch <- prometheus.MustNewConstMetric(i.desc, i.valType, i.eval(c.stats))\n\t}\n\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\tif ch == nil {\n\t\tglog.Info(\"Prometheus channel is closed. Skipping\")\n\t\treturn\n\t}\n\n\te.mutex.Lock()\n\tdefer func() {\n\t\te.mutex.Unlock()\n\t\te.cleanup.Range(func(key, value interface{}) bool {\n\t\t\tswitch chiName := key.(type) {\n\t\t\tcase string:\n\t\t\t\te.cleanup.Delete(key)\n\t\t\t\te.removeInstallationReference(chiName)\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\t}()\n\n\tglog.Info(\"Starting Collect\")\n\tvar wg = sync.WaitGroup{}\n\t// Getting hostnames of Pods and requesting the metrics data from ClickHouse instances within\n\tfor chiName := range e.chInstallations {\n\t\t// Loop over all hostnames of this installation\n\t\tglog.Infof(\"Collecting metrics for %s\\n\", chiName)\n\t\tfor _, hostname := range e.chInstallations[chiName].hostnames {\n\t\t\twg.Add(1)\n\t\t\tgo func(name, hostname string, c chan<- prometheus.Metric) {\n\t\t\t\tdefer wg.Done()\n\n\t\t\t\tglog.Infof(\"Querying metrics for %s\\n\", hostname)\n\t\t\t\tmetricsData := make([][]string, 0)\n\t\t\t\tfetcher := e.newFetcher(hostname)\n\t\t\t\tif err := fetcher.clickHouseQueryMetrics(&metricsData); err != nil {\n\t\t\t\t\t// In case of an error fetching data from clickhouse store CHI name in e.cleanup\n\t\t\t\t\tglog.Infof(\"Error querying metrics for %s: %s\\n\", hostname, err)\n\t\t\t\t\te.cleanup.Store(name, struct{}{})\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tglog.Infof(\"Extracted %d metrics for %s\\n\", len(metricsData), hostname)\n\t\t\t\twriteMetricsDataToPrometheus(c, metricsData, name, hostname)\n\n\t\t\t\tglog.Infof(\"Querying table sizes for %s\\n\", hostname)\n\t\t\t\ttableSizes := make([][]string, 0)\n\t\t\t\tif err := fetcher.clickHouseQueryTableSizes(&tableSizes); err != nil {\n\t\t\t\t\t// In case of an error fetching data from clickhouse store CHI name in e.cleanup\n\t\t\t\t\tglog.Infof(\"Error querying table sizes for %s: %s\\n\", hostname, err)\n\t\t\t\t\te.cleanup.Store(name, struct{}{})\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tglog.Infof(\"Extracted %d table sizes for %s\\n\", len(tableSizes), hostname)\n\t\t\t\twriteTableSizesDataToPrometheus(c, tableSizes, name, hostname)\n\n\t\t\t}(chiName, hostname, ch)\n\t\t}\n\t}\n\twg.Wait()\n\tglog.Info(\"Finished Collect\")\n}","func (collector *atlassianUPMCollector) Collect(ch chan<- prometheus.Metric) {\n\tstartTime := time.Now()\n\tlog.Debug(\"Collect start\")\n\n\tlog.Debug(\"create request object\")\n\treq, err := http.NewRequest(\"GET\", baseURL, nil)\n\tif err != nil {\n\t\tlog.Error(\"http.NewRequest returned an error:\", err)\n\t}\n\n\tlog.Debug(\"create Basic auth string from argument passed\")\n\tbearer = \"Basic \" + *token\n\n\tlog.Debug(\"add authorization header to the request\")\n\treq.Header.Add(\"Authorization\", bearer)\n\n\tlog.Debug(\"add content type to the request\")\n\treq.Header.Add(\"content-type\", \"application/json\")\n\n\tlog.Debug(\"make request... get back a response\")\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\tlog.Debug(\"set metric atlassian_upm_rest_url_up\")\n\t\tch <- prometheus.MustNewConstMetric(collector.atlassianUPMUpMetric, prometheus.GaugeValue, 0, *fqdn)\n\t\tlog.Warn(\"http.DefaultClient.Do returned an error:\", err, \" return from Collect\")\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != 200 {\n\t\tlog.Debug(\"response status code: \", resp.StatusCode)\n\t}\n\n\tlog.Debug(\"set metric atlassian_upm_rest_url_up\")\n\tch <- prometheus.MustNewConstMetric(collector.atlassianUPMUpMetric, prometheus.GaugeValue, 1, *fqdn)\n\n\tvar allPlugins restPlugins\n\tif resp.StatusCode == 200 {\n\t\tlog.Debug(\"get all plugins\")\n\t\tallPlugins = plugins(resp)\n\n\t\t// return user-installed plugins if argument passed\n\t\tif *userInstalled {\n\t\t\tlog.Debug(\"-user-installed found\")\n\t\t\tallPlugins = userInstalledPlugins(allPlugins)\n\t\t}\n\n\t\t// plugins have the ability to be installed, but disabled, this will remove them if disabled\n\t\tif *dropDisabled {\n\t\t\tlog.Debug(\"-drop-disabled found\")\n\t\t\tallPlugins = dropDisabledPlugins(allPlugins)\n\t\t}\n\n\t\t// Jira specific\n\t\t// some plugins maintained by Jira have an additional element, this gives the option to drop those plugins\n\t\tif *dropJiraSoftware {\n\t\t\tlog.Debug(\"-drop-jira-software found\")\n\t\t\tallPlugins = dropJiraSoftwarePlugins(allPlugins)\n\t\t}\n\n\t\tlog.Debug(\"range over values in response, add each as metric with labels\")\n\t\tfor _, plugin := range allPlugins.Plugins {\n\n\t\t\tlog.Debug(\"creating plugin metric for: \" + plugin.Name)\n\t\t\tch <- prometheus.MustNewConstMetric(\n\t\t\t\tcollector.atlassianUPMPlugins,\n\t\t\t\tprometheus.GaugeValue,\n\t\t\t\t0,\n\t\t\t\tstrconv.FormatBool(plugin.Enabled), // convert bool to string for the 'enabled' value in the labels\n\t\t\t\tstring(plugin.Name),\n\t\t\t\tstring(plugin.Key),\n\t\t\t\tstring(plugin.Version),\n\t\t\t\tstrconv.FormatBool(plugin.UserInstalled),\n\t\t\t\t*fqdn,\n\t\t\t)\n\t\t}\n\t}\n\n\tif resp.StatusCode == 200 && *checkUpdates {\n\t\tlog.Debug(\"get remaining plugins available info\")\n\t\tavailablePluginsMap := getAvailablePluginInfo(allPlugins)\n\n\t\tlog.Debug(\"range over values in response, add each as metric with labels\")\n\t\tfor _, plugin := range availablePluginsMap {\n\t\t\tavailableUpdate := false\n\n\t\t\tverInstalled, err := version.NewVersion(plugin.InstalledVersion)\n\t\t\tif err != nil {\n\t\t\t\tlog.Debug(\"error turning plugin installed into version object\")\n\t\t\t}\n\n\t\t\tverAvailable, err := version.NewVersion(plugin.Version)\n\t\t\tif err != nil {\n\t\t\t\tlog.Debug(\"error turning available plugin into version object\")\n\t\t\t}\n\n\t\t\tif verInstalled.LessThan(verAvailable) {\n\t\t\t\tlog.Debug(\"plugin: \", plugin.Name, \", is currently running: \", plugin.InstalledVersion, \", and can be upgraded to: \", plugin.Version)\n\t\t\t\tavailableUpdate = true\n\t\t\t}\n\n\t\t\tlog.Debug(\"creating plugin version metric for: \", plugin.Name, \", with Key: \", plugin.Key)\n\t\t\tch <- prometheus.MustNewConstMetric(\n\t\t\t\tcollector.atlassianUPMVersionsMetric,\n\t\t\t\tprometheus.GaugeValue,\n\t\t\t\tboolToFloat(availableUpdate),\n\t\t\t\tstring(plugin.Name),\n\t\t\t\tstring(plugin.Key),\n\t\t\t\tstring(plugin.Version),\n\t\t\t\tstring(plugin.InstalledVersion),\n\t\t\t\tstrconv.FormatBool(plugin.Enabled), // convert bool to string for the 'enabled' value in the labels\n\t\t\t\tstrconv.FormatBool(plugin.UserInstalled),\n\t\t\t\t*fqdn,\n\t\t\t)\n\t\t}\n\t}\n\n\tfinishTime := time.Now()\n\telapsedTime := finishTime.Sub(startTime)\n\tlog.Debug(\"set the duration metric\")\n\tch <- prometheus.MustNewConstMetric(collector.atlassianUPMTimeMetric, prometheus.GaugeValue, elapsedTime.Seconds(), *fqdn)\n\n\tlog.Debug(\"Collect finished\")\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\tok := e.collectPeersMetric(ch)\n\tok = e.collectLeaderMetric(ch) && ok\n\tok = e.collectNodesMetric(ch) && ok\n\tok = e.collectMembersMetric(ch) && ok\n\tok = e.collectMembersWanMetric(ch) && ok\n\tok = e.collectServicesMetric(ch) && ok\n\tok = e.collectHealthStateMetric(ch) && ok\n\tok = e.collectKeyValues(ch) && ok\n\n\tif ok {\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tup, prometheus.GaugeValue, 1.0,\n\t\t)\n\t} else {\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tup, prometheus.GaugeValue, 0.0,\n\t\t)\n\t}\n}","func (c *prometheusCollector) Collect(ch chan<- prometheus.Metric) {\n\tvar stats = c.db.Stats()\n\n\tch <- prometheus.MustNewConstMetric(c.maxOpenConnections, prometheus.GaugeValue, float64(stats.MaxOpenConnections))\n\tch <- prometheus.MustNewConstMetric(c.openConnections, prometheus.GaugeValue, float64(stats.OpenConnections))\n\tch <- prometheus.MustNewConstMetric(c.inUse, prometheus.GaugeValue, float64(stats.InUse))\n\tch <- prometheus.MustNewConstMetric(c.idle, prometheus.GaugeValue, float64(stats.Idle))\n\tch <- prometheus.MustNewConstMetric(c.waitCount, prometheus.CounterValue, float64(stats.WaitCount))\n\tch <- prometheus.MustNewConstMetric(c.waitDuration, prometheus.CounterValue, float64(stats.WaitDuration))\n\tch <- prometheus.MustNewConstMetric(c.maxIdleClosed, prometheus.CounterValue, float64(stats.MaxIdleClosed))\n\tch <- prometheus.MustNewConstMetric(c.maxIdleTimeClosed, prometheus.CounterValue, float64(stats.MaxIdleTimeClosed))\n\tch <- prometheus.MustNewConstMetric(c.maxLifetimeClosed, prometheus.CounterValue, float64(stats.MaxLifetimeClosed))\n}","func (c *filebeatCollector) Collect(ch chan<- prometheus.Metric) {\n\n\tfor _, i := range c.metrics {\n\t\tch <- prometheus.MustNewConstMetric(i.desc, i.valType, i.eval(c.stats))\n\t}\n\n}","func CollectAllMetrics(client *statsd.Client, log *li.StandardLogger) {\n\n\tvar metrics []metric\n\tmetrics = append(metrics, metric{name: \"gpu.temperature\", cmd: \"vcgencmd measure_temp | egrep -o '[0-9]*\\\\.[0-9]*'\"})\n\tmetrics = append(metrics, metric{name: \"cpu.temperature\", cmd: \"cat /sys/class/thermal/thermal_zone0/temp | awk 'END {print $1/1000}'\"})\n\tmetrics = append(metrics, metric{name: \"threads\", cmd: \"ps -eo nlwp | tail -n +2 | awk '{ num_threads += $1 } END { print num_threads }'\"})\n\tmetrics = append(metrics, metric{name: \"processes\", cmd: \"ps axu | wc -l\"})\n\n\tfor range time.Tick(15 * time.Second) {\n\t\tlog.Info(\"Starting metric collection\")\n\t\tfor _, m := range metrics {\n\t\t\terr := collectMetric(m, client, log)\n\t\t\tif err != nil {\n\t\t\t\tlog.Error(err)\n\t\t\t}\n\t\t}\n\t}\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\te.mutex.Lock() // To protect metrics from concurrent collects.\n\tdefer e.mutex.Unlock()\n\tif err := e.collect(ch); err != nil {\n\t\tlog.Errorf(\"Error scraping: %s\", err)\n\t}\n\treturn\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\te.mutex.Lock()\n\tdefer e.mutex.Unlock()\n\n\te.scrape()\n\n\te.up.Collect(ch)\n\te.totalScrapes.Collect(ch)\n\te.exchangeStatus.Collect(ch)\n\te.ltp.Collect(ch)\n\te.bestBid.Collect(ch)\n\te.bestAsk.Collect(ch)\n\te.bestBidSize.Collect(ch)\n\te.bestAskSize.Collect(ch)\n\te.totalBidDepth.Collect(ch)\n\te.totalAskDepth.Collect(ch)\n\te.volume.Collect(ch)\n\te.volumeByProduct.Collect(ch)\n}","func (c *VMCollector) Collect(ch chan<- prometheus.Metric) {\n\tfor _, m := range c.getMetrics() {\n\t\tch <- m\n\t}\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\te.mutex.Lock() // To protect metrics from concurrent collects.\n\tdefer e.mutex.Unlock()\n\tif err := e.collect(ch); err != nil {\n\t\tlog.Errorf(\"Error scraping ingestor: %s\", err)\n\t}\n\treturn\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\te.mutex.Lock() // To protect metrics from concurrent collects.\n\tdefer e.mutex.Unlock()\n\tif err := e.collect(ch); err != nil {\n\t\tglog.Error(fmt.Sprintf(\"Error collecting stats: %s\", err))\n\t}\n\treturn\n}","func (*noOpConntracker) Collect(ch chan<- prometheus.Metric) {}","func (o *OSDCollector) Collect(ch chan<- prometheus.Metric) {\n\tif err := o.collectOSDPerf(); err != nil {\n\t\tlog.Println(\"failed collecting osd perf stats:\", err)\n\t}\n\n\tif err := o.collectOSDDump(); err != nil {\n\t\tlog.Println(\"failed collecting osd dump:\", err)\n\t}\n\n\tif err := o.collectOSDDF(); err != nil {\n\t\tlog.Println(\"failed collecting osd metrics:\", err)\n\t}\n\n\tif err := o.collectOSDTreeDown(ch); err != nil {\n\t\tlog.Println(\"failed collecting osd metrics:\", err)\n\t}\n\n\tfor _, metric := range o.collectorList() {\n\t\tmetric.Collect(ch)\n\t}\n\n\tif err := o.collectOSDScrubState(ch); err != nil {\n\t\tlog.Println(\"failed collecting osd scrub state:\", err)\n\t}\n}","func (c *beatCollector) Collect(ch chan<- prometheus.Metric) {\n\n\tfor _, i := range c.metrics {\n\t\tch <- prometheus.MustNewConstMetric(i.desc, i.valType, i.eval(c.stats))\n\t}\n\n}","func (m httpReferenceDiscoveryMetrics) Collect(metrics chan<- prometheus.Metric) {\n\tm.firstPacket.Collect(metrics)\n\tm.totalTime.Collect(metrics)\n\tm.advertisedRefs.Collect(metrics)\n}","func CollectProcessMetrics(refresh time.Duration) {\n\t// Short circuit if the metics system is disabled\n\tif !Enabled {\n\t\treturn\n\t}\n\t// Create the various data collectors\n\tmemstates := make([]*runtime.MemStats, 2)\n\tdiskstates := make([]*DiskStats, 2)\n\tfor i := 0; i < len(memstates); i++ {\n\t\tmemstates[i] = new(runtime.MemStats)\n\t\tdiskstates[i] = new(DiskStats)\n\t}\n\t// Define the various metics to collect\n\tmemAllocs := metics.GetOrRegisterMeter(\"system/memory/allocs\", metics.DefaultRegistry)\n\tmemFrees := metics.GetOrRegisterMeter(\"system/memory/frees\", metics.DefaultRegistry)\n\tmemInuse := metics.GetOrRegisterMeter(\"system/memory/inuse\", metics.DefaultRegistry)\n\tmemPauses := metics.GetOrRegisterMeter(\"system/memory/pauses\", metics.DefaultRegistry)\n\n\tvar diskReads, diskReadBytes, diskWrites, diskWriteBytes metics.Meter\n\tif err := ReadDiskStats(diskstates[0]); err == nil {\n\t\tdiskReads = metics.GetOrRegisterMeter(\"system/disk/readcount\", metics.DefaultRegistry)\n\t\tdiskReadBytes = metics.GetOrRegisterMeter(\"system/disk/readdata\", metics.DefaultRegistry)\n\t\tdiskWrites = metics.GetOrRegisterMeter(\"system/disk/writecount\", metics.DefaultRegistry)\n\t\tdiskWriteBytes = metics.GetOrRegisterMeter(\"system/disk/writedata\", metics.DefaultRegistry)\n\t} else {\n\t\tbgmlogs.Debug(\"Failed to read disk metics\", \"err\", err)\n\t}\n\t// Iterate loading the different states and updating the meters\n\tfor i := 1; ; i++ {\n\t\truntime.ReadMemStats(memstates[i%2])\n\t\tmemAllocs.Mark(int64(memstates[i%2].Mallocs - memstates[(i-1)%2].Mallocs))\n\t\tmemFrees.Mark(int64(memstates[i%2].Frees - memstates[(i-1)%2].Frees))\n\t\tmemInuse.Mark(int64(memstates[i%2].Alloc - memstates[(i-1)%2].Alloc))\n\t\tmemPauses.Mark(int64(memstates[i%2].PauseTotalNs - memstates[(i-1)%2].PauseTotalNs))\n\n\t\tif ReadDiskStats(diskstates[i%2]) == nil {\n\t\t\tdiskReads.Mark(diskstates[i%2].ReadCount - diskstates[(i-1)%2].ReadCount)\n\t\t\tdiskReadBytes.Mark(diskstates[i%2].ReadBytes - diskstates[(i-1)%2].ReadBytes)\n\t\t\tdiskWrites.Mark(diskstates[i%2].WriteCount - diskstates[(i-1)%2].WriteCount)\n\t\t\tdiskWriteBytes.Mark(diskstates[i%2].WriteBytes - diskstates[(i-1)%2].WriteBytes)\n\t\t}\n\t\ttime.Sleep(refresh)\n\t}\n}","func (t *TimestampCollector) Collect(ch chan<- prometheus.Metric) {\n\t// New map to dedup filenames.\n\tuniqueFiles := make(map[string]float64)\n\tt.lock.RLock()\n\tfor fileSD := range t.discoverers {\n\t\tfileSD.lock.RLock()\n\t\tfor filename, timestamp := range fileSD.timestamps {\n\t\t\tuniqueFiles[filename] = timestamp\n\t\t}\n\t\tfileSD.lock.RUnlock()\n\t}\n\tt.lock.RUnlock()\n\tfor filename, timestamp := range uniqueFiles {\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tt.Description,\n\t\t\tprometheus.GaugeValue,\n\t\t\ttimestamp,\n\t\t\tfilename,\n\t\t)\n\t}\n}","func (m *Client) Collect(ch chan<- prometheus.Metric) {\n\tm.storeMu.Lock()\n\tdefer m.storeMu.Unlock()\n\n\tch <- prometheus.MustNewConstMetric(m.storeValuesDesc, prometheus.GaugeValue, float64(len(m.store)))\n\n\tfor k, v := range m.store {\n\t\tch <- prometheus.MustNewConstMetric(m.storeSizesDesc, prometheus.GaugeValue, float64(len(v.value)), k)\n\t}\n}","func (c *Exporter) Collect(ch chan<- prometheus.Metric) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tfor _, cc := range c.collectors {\n\t\tcc.Collect(ch)\n\t}\n}","func (c *Exporter) Collect(ch chan<- prometheus.Metric) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tfor _, cc := range c.collectors {\n\t\tcc.Collect(ch)\n\t}\n}","func (c *collector) Collect(ch chan<- prometheus.Metric) {\n\tc.m.Lock()\n\tfor _, m := range c.metrics {\n\t\tch <- m.metric\n\t}\n\tc.m.Unlock()\n}","func (a *AttunityCollector) Collect(ch chan<- prometheus.Metric) {\n\n\t// Collect information on what servers are active\n\tservers, err := a.servers()\n\tif err != nil {\n\n\t\t// If the error is because the session_id expired, attempt to get a new one and collect info again\n\t\t// else, just fail with an invalid metric containing the error\n\t\tif strings.Contains(err.Error(), \"INVALID_SESSION_ID\") {\n\t\t\ta.SessionID = getSessionID(a.httpClient, a.APIURL, a.auth)\n\n\t\t\tservers, err = a.servers()\n\t\t\tif err != nil {\n\t\t\t\tlogrus.Error(err)\n\t\t\t\tch <- prometheus.NewInvalidMetric(prometheus.NewDesc(\"attunity_error\", \"Error scraping target\", nil, nil), err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t} else {\n\t\t\tlogrus.Error(err)\n\t\t\tch <- prometheus.NewInvalidMetric(prometheus.NewDesc(\"attunity_error\", \"Error scraping target\", nil, nil), err)\n\t\t\treturn\n\t\t}\n\n\t} // end error handling for a.servers()\n\n\tfor _, s := range servers {\n\t\tch <- prometheus.MustNewConstMetric(serverDesc, prometheus.GaugeValue, 1.0, s.Name, s.State, s.Platform, s.Host)\n\t}\n\n\t// For each server, concurrently collect detailed information on\n\t// the tasks that are running on them.\n\twg := sync.WaitGroup{}\n\twg.Add(len(servers))\n\tfor _, s := range servers {\n\t\t// If the Server is not monitored, then it will not have any tasks so we can skip this bit.\n\t\tif s.State != \"MONITORED\" {\n\t\t\twg.Done()\n\t\t\tcontinue\n\t\t}\n\t\tgo func(s server) {\n\t\t\ttaskStates, err := a.taskStates(s.Name)\n\t\t\tif err != nil {\n\t\t\t\tlogrus.Error(err)\n\t\t\t} else {\n\t\t\t\tfor _, t := range taskStates {\n\t\t\t\t\t// inspired by: https://github.com/prometheus/node_exporter/blob/v0.18.1/collector/systemd_linux.go#L222\n\t\t\t\t\tfor _, tsn := range taskStateNames {\n\t\t\t\t\t\tvalue := 0.0\n\t\t\t\t\t\tif t.State == tsn {\n\t\t\t\t\t\t\tvalue = 1.0\n\t\t\t\t\t\t}\n\t\t\t\t\t\tch <- prometheus.MustNewConstMetric(taskStateDesc, prometheus.GaugeValue, value, s.Name, t.Name, tsn)\n\t\t\t\t\t}\n\n\t\t\t\t\t// Get details on each of the tasks and send them to the channel, too\n\t\t\t\t\tt.details(s.Name, a, ch)\n\t\t\t\t}\n\t\t\t}\n\t\t\twg.Done()\n\t\t}(s)\n\t}\n\n\t// For each server, collect high level details such as\n\t// how many tasks are in each state on them and\n\t// how many days until license expiration\n\twg.Add(len(servers))\n\tfor _, s := range servers {\n\t\tgo func(s server) {\n\t\t\tserverDeets, err := a.serverDetails(s.Name)\n\t\t\tif err != nil {\n\t\t\t\tlogrus.Error(err)\n\t\t\t} else {\n\t\t\t\t// Create metrics for task totals by state\n\t\t\t\t// These counts will not be affected by included/excluded task in the config file\n\t\t\t\tch <- prometheus.MustNewConstMetric(serverTasksDesc, prometheus.GaugeValue, float64(serverDeets.TaskSummary.Running), s.Name, \"RUNNING\")\n\t\t\t\tch <- prometheus.MustNewConstMetric(serverTasksDesc, prometheus.GaugeValue, float64(serverDeets.TaskSummary.Stopped), s.Name, \"STOPPED\")\n\t\t\t\tch <- prometheus.MustNewConstMetric(serverTasksDesc, prometheus.GaugeValue, float64(serverDeets.TaskSummary.Error), s.Name, \"ERROR\")\n\t\t\t\tch <- prometheus.MustNewConstMetric(serverTasksDesc, prometheus.GaugeValue, float64(serverDeets.TaskSummary.Recovering), s.Name, \"RECOVERING\")\n\n\t\t\t\t// Create metric for license expiration\n\t\t\t\tch <- prometheus.MustNewConstMetric(serverLicenseExpirationDesc, prometheus.GaugeValue, float64(serverDeets.License.DaysToExpiration), s.Name)\n\t\t\t}\n\t\t\twg.Done()\n\t\t}(s)\n\t}\n\twg.Wait()\n}","func (collector *Metrics) Collect(ch chan<- prometheus.Metric) {\n\n\tcollectedIssues, err := fetchJiraIssues()\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn\n\t}\n\n\tfor _, issue := range collectedIssues.Issues {\n\t\tcreatedTimestamp := convertToUnixTime(issue.Fields.Created)\n\t\tch <- prometheus.MustNewConstMetric(collector.issue, prometheus.CounterValue, createdTimestamp, issue.Fields.Status.Name, issue.Fields.Project.Name, issue.Key, issue.Fields.Assignee.Name, issue.Fields.Location.Name, issue.Fields.Priority.Name, issue.Fields.Level.Name, issue.Fields.RequestType.Name, issue.Fields.Feedback, issue.Fields.Urgency.Name, issue.Fields.IssueType.Name, issue.Fields.Reporter.Name, issue.Fields.Satisfaction)\n\t}\n}","func (c collector) Collect(ch chan<- prometheus.Metric) {\n\tvar wg sync.WaitGroup\n\n\t// We don't bail out on errors because those can happen if there is a race condition between\n\t// the destruction of a container and us getting to read the cgroup data. We just don't report\n\t// the values we don't get.\n\n\tcollectors := []func(string, *regexp.Regexp){\n\t\tfunc(path string, re *regexp.Regexp) {\n\t\t\tdefer wg.Done()\n\t\t\tnuma, err := cgroups.GetNumaStats(cgroupPath(\"memory\", path))\n\t\t\tif err == nil {\n\t\t\t\tupdateNumaStatMetric(ch, re.FindStringSubmatch(filepath.Base(path))[0], numa)\n\t\t\t} else {\n\t\t\t\tlog.Error(\"failed to collect NUMA stats for %s: %v\", path, err)\n\t\t\t}\n\t\t},\n\t\tfunc(path string, re *regexp.Regexp) {\n\t\t\tdefer wg.Done()\n\t\t\tmemory, err := cgroups.GetMemoryUsage(cgroupPath(\"memory\", path))\n\t\t\tif err == nil {\n\t\t\t\tupdateMemoryUsageMetric(ch, re.FindStringSubmatch(filepath.Base(path))[0], memory)\n\t\t\t} else {\n\t\t\t\tlog.Error(\"failed to collect memory usage stats for %s: %v\", path, err)\n\t\t\t}\n\t\t},\n\t\tfunc(path string, re *regexp.Regexp) {\n\t\t\tdefer wg.Done()\n\t\t\tmigrate, err := cgroups.GetCPUSetMemoryMigrate(cgroupPath(\"cpuset\", path))\n\t\t\tif err == nil {\n\t\t\t\tupdateMemoryMigrateMetric(ch, re.FindStringSubmatch(filepath.Base(path))[0], migrate)\n\t\t\t} else {\n\t\t\t\tlog.Error(\"failed to collect memory migration stats for %s: %v\", path, err)\n\t\t\t}\n\t\t},\n\t\tfunc(path string, re *regexp.Regexp) {\n\t\t\tdefer wg.Done()\n\t\t\tcpuAcctUsage, err := cgroups.GetCPUAcctStats(cgroupPath(\"cpuacct\", path))\n\t\t\tif err == nil {\n\t\t\t\tupdateCPUAcctUsageMetric(ch, re.FindStringSubmatch(filepath.Base(path))[0], cpuAcctUsage)\n\t\t\t} else {\n\t\t\t\tlog.Error(\"failed to collect CPU accounting stats for %s: %v\", path, err)\n\t\t\t}\n\t\t},\n\t\tfunc(path string, re *regexp.Regexp) {\n\t\t\tdefer wg.Done()\n\t\t\thugeTlbUsage, err := cgroups.GetHugetlbUsage(cgroupPath(\"hugetlb\", path))\n\t\t\tif err == nil {\n\t\t\t\tupdateHugeTlbUsageMetric(ch, re.FindStringSubmatch(filepath.Base(path))[0], hugeTlbUsage)\n\t\t\t} else {\n\t\t\t\tlog.Error(\"failed to collect hugetlb stats for %s: %v\", path, err)\n\t\t\t}\n\t\t},\n\t\tfunc(path string, re *regexp.Regexp) {\n\t\t\tdefer wg.Done()\n\t\t\tblkioDeviceUsage, err := cgroups.GetBlkioThrottleBytes(cgroupPath(\"blkio\", path))\n\t\t\tif err == nil {\n\t\t\t\tupdateBlkioDeviceUsageMetric(ch, re.FindStringSubmatch(filepath.Base(path))[0], blkioDeviceUsage)\n\t\t\t} else {\n\t\t\t\tlog.Error(\"failed to collect blkio stats for %s: %v\", path, err)\n\t\t\t}\n\t\t},\n\t}\n\n\tcontainerIDRegexp := regexp.MustCompile(`[a-z0-9]{64}`)\n\n\tfor _, path := range walkCgroups() {\n\t\twg.Add(len(collectors))\n\t\tfor _, fn := range collectors {\n\t\t\tgo fn(path, containerIDRegexp)\n\t\t}\n\t}\n\n\t// We need to wait so that the response channel doesn't get closed.\n\twg.Wait()\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\te.mu.Lock()\n\tdefer e.mu.Unlock()\n\n\tfor _, cc := range e.collectors {\n\t\tcc.Collect(ch)\n\t}\n}","func (c *CephExporter) Collect(ch chan<- prometheus.Metric) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tfor _, cc := range c.collectors {\n\t\tcc.Collect(ch)\n\t}\n}","func (n LXCCollector) Collect(ch chan<- prometheus.Metric) {\n\twg := sync.WaitGroup{}\n\twg.Add(len(n.collectors))\n\tfor name, c := range n.collectors {\n\t\tgo func(name string, c collector.Collector) {\n\t\t\texecute(name, c, ch)\n\t\t\twg.Done()\n\t\t}(name, c)\n\t}\n\twg.Wait()\n\tscrapeDurations.Collect(ch)\n}","func (c *Collector) Collect(ch chan<- prometheus.Metric) {\n\tsess, err := sessions.CreateAWSSession()\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn\n\t}\n\n\t// Init WaitGroup. Without a WaitGroup the channel we write\n\t// results to will close before the goroutines finish\n\tvar wg sync.WaitGroup\n\twg.Add(len(c.Scrapers))\n\n\t// Iterate through all scrapers and invoke the scrape\n\tfor _, scraper := range c.Scrapers {\n\t\t// Wrape the scrape invocation in a goroutine, but we need to pass\n\t\t// the scraper into the function explicitly to re-scope the variable\n\t\t// the goroutine accesses. If we don't do this, we can sometimes hit\n\t\t// a case where the scraper reports results twice and the collector panics\n\t\tgo func(scraper *Scraper) {\n\t\t\t// Done call deferred until end of the scrape\n\t\t\tdefer wg.Done()\n\n\t\t\tlog.Debugf(\"Running scrape: %s\", scraper.ID)\n\t\t\tscrapeResults := scraper.Scrape(sess)\n\n\t\t\t// Iterate through scrape results and send the metric\n\t\t\tfor key, results := range scrapeResults {\n\t\t\t\tfor _, result := range results {\n\t\t\t\t\tch <- prometheus.MustNewConstMetric(scraper.Metrics[key].metric, result.Type, result.Value, result.Labels...)\n\t\t\t\t}\n\t\t\t}\n\t\t\tlog.Debugf(\"Scrape completed: %s\", scraper.ID)\n\t\t}(scraper)\n\t}\n\t// Wait\n\twg.Wait()\n}","func (e *Exporter) collect(ch chan<- prometheus.Metric) error {\n\tvar mempct, memtot, memfree float64\n\tif v, e := mem.VirtualMemory(); e == nil {\n\t\tmempct = v.UsedPercent\n\t\tmemtot = float64(v.Total)\n\t\tmemfree = float64(v.Free)\n\t}\n\tvar swappct, swaptot, swapfree float64\n\tif v, e := mem.SwapMemory(); e == nil {\n\t\tswappct = v.UsedPercent\n\t\tswaptot = float64(v.Total)\n\t\tswapfree = float64(v.Free)\n\t}\n\tvar cpupct float64\n\tif c, e := cpu.Percent(time.Millisecond, false); e == nil {\n\t\tcpupct = c[0] // one value since we didn't ask per cpu\n\t}\n\tvar load1, load5, load15 float64\n\tif l, e := load.Avg(); e == nil {\n\t\tload1 = l.Load1\n\t\tload5 = l.Load5\n\t\tload15 = l.Load15\n\t}\n\n\tvar cpuTotal, vsize, rss, openFDs, maxFDs, maxVsize float64\n\tif proc, err := procfs.NewProc(int(*pid)); err == nil {\n\t\tif stat, err := proc.NewStat(); err == nil {\n\t\t\tcpuTotal = float64(stat.CPUTime())\n\t\t\tvsize = float64(stat.VirtualMemory())\n\t\t\trss = float64(stat.ResidentMemory())\n\t\t}\n\t\tif fds, err := proc.FileDescriptorsLen(); err == nil {\n\t\t\topenFDs = float64(fds)\n\t\t}\n\t\tif limits, err := proc.NewLimits(); err == nil {\n\t\t\tmaxFDs = float64(limits.OpenFiles)\n\t\t\tmaxVsize = float64(limits.AddressSpace)\n\t\t}\n\t}\n\n\tvar procCpu, procMem float64\n\tvar estCon, lisCon, othCon, totCon, closeCon, timeCon, openFiles float64\n\tvar nThreads float64\n\tif proc, err := process.NewProcess(int32(*pid)); err == nil {\n\t\tif v, e := proc.CPUPercent(); e == nil {\n\t\t\tprocCpu = float64(v)\n\t\t}\n\t\tif v, e := proc.MemoryPercent(); e == nil {\n\t\t\tprocMem = float64(v)\n\t\t}\n\n\t\tif v, e := proc.NumThreads(); e == nil {\n\t\t\tnThreads = float64(v)\n\t\t}\n\t\tif connections, e := proc.Connections(); e == nil {\n\t\t\tfor _, v := range connections {\n\t\t\t\tif v.Status == \"LISTEN\" {\n\t\t\t\t\tlisCon += 1\n\t\t\t\t} else if v.Status == \"ESTABLISHED\" {\n\t\t\t\t\testCon += 1\n\t\t\t\t} else if v.Status == \"TIME_WAIT\" {\n\t\t\t\t\ttimeCon += 1\n\t\t\t\t} else if v.Status == \"CLOSE_WAIT\" {\n\t\t\t\t\tcloseCon += 1\n\t\t\t\t} else {\n\t\t\t\t\tothCon += 1\n\t\t\t\t}\n\t\t\t}\n\t\t\ttotCon = lisCon + estCon + timeCon + closeCon + othCon\n\t\t}\n\t\tif oFiles, e := proc.OpenFiles(); e == nil {\n\t\t\topenFiles = float64(len(oFiles))\n\t\t}\n\t}\n\n\t// metrics from process collector\n\tch <- prometheus.MustNewConstMetric(e.cpuTotal, prometheus.CounterValue, cpuTotal)\n\tch <- prometheus.MustNewConstMetric(e.openFDs, prometheus.CounterValue, openFDs)\n\tch <- prometheus.MustNewConstMetric(e.maxFDs, prometheus.CounterValue, maxFDs)\n\tch <- prometheus.MustNewConstMetric(e.vsize, prometheus.CounterValue, vsize)\n\tch <- prometheus.MustNewConstMetric(e.maxVsize, prometheus.CounterValue, maxVsize)\n\tch <- prometheus.MustNewConstMetric(e.rss, prometheus.CounterValue, rss)\n\t// node specific metrics\n\tch <- prometheus.MustNewConstMetric(e.memPercent, prometheus.CounterValue, mempct)\n\tch <- prometheus.MustNewConstMetric(e.memTotal, prometheus.CounterValue, memtot)\n\tch <- prometheus.MustNewConstMetric(e.memFree, prometheus.CounterValue, memfree)\n\tch <- prometheus.MustNewConstMetric(e.swapPercent, prometheus.CounterValue, swappct)\n\tch <- prometheus.MustNewConstMetric(e.swapTotal, prometheus.CounterValue, swaptot)\n\tch <- prometheus.MustNewConstMetric(e.swapFree, prometheus.CounterValue, swapfree)\n\tch <- prometheus.MustNewConstMetric(e.numCpus, prometheus.CounterValue, float64(runtime.NumCPU()))\n\tch <- prometheus.MustNewConstMetric(e.load1, prometheus.CounterValue, load1)\n\tch <- prometheus.MustNewConstMetric(e.load5, prometheus.CounterValue, load5)\n\tch <- prometheus.MustNewConstMetric(e.load15, prometheus.CounterValue, load15)\n\t// process specific metrics\n\tch <- prometheus.MustNewConstMetric(e.procCpu, prometheus.CounterValue, procCpu)\n\tch <- prometheus.MustNewConstMetric(e.procMem, prometheus.CounterValue, procMem)\n\tch <- prometheus.MustNewConstMetric(e.numThreads, prometheus.CounterValue, nThreads)\n\tch <- prometheus.MustNewConstMetric(e.cpuPercent, prometheus.CounterValue, cpupct)\n\tch <- prometheus.MustNewConstMetric(e.openFiles, prometheus.CounterValue, openFiles)\n\tch <- prometheus.MustNewConstMetric(e.totCon, prometheus.CounterValue, totCon)\n\tch <- prometheus.MustNewConstMetric(e.lisCon, prometheus.CounterValue, lisCon)\n\tch <- prometheus.MustNewConstMetric(e.estCon, prometheus.CounterValue, estCon)\n\tch <- prometheus.MustNewConstMetric(e.closeCon, prometheus.CounterValue, closeCon)\n\tch <- prometheus.MustNewConstMetric(e.timeCon, prometheus.CounterValue, timeCon)\n\treturn nil\n}","func (o *requestMetrics) Collect(ch chan<- prometheus.Metric) {\n\tmetricFamilies, err := o.stStore.GetPromDirectMetrics()\n\tif err != nil {\n\t\tklog.Errorf(\"fetch prometheus metrics failed: %v\", err)\n\t\treturn\n\t}\n\to.handleMetrics(metricFamilies, ch)\n}","func (e *ebpfConntracker) Collect(ch chan<- prometheus.Metric) {\n\tebpfTelemetry := &netebpf.ConntrackTelemetry{}\n\tif err := e.telemetryMap.Lookup(unsafe.Pointer(&zero), unsafe.Pointer(ebpfTelemetry)); err != nil {\n\t\tlog.Tracef(\"error retrieving the telemetry struct: %s\", err)\n\t} else {\n\t\tdelta := ebpfTelemetry.Registers - conntrackerTelemetry.lastRegisters\n\t\tconntrackerTelemetry.lastRegisters = ebpfTelemetry.Registers\n\t\tch <- prometheus.MustNewConstMetric(conntrackerTelemetry.registersTotal, prometheus.CounterValue, float64(delta))\n\t}\n}","func (c *MSCluster_ClusterCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) error {\n\tvar dst []MSCluster_Cluster\n\tq := queryAll(&dst, c.logger)\n\tif err := wmi.QueryNamespace(q, &dst, \"root/MSCluster\"); err != nil {\n\t\treturn err\n\t}\n\n\tfor _, v := range dst {\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.AddEvictDelay,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.AddEvictDelay),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.AdminAccessPoint,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.AdminAccessPoint),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.AutoAssignNodeSite,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.AutoAssignNodeSite),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.AutoBalancerLevel,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.AutoBalancerLevel),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.AutoBalancerMode,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.AutoBalancerMode),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.BackupInProgress,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.BackupInProgress),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.BlockCacheSize,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.BlockCacheSize),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.ClusSvcHangTimeout,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.ClusSvcHangTimeout),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.ClusSvcRegroupOpeningTimeout,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.ClusSvcRegroupOpeningTimeout),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.ClusSvcRegroupPruningTimeout,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.ClusSvcRegroupPruningTimeout),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.ClusSvcRegroupStageTimeout,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.ClusSvcRegroupStageTimeout),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.ClusSvcRegroupTickInMilliseconds,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.ClusSvcRegroupTickInMilliseconds),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.ClusterEnforcedAntiAffinity,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.ClusterEnforcedAntiAffinity),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.ClusterFunctionalLevel,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.ClusterFunctionalLevel),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.ClusterGroupWaitDelay,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.ClusterGroupWaitDelay),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.ClusterLogLevel,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.ClusterLogLevel),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.ClusterLogSize,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.ClusterLogSize),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.ClusterUpgradeVersion,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.ClusterUpgradeVersion),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.CrossSiteDelay,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.CrossSiteDelay),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.CrossSiteThreshold,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.CrossSiteThreshold),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.CrossSubnetDelay,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.CrossSubnetDelay),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.CrossSubnetThreshold,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.CrossSubnetThreshold),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.CsvBalancer,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.CsvBalancer),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.DatabaseReadWriteMode,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.DatabaseReadWriteMode),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.DefaultNetworkRole,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.DefaultNetworkRole),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.DetectedCloudPlatform,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.DetectedCloudPlatform),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.DetectManagedEvents,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.DetectManagedEvents),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.DetectManagedEventsThreshold,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.DetectManagedEventsThreshold),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.DisableGroupPreferredOwnerRandomization,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.DisableGroupPreferredOwnerRandomization),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.DrainOnShutdown,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.DrainOnShutdown),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.DynamicQuorumEnabled,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.DynamicQuorumEnabled),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.EnableSharedVolumes,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.EnableSharedVolumes),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.FixQuorum,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.FixQuorum),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.GracePeriodEnabled,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.GracePeriodEnabled),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.GracePeriodTimeout,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.GracePeriodTimeout),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.GroupDependencyTimeout,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.GroupDependencyTimeout),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.HangRecoveryAction,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.HangRecoveryAction),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.IgnorePersistentStateOnStartup,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.IgnorePersistentStateOnStartup),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.LogResourceControls,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.LogResourceControls),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.LowerQuorumPriorityNodeId,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.LowerQuorumPriorityNodeId),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.MaxNumberOfNodes,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.MaxNumberOfNodes),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.MessageBufferLength,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.MessageBufferLength),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.MinimumNeverPreemptPriority,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.MinimumNeverPreemptPriority),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.MinimumPreemptorPriority,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.MinimumPreemptorPriority),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.NetftIPSecEnabled,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.NetftIPSecEnabled),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.PlacementOptions,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.PlacementOptions),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.PlumbAllCrossSubnetRoutes,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.PlumbAllCrossSubnetRoutes),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.PreventQuorum,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.PreventQuorum),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.QuarantineDuration,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.QuarantineDuration),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.QuarantineThreshold,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.QuarantineThreshold),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.QuorumArbitrationTimeMax,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.QuorumArbitrationTimeMax),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.QuorumArbitrationTimeMin,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.QuorumArbitrationTimeMin),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.QuorumLogFileSize,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.QuorumLogFileSize),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.QuorumTypeValue,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.QuorumTypeValue),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.RequestReplyTimeout,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.RequestReplyTimeout),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.ResiliencyDefaultPeriod,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.ResiliencyDefaultPeriod),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.ResiliencyLevel,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.ResiliencyLevel),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.ResourceDllDeadlockPeriod,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.ResourceDllDeadlockPeriod),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.RootMemoryReserved,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.RootMemoryReserved),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.RouteHistoryLength,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.RouteHistoryLength),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.S2DBusTypes,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.S2DBusTypes),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.S2DCacheDesiredState,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.S2DCacheDesiredState),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.S2DCacheFlashReservePercent,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.S2DCacheFlashReservePercent),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.S2DCachePageSizeKBytes,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.S2DCachePageSizeKBytes),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.S2DEnabled,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.S2DEnabled),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.S2DIOLatencyThreshold,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.S2DIOLatencyThreshold),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.S2DOptimizations,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.S2DOptimizations),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.SameSubnetDelay,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.SameSubnetDelay),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.SameSubnetThreshold,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.SameSubnetThreshold),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.SecurityLevel,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.SecurityLevel),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.SecurityLevelForStorage,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.SecurityLevelForStorage),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.SharedVolumeVssWriterOperationTimeout,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.SharedVolumeVssWriterOperationTimeout),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.ShutdownTimeoutInMinutes,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.ShutdownTimeoutInMinutes),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.UseClientAccessNetworksForSharedVolumes,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.UseClientAccessNetworksForSharedVolumes),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.WitnessDatabaseWriteTimeout,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.WitnessDatabaseWriteTimeout),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.WitnessDynamicWeight,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.WitnessDynamicWeight),\n\t\t\tv.Name,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.WitnessRestartInterval,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(v.WitnessRestartInterval),\n\t\t\tv.Name,\n\t\t)\n\n\t}\n\n\treturn nil\n}","func (c *TeamsCollector) Collect(ch chan<- prometheus.Metric) {\n\n\tteams := getTotalTeams()\n\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.totalTeamsGaugeDesc,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(teams),\n\t)\n}","func (p *plug) Collect(ch chan<- prometheus.Metric) {\n\tp.doStats(ch, doMetric)\n}","func (p *ProcMetrics) Collect() {\n\tif m, err := CollectProcInfo(p.pid); err == nil {\n\t\tnow := time.Now()\n\n\t\tif !p.lastTime.IsZero() {\n\t\t\tratio := 1.0\n\t\t\tswitch {\n\t\t\tcase m.CPU.Period > 0 && m.CPU.Quota > 0:\n\t\t\t\tratio = float64(m.CPU.Quota) / float64(m.CPU.Period)\n\t\t\tcase m.CPU.Shares > 0:\n\t\t\t\tratio = float64(m.CPU.Shares) / 1024\n\t\t\tdefault:\n\t\t\t\tratio = 1 / float64(runtime.NumCPU())\n\t\t\t}\n\n\t\t\tinterval := ratio * float64(now.Sub(p.lastTime))\n\n\t\t\tp.cpu.user.time = m.CPU.User - p.last.CPU.User\n\t\t\tp.cpu.user.percent = 100 * float64(p.cpu.user.time) / interval\n\n\t\t\tp.cpu.system.time = m.CPU.Sys - p.last.CPU.Sys\n\t\t\tp.cpu.system.percent = 100 * float64(p.cpu.system.time) / interval\n\n\t\t\tp.cpu.total.time = (m.CPU.User + m.CPU.Sys) - (p.last.CPU.User + p.last.CPU.Sys)\n\t\t\tp.cpu.total.percent = 100 * float64(p.cpu.total.time) / interval\n\t\t}\n\n\t\tp.memory.available = m.Memory.Available\n\t\tp.memory.size = m.Memory.Size\n\t\tp.memory.resident.usage = m.Memory.Resident\n\t\tp.memory.resident.percent = 100 * float64(p.memory.resident.usage) / float64(p.memory.available)\n\t\tp.memory.shared.usage = m.Memory.Shared\n\t\tp.memory.text.usage = m.Memory.Text\n\t\tp.memory.data.usage = m.Memory.Data\n\t\tp.memory.pagefault.major.count = m.Memory.MajorPageFaults - p.last.Memory.MajorPageFaults\n\t\tp.memory.pagefault.minor.count = m.Memory.MinorPageFaults - p.last.Memory.MinorPageFaults\n\n\t\tp.files.open = m.Files.Open\n\t\tp.files.max = m.Files.Max\n\n\t\tp.threads.num = m.Threads.Num\n\t\tp.threads.switches.voluntary.count = m.Threads.VoluntaryContextSwitches - p.last.Threads.VoluntaryContextSwitches\n\t\tp.threads.switches.involuntary.count = m.Threads.InvoluntaryContextSwitches - p.last.Threads.InvoluntaryContextSwitches\n\n\t\tp.last = m\n\t\tp.lastTime = now\n\t\tp.engine.Report(p)\n\t}\n}","func (b *EBPFTelemetry) Collect(ch chan<- prometheus.Metric) {\n\tb.getHelpersTelemetry(ch)\n\tb.getMapsTelemetry(ch)\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\te.withCollectors(func(cs []prometheus.Collector) {\n\t\tfor _, c := range cs {\n\t\t\tc.Collect(ch)\n\t\t}\n\t})\n}","func (dc *daemonsetCollector) Collect(ch chan<- prometheus.Metric) {\n\tdss, err := dc.store.List()\n\tif err != nil {\n\t\tScrapeErrorTotalMetric.With(prometheus.Labels{\"resource\": \"daemonset\"}).Inc()\n\t\tglog.Errorf(\"listing daemonsets failed: %s\", err)\n\t\treturn\n\t}\n\tScrapeErrorTotalMetric.With(prometheus.Labels{\"resource\": \"daemonset\"}).Add(0)\n\n\tResourcesPerScrapeMetric.With(prometheus.Labels{\"resource\": \"daemonset\"}).Observe(float64(len(dss)))\n\tfor _, d := range dss {\n\t\tdc.collectDaemonSet(ch, d)\n\t}\n\n\tglog.V(4).Infof(\"collected %d daemonsets\", len(dss))\n}","func (h *Metrics) Collect(in chan<- prometheus.Metric) {\n\th.duration.Collect(in)\n\th.totalRequests.Collect(in)\n\th.requestSize.Collect(in)\n\th.responseSize.Collect(in)\n\th.handlerStatuses.Collect(in)\n\th.responseTime.Collect(in)\n}","func (coll WmiCollector) Collect(ch chan<- prometheus.Metric) {\n\tdefer trace()()\n\twg := sync.WaitGroup{}\n\twg.Add(len(coll.collectors))\n\tfor name, c := range coll.collectors {\n\t\tgo func(name string, c collector.Collector) {\n\t\t\texecute(name, c, ch)\n\t\t\twg.Done()\n\t\t}(name, c)\n\t}\n\twg.Wait()\n\tscrapeDurations.Collect(ch)\n}","func (e *exporter) Collect(ch chan<- prometheus.Metric) {\n\twg := sync.WaitGroup{}\n\twg.Add(len(e.Collectors))\n\tfor name, c := range e.Collectors {\n\t\tgo func(name string, c Collector) {\n\t\t\texecute(name, c, ch)\n\t\t\twg.Done()\n\t\t}(name, c)\n\t}\n\twg.Wait()\n}","func (c *collector) Collect(ch chan<- prometheus.Metric) {\n\tstart := time.Now()\n\n\tp := \"Chassis/1\"\n\terr := power.Collect(p, c.cl, ch)\n\tif err != nil {\n\t\tlogrus.Error(err)\n\t}\n\n\terr = thermal.Collect(p, c.cl, ch)\n\tif err != nil {\n\t\tlogrus.Error(err)\n\t}\n\n\tduration := time.Now().Sub(start).Seconds()\n\tch <- prometheus.MustNewConstMetric(scrapeDurationDesc, prometheus.GaugeValue, duration, c.cl.HostName())\n}","func (t *File_summary_by_instance) Collect(dbh *sql.DB) {\n\tstart := time.Now()\n\t// UPDATE current from db handle\n\tt.current = merge_by_table_name(select_fsbi_rows(dbh), t.global_variables)\n\n\t// copy in initial data if it was not there\n\tif len(t.initial) == 0 && len(t.current) > 0 {\n\t\tt.initial = make(file_summary_by_instance_rows, len(t.current))\n\t\tcopy(t.initial, t.current)\n\t}\n\n\t// check for reload initial characteristics\n\tif t.initial.needs_refresh(t.current) {\n\t\tt.initial = make(file_summary_by_instance_rows, len(t.current))\n\t\tcopy(t.initial, t.current)\n\t}\n\n\t// update results to current value\n\tt.results = make(file_summary_by_instance_rows, len(t.current))\n\tcopy(t.results, t.current)\n\n\t// make relative if need be\n\tif t.WantRelativeStats() {\n\t\tt.results.subtract(t.initial)\n\t}\n\n\t// sort the results\n\tt.results.sort()\n\n\t// setup the totals\n\tt.totals = t.results.totals()\n\tlib.Logger.Println(\"File_summary_by_instance.Collect() took:\", time.Duration(time.Since(start)).String())\n}","func (n NodeCollector) Collect(ch chan<- prometheus.Metric) {\n\twg := sync.WaitGroup{}\n\twg.Add(len(n.collectors))\n\tfor name, c := range n.collectors {\n\t\tgo func(name string, c collector.Collector) {\n\t\t\texecute(name, c, ch)\n\t\t\twg.Done()\n\t\t}(name, c)\n\t}\n\twg.Wait()\n\tscrapeDurations.Collect(ch)\n}","func (c *StatsCollector) Collect(metricChannel chan<- prometheus.Metric) {\n\t// read all stats from Kamailio\n\tif completeStatMap, err := c.fetchStats(); err == nil {\n\t\t// and produce various prometheus.Metric for well-known stats\n\t\tproduceMetrics(completeStatMap, metricChannel)\n\t\t// produce prometheus.Metric objects for scripted stats (if any)\n\t\tconvertScriptedMetrics(completeStatMap, metricChannel)\n\t} else {\n\t\t// something went wrong\n\t\t// TODO: add a error metric\n\t\tlog.Error(\"Could not fetch values from kamailio\", err)\n\t}\n}","func (c *ImageCollector) Collect(ch chan<- prometheus.Metric) {\n\tctx, cancel := context.WithTimeout(context.Background(), c.config.Timeout)\n\tdefer cancel()\n\n\tnow := time.Now()\n\timages, err := c.client.Image.All(ctx)\n\n\tif err != nil {\n\t\tlevel.Error(c.logger).Log(\n\t\t\t\"msg\", \"Failed to fetch images\",\n\t\t\t\"err\", err,\n\t\t)\n\n\t\tc.failures.WithLabelValues(\"image\").Inc()\n\t\treturn\n\t}\n\n\tlevel.Debug(c.logger).Log(\n\t\t\"msg\", \"Fetched images\",\n\t\t\"count\", len(images),\n\t)\n\n\tfor _, image := range images {\n\t\tvar (\n\t\t\tactive float64\n\t\t\tname string\n\t\t\tdeprecated float64\n\t\t)\n\n\t\tif image.CreatedFrom != nil {\n\t\t\tname = image.CreatedFrom.Name\n\t\t}\n\n\t\tif image.BoundTo != nil && image.BoundTo.Name != \"\" {\n\t\t\tactive = 1.0\n\t\t\tname = image.BoundTo.Name\n\t\t}\n\n\t\tlabels := []string{\n\t\t\tstrconv.FormatInt(image.ID, 10),\n\t\t\timage.Name,\n\t\t\tstring(image.Type),\n\t\t\tname,\n\t\t\timage.OSFlavor,\n\t\t\timage.OSVersion,\n\t\t}\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.Active,\n\t\t\tprometheus.GaugeValue,\n\t\t\tactive,\n\t\t\tlabels...,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.ImageSize,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(image.ImageSize*1024*1024),\n\t\t\tlabels...,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.DiskSize,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(image.DiskSize*1024*1024),\n\t\t\tlabels...,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.Created,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(image.Created.Unix()),\n\t\t\tlabels...,\n\t\t)\n\n\t\tif !image.Deprecated.IsZero() {\n\t\t\tdeprecated = float64(image.Deprecated.Unix())\n\t\t}\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.Deprecated,\n\t\t\tprometheus.GaugeValue,\n\t\t\tdeprecated,\n\t\t\tlabels...,\n\t\t)\n\t}\n\n\tlevel.Debug(c.logger).Log(\n\t\t\"msg\", \"Processed image collector\",\n\t\t\"duration\", time.Since(now),\n\t)\n\n\tc.duration.WithLabelValues(\"image\").Observe(time.Since(now).Seconds())\n}","func (c *grpcClientManagerCollector) Collect(ch chan<- prometheus.Metric) {\n\tfor _, con := range c.cm.Metrics().Connections {\n\t\tl := []string{con.Target}\n\t\tch <- prometheus.MustNewConstMetric(connectionStateDesc, prometheus.GaugeValue, float64(con.State), l...)\n\t}\n}","func (c *SchedulerController) CollectMetrics(ch chan<- prometheus.Metric) {\n\tmetric, err := prometheus.NewConstMetric(scheduler.ControllerWorkerSum, prometheus.GaugeValue, float64(c.RunningWorkers()), \"seed\")\n\tif err != nil {\n\t\tscheduler.ScrapeFailures.With(prometheus.Labels{\"kind\": \"gardener-shoot-scheduler\"}).Inc()\n\t\treturn\n\t}\n\tch <- metric\n}","func (pc *PBSCollector) Collect(ch chan<- prometheus.Metric) {\n\tpc.mutex.Lock()\n\tdefer pc.mutex.Unlock()\n\tlog.Debugf(\"Time since last scrape: %f seconds\", time.Since(pc.lastScrape).Seconds())\n\n\tif time.Since(pc.lastScrape).Seconds() > float64(pc.scrapeInterval) {\n\t\tpc.updateDynamicJobIds()\n\t\tvar err error\n\t\tpc.sshClient, err = pc.sshConfig.NewClient()\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Creating SSH client: %s\", err.Error())\n\t\t\treturn\n\t\t}\n\t\tdefer pc.sshClient.Close()\n\t\tlog.Infof(\"Collecting metrics from PBS...\")\n\t\tpc.trackedJobs = make(map[string]bool)\n\t\tif pc.targetJobIds != \"\" {\n\t\t\tpc.collectJobs(ch)\n\t\t}\n\t\tif !pc.skipInfra {\n\t\t\tpc.collectQueues(ch)\n\t\t}\n\t\tpc.lastScrape = time.Now()\n\t}\n\tpc.updateMetrics(ch)\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\tupValue := 1\n\n\tif err := e.collect(ch); err != nil {\n\t\tlog.Printf(\"Error scraping clickhouse: %s\", err)\n\t\te.scrapeFailures.Inc()\n\t\te.scrapeFailures.Collect(ch)\n\n\t\tupValue = 0\n\t}\n\n\tch <- prometheus.MustNewConstMetric(\n\t\tprometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, \"\", \"up\"),\n\t\t\t\"Was the last query of ClickHouse successful.\",\n\t\t\tnil, nil,\n\t\t),\n\t\tprometheus.GaugeValue, float64(upValue),\n\t)\n\n}","func (cpuCollector *CPUCollector) Collect() {\n\tcpuCollector.cpuStats.GetCPUStats()\n\n\tcpuCollector.cpuMetrics.cpuTotal.Set(float64(cpuCollector.cpuStats.Total))\n\tcpuCollector.cpuMetrics.cupIdle.Set(float64(cpuCollector.cpuStats.Idle))\n\tcpuCollector.cpuMetrics.cpuUtilization.Set(cpuCollector.cpuStats.Utilization)\n}","func (e Exporter) Collect(ch chan<- prometheus.Metric) {\n\tctx := context.Background()\n\n\tcontainerService, err := container.NewService(ctx)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tcloudresourcemanagerService, err := cloudresourcemanager.NewService(ctx)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tprojectsListResponse, err := cloudresourcemanagerService.Projects.List().Filter(\"lifecycleState:ACTIVE\").Context(ctx).Do()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tlog.Infof(\"Found %d projects\", len(projectsListResponse.Projects))\n\n\tvar mutex = &sync.Mutex{}\n\tvar wg sync.WaitGroup\n\twg.Add(len(projectsListResponse.Projects))\n\n\tvalidMasterVersions := map[string][]string{}\n\tmasterVersionCount := map[string]float64{}\n\n\tfor _, p := range projectsListResponse.Projects {\n\t\tgo func(p *cloudresourcemanager.Project) {\n\t\t\tdefer wg.Done()\n\t\t\tresp, err := containerService.Projects.Locations.Clusters.List(\"projects/\" + p.ProjectId + \"/locations/-\").Context(ctx).Do()\n\t\t\tif err != nil {\n\t\t\t\tif ae, ok := err.(*googleapi.Error); ok && ae.Code == http.StatusForbidden {\n\t\t\t\t\tlog.Warnf(\"Missing roles/container.clusterViewer on %s (%s)\", p.Name, p.ProjectId)\n\t\t\t\t\treturn\n\t\t\t\t} else if ae, ok := err.(*googleapi.Error); ok && ae.Code == http.StatusTooManyRequests {\n\t\t\t\t\tlog.Warn(\"Quota exceeded\")\n\t\t\t\t\treturn\n\t\t\t\t} else {\n\t\t\t\t\tlog.Fatal(err)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor _, c := range resp.Clusters {\n\t\t\t\tmutex.Lock()\n\t\t\t\tif _, ok := validMasterVersions[c.Location]; !ok {\n\t\t\t\t\tlog.Infof(\"Pulling server configs for location %s\", c.Location)\n\t\t\t\t\tserverConfig, err := containerService.Projects.Locations.GetServerConfig(\"projects/\" + p.ProjectId + \"/locations/\" + c.Location).Do()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tif ae, ok := err.(*googleapi.Error); ok && ae.Code == http.StatusTooManyRequests {\n\t\t\t\t\t\t\tlog.Warn(\"Quota exceeded\")\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlog.Fatal(err)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tvalidMasterVersions[c.Location] = serverConfig.ValidMasterVersions\n\t\t\t\t}\n\n\t\t\t\tif _, ok := masterVersionCount[c.CurrentMasterVersion]; !ok {\n\t\t\t\t\tmasterVersionCount[c.CurrentMasterVersion] = 1\n\t\t\t\t} else {\n\t\t\t\t\tmasterVersionCount[c.CurrentMasterVersion]++\n\t\t\t\t}\n\t\t\t\tmutex.Unlock()\n\n\t\t\t\tif !contains(c.CurrentMasterVersion, validMasterVersions[c.Location]) {\n\t\t\t\t\tch <- prometheus.MustNewConstMetric(\n\t\t\t\t\t\te.Metrics[\"gkeUnsupportedMasterVersion\"],\n\t\t\t\t\t\tprometheus.CounterValue,\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t[]string{\n\t\t\t\t\t\t\tc.CurrentMasterVersion,\n\t\t\t\t\t\t\tp.ProjectId,\n\t\t\t\t\t\t\tp.Name,\n\t\t\t\t\t\t\tc.Name,\n\t\t\t\t\t\t\tc.Location,\n\t\t\t\t\t\t}...,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}(p)\n\t}\n\n\twg.Wait()\n\n\tfor version, cnt := range masterVersionCount {\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\te.Metrics[\"gkeMasterVersion\"],\n\t\t\tprometheus.CounterValue,\n\t\t\tcnt,\n\t\t\t[]string{\n\t\t\t\tversion,\n\t\t\t}...,\n\t\t)\n\t}\n\n\tlog.Info(\"Done\")\n}","func (o *observer) Collect(ch chan<- prometheus.Metric) {\n\to.updateError.Collect(ch)\n\to.verifyError.Collect(ch)\n\to.expiration.Collect(ch)\n}","func collectMetrics(db *sql.DB, populaterWg *sync.WaitGroup, i *integration.Integration, instanceLookUp map[string]string) {\n\tdefer populaterWg.Done()\n\n\tvar collectorWg sync.WaitGroup\n\tmetricChan := make(chan newrelicMetricSender, 100) // large buffer for speed\n\n\t// Create a goroutine for each of the metric groups to collect\n\tcollectorWg.Add(5)\n\tgo oracleReadWriteMetrics.Collect(db, &collectorWg, metricChan)\n\tgo oraclePgaMetrics.Collect(db, &collectorWg, metricChan)\n\tgo oracleSysMetrics.Collect(db, &collectorWg, metricChan)\n\tgo globalNameInstanceMetric.Collect(db, &collectorWg, metricChan)\n\tgo dbIDInstanceMetric.Collect(db, &collectorWg, metricChan)\n\n\t// Separate logic is needed to see if we should even collect tablespaces\n\tcollectTableSpaces(db, &collectorWg, metricChan)\n\n\t// When the metric groups are finished collecting, close the channel\n\tgo func() {\n\t\tcollectorWg.Wait()\n\t\tclose(metricChan)\n\t}()\n\n\t// Create a goroutine to read from the metric channel and insert the metrics\n\tpopulateMetrics(metricChan, i, instanceLookUp)\n}","func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\n\te.mutex.Lock() // To protect metrics from concurrent collects.\n\tdefer e.mutex.Unlock()\n\n\tfor _, pool := range *e.zpools {\n\t\tpool.getStatus()\n\n\t\tpoolUsage := prometheus.NewGauge(prometheus.GaugeOpts{\n\t\t\tName: \"zpool_capacity_percentage\",\n\t\t\tHelp: \"Current zpool capacity level\",\n\t\t\tConstLabels: prometheus.Labels{\n\t\t\t\t\"name\": pool.name,\n\t\t\t},\n\t\t})\n\t\tpoolUsage.Set(float64(pool.capacity))\n\t\tch <- poolUsage\n\n\t\tprovidersOnline := prometheus.NewGauge(prometheus.GaugeOpts{\n\t\t\tName: \"zpool_online_providers_count\",\n\t\t\tHelp: \"Number of ONLINE zpool providers (disks)\",\n\t\t\tConstLabels: prometheus.Labels{\n\t\t\t\t\"name\": pool.name,\n\t\t\t},\n\t\t})\n\t\tprovidersOnline.Set(float64(pool.online))\n\t\tch <- providersOnline\n\n\t\tprovidersFaulted := prometheus.NewGauge(prometheus.GaugeOpts{\n\t\t\tName: \"zpool_faulted_providers_count\",\n\t\t\tHelp: \"Number of FAULTED/UNAVAIL zpool providers (disks)\",\n\t\t\tConstLabels: prometheus.Labels{\n\t\t\t\t\"name\": pool.name,\n\t\t\t},\n\t\t})\n\t\tprovidersFaulted.Set(float64(pool.faulted))\n\t\tch <- providersFaulted\n\t}\n\n}","func (c *solarCollector) collect(ch chan<- prometheus.Metric) error {\n\t// fetch the status of the controller\n\ttracer, err := gotracer.Status(\"/dev/ttyUSB0\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t/*\n\t * report the collected data\n\t */\n\n\t// store boolean values as a float (1 == true, 0 == false)\n\tvar loadIsActive float64\n\t// Panel array\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.panelVoltage,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.ArrayVoltage),\n\t)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.panelCurrent,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.ArrayCurrent),\n\t)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.panelPower,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.ArrayPower),\n\t)\n\n\t// Batteries\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.batteryCurrent,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.BatteryCurrent),\n\t)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.batteryVoltage,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.BatteryVoltage),\n\t)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.batterySOC,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.BatterySOC),\n\t)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.batteryTemp,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.BatteryTemp),\n\t)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.batteryMinVoltage,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.BatteryMinVoltage),\n\t)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.batteryMaxVoltage,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.BatteryMaxVoltage),\n\t)\n\n\t// Load output\n\tif tracer.Load {\n\t\tloadIsActive = 1\n\t}\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.loadActive,\n\t\tprometheus.GaugeValue,\n\t\tloadIsActive,\n\t)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.loadVoltage,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.LoadVoltage),\n\t)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.loadCurrent,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.LoadCurrent),\n\t)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.loadPower,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.LoadPower),\n\t)\n\n\t// controller infos\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.deviceTemp,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.DeviceTemp),\n\t)\n\n\t// energy consumed\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.energyConsumedDaily,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.EnergyConsumedDaily),\n\t)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.energyConsumedMonthly,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.EnergyConsumedMonthly),\n\t)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.energyConsumedAnnual,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.EnergyConsumedAnnual),\n\t)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.energyConsumedTotal,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.EnergyConsumedTotal),\n\t)\n\t// energy generated\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.energyGeneratedDaily,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.EnergyGeneratedDaily),\n\t)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.energyGeneratedMonthly,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.EnergyGeneratedMonthly),\n\t)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.energyGeneratedAnnual,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.EnergyGeneratedAnnual),\n\t)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.energyGeneratedTotal,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(tracer.EnergyGeneratedTotal),\n\t)\n\n\treturn nil\n}","func (e *PostfixExporter) Collect(ch chan<- prometheus.Metric) {\n\terr := CollectShowqFromSocket(e.showqPath, ch)\n\tif err == nil {\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tpostfixUpDesc,\n\t\t\tprometheus.GaugeValue,\n\t\t\t1.0,\n\t\t\te.showqPath)\n\t} else {\n\t\tlog.Printf(\"Failed to scrape showq socket: %s\", err)\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tpostfixUpDesc,\n\t\t\tprometheus.GaugeValue,\n\t\t\t0.0,\n\t\t\te.showqPath)\n\t}\n\n\terr = e.CollectLogfileFromFile(e.logfilePath)\n\tif err == nil {\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tpostfixUpDesc,\n\t\t\tprometheus.GaugeValue,\n\t\t\t1.0,\n\t\t\te.logfilePath)\n\t} else {\n\t\tlog.Printf(\"Failed to scrape logfile: %s\", err)\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tpostfixUpDesc,\n\t\t\tprometheus.GaugeValue,\n\t\t\t0.0,\n\t\t\te.logfilePath)\n\t}\n\n\tch <- e.cleanupProcesses\n\tch <- e.cleanupRejects\n\te.lmtpDelays.Collect(ch)\n\te.pipeDelays.Collect(ch)\n\tch <- e.qmgrInsertsNrcpt\n\tch <- e.qmgrInsertsSize\n\tch <- e.qmgrRemoves\n\te.smtpDelays.Collect(ch)\n\te.smtpTLSConnects.Collect(ch)\n\tch <- e.smtpdConnects\n\tch <- e.smtpdDisconnects\n\tch <- e.smtpdFCrDNSErrors\n\te.smtpdLostConnections.Collect(ch)\n\te.smtpdProcesses.Collect(ch)\n\te.smtpdRejects.Collect(ch)\n\tch <- e.smtpdSASLAuthenticationFailures\n\te.smtpdTLSConnects.Collect(ch)\n\te.unsupportedLogEntries.Collect(ch)\n}","func (coll WmiCollector) Collect(ch chan<- prometheus.Metric) {\n\texecute(coll.collector, ch)\n}","func (m *MeterImpl) collect(ctx context.Context, labels []attribute.KeyValue, measurements []Measurement) {\n\tm.provider.addMeasurement(Batch{\n\t\tCtx: ctx,\n\t\tLabels: labels,\n\t\tMeasurements: measurements,\n\t\tLibrary: m.library,\n\t})\n}","func (c *libbeatCollector) Collect(ch chan<- prometheus.Metric) {\n\n\tfor _, i := range c.metrics {\n\t\tch <- prometheus.MustNewConstMetric(i.desc, i.valType, i.eval(c.stats))\n\t}\n\n\t// output.type with dynamic label\n\tch <- prometheus.MustNewConstMetric(libbeatOutputType, prometheus.CounterValue, float64(1), c.stats.LibBeat.Output.Type)\n\n}","func (c *Client) Collect(ch chan<- prometheus.Metric) {\n\tc.metrics.functionInvocation.Collect(ch)\n\tc.metrics.functionsHistogram.Collect(ch)\n\tc.metrics.queueHistogram.Collect(ch)\n\tc.metrics.functionInvocationStarted.Collect(ch)\n\tc.metrics.serviceReplicasGauge.Reset()\n\tfor _, service := range c.services {\n\t\tvar serviceName string\n\t\tif len(service.Namespace) > 0 {\n\t\t\tserviceName = fmt.Sprintf(\"%s.%s\", service.Name, service.Namespace)\n\t\t} else {\n\t\t\tserviceName = service.Name\n\t\t}\n\t\tc.metrics.serviceReplicasGauge.\n\t\t\tWithLabelValues(serviceName).\n\t\t\tSet(float64(service.Replicas))\n\t}\n\tc.metrics.serviceReplicasGauge.Collect(ch)\n}","func appStatsCollect(ctx *zedrouterContext) {\n\tlog.Infof(\"appStatsCollect: containerStats, started\")\n\tappStatsCollectTimer := time.NewTimer(time.Duration(ctx.appStatsInterval) * time.Second)\n\tfor {\n\t\tselect {\n\t\tcase <-appStatsCollectTimer.C:\n\t\t\titems, stopped := checkAppStopStatsCollect(ctx)\n\t\t\tif stopped {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tcollectTime := time.Now() // all apps collection assign the same timestamp\n\t\t\tfor _, st := range items {\n\t\t\t\tstatus := st.(types.AppNetworkStatus)\n\t\t\t\tif status.GetStatsIPAddr != nil {\n\t\t\t\t\tacMetrics, err := appContainerGetStats(status.GetStatsIPAddr)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Errorf(\"appStatsCollect: can't get App %s Container Metrics on %s, %v\",\n\t\t\t\t\t\t\tstatus.UUIDandVersion.UUID.String(), status.GetStatsIPAddr.String(), err)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tacMetrics.UUIDandVersion = status.UUIDandVersion\n\t\t\t\t\tacMetrics.CollectTime = collectTime\n\t\t\t\t\tctx.pubAppContainerMetrics.Publish(acMetrics.Key(), acMetrics)\n\t\t\t\t}\n\t\t\t}\n\t\t\tappStatsCollectTimer = time.NewTimer(time.Duration(ctx.appStatsInterval) * time.Second)\n\t\t}\n\t}\n}","func (c *SVCResponse) Collect(ch chan<- prometheus.Metric) {\n\tvar err error\n\tc.totalScrapes.Inc()\n\tdefer func() {\n\t\tch <- c.up\n\t\tch <- c.totalScrapes\n\t\tch <- c.jsonParseFailures\n\t}()\n\n\tSVCResp, err := c.fetchDataAndDecode()\n\tif err != nil {\n\t\tc.up.Set(0)\n\t\t_ = level.Warn(*c.logger).Log(\n\t\t\t\"msg\", \"failed to fetch and decode data\",\n\t\t\t\"err\", err,\n\t\t)\n\t\treturn\n\t}\n\tc.up.Set(1)\n\n\tfor _, metric := range c.metrics {\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tmetric.Desc,\n\t\t\tmetric.Type,\n\t\t\tmetric.Value(&SVCResp),\n\t\t)\n\t}\n\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.data.Desc,\n\t\tc.data.Type,\n\t\tc.data.Value(&SVCResp),\n\t\tSVCResp.UniqueID, SVCResp.Version, SVCResp.LongVersion, SVCResp.Platform,\n\t)\n}","func (s *stats) collect() {\n\truntime.GC()\n\truntime.Gosched()\n\n\tm := new(runtime.MemStats)\n\truntime.ReadMemStats(m)\n\n\tg := runtime.NumGoroutine()\n\tp := player.PlayerList.Length()\n\n\t// Calculate difference in resources since last run\n\tΔa := int64(m.Alloc - s.Alloc)\n\tΔh := int(m.HeapObjects - s.HeapObjects)\n\tΔg := g - s.Goroutines\n\n\t// Calculate max players\n\tmaxPlayers := s.MaxPlayers\n\tif s.MaxPlayers < p {\n\t\tmaxPlayers = p\n\t}\n\n\t// Calculate scaled numeric and prefix parts of Alloc and Alloc difference\n\tan, ap := uscale(m.Alloc)\n\tΔan, Δap := scale(Δa)\n\n\tlog.Printf(\"A[%4d%-2s %+5d%-2s] HO[%14d %+9d] GO[%6d %+6d] PL %d/%d\",\n\t\tan, ap, Δan, Δap, m.HeapObjects, Δh, g, Δg, p, maxPlayers,\n\t)\n\n\t// Save current stats\n\ts.Alloc = m.Alloc\n\ts.HeapObjects = m.HeapObjects\n\ts.Goroutines = g\n\ts.MaxPlayers = maxPlayers\n}","func (c *ledCollector) Collect(ch chan<- prometheus.Metric) {\n\tfor _, led := range c.leds {\n\t\tn := name(led.Name())\n\t\tbrightness, err := led.Brightness()\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.brightness,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(brightness),\n\t\t\tn,\n\t\t)\n\t\tmaxBrightness, err := led.MaxBrightness()\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.maxBrightness,\n\t\t\tprometheus.GaugeValue,\n\t\t\tfloat64(maxBrightness),\n\t\t\tn,\n\t\t)\n\t}\n}","func (a collectorAdapter) Collect(ch chan<- prometheus.Metric) {\n\tif err := a.Update(ch); err != nil {\n\t\tpanic(fmt.Sprintf(\"failed to update collector: %v\", err))\n\t}\n}"],"string":"[\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\te.mutex.Lock() // To protect metrics from concurrent collects.\\n\\tdefer e.mutex.Unlock()\\n\\n\\tif err := e.scrape(); err != nil {\\n\\t\\tlog.Error(err)\\n\\t\\tnomad_up.Set(0)\\n\\t\\tch <- nomad_up\\n\\t\\treturn\\n\\t}\\n\\n\\tch <- nomad_up\\n\\tch <- metric_uptime\\n\\tch <- metric_request_response_time_total\\n\\tch <- metric_request_response_time_avg\\n\\n\\tfor _, metric := range metric_request_status_count_current {\\n\\t\\tch <- metric\\n\\t}\\n\\tfor _, metric := range metric_request_status_count_total {\\n\\t\\tch <- metric\\n\\t}\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\te.mutex.Lock() // To protect metrics from concurrent collects.\\n\\tdefer e.mutex.Unlock()\\n\\tif err := e.scrape(ch); err != nil {\\n\\t\\tlog.Printf(\\\"Error scraping nightscout url: %s\\\", err)\\n\\t}\\n\\n\\te.statusNightscout.Collect(ch)\\n\\n\\treturn\\n}\",\n \"func (c *Collector) Collect(ch chan<- prometheus.Metric) {\\n\\tip := os.Getenv(\\\"DYNO_INSTANCE\\\")\\n\\tif ip == \\\"\\\" {\\n\\t\\tlogg.Error(\\\"could not get ip address from env variable: DYNO_INSTANCE\\\")\\n\\t}\\n\\n\\ttoken := os.Getenv(\\\"DYNO_TOKEN\\\")\\n\\tif token == \\\"\\\" {\\n\\t\\tlogg.Error(\\\"could not get token from env variable: DYNO_TOKEN\\\")\\n\\t}\\n\\n\\tvar rack, dc string\\n\\tir, err := c.dyno.Info()\\n\\tif err != nil {\\n\\t\\tlogg.Error(err.Error())\\n\\t} else {\\n\\t\\track = ir.Rack\\n\\t\\tdc = ir.DC\\n\\n\\t\\tch <- c.uptime.mustNewConstMetric(float64(ir.Uptime), rack, dc, token, ip)\\n\\t\\tch <- c.clientConnections.mustNewConstMetric(float64(ir.Pool.ClientConnections), rack, dc, token, ip)\\n\\t\\tch <- c.clientReadRequests.mustNewConstMetric(float64(ir.Pool.ClientReadRequests), rack, dc, token, ip)\\n\\t\\tch <- c.clientWriteRequests.mustNewConstMetric(float64(ir.Pool.ClientWriteRequests), rack, dc, token, ip)\\n\\t\\tch <- c.clientDroppedRequests.mustNewConstMetric(float64(ir.Pool.ClientDroppedRequests), rack, dc, token, ip)\\n\\t}\\n\\n\\tstateVal := 1 // until proven otherwise\\n\\tstateStr := \\\"unknown\\\" // always have a value for the state label\\n\\n\\tstate, err := c.dyno.GetState()\\n\\tif err != nil {\\n\\t\\tstateVal = 0\\n\\t\\tlogg.Error(err.Error())\\n\\t} else {\\n\\t\\tstateStr = string(state)\\n\\t}\\n\\n\\tif state != Normal {\\n\\t\\tstateVal = 0\\n\\t}\\n\\tch <- c.state.mustNewConstMetric(float64(stateVal), stateStr, rack, dc, token, ip)\\n\\n\\tsize, err := c.dyno.Backend.DBSize()\\n\\tif err != nil {\\n\\t\\tlogg.Error(err.Error())\\n\\t} else {\\n\\t\\tch <- c.dbSize.mustNewConstMetric(float64(size), rack, dc, token, ip)\\n\\t}\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\te.mutex.Lock() // To protect metrics from concurrent collects.\\n\\tdefer e.mutex.Unlock()\\n\\n\\t// Reset metrics.\\n\\tfor _, vec := range e.gauges {\\n\\t\\tvec.Reset()\\n\\t}\\n\\n\\tfor _, vec := range e.counters {\\n\\t\\tvec.Reset()\\n\\t}\\n\\n\\tresp, err := e.client.Get(e.URI)\\n\\tif err != nil {\\n\\t\\te.up.Set(0)\\n\\t\\tlog.Printf(\\\"Error while querying Elasticsearch: %v\\\", err)\\n\\t\\treturn\\n\\t}\\n\\tdefer resp.Body.Close()\\n\\n\\tbody, err := ioutil.ReadAll(resp.Body)\\n\\n\\tif err != nil {\\n\\t\\tlog.Printf(\\\"Failed to read ES response body: %v\\\", err)\\n\\t\\te.up.Set(0)\\n\\t\\treturn\\n\\t}\\n\\n\\te.up.Set(1)\\n\\n\\tvar all_stats NodeStatsResponse\\n\\terr = json.Unmarshal(body, &all_stats)\\n\\n\\tif err != nil {\\n\\t\\tlog.Printf(\\\"Failed to unmarshal JSON into struct: %v\\\", err)\\n\\t\\treturn\\n\\t}\\n\\n\\t// Regardless of whether we're querying the local host or the whole\\n\\t// cluster, here we can just iterate through all nodes found.\\n\\n\\tfor node, stats := range all_stats.Nodes {\\n\\t\\tlog.Printf(\\\"Processing node %v\\\", node)\\n\\t\\t// GC Stats\\n\\t\\tfor collector, gcstats := range stats.JVM.GC.Collectors {\\n\\t\\t\\te.counters[\\\"jvm_gc_collection_count\\\"].WithLabelValues(all_stats.ClusterName, stats.Name, collector).Set(float64(gcstats.CollectionCount))\\n\\t\\t\\te.counters[\\\"jvm_gc_collection_time_in_millis\\\"].WithLabelValues(all_stats.ClusterName, stats.Name, collector).Set(float64(gcstats.CollectionTime))\\n\\t\\t}\\n\\n\\t\\t// Breaker stats\\n\\t\\tfor breaker, bstats := range stats.Breakers {\\n\\t\\t\\te.gauges[\\\"breakers_estimated_size_in_bytes\\\"].WithLabelValues(all_stats.ClusterName, stats.Name, breaker).Set(float64(bstats.EstimatedSize))\\n\\t\\t\\te.gauges[\\\"breakers_limit_size_in_bytes\\\"].WithLabelValues(all_stats.ClusterName, stats.Name, breaker).Set(float64(bstats.LimitSize))\\n\\t\\t}\\n\\n\\t\\t// JVM Memory Stats\\n\\t\\te.gauges[\\\"jvm_mem_heap_committed_in_bytes\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.JVM.Mem.HeapCommitted))\\n\\t\\te.gauges[\\\"jvm_mem_heap_used_in_bytes\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.JVM.Mem.HeapUsed))\\n\\t\\te.gauges[\\\"jvm_mem_heap_max_in_bytes\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.JVM.Mem.HeapMax))\\n\\t\\te.gauges[\\\"jvm_mem_non_heap_committed_in_bytes\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.JVM.Mem.NonHeapCommitted))\\n\\t\\te.gauges[\\\"jvm_mem_non_heap_used_in_bytes\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.JVM.Mem.NonHeapUsed))\\n\\n\\t\\t// Indices Stats\\n\\t\\te.gauges[\\\"indices_fielddata_evictions\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.FieldData.Evictions))\\n\\t\\te.gauges[\\\"indices_fielddata_memory_size_in_bytes\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.FieldData.MemorySize))\\n\\t\\te.gauges[\\\"indices_filter_cache_evictions\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.FilterCache.Evictions))\\n\\t\\te.gauges[\\\"indices_filter_cache_memory_size_in_bytes\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.FilterCache.MemorySize))\\n\\n\\t\\te.gauges[\\\"indices_docs_count\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.Docs.Count))\\n\\t\\te.gauges[\\\"indices_docs_deleted\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.Docs.Deleted))\\n\\n\\t\\te.gauges[\\\"indices_segments_memory_in_bytes\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.Segments.Memory))\\n\\n\\t\\te.gauges[\\\"indices_store_size_in_bytes\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.Store.Size))\\n\\t\\te.counters[\\\"indices_store_throttle_time_in_millis\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.Store.ThrottleTime))\\n\\n\\t\\te.counters[\\\"indices_flush_total\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.Flush.Total))\\n\\t\\te.counters[\\\"indices_flush_time_in_millis\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Indices.Flush.Time))\\n\\n\\t\\t// Transport Stats\\n\\t\\te.counters[\\\"transport_rx_count\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Transport.RxCount))\\n\\t\\te.counters[\\\"transport_rx_size_in_bytes\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Transport.RxSize))\\n\\t\\te.counters[\\\"transport_tx_count\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Transport.TxCount))\\n\\t\\te.counters[\\\"transport_tx_size_in_bytes\\\"].WithLabelValues(all_stats.ClusterName, stats.Name).Set(float64(stats.Transport.TxSize))\\n\\t}\\n\\n\\t// Report metrics.\\n\\tch <- e.up\\n\\n\\tfor _, vec := range e.counters {\\n\\t\\tvec.Collect(ch)\\n\\t}\\n\\n\\tfor _, vec := range e.gauges {\\n\\t\\tvec.Collect(ch)\\n\\t}\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\t// Protect metrics from concurrent collects.\\n\\te.mutex.Lock()\\n\\tdefer e.mutex.Unlock()\\n\\n\\t// Scrape metrics from Tankerkoenig API.\\n\\tif err := e.scrape(ch); err != nil {\\n\\t\\te.logger.Printf(\\\"error: cannot scrape tankerkoenig api: %v\\\", err)\\n\\t}\\n\\n\\t// Collect metrics.\\n\\te.up.Collect(ch)\\n\\te.scrapeDuration.Collect(ch)\\n\\te.failedScrapes.Collect(ch)\\n\\te.totalScrapes.Collect(ch)\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\te.mutex.Lock() // To protect metrics from concurrent collects.\\n\\tdefer e.mutex.Unlock()\\n\\n\\tup := e.scrape(ch)\\n\\n\\tch <- prometheus.MustNewConstMetric(artifactoryUp, prometheus.GaugeValue, up)\\n\\tch <- e.totalScrapes\\n\\tch <- e.jsonParseFailures\\n}\",\n \"func (c *MetricsCollector) Collect(ch chan<- prometheus.Metric) {\\n\\tfor _, s := range c.status {\\n\\t\\ts.RLock()\\n\\t\\tdefer s.RUnlock()\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.verify,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(s.VerifyRestore),\\n\\t\\t\\t\\\"verify_restore\\\",\\n\\t\\t\\ts.BackupService,\\n\\t\\t\\ts.StorageService,\\n\\t\\t)\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.verify,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(s.VerifyDiff),\\n\\t\\t\\t\\\"verify_diff\\\",\\n\\t\\t\\ts.BackupService,\\n\\t\\t\\ts.StorageService,\\n\\t\\t)\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.verify,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(s.VerifyChecksum),\\n\\t\\t\\t\\\"verify_checksum\\\",\\n\\t\\t\\ts.BackupService,\\n\\t\\t\\ts.StorageService,\\n\\t\\t)\\n\\t}\\n\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\tfor _, db := range e.dbs {\\n\\t\\t// logger.Log(\\\"Scraping\\\", db.String())\\n\\t\\tgo e.scrapeDatabase(db)\\n\\t}\\n\\te.mutex.Lock()\\n\\tdefer e.mutex.Unlock()\\n\\te.cpuPercent.Collect(ch)\\n\\te.dataIO.Collect(ch)\\n\\te.logIO.Collect(ch)\\n\\te.memoryPercent.Collect(ch)\\n\\te.workPercent.Collect(ch)\\n\\te.sessionPercent.Collect(ch)\\n\\te.storagePercent.Collect(ch)\\n\\te.dbUp.Collect(ch)\\n\\te.up.Set(1)\\n}\",\n \"func (sc *SlurmCollector) Collect(ch chan<- prometheus.Metric) {\\n\\tsc.mutex.Lock()\\n\\tdefer sc.mutex.Unlock()\\n\\n\\tlog.Debugf(\\\"Time since last scrape: %f seconds\\\", time.Since(sc.lastScrape).Seconds())\\n\\tif time.Since(sc.lastScrape).Seconds() > float64(sc.scrapeInterval) {\\n\\t\\tsc.updateDynamicJobIds()\\n\\t\\tvar err error\\n\\t\\tsc.sshClient, err = sc.sshConfig.NewClient()\\n\\t\\tif err != nil {\\n\\t\\t\\tlog.Errorf(\\\"Creating SSH client: %s\\\", err.Error())\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tdefer sc.sshClient.Close()\\n\\t\\tlog.Infof(\\\"Collecting metrics from Slurm...\\\")\\n\\t\\tsc.trackedJobs = make(map[string]bool)\\n\\t\\tif sc.targetJobIds == \\\"\\\" {\\n\\t\\t\\t// sc.collectQueue()\\n\\t\\t} else {\\n\\t\\t\\tsc.collectAcct()\\n\\t\\t}\\n\\t\\tif !sc.skipInfra {\\n\\t\\t\\tsc.collectInfo()\\n\\t\\t}\\n\\t\\tsc.lastScrape = time.Now()\\n\\t\\tsc.delJobs()\\n\\n\\t}\\n\\n\\tsc.updateMetrics(ch)\\n}\",\n \"func (c *Collector) Collect(ch chan<- prometheus.Metric) {\\n\\tc.Lock()\\n\\tdefer c.Unlock()\\n\\n\\tc.totalScrapes.Inc()\\n\\terr := c.getDadataBalance()\\n\\tif err != nil {\\n\\t\\tc.failedBalanceScrapes.Inc()\\n\\t}\\n\\terr = c.getDadataStats()\\n\\tif err != nil {\\n\\t\\tc.failedStatsScrapes.Inc()\\n\\t}\\n\\n\\tch <- c.totalScrapes\\n\\tch <- c.failedBalanceScrapes\\n\\tch <- c.failedStatsScrapes\\n\\tch <- c.CurrentBalance\\n\\tch <- c.ServicesClean\\n\\tch <- c.ServicesMerging\\n\\tch <- c.ServicesSuggestions\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\te.mutex.Lock()\\n\\tdefer e.mutex.Unlock()\\n\\n\\tfor _, vec := range e.gauges {\\n\\t\\tvec.Reset()\\n\\t}\\n\\n\\tdefer func() { ch <- e.up }()\\n\\n\\t// If we fail at any point in retrieving GPU status, we fail 0\\n\\te.up.Set(1)\\n\\n\\te.GetTelemetryFromNVML()\\n\\n\\tfor _, vec := range e.gauges {\\n\\t\\tvec.Collect(ch)\\n\\t}\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\tvar (\\n\\t\\tdata *Data\\n\\t\\terr error\\n\\t)\\n\\n\\te.mutex.Lock() // To protect metrics from concurrent collects.\\n\\tdefer e.mutex.Unlock()\\n\\n\\te.resetGaugeVecs() // Clean starting point\\n\\n\\tvar endpointOfAPI []string\\n\\tif strings.HasSuffix(rancherURL, \\\"v3\\\") || strings.HasSuffix(rancherURL, \\\"v3/\\\") {\\n\\t\\tendpointOfAPI = endpointsV3\\n\\t} else {\\n\\t\\tendpointOfAPI = endpoints\\n\\t}\\n\\n\\tcacheExpired := e.IsCacheExpired()\\n\\n\\t// Range over the pre-configured endpoints array\\n\\tfor _, p := range endpointOfAPI {\\n\\t\\tif cacheExpired {\\n\\t\\t\\tdata, err = e.gatherData(e.rancherURL, e.resourceLimit, e.accessKey, e.secretKey, p, ch)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tlog.Errorf(\\\"Error getting JSON from URL %s\\\", p)\\n\\t\\t\\t\\treturn\\n\\t\\t\\t}\\n\\t\\t\\te.cache[p] = data\\n\\t\\t} else {\\n\\t\\t\\td, ok := e.cache[p]\\n\\t\\t\\tif !ok {\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\n\\t\\t\\tdata = d\\n\\t\\t}\\n\\n\\t\\tif err := e.processMetrics(data, p, e.hideSys, ch); err != nil {\\n\\t\\t\\tlog.Errorf(\\\"Error scraping rancher url: %s\\\", err)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tlog.Infof(\\\"Metrics successfully processed for %s\\\", p)\\n\\t}\\n\\n\\tif cacheExpired {\\n\\t\\te.RenewCache()\\n\\t}\\n\\n\\tfor _, m := range e.gaugeVecs {\\n\\t\\tm.Collect(ch)\\n\\t}\\n}\",\n \"func (collector *OpenweatherCollector) Collect(ch chan<- prometheus.Metric) {\\n\\t// Get Coords\\n\\tlatitude, longitude := geo.Get_coords(openstreetmap.Geocoder(), collector.Location)\\n\\n\\t// Setup HTTP Client\\n\\tclient := &http.Client{\\n\\t\\tTimeout: 1 * time.Second,\\n\\t}\\n\\n\\t// Grab Metrics\\n\\tw, err := owm.NewCurrent(collector.DegreesUnit, collector.Language, collector.ApiKey, owm.WithHttpClient(client))\\n\\tif err != nil {\\n\\t\\tlog.Fatalln(err)\\n\\t} else {\\n\\t\\tlog.Infof(\\\"Collecting metrics from openweather API successful\\\")\\n\\t}\\n\\n\\tw.CurrentByCoordinates(&owm.Coordinates{Longitude: longitude, Latitude: latitude})\\n\\n\\t// Get Weather description out of Weather slice to pass as label\\n\\tvar weather_description string\\n\\tfor _, n := range w.Weather {\\n\\t\\tweather_description = n.Description\\n\\t}\\n\\n\\t//Write latest value for each metric in the prometheus metric channel.\\n\\t//Note that you can pass CounterValue, GaugeValue, or UntypedValue types here.\\n\\tch <- prometheus.MustNewConstMetric(collector.temperatureMetric, prometheus.GaugeValue, w.Main.Temp, collector.Location)\\n\\tch <- prometheus.MustNewConstMetric(collector.humidity, prometheus.GaugeValue, float64(w.Main.Humidity), collector.Location)\\n\\tch <- prometheus.MustNewConstMetric(collector.feelslike, prometheus.GaugeValue, w.Main.FeelsLike, collector.Location)\\n\\tch <- prometheus.MustNewConstMetric(collector.pressure, prometheus.GaugeValue, w.Main.Pressure, collector.Location)\\n\\tch <- prometheus.MustNewConstMetric(collector.windspeed, prometheus.GaugeValue, w.Wind.Speed, collector.Location)\\n\\tch <- prometheus.MustNewConstMetric(collector.rain1h, prometheus.GaugeValue, w.Rain.OneH, collector.Location)\\n\\tch <- prometheus.MustNewConstMetric(collector.winddegree, prometheus.GaugeValue, w.Wind.Deg, collector.Location)\\n\\tch <- prometheus.MustNewConstMetric(collector.cloudiness, prometheus.GaugeValue, float64(w.Clouds.All), collector.Location)\\n\\tch <- prometheus.MustNewConstMetric(collector.sunrise, prometheus.GaugeValue, float64(w.Sys.Sunrise), collector.Location)\\n\\tch <- prometheus.MustNewConstMetric(collector.sunset, prometheus.GaugeValue, float64(w.Sys.Sunset), collector.Location)\\n\\tch <- prometheus.MustNewConstMetric(collector.snow1h, prometheus.GaugeValue, w.Snow.OneH, collector.Location)\\n\\tch <- prometheus.MustNewConstMetric(collector.currentconditions, prometheus.GaugeValue, 0, collector.Location, weather_description)\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\tvar up float64 = 1\\n\\n\\tglobalMutex.Lock()\\n\\tdefer globalMutex.Unlock()\\n\\n\\tif e.config.resetStats && !globalResetExecuted {\\n\\t\\t// Its time to try to reset the stats\\n\\t\\tif e.resetStatsSemp1() {\\n\\t\\t\\tlevel.Info(e.logger).Log(\\\"msg\\\", \\\"Statistics successfully reset\\\")\\n\\t\\t\\tglobalResetExecuted = true\\n\\t\\t\\tup = 1\\n\\t\\t} else {\\n\\t\\t\\tup = 0\\n\\t\\t}\\n\\t}\\n\\n\\tif e.config.details {\\n\\t\\tif up > 0 {\\n\\t\\t\\tup = e.getClientSemp1(ch)\\n\\t\\t}\\n\\t\\tif up > 0 {\\n\\t\\t\\tup = e.getQueueSemp1(ch)\\n\\t\\t}\\n\\t\\tif up > 0 && e.config.scrapeRates {\\n\\t\\t\\tup = e.getQueueRatesSemp1(ch)\\n\\t\\t}\\n\\t} else { // Basic\\n\\t\\tif up > 0 {\\n\\t\\t\\tup = e.getRedundancySemp1(ch)\\n\\t\\t}\\n\\t\\tif up > 0 {\\n\\t\\t\\tup = e.getSpoolSemp1(ch)\\n\\t\\t}\\n\\t\\tif up > 0 {\\n\\t\\t\\tup = e.getHealthSemp1(ch)\\n\\t\\t}\\n\\t\\tif up > 0 {\\n\\t\\t\\tup = e.getVpnSemp1(ch)\\n\\t\\t}\\n\\t}\\n\\n\\tch <- prometheus.MustNewConstMetric(solaceUp, prometheus.GaugeValue, up)\\n}\",\n \"func (c *OrchestratorCollector) Collect(ch chan<- prometheus.Metric) {\\n\\tc.mutex.Lock() // To protect metrics from concurrent collects\\n\\tdefer c.mutex.Unlock()\\n\\n\\tstats, err := c.orchestratorClient.GetMetrics()\\n\\tif err != nil {\\n\\t\\tc.upMetric.Set(serviceDown)\\n\\t\\tch <- c.upMetric\\n\\t\\tlog.Printf(\\\"Error getting Orchestrator stats: %v\\\", err)\\n\\t\\treturn\\n\\t}\\n\\n\\tc.upMetric.Set(serviceUp)\\n\\tch <- c.upMetric\\n\\n\\tch <- prometheus.MustNewConstMetric(c.metrics[\\\"cluter_size\\\"],\\n\\t\\tprometheus.GaugeValue, float64(len(stats.Status.Details.AvailableNodes)))\\n\\tch <- prometheus.MustNewConstMetric(c.metrics[\\\"is_active_node\\\"],\\n\\t\\tprometheus.GaugeValue, boolToFloat64(stats.Status.Details.IsActiveNode))\\n\\tch <- prometheus.MustNewConstMetric(c.metrics[\\\"problems\\\"],\\n\\t\\tprometheus.GaugeValue, float64(len(stats.Problems)))\\n\\tch <- prometheus.MustNewConstMetric(c.metrics[\\\"last_failover_id\\\"],\\n\\t\\tprometheus.CounterValue, float64(stats.LastFailoverID))\\n\\tch <- prometheus.MustNewConstMetric(c.metrics[\\\"is_healthy\\\"],\\n\\t\\tprometheus.GaugeValue, boolToFloat64(stats.Status.Details.Healthy))\\n\\tch <- prometheus.MustNewConstMetric(c.metrics[\\\"failed_seeds\\\"],\\n\\t\\tprometheus.CounterValue, float64(stats.FailedSeeds))\\n}\",\n \"func (k *KACollector) Collect(ch chan<- prometheus.Metric) {\\n\\tk.mutex.Lock()\\n\\tdefer k.mutex.Unlock()\\n\\n\\tvar err error\\n\\tvar kaStats []KAStats\\n\\n\\tif k.useJSON {\\n\\t\\tkaStats, err = k.json()\\n\\t\\tif err != nil {\\n\\t\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_up\\\"], prometheus.GaugeValue, 0)\\n\\t\\t\\tlog.Printf(\\\"keepalived_exporter: %v\\\", err)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t} else {\\n\\t\\tkaStats, err = k.text()\\n\\t\\tif err != nil {\\n\\t\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_up\\\"], prometheus.GaugeValue, 0)\\n\\t\\t\\tlog.Printf(\\\"keepalived_exporter: %v\\\", err)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t}\\n\\n\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_up\\\"], prometheus.GaugeValue, 1)\\n\\n\\tfor _, st := range kaStats {\\n\\t\\tstate := \\\"\\\"\\n\\t\\tif _, ok := state2string[st.Data.State]; ok {\\n\\t\\t\\tstate = state2string[st.Data.State]\\n\\t\\t}\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_vrrp_advert_rcvd\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(st.Stats.AdvertRcvd), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_vrrp_advert_sent\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(st.Stats.AdvertSent), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_vrrp_become_master\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(st.Stats.BecomeMaster), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_vrrp_release_master\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(st.Stats.ReleaseMaster), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_vrrp_packet_len_err\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(st.Stats.PacketLenErr), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_vrrp_advert_interval_err\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(st.Stats.AdvertIntervalErr), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_vrrp_ip_ttl_err\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(st.Stats.AdvertIntervalErr), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_vrrp_invalid_type_rcvd\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(st.Stats.InvalidTypeRcvd), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_vrrp_addr_list_err\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(st.Stats.AddrListErr), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_vrrp_invalid_authtype\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(st.Stats.InvalidAuthtype), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_vrrp_authtype_mismatch\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(st.Stats.AuthtypeMismatch), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_vrrp_auth_failure\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(st.Stats.AuthFailure), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_vrrp_pri_zero_rcvd\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(st.Stats.PriZeroRcvd), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_vrrp_pri_zero_sent\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(st.Stats.PriZeroSent), st.Data.Iname, st.Data.IfpIfname, strconv.Itoa(st.Data.Vrid), state)\\n\\t}\\n\\n\\tif k.handle == nil {\\n\\t\\treturn\\n\\t}\\n\\n\\tsvcs, err := k.handle.GetServices()\\n\\tif err != nil {\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_up\\\"], prometheus.GaugeValue, 0)\\n\\t\\tlog.Printf(\\\"keepalived_exporter: services: %v\\\", err)\\n\\t\\treturn\\n\\t}\\n\\n\\tfor _, s := range svcs {\\n\\t\\tdsts, err := k.handle.GetDestinations(s)\\n\\t\\tif err != nil {\\n\\t\\t\\tlog.Printf(\\\"keepalived_exporter: destinations: %v\\\", err)\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\n\\t\\taddr := s.Address.String() + \\\":\\\" + strconv.Itoa(int(s.Port))\\n\\t\\tproto := strconv.Itoa(int(s.Protocol))\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_lvs_vip_in_packets\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(s.Stats.PacketsIn), addr, proto)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_lvs_vip_out_packets\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(s.Stats.PacketsOut), addr, proto)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_lvs_vip_in_bytes\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(s.Stats.BytesIn), addr, proto)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_lvs_vip_out_bytes\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(s.Stats.BytesOut), addr, proto)\\n\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_lvs_vip_conn\\\"], prometheus.CounterValue,\\n\\t\\t\\tfloat64(s.Stats.Connections), addr, proto)\\n\\n\\t\\tfor _, d := range dsts {\\n\\t\\t\\taddr := d.Address.String() + \\\":\\\" + strconv.Itoa(int(d.Port))\\n\\n\\t\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_lvs_rs_in_packets\\\"], prometheus.CounterValue,\\n\\t\\t\\t\\tfloat64(d.Stats.PacketsIn), addr, proto)\\n\\t\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_lvs_rs_out_packets\\\"], prometheus.CounterValue,\\n\\t\\t\\t\\tfloat64(d.Stats.PacketsOut), addr, proto)\\n\\t\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_lvs_rs_in_bytes\\\"], prometheus.CounterValue,\\n\\t\\t\\t\\tfloat64(d.Stats.BytesIn), addr, proto)\\n\\t\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_lvs_rs_out_bytes\\\"], prometheus.CounterValue,\\n\\t\\t\\t\\tfloat64(d.Stats.BytesOut), addr, proto)\\n\\t\\t\\tch <- prometheus.MustNewConstMetric(k.metrics[\\\"keepalived_lvs_rs_conn\\\"], prometheus.CounterValue,\\n\\t\\t\\t\\tfloat64(d.Stats.Connections), addr, proto)\\n\\t\\t}\\n\\t}\\n}\",\n \"func (c *solarCollector) Collect(ch chan<- prometheus.Metric) {\\n\\tc.mutex.Lock() // To protect metrics from concurrent collects.\\n\\tdefer c.mutex.Unlock()\\n\\tif err := c.collect(ch); err != nil {\\n\\t\\tlog.Printf(\\\"Error getting solar controller data: %s\\\", err)\\n\\t\\tc.scrapeFailures.Inc()\\n\\t\\tc.scrapeFailures.Collect(ch)\\n\\t}\\n\\treturn\\n}\",\n \"func (c *ClusterManager) Collect(ch chan<- prometheus.Metric) {\\n\\toomCountByHost, ramUsageByHost := c.ReallyExpensiveAssessmentOfTheSystemState()\\n\\tfor host, oomCount := range oomCountByHost {\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.OOMCountDesc,\\n\\t\\t\\tprometheus.CounterValue,\\n\\t\\t\\tfloat64(oomCount),\\n\\t\\t\\thost,\\n\\t\\t)\\n\\t}\\n\\tfor host, ramUsage := range ramUsageByHost {\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.RAMUsageDesc,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tramUsage,\\n\\t\\t\\thost,\\n\\t\\t)\\n\\t}\\n}\",\n \"func (e *UwsgiExporter) Collect(ch chan<- prometheus.Metric) {\\n\\tstartTime := time.Now()\\n\\terr := e.execute(ch)\\n\\td := time.Since(startTime).Seconds()\\n\\n\\tif err != nil {\\n\\t\\tlog.Errorf(\\\"ERROR: scrape failed after %fs: %s\\\", d, err)\\n\\t\\te.uwsgiUp.Set(0)\\n\\t\\te.scrapeDurations.WithLabelValues(\\\"error\\\").Observe(d)\\n\\t} else {\\n\\t\\tlog.Debugf(\\\"OK: scrape successful after %fs.\\\", d)\\n\\t\\te.uwsgiUp.Set(1)\\n\\t\\te.scrapeDurations.WithLabelValues(\\\"success\\\").Observe(d)\\n\\t}\\n\\n\\te.uwsgiUp.Collect(ch)\\n\\te.scrapeDurations.Collect(ch)\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\tignore := strings.Split(*flagStatsIgnore, \\\",\\\")\\n\\tif len(ignore) == 1 && ignore[0] == \\\"\\\" {\\n\\t\\tignore = []string{}\\n\\t}\\n\\tnicks := strings.Split(*flagStatsNicks, \\\",\\\")\\n\\tif len(nicks) == 1 && nicks[0] == \\\"\\\" {\\n\\t\\tnicks = []string{}\\n\\t}\\n\\tres := e.client.Stats(irc.StatsRequest{\\n\\t\\tLocal: *flagStatsLocal,\\n\\t\\tTimeout: *flagStatsTimeout,\\n\\t\\tIgnoreServers: ignore,\\n\\t\\tNicks: nicks,\\n\\t})\\n\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tconnected, prometheus.GaugeValue, boolToFloat[e.client.Server != \\\"\\\"])\\n\\n\\t_, ok := res.Servers[e.client.Server]\\n\\tif res.Timeout && !ok {\\n\\t\\t// Timeout, no data at all\\n\\t\\tif e.client.Server != \\\"\\\" {\\n\\t\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\t\\tup, prometheus.GaugeValue, 0.0, e.client.Server)\\n\\t\\t}\\n\\t} else {\\n\\t\\t// Global state\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tchannels, prometheus.GaugeValue, float64(res.Channels))\\n\\n\\t\\tfor nick, nickIson := range res.Nicks {\\n\\t\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\t\\tison, prometheus.GaugeValue, boolToFloat[nickIson], nick)\\n\\t\\t}\\n\\n\\t\\t// Per server state\\n\\t\\tfor server, stats := range res.Servers {\\n\\t\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\t\\tdistance, prometheus.GaugeValue, float64(stats.Distance), server)\\n\\n\\t\\t\\tif *flagStatsLocal && e.client.Server != server {\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\n\\n\\t\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\t\\tup, prometheus.GaugeValue, boolToFloat[stats.Up], server)\\n\\n\\t\\t\\tif stats.Up {\\n\\t\\t\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\t\\t\\tusers, prometheus.GaugeValue, float64(stats.Users), server)\\n\\n\\t\\t\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\t\\t\\tlatency, prometheus.GaugeValue, float64(stats.ResponseTime.Sub(stats.RequestTime))/float64(time.Second), server)\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\te.mutex.Lock() // To protect metrics from concurrent collects.\\n\\tdefer e.mutex.Unlock()\\n if err := e.scrape(ch); err != nil {\\n\\t\\tlog.Infof(\\\"Error scraping tinystats: %s\\\", err)\\n\\t}\\n e.ipv4QueryA.Collect(ch)\\n e.ipv4QueryNS.Collect(ch)\\n e.ipv4QueryCNAME.Collect(ch)\\n e.ipv4QuerySOA.Collect(ch)\\n e.ipv4QueryPTR.Collect(ch)\\n e.ipv4QueryHINFO.Collect(ch)\\n e.ipv4QueryMX.Collect(ch)\\n e.ipv4QueryTXT.Collect(ch)\\n e.ipv4QueryRP.Collect(ch)\\n e.ipv4QuerySIG.Collect(ch)\\n e.ipv4QueryKEY.Collect(ch)\\n e.ipv4QueryAAAA.Collect(ch)\\n e.ipv4QueryAXFR.Collect(ch)\\n e.ipv4QueryANY.Collect(ch)\\n e.ipv4QueryTOTAL.Collect(ch)\\n e.ipv4QueryOTHER.Collect(ch)\\n e.ipv4QueryNOTAUTH.Collect(ch)\\n e.ipv4QueryNOTIMPL.Collect(ch)\\n e.ipv4QueryBADCLASS.Collect(ch)\\n e.ipv4QueryNOQUERY.Collect(ch)\\n\\n e.ipv6QueryA.Collect(ch)\\n e.ipv6QueryNS.Collect(ch)\\n e.ipv6QueryCNAME.Collect(ch)\\n e.ipv6QuerySOA.Collect(ch)\\n e.ipv6QueryPTR.Collect(ch)\\n e.ipv6QueryHINFO.Collect(ch)\\n e.ipv6QueryMX.Collect(ch)\\n e.ipv6QueryTXT.Collect(ch)\\n e.ipv6QueryRP.Collect(ch)\\n e.ipv6QuerySIG.Collect(ch)\\n e.ipv6QueryKEY.Collect(ch)\\n e.ipv6QueryAAAA.Collect(ch)\\n e.ipv6QueryAXFR.Collect(ch)\\n e.ipv6QueryANY.Collect(ch)\\n e.ipv6QueryTOTAL.Collect(ch)\\n e.ipv6QueryOTHER.Collect(ch)\\n e.ipv6QueryNOTAUTH.Collect(ch)\\n e.ipv6QueryNOTIMPL.Collect(ch)\\n e.ipv6QueryBADCLASS.Collect(ch)\\n e.ipv6QueryNOQUERY.Collect(ch)\\n\\n\\treturn\\n}\",\n \"func (r *RGWCollector) Collect(ch chan<- prometheus.Metric, version *Version) {\\n\\tif !r.background {\\n\\t\\tr.logger.WithField(\\\"background\\\", r.background).Debug(\\\"collecting RGW GC stats\\\")\\n\\t\\terr := r.collect()\\n\\t\\tif err != nil {\\n\\t\\t\\tr.logger.WithField(\\\"background\\\", r.background).WithError(err).Error(\\\"error collecting RGW GC stats\\\")\\n\\t\\t}\\n\\t}\\n\\n\\tfor _, metric := range r.collectorList() {\\n\\t\\tmetric.Collect(ch)\\n\\t}\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\te.mutex.Lock() // To protect metrics from concurrent collects.\\n\\tdefer e.mutex.Unlock()\\n\\n\\tup, result := e.scrape(ch)\\n\\n\\tch <- e.totalScrapes\\n\\tch <- e.jsonParseFailures\\n\\tch <- prometheus.MustNewConstMetric(iqAirUp, prometheus.GaugeValue, up)\\n\\tch <- prometheus.MustNewConstMetric(iqAirCO2, prometheus.GaugeValue, float64(result.CO2))\\n\\tch <- prometheus.MustNewConstMetric(iqAirP25, prometheus.GaugeValue, float64(result.P25))\\n\\tch <- prometheus.MustNewConstMetric(iqAirP10, prometheus.GaugeValue, float64(result.P10))\\n\\tch <- prometheus.MustNewConstMetric(iqAirTemp, prometheus.GaugeValue, float64(result.Temperature))\\n\\tch <- prometheus.MustNewConstMetric(iqAirHumidity, prometheus.GaugeValue, float64(result.Humidity))\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\tlog.Infof(\\\"Syno exporter starting\\\")\\n\\tif e.Client == nil {\\n\\t\\tlog.Errorf(\\\"Syno client not configured.\\\")\\n\\t\\treturn\\n\\t}\\n\\terr := e.Client.Connect()\\n\\tif err != nil {\\n\\t\\tlog.Errorln(\\\"Can't connect to Synology for SNMP: %s\\\", err)\\n\\t\\treturn\\n\\t}\\n\\tdefer e.Client.SNMP.Conn.Close()\\n\\n\\te.collectSystemMetrics(ch)\\n\\te.collectCPUMetrics(ch)\\n\\te.collectLoadMetrics(ch)\\n\\te.collectMemoryMetrics(ch)\\n\\te.collectNetworkMetrics(ch)\\n\\te.collectDiskMetrics(ch)\\n\\n\\tlog.Infof(\\\"Syno exporter finished\\\")\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\n\\te.mutex.Lock() // To protect metrics from concurrent collects.\\n\\tdefer e.mutex.Unlock()\\n\\n\\te.zpool.getStatus()\\n\\te.poolUsage.Set(float64(e.zpool.capacity))\\n\\te.providersOnline.Set(float64(e.zpool.online))\\n\\te.providersFaulted.Set(float64(e.zpool.faulted))\\n\\n\\tch <- e.poolUsage\\n\\tch <- e.providersOnline\\n\\tch <- e.providersFaulted\\n}\",\n \"func Collect(metrics []Metric, c CloudWatchService, namespace string) {\\n\\tid, err := GetInstanceID()\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n\\tfor _, metric := range metrics {\\n\\t\\tmetric.Collect(id, c, namespace)\\n\\t}\\n}\",\n \"func (p *Collector) Collect(c chan<- prometheus.Metric) {\\n\\tp.Sink.mu.Lock()\\n\\tdefer p.Sink.mu.Unlock()\\n\\n\\texpire := p.Sink.expiration != 0\\n\\tnow := time.Now()\\n\\tfor k, v := range p.Sink.gauges {\\n\\t\\tlast := p.Sink.updates[k]\\n\\t\\tif expire && last.Add(p.Sink.expiration).Before(now) {\\n\\t\\t\\tdelete(p.Sink.updates, k)\\n\\t\\t\\tdelete(p.Sink.gauges, k)\\n\\t\\t} else {\\n\\t\\t\\tv.Collect(c)\\n\\t\\t}\\n\\t}\\n\\tfor k, v := range p.Sink.summaries {\\n\\t\\tlast := p.Sink.updates[k]\\n\\t\\tif expire && last.Add(p.Sink.expiration).Before(now) {\\n\\t\\t\\tdelete(p.Sink.updates, k)\\n\\t\\t\\tdelete(p.Sink.summaries, k)\\n\\t\\t} else {\\n\\t\\t\\tv.Collect(c)\\n\\t\\t}\\n\\t}\\n\\tfor k, v := range p.Sink.counters {\\n\\t\\tlast := p.Sink.updates[k]\\n\\t\\tif expire && last.Add(p.Sink.expiration).Before(now) {\\n\\t\\t\\tdelete(p.Sink.updates, k)\\n\\t\\t\\tdelete(p.Sink.counters, k)\\n\\t\\t} else {\\n\\t\\t\\tv.Collect(c)\\n\\t\\t}\\n\\t}\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\tresp, err := e.Pihole.GetMetrics()\\n\\tif err != nil {\\n\\t\\tlog.Errorf(\\\"Pihole error: %s\\\", err.Error())\\n\\t\\treturn\\n\\t}\\n\\tlog.Debugf(\\\"PiHole metrics: %#v\\\", resp)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tdomainsBeingBlocked, prometheus.CounterValue, float64(resp.DomainsBeingBlocked))\\n\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tdnsQueries, prometheus.CounterValue, float64(resp.DNSQueriesToday))\\n\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tadsBlocked, prometheus.CounterValue, float64(resp.AdsBlockedToday))\\n\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tadsPercentage, prometheus.CounterValue, float64(resp.AdsPercentageToday))\\n\\n\\tfor k, v := range resp.Querytypes {\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tqueryTypes, prometheus.CounterValue, v, k)\\n\\t}\\n\\tfor k, v := range resp.TopQueries {\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\ttopQueries, prometheus.CounterValue, float64(v), k)\\n\\t}\\n\\tfor k, v := range resp.TopAds {\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\ttopAds, prometheus.CounterValue, float64(v), k)\\n\\n\\t}\\n\\tfor k, v := range resp.TopSources {\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\ttopSources, prometheus.CounterValue, float64(v), k)\\n\\t}\\n}\",\n \"func (collector *MetricsCollector) Collect(ch chan<- prometheus.Metric) {\\n\\tfilterMetricsByKind := func(kind string, orgMetrics []constMetric) (filteredMetrics []constMetric) {\\n\\t\\tfor _, metric := range orgMetrics {\\n\\t\\t\\tif metric.kind == kind {\\n\\t\\t\\t\\tfilteredMetrics = append(filteredMetrics, metric)\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\treturn filteredMetrics\\n\\t}\\n\\tcollector.defMetrics.reset()\\n\\tfor k := range collector.metrics {\\n\\t\\tcounters := filterMetricsByKind(config.KeyMetricTypeCounter, collector.metrics[k])\\n\\t\\tgauges := filterMetricsByKind(config.KeyMetricTypeGauge, collector.metrics[k])\\n\\t\\thistograms := filterMetricsByKind(config.KeyMetricTypeHistogram, collector.metrics[k])\\n\\t\\tcollectCounters(counters, collector.defMetrics, ch)\\n\\t\\tcollectGauges(gauges, collector.defMetrics, ch)\\n\\t\\tcollectHistograms(histograms, collector.defMetrics, ch)\\n\\t\\tcollector.cache.Reset()\\n\\t}\\n\\tcollector.defMetrics.collectDefaultMetrics(ch)\\n}\",\n \"func (collector *Collector) Collect(ch chan<- prometheus.Metric) {\\n\\tch <- prometheus.MustNewConstMetric(collector.incidentsCreatedCount, prometheus.CounterValue, collector.storage.GetIncidentsCreatedCount())\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\tjunosTotalScrapeCount++\\n\\tch <- prometheus.MustNewConstMetric(junosDesc[\\\"ScrapesTotal\\\"], prometheus.CounterValue, junosTotalScrapeCount)\\n\\n\\twg := &sync.WaitGroup{}\\n\\tfor _, collector := range e.Collectors {\\n\\t\\twg.Add(1)\\n\\t\\tgo e.runCollector(ch, collector, wg)\\n\\t}\\n\\twg.Wait()\\n}\",\n \"func (c *auditdCollector) Collect(ch chan<- prometheus.Metric) {\\n\\n\\tfor _, i := range c.metrics {\\n\\t\\tch <- prometheus.MustNewConstMetric(i.desc, i.valType, i.eval(c.stats))\\n\\t}\\n\\n}\",\n \"func (o *OSDCollector) Collect(ch chan<- prometheus.Metric, version *Version) {\\n\\t// Reset daemon specific metrics; daemons can leave the cluster\\n\\to.CrushWeight.Reset()\\n\\to.Depth.Reset()\\n\\to.Reweight.Reset()\\n\\to.Bytes.Reset()\\n\\to.UsedBytes.Reset()\\n\\to.AvailBytes.Reset()\\n\\to.Utilization.Reset()\\n\\to.Variance.Reset()\\n\\to.Pgs.Reset()\\n\\to.CommitLatency.Reset()\\n\\to.ApplyLatency.Reset()\\n\\to.OSDIn.Reset()\\n\\to.OSDUp.Reset()\\n\\to.OSDMetadata.Reset()\\n\\to.buildOSDLabelCache()\\n\\n\\tlocalWg := &sync.WaitGroup{}\\n\\n\\tlocalWg.Add(1)\\n\\tgo func() {\\n\\t\\tdefer localWg.Done()\\n\\t\\tif err := o.collectOSDPerf(); err != nil {\\n\\t\\t\\to.logger.WithError(err).Error(\\\"error collecting OSD perf metrics\\\")\\n\\t\\t}\\n\\t}()\\n\\n\\tlocalWg.Add(1)\\n\\tgo func() {\\n\\t\\tdefer localWg.Done()\\n\\t\\tif err := o.collectOSDMetadata(); err != nil {\\n\\t\\t\\to.logger.WithError(err).Error(\\\"error collecting OSD metadata metrics\\\")\\n\\t\\t}\\n\\t}()\\n\\n\\tlocalWg.Add(1)\\n\\tgo func() {\\n\\t\\tdefer localWg.Done()\\n\\t\\tif err := o.collectOSDDump(); err != nil {\\n\\t\\t\\to.logger.WithError(err).Error(\\\"error collecting OSD dump metrics\\\")\\n\\t\\t}\\n\\t}()\\n\\n\\tlocalWg.Add(1)\\n\\tgo func() {\\n\\t\\tdefer localWg.Done()\\n\\t\\tif err := o.collectOSDDF(); err != nil {\\n\\t\\t\\to.logger.WithError(err).Error(\\\"error collecting OSD df metrics\\\")\\n\\t\\t}\\n\\t}()\\n\\n\\tlocalWg.Add(1)\\n\\tgo func() {\\n\\t\\tdefer localWg.Done()\\n\\t\\tif err := o.collectOSDTreeDown(ch); err != nil {\\n\\t\\t\\to.logger.WithError(err).Error(\\\"error collecting OSD tree down metrics\\\")\\n\\t\\t}\\n\\t}()\\n\\n\\tlocalWg.Add(1)\\n\\tgo func() {\\n\\t\\tdefer localWg.Done()\\n\\t\\tif err := o.collectOSDScrubState(ch); err != nil {\\n\\t\\t\\to.logger.WithError(err).Error(\\\"error collecting OSD scrub metrics\\\")\\n\\t\\t}\\n\\t}()\\n\\n\\tlocalWg.Wait()\\n\\n\\tfor _, metric := range o.collectorList() {\\n\\t\\tmetric.Collect(ch)\\n\\t}\\n}\",\n \"func (c *metricbeatCollector) Collect(ch chan<- prometheus.Metric) {\\n\\n\\tfor _, i := range c.metrics {\\n\\t\\tch <- prometheus.MustNewConstMetric(i.desc, i.valType, i.eval(c.stats))\\n\\t}\\n\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\tif ch == nil {\\n\\t\\tglog.Info(\\\"Prometheus channel is closed. Skipping\\\")\\n\\t\\treturn\\n\\t}\\n\\n\\te.mutex.Lock()\\n\\tdefer func() {\\n\\t\\te.mutex.Unlock()\\n\\t\\te.cleanup.Range(func(key, value interface{}) bool {\\n\\t\\t\\tswitch chiName := key.(type) {\\n\\t\\t\\tcase string:\\n\\t\\t\\t\\te.cleanup.Delete(key)\\n\\t\\t\\t\\te.removeInstallationReference(chiName)\\n\\t\\t\\t}\\n\\t\\t\\treturn true\\n\\t\\t})\\n\\t}()\\n\\n\\tglog.Info(\\\"Starting Collect\\\")\\n\\tvar wg = sync.WaitGroup{}\\n\\t// Getting hostnames of Pods and requesting the metrics data from ClickHouse instances within\\n\\tfor chiName := range e.chInstallations {\\n\\t\\t// Loop over all hostnames of this installation\\n\\t\\tglog.Infof(\\\"Collecting metrics for %s\\\\n\\\", chiName)\\n\\t\\tfor _, hostname := range e.chInstallations[chiName].hostnames {\\n\\t\\t\\twg.Add(1)\\n\\t\\t\\tgo func(name, hostname string, c chan<- prometheus.Metric) {\\n\\t\\t\\t\\tdefer wg.Done()\\n\\n\\t\\t\\t\\tglog.Infof(\\\"Querying metrics for %s\\\\n\\\", hostname)\\n\\t\\t\\t\\tmetricsData := make([][]string, 0)\\n\\t\\t\\t\\tfetcher := e.newFetcher(hostname)\\n\\t\\t\\t\\tif err := fetcher.clickHouseQueryMetrics(&metricsData); err != nil {\\n\\t\\t\\t\\t\\t// In case of an error fetching data from clickhouse store CHI name in e.cleanup\\n\\t\\t\\t\\t\\tglog.Infof(\\\"Error querying metrics for %s: %s\\\\n\\\", hostname, err)\\n\\t\\t\\t\\t\\te.cleanup.Store(name, struct{}{})\\n\\t\\t\\t\\t\\treturn\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tglog.Infof(\\\"Extracted %d metrics for %s\\\\n\\\", len(metricsData), hostname)\\n\\t\\t\\t\\twriteMetricsDataToPrometheus(c, metricsData, name, hostname)\\n\\n\\t\\t\\t\\tglog.Infof(\\\"Querying table sizes for %s\\\\n\\\", hostname)\\n\\t\\t\\t\\ttableSizes := make([][]string, 0)\\n\\t\\t\\t\\tif err := fetcher.clickHouseQueryTableSizes(&tableSizes); err != nil {\\n\\t\\t\\t\\t\\t// In case of an error fetching data from clickhouse store CHI name in e.cleanup\\n\\t\\t\\t\\t\\tglog.Infof(\\\"Error querying table sizes for %s: %s\\\\n\\\", hostname, err)\\n\\t\\t\\t\\t\\te.cleanup.Store(name, struct{}{})\\n\\t\\t\\t\\t\\treturn\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tglog.Infof(\\\"Extracted %d table sizes for %s\\\\n\\\", len(tableSizes), hostname)\\n\\t\\t\\t\\twriteTableSizesDataToPrometheus(c, tableSizes, name, hostname)\\n\\n\\t\\t\\t}(chiName, hostname, ch)\\n\\t\\t}\\n\\t}\\n\\twg.Wait()\\n\\tglog.Info(\\\"Finished Collect\\\")\\n}\",\n \"func (collector *atlassianUPMCollector) Collect(ch chan<- prometheus.Metric) {\\n\\tstartTime := time.Now()\\n\\tlog.Debug(\\\"Collect start\\\")\\n\\n\\tlog.Debug(\\\"create request object\\\")\\n\\treq, err := http.NewRequest(\\\"GET\\\", baseURL, nil)\\n\\tif err != nil {\\n\\t\\tlog.Error(\\\"http.NewRequest returned an error:\\\", err)\\n\\t}\\n\\n\\tlog.Debug(\\\"create Basic auth string from argument passed\\\")\\n\\tbearer = \\\"Basic \\\" + *token\\n\\n\\tlog.Debug(\\\"add authorization header to the request\\\")\\n\\treq.Header.Add(\\\"Authorization\\\", bearer)\\n\\n\\tlog.Debug(\\\"add content type to the request\\\")\\n\\treq.Header.Add(\\\"content-type\\\", \\\"application/json\\\")\\n\\n\\tlog.Debug(\\\"make request... get back a response\\\")\\n\\tresp, err := http.DefaultClient.Do(req)\\n\\tif err != nil {\\n\\t\\tlog.Debug(\\\"set metric atlassian_upm_rest_url_up\\\")\\n\\t\\tch <- prometheus.MustNewConstMetric(collector.atlassianUPMUpMetric, prometheus.GaugeValue, 0, *fqdn)\\n\\t\\tlog.Warn(\\\"http.DefaultClient.Do returned an error:\\\", err, \\\" return from Collect\\\")\\n\\t\\treturn\\n\\t}\\n\\tdefer resp.Body.Close()\\n\\n\\tif resp.StatusCode != 200 {\\n\\t\\tlog.Debug(\\\"response status code: \\\", resp.StatusCode)\\n\\t}\\n\\n\\tlog.Debug(\\\"set metric atlassian_upm_rest_url_up\\\")\\n\\tch <- prometheus.MustNewConstMetric(collector.atlassianUPMUpMetric, prometheus.GaugeValue, 1, *fqdn)\\n\\n\\tvar allPlugins restPlugins\\n\\tif resp.StatusCode == 200 {\\n\\t\\tlog.Debug(\\\"get all plugins\\\")\\n\\t\\tallPlugins = plugins(resp)\\n\\n\\t\\t// return user-installed plugins if argument passed\\n\\t\\tif *userInstalled {\\n\\t\\t\\tlog.Debug(\\\"-user-installed found\\\")\\n\\t\\t\\tallPlugins = userInstalledPlugins(allPlugins)\\n\\t\\t}\\n\\n\\t\\t// plugins have the ability to be installed, but disabled, this will remove them if disabled\\n\\t\\tif *dropDisabled {\\n\\t\\t\\tlog.Debug(\\\"-drop-disabled found\\\")\\n\\t\\t\\tallPlugins = dropDisabledPlugins(allPlugins)\\n\\t\\t}\\n\\n\\t\\t// Jira specific\\n\\t\\t// some plugins maintained by Jira have an additional element, this gives the option to drop those plugins\\n\\t\\tif *dropJiraSoftware {\\n\\t\\t\\tlog.Debug(\\\"-drop-jira-software found\\\")\\n\\t\\t\\tallPlugins = dropJiraSoftwarePlugins(allPlugins)\\n\\t\\t}\\n\\n\\t\\tlog.Debug(\\\"range over values in response, add each as metric with labels\\\")\\n\\t\\tfor _, plugin := range allPlugins.Plugins {\\n\\n\\t\\t\\tlog.Debug(\\\"creating plugin metric for: \\\" + plugin.Name)\\n\\t\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\t\\tcollector.atlassianUPMPlugins,\\n\\t\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\t\\t0,\\n\\t\\t\\t\\tstrconv.FormatBool(plugin.Enabled), // convert bool to string for the 'enabled' value in the labels\\n\\t\\t\\t\\tstring(plugin.Name),\\n\\t\\t\\t\\tstring(plugin.Key),\\n\\t\\t\\t\\tstring(plugin.Version),\\n\\t\\t\\t\\tstrconv.FormatBool(plugin.UserInstalled),\\n\\t\\t\\t\\t*fqdn,\\n\\t\\t\\t)\\n\\t\\t}\\n\\t}\\n\\n\\tif resp.StatusCode == 200 && *checkUpdates {\\n\\t\\tlog.Debug(\\\"get remaining plugins available info\\\")\\n\\t\\tavailablePluginsMap := getAvailablePluginInfo(allPlugins)\\n\\n\\t\\tlog.Debug(\\\"range over values in response, add each as metric with labels\\\")\\n\\t\\tfor _, plugin := range availablePluginsMap {\\n\\t\\t\\tavailableUpdate := false\\n\\n\\t\\t\\tverInstalled, err := version.NewVersion(plugin.InstalledVersion)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tlog.Debug(\\\"error turning plugin installed into version object\\\")\\n\\t\\t\\t}\\n\\n\\t\\t\\tverAvailable, err := version.NewVersion(plugin.Version)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tlog.Debug(\\\"error turning available plugin into version object\\\")\\n\\t\\t\\t}\\n\\n\\t\\t\\tif verInstalled.LessThan(verAvailable) {\\n\\t\\t\\t\\tlog.Debug(\\\"plugin: \\\", plugin.Name, \\\", is currently running: \\\", plugin.InstalledVersion, \\\", and can be upgraded to: \\\", plugin.Version)\\n\\t\\t\\t\\tavailableUpdate = true\\n\\t\\t\\t}\\n\\n\\t\\t\\tlog.Debug(\\\"creating plugin version metric for: \\\", plugin.Name, \\\", with Key: \\\", plugin.Key)\\n\\t\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\t\\tcollector.atlassianUPMVersionsMetric,\\n\\t\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\t\\tboolToFloat(availableUpdate),\\n\\t\\t\\t\\tstring(plugin.Name),\\n\\t\\t\\t\\tstring(plugin.Key),\\n\\t\\t\\t\\tstring(plugin.Version),\\n\\t\\t\\t\\tstring(plugin.InstalledVersion),\\n\\t\\t\\t\\tstrconv.FormatBool(plugin.Enabled), // convert bool to string for the 'enabled' value in the labels\\n\\t\\t\\t\\tstrconv.FormatBool(plugin.UserInstalled),\\n\\t\\t\\t\\t*fqdn,\\n\\t\\t\\t)\\n\\t\\t}\\n\\t}\\n\\n\\tfinishTime := time.Now()\\n\\telapsedTime := finishTime.Sub(startTime)\\n\\tlog.Debug(\\\"set the duration metric\\\")\\n\\tch <- prometheus.MustNewConstMetric(collector.atlassianUPMTimeMetric, prometheus.GaugeValue, elapsedTime.Seconds(), *fqdn)\\n\\n\\tlog.Debug(\\\"Collect finished\\\")\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\tok := e.collectPeersMetric(ch)\\n\\tok = e.collectLeaderMetric(ch) && ok\\n\\tok = e.collectNodesMetric(ch) && ok\\n\\tok = e.collectMembersMetric(ch) && ok\\n\\tok = e.collectMembersWanMetric(ch) && ok\\n\\tok = e.collectServicesMetric(ch) && ok\\n\\tok = e.collectHealthStateMetric(ch) && ok\\n\\tok = e.collectKeyValues(ch) && ok\\n\\n\\tif ok {\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tup, prometheus.GaugeValue, 1.0,\\n\\t\\t)\\n\\t} else {\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tup, prometheus.GaugeValue, 0.0,\\n\\t\\t)\\n\\t}\\n}\",\n \"func (c *prometheusCollector) Collect(ch chan<- prometheus.Metric) {\\n\\tvar stats = c.db.Stats()\\n\\n\\tch <- prometheus.MustNewConstMetric(c.maxOpenConnections, prometheus.GaugeValue, float64(stats.MaxOpenConnections))\\n\\tch <- prometheus.MustNewConstMetric(c.openConnections, prometheus.GaugeValue, float64(stats.OpenConnections))\\n\\tch <- prometheus.MustNewConstMetric(c.inUse, prometheus.GaugeValue, float64(stats.InUse))\\n\\tch <- prometheus.MustNewConstMetric(c.idle, prometheus.GaugeValue, float64(stats.Idle))\\n\\tch <- prometheus.MustNewConstMetric(c.waitCount, prometheus.CounterValue, float64(stats.WaitCount))\\n\\tch <- prometheus.MustNewConstMetric(c.waitDuration, prometheus.CounterValue, float64(stats.WaitDuration))\\n\\tch <- prometheus.MustNewConstMetric(c.maxIdleClosed, prometheus.CounterValue, float64(stats.MaxIdleClosed))\\n\\tch <- prometheus.MustNewConstMetric(c.maxIdleTimeClosed, prometheus.CounterValue, float64(stats.MaxIdleTimeClosed))\\n\\tch <- prometheus.MustNewConstMetric(c.maxLifetimeClosed, prometheus.CounterValue, float64(stats.MaxLifetimeClosed))\\n}\",\n \"func (c *filebeatCollector) Collect(ch chan<- prometheus.Metric) {\\n\\n\\tfor _, i := range c.metrics {\\n\\t\\tch <- prometheus.MustNewConstMetric(i.desc, i.valType, i.eval(c.stats))\\n\\t}\\n\\n}\",\n \"func CollectAllMetrics(client *statsd.Client, log *li.StandardLogger) {\\n\\n\\tvar metrics []metric\\n\\tmetrics = append(metrics, metric{name: \\\"gpu.temperature\\\", cmd: \\\"vcgencmd measure_temp | egrep -o '[0-9]*\\\\\\\\.[0-9]*'\\\"})\\n\\tmetrics = append(metrics, metric{name: \\\"cpu.temperature\\\", cmd: \\\"cat /sys/class/thermal/thermal_zone0/temp | awk 'END {print $1/1000}'\\\"})\\n\\tmetrics = append(metrics, metric{name: \\\"threads\\\", cmd: \\\"ps -eo nlwp | tail -n +2 | awk '{ num_threads += $1 } END { print num_threads }'\\\"})\\n\\tmetrics = append(metrics, metric{name: \\\"processes\\\", cmd: \\\"ps axu | wc -l\\\"})\\n\\n\\tfor range time.Tick(15 * time.Second) {\\n\\t\\tlog.Info(\\\"Starting metric collection\\\")\\n\\t\\tfor _, m := range metrics {\\n\\t\\t\\terr := collectMetric(m, client, log)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tlog.Error(err)\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\te.mutex.Lock() // To protect metrics from concurrent collects.\\n\\tdefer e.mutex.Unlock()\\n\\tif err := e.collect(ch); err != nil {\\n\\t\\tlog.Errorf(\\\"Error scraping: %s\\\", err)\\n\\t}\\n\\treturn\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\te.mutex.Lock()\\n\\tdefer e.mutex.Unlock()\\n\\n\\te.scrape()\\n\\n\\te.up.Collect(ch)\\n\\te.totalScrapes.Collect(ch)\\n\\te.exchangeStatus.Collect(ch)\\n\\te.ltp.Collect(ch)\\n\\te.bestBid.Collect(ch)\\n\\te.bestAsk.Collect(ch)\\n\\te.bestBidSize.Collect(ch)\\n\\te.bestAskSize.Collect(ch)\\n\\te.totalBidDepth.Collect(ch)\\n\\te.totalAskDepth.Collect(ch)\\n\\te.volume.Collect(ch)\\n\\te.volumeByProduct.Collect(ch)\\n}\",\n \"func (c *VMCollector) Collect(ch chan<- prometheus.Metric) {\\n\\tfor _, m := range c.getMetrics() {\\n\\t\\tch <- m\\n\\t}\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\te.mutex.Lock() // To protect metrics from concurrent collects.\\n\\tdefer e.mutex.Unlock()\\n\\tif err := e.collect(ch); err != nil {\\n\\t\\tlog.Errorf(\\\"Error scraping ingestor: %s\\\", err)\\n\\t}\\n\\treturn\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\te.mutex.Lock() // To protect metrics from concurrent collects.\\n\\tdefer e.mutex.Unlock()\\n\\tif err := e.collect(ch); err != nil {\\n\\t\\tglog.Error(fmt.Sprintf(\\\"Error collecting stats: %s\\\", err))\\n\\t}\\n\\treturn\\n}\",\n \"func (*noOpConntracker) Collect(ch chan<- prometheus.Metric) {}\",\n \"func (o *OSDCollector) Collect(ch chan<- prometheus.Metric) {\\n\\tif err := o.collectOSDPerf(); err != nil {\\n\\t\\tlog.Println(\\\"failed collecting osd perf stats:\\\", err)\\n\\t}\\n\\n\\tif err := o.collectOSDDump(); err != nil {\\n\\t\\tlog.Println(\\\"failed collecting osd dump:\\\", err)\\n\\t}\\n\\n\\tif err := o.collectOSDDF(); err != nil {\\n\\t\\tlog.Println(\\\"failed collecting osd metrics:\\\", err)\\n\\t}\\n\\n\\tif err := o.collectOSDTreeDown(ch); err != nil {\\n\\t\\tlog.Println(\\\"failed collecting osd metrics:\\\", err)\\n\\t}\\n\\n\\tfor _, metric := range o.collectorList() {\\n\\t\\tmetric.Collect(ch)\\n\\t}\\n\\n\\tif err := o.collectOSDScrubState(ch); err != nil {\\n\\t\\tlog.Println(\\\"failed collecting osd scrub state:\\\", err)\\n\\t}\\n}\",\n \"func (c *beatCollector) Collect(ch chan<- prometheus.Metric) {\\n\\n\\tfor _, i := range c.metrics {\\n\\t\\tch <- prometheus.MustNewConstMetric(i.desc, i.valType, i.eval(c.stats))\\n\\t}\\n\\n}\",\n \"func (m httpReferenceDiscoveryMetrics) Collect(metrics chan<- prometheus.Metric) {\\n\\tm.firstPacket.Collect(metrics)\\n\\tm.totalTime.Collect(metrics)\\n\\tm.advertisedRefs.Collect(metrics)\\n}\",\n \"func CollectProcessMetrics(refresh time.Duration) {\\n\\t// Short circuit if the metics system is disabled\\n\\tif !Enabled {\\n\\t\\treturn\\n\\t}\\n\\t// Create the various data collectors\\n\\tmemstates := make([]*runtime.MemStats, 2)\\n\\tdiskstates := make([]*DiskStats, 2)\\n\\tfor i := 0; i < len(memstates); i++ {\\n\\t\\tmemstates[i] = new(runtime.MemStats)\\n\\t\\tdiskstates[i] = new(DiskStats)\\n\\t}\\n\\t// Define the various metics to collect\\n\\tmemAllocs := metics.GetOrRegisterMeter(\\\"system/memory/allocs\\\", metics.DefaultRegistry)\\n\\tmemFrees := metics.GetOrRegisterMeter(\\\"system/memory/frees\\\", metics.DefaultRegistry)\\n\\tmemInuse := metics.GetOrRegisterMeter(\\\"system/memory/inuse\\\", metics.DefaultRegistry)\\n\\tmemPauses := metics.GetOrRegisterMeter(\\\"system/memory/pauses\\\", metics.DefaultRegistry)\\n\\n\\tvar diskReads, diskReadBytes, diskWrites, diskWriteBytes metics.Meter\\n\\tif err := ReadDiskStats(diskstates[0]); err == nil {\\n\\t\\tdiskReads = metics.GetOrRegisterMeter(\\\"system/disk/readcount\\\", metics.DefaultRegistry)\\n\\t\\tdiskReadBytes = metics.GetOrRegisterMeter(\\\"system/disk/readdata\\\", metics.DefaultRegistry)\\n\\t\\tdiskWrites = metics.GetOrRegisterMeter(\\\"system/disk/writecount\\\", metics.DefaultRegistry)\\n\\t\\tdiskWriteBytes = metics.GetOrRegisterMeter(\\\"system/disk/writedata\\\", metics.DefaultRegistry)\\n\\t} else {\\n\\t\\tbgmlogs.Debug(\\\"Failed to read disk metics\\\", \\\"err\\\", err)\\n\\t}\\n\\t// Iterate loading the different states and updating the meters\\n\\tfor i := 1; ; i++ {\\n\\t\\truntime.ReadMemStats(memstates[i%2])\\n\\t\\tmemAllocs.Mark(int64(memstates[i%2].Mallocs - memstates[(i-1)%2].Mallocs))\\n\\t\\tmemFrees.Mark(int64(memstates[i%2].Frees - memstates[(i-1)%2].Frees))\\n\\t\\tmemInuse.Mark(int64(memstates[i%2].Alloc - memstates[(i-1)%2].Alloc))\\n\\t\\tmemPauses.Mark(int64(memstates[i%2].PauseTotalNs - memstates[(i-1)%2].PauseTotalNs))\\n\\n\\t\\tif ReadDiskStats(diskstates[i%2]) == nil {\\n\\t\\t\\tdiskReads.Mark(diskstates[i%2].ReadCount - diskstates[(i-1)%2].ReadCount)\\n\\t\\t\\tdiskReadBytes.Mark(diskstates[i%2].ReadBytes - diskstates[(i-1)%2].ReadBytes)\\n\\t\\t\\tdiskWrites.Mark(diskstates[i%2].WriteCount - diskstates[(i-1)%2].WriteCount)\\n\\t\\t\\tdiskWriteBytes.Mark(diskstates[i%2].WriteBytes - diskstates[(i-1)%2].WriteBytes)\\n\\t\\t}\\n\\t\\ttime.Sleep(refresh)\\n\\t}\\n}\",\n \"func (t *TimestampCollector) Collect(ch chan<- prometheus.Metric) {\\n\\t// New map to dedup filenames.\\n\\tuniqueFiles := make(map[string]float64)\\n\\tt.lock.RLock()\\n\\tfor fileSD := range t.discoverers {\\n\\t\\tfileSD.lock.RLock()\\n\\t\\tfor filename, timestamp := range fileSD.timestamps {\\n\\t\\t\\tuniqueFiles[filename] = timestamp\\n\\t\\t}\\n\\t\\tfileSD.lock.RUnlock()\\n\\t}\\n\\tt.lock.RUnlock()\\n\\tfor filename, timestamp := range uniqueFiles {\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tt.Description,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\ttimestamp,\\n\\t\\t\\tfilename,\\n\\t\\t)\\n\\t}\\n}\",\n \"func (m *Client) Collect(ch chan<- prometheus.Metric) {\\n\\tm.storeMu.Lock()\\n\\tdefer m.storeMu.Unlock()\\n\\n\\tch <- prometheus.MustNewConstMetric(m.storeValuesDesc, prometheus.GaugeValue, float64(len(m.store)))\\n\\n\\tfor k, v := range m.store {\\n\\t\\tch <- prometheus.MustNewConstMetric(m.storeSizesDesc, prometheus.GaugeValue, float64(len(v.value)), k)\\n\\t}\\n}\",\n \"func (c *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\tc.mu.Lock()\\n\\tdefer c.mu.Unlock()\\n\\n\\tfor _, cc := range c.collectors {\\n\\t\\tcc.Collect(ch)\\n\\t}\\n}\",\n \"func (c *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\tc.mu.Lock()\\n\\tdefer c.mu.Unlock()\\n\\n\\tfor _, cc := range c.collectors {\\n\\t\\tcc.Collect(ch)\\n\\t}\\n}\",\n \"func (c *collector) Collect(ch chan<- prometheus.Metric) {\\n\\tc.m.Lock()\\n\\tfor _, m := range c.metrics {\\n\\t\\tch <- m.metric\\n\\t}\\n\\tc.m.Unlock()\\n}\",\n \"func (a *AttunityCollector) Collect(ch chan<- prometheus.Metric) {\\n\\n\\t// Collect information on what servers are active\\n\\tservers, err := a.servers()\\n\\tif err != nil {\\n\\n\\t\\t// If the error is because the session_id expired, attempt to get a new one and collect info again\\n\\t\\t// else, just fail with an invalid metric containing the error\\n\\t\\tif strings.Contains(err.Error(), \\\"INVALID_SESSION_ID\\\") {\\n\\t\\t\\ta.SessionID = getSessionID(a.httpClient, a.APIURL, a.auth)\\n\\n\\t\\t\\tservers, err = a.servers()\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tlogrus.Error(err)\\n\\t\\t\\t\\tch <- prometheus.NewInvalidMetric(prometheus.NewDesc(\\\"attunity_error\\\", \\\"Error scraping target\\\", nil, nil), err)\\n\\t\\t\\t\\treturn\\n\\t\\t\\t}\\n\\n\\t\\t} else {\\n\\t\\t\\tlogrus.Error(err)\\n\\t\\t\\tch <- prometheus.NewInvalidMetric(prometheus.NewDesc(\\\"attunity_error\\\", \\\"Error scraping target\\\", nil, nil), err)\\n\\t\\t\\treturn\\n\\t\\t}\\n\\n\\t} // end error handling for a.servers()\\n\\n\\tfor _, s := range servers {\\n\\t\\tch <- prometheus.MustNewConstMetric(serverDesc, prometheus.GaugeValue, 1.0, s.Name, s.State, s.Platform, s.Host)\\n\\t}\\n\\n\\t// For each server, concurrently collect detailed information on\\n\\t// the tasks that are running on them.\\n\\twg := sync.WaitGroup{}\\n\\twg.Add(len(servers))\\n\\tfor _, s := range servers {\\n\\t\\t// If the Server is not monitored, then it will not have any tasks so we can skip this bit.\\n\\t\\tif s.State != \\\"MONITORED\\\" {\\n\\t\\t\\twg.Done()\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\t\\tgo func(s server) {\\n\\t\\t\\ttaskStates, err := a.taskStates(s.Name)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tlogrus.Error(err)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tfor _, t := range taskStates {\\n\\t\\t\\t\\t\\t// inspired by: https://github.com/prometheus/node_exporter/blob/v0.18.1/collector/systemd_linux.go#L222\\n\\t\\t\\t\\t\\tfor _, tsn := range taskStateNames {\\n\\t\\t\\t\\t\\t\\tvalue := 0.0\\n\\t\\t\\t\\t\\t\\tif t.State == tsn {\\n\\t\\t\\t\\t\\t\\t\\tvalue = 1.0\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\tch <- prometheus.MustNewConstMetric(taskStateDesc, prometheus.GaugeValue, value, s.Name, t.Name, tsn)\\n\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t\\t// Get details on each of the tasks and send them to the channel, too\\n\\t\\t\\t\\t\\tt.details(s.Name, a, ch)\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\twg.Done()\\n\\t\\t}(s)\\n\\t}\\n\\n\\t// For each server, collect high level details such as\\n\\t// how many tasks are in each state on them and\\n\\t// how many days until license expiration\\n\\twg.Add(len(servers))\\n\\tfor _, s := range servers {\\n\\t\\tgo func(s server) {\\n\\t\\t\\tserverDeets, err := a.serverDetails(s.Name)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tlogrus.Error(err)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\t// Create metrics for task totals by state\\n\\t\\t\\t\\t// These counts will not be affected by included/excluded task in the config file\\n\\t\\t\\t\\tch <- prometheus.MustNewConstMetric(serverTasksDesc, prometheus.GaugeValue, float64(serverDeets.TaskSummary.Running), s.Name, \\\"RUNNING\\\")\\n\\t\\t\\t\\tch <- prometheus.MustNewConstMetric(serverTasksDesc, prometheus.GaugeValue, float64(serverDeets.TaskSummary.Stopped), s.Name, \\\"STOPPED\\\")\\n\\t\\t\\t\\tch <- prometheus.MustNewConstMetric(serverTasksDesc, prometheus.GaugeValue, float64(serverDeets.TaskSummary.Error), s.Name, \\\"ERROR\\\")\\n\\t\\t\\t\\tch <- prometheus.MustNewConstMetric(serverTasksDesc, prometheus.GaugeValue, float64(serverDeets.TaskSummary.Recovering), s.Name, \\\"RECOVERING\\\")\\n\\n\\t\\t\\t\\t// Create metric for license expiration\\n\\t\\t\\t\\tch <- prometheus.MustNewConstMetric(serverLicenseExpirationDesc, prometheus.GaugeValue, float64(serverDeets.License.DaysToExpiration), s.Name)\\n\\t\\t\\t}\\n\\t\\t\\twg.Done()\\n\\t\\t}(s)\\n\\t}\\n\\twg.Wait()\\n}\",\n \"func (collector *Metrics) Collect(ch chan<- prometheus.Metric) {\\n\\n\\tcollectedIssues, err := fetchJiraIssues()\\n\\tif err != nil {\\n\\t\\tlog.Error(err)\\n\\t\\treturn\\n\\t}\\n\\n\\tfor _, issue := range collectedIssues.Issues {\\n\\t\\tcreatedTimestamp := convertToUnixTime(issue.Fields.Created)\\n\\t\\tch <- prometheus.MustNewConstMetric(collector.issue, prometheus.CounterValue, createdTimestamp, issue.Fields.Status.Name, issue.Fields.Project.Name, issue.Key, issue.Fields.Assignee.Name, issue.Fields.Location.Name, issue.Fields.Priority.Name, issue.Fields.Level.Name, issue.Fields.RequestType.Name, issue.Fields.Feedback, issue.Fields.Urgency.Name, issue.Fields.IssueType.Name, issue.Fields.Reporter.Name, issue.Fields.Satisfaction)\\n\\t}\\n}\",\n \"func (c collector) Collect(ch chan<- prometheus.Metric) {\\n\\tvar wg sync.WaitGroup\\n\\n\\t// We don't bail out on errors because those can happen if there is a race condition between\\n\\t// the destruction of a container and us getting to read the cgroup data. We just don't report\\n\\t// the values we don't get.\\n\\n\\tcollectors := []func(string, *regexp.Regexp){\\n\\t\\tfunc(path string, re *regexp.Regexp) {\\n\\t\\t\\tdefer wg.Done()\\n\\t\\t\\tnuma, err := cgroups.GetNumaStats(cgroupPath(\\\"memory\\\", path))\\n\\t\\t\\tif err == nil {\\n\\t\\t\\t\\tupdateNumaStatMetric(ch, re.FindStringSubmatch(filepath.Base(path))[0], numa)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tlog.Error(\\\"failed to collect NUMA stats for %s: %v\\\", path, err)\\n\\t\\t\\t}\\n\\t\\t},\\n\\t\\tfunc(path string, re *regexp.Regexp) {\\n\\t\\t\\tdefer wg.Done()\\n\\t\\t\\tmemory, err := cgroups.GetMemoryUsage(cgroupPath(\\\"memory\\\", path))\\n\\t\\t\\tif err == nil {\\n\\t\\t\\t\\tupdateMemoryUsageMetric(ch, re.FindStringSubmatch(filepath.Base(path))[0], memory)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tlog.Error(\\\"failed to collect memory usage stats for %s: %v\\\", path, err)\\n\\t\\t\\t}\\n\\t\\t},\\n\\t\\tfunc(path string, re *regexp.Regexp) {\\n\\t\\t\\tdefer wg.Done()\\n\\t\\t\\tmigrate, err := cgroups.GetCPUSetMemoryMigrate(cgroupPath(\\\"cpuset\\\", path))\\n\\t\\t\\tif err == nil {\\n\\t\\t\\t\\tupdateMemoryMigrateMetric(ch, re.FindStringSubmatch(filepath.Base(path))[0], migrate)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tlog.Error(\\\"failed to collect memory migration stats for %s: %v\\\", path, err)\\n\\t\\t\\t}\\n\\t\\t},\\n\\t\\tfunc(path string, re *regexp.Regexp) {\\n\\t\\t\\tdefer wg.Done()\\n\\t\\t\\tcpuAcctUsage, err := cgroups.GetCPUAcctStats(cgroupPath(\\\"cpuacct\\\", path))\\n\\t\\t\\tif err == nil {\\n\\t\\t\\t\\tupdateCPUAcctUsageMetric(ch, re.FindStringSubmatch(filepath.Base(path))[0], cpuAcctUsage)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tlog.Error(\\\"failed to collect CPU accounting stats for %s: %v\\\", path, err)\\n\\t\\t\\t}\\n\\t\\t},\\n\\t\\tfunc(path string, re *regexp.Regexp) {\\n\\t\\t\\tdefer wg.Done()\\n\\t\\t\\thugeTlbUsage, err := cgroups.GetHugetlbUsage(cgroupPath(\\\"hugetlb\\\", path))\\n\\t\\t\\tif err == nil {\\n\\t\\t\\t\\tupdateHugeTlbUsageMetric(ch, re.FindStringSubmatch(filepath.Base(path))[0], hugeTlbUsage)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tlog.Error(\\\"failed to collect hugetlb stats for %s: %v\\\", path, err)\\n\\t\\t\\t}\\n\\t\\t},\\n\\t\\tfunc(path string, re *regexp.Regexp) {\\n\\t\\t\\tdefer wg.Done()\\n\\t\\t\\tblkioDeviceUsage, err := cgroups.GetBlkioThrottleBytes(cgroupPath(\\\"blkio\\\", path))\\n\\t\\t\\tif err == nil {\\n\\t\\t\\t\\tupdateBlkioDeviceUsageMetric(ch, re.FindStringSubmatch(filepath.Base(path))[0], blkioDeviceUsage)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tlog.Error(\\\"failed to collect blkio stats for %s: %v\\\", path, err)\\n\\t\\t\\t}\\n\\t\\t},\\n\\t}\\n\\n\\tcontainerIDRegexp := regexp.MustCompile(`[a-z0-9]{64}`)\\n\\n\\tfor _, path := range walkCgroups() {\\n\\t\\twg.Add(len(collectors))\\n\\t\\tfor _, fn := range collectors {\\n\\t\\t\\tgo fn(path, containerIDRegexp)\\n\\t\\t}\\n\\t}\\n\\n\\t// We need to wait so that the response channel doesn't get closed.\\n\\twg.Wait()\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\te.mu.Lock()\\n\\tdefer e.mu.Unlock()\\n\\n\\tfor _, cc := range e.collectors {\\n\\t\\tcc.Collect(ch)\\n\\t}\\n}\",\n \"func (c *CephExporter) Collect(ch chan<- prometheus.Metric) {\\n\\tc.mu.Lock()\\n\\tdefer c.mu.Unlock()\\n\\n\\tfor _, cc := range c.collectors {\\n\\t\\tcc.Collect(ch)\\n\\t}\\n}\",\n \"func (n LXCCollector) Collect(ch chan<- prometheus.Metric) {\\n\\twg := sync.WaitGroup{}\\n\\twg.Add(len(n.collectors))\\n\\tfor name, c := range n.collectors {\\n\\t\\tgo func(name string, c collector.Collector) {\\n\\t\\t\\texecute(name, c, ch)\\n\\t\\t\\twg.Done()\\n\\t\\t}(name, c)\\n\\t}\\n\\twg.Wait()\\n\\tscrapeDurations.Collect(ch)\\n}\",\n \"func (c *Collector) Collect(ch chan<- prometheus.Metric) {\\n\\tsess, err := sessions.CreateAWSSession()\\n\\tif err != nil {\\n\\t\\tlog.Error(err)\\n\\t\\treturn\\n\\t}\\n\\n\\t// Init WaitGroup. Without a WaitGroup the channel we write\\n\\t// results to will close before the goroutines finish\\n\\tvar wg sync.WaitGroup\\n\\twg.Add(len(c.Scrapers))\\n\\n\\t// Iterate through all scrapers and invoke the scrape\\n\\tfor _, scraper := range c.Scrapers {\\n\\t\\t// Wrape the scrape invocation in a goroutine, but we need to pass\\n\\t\\t// the scraper into the function explicitly to re-scope the variable\\n\\t\\t// the goroutine accesses. If we don't do this, we can sometimes hit\\n\\t\\t// a case where the scraper reports results twice and the collector panics\\n\\t\\tgo func(scraper *Scraper) {\\n\\t\\t\\t// Done call deferred until end of the scrape\\n\\t\\t\\tdefer wg.Done()\\n\\n\\t\\t\\tlog.Debugf(\\\"Running scrape: %s\\\", scraper.ID)\\n\\t\\t\\tscrapeResults := scraper.Scrape(sess)\\n\\n\\t\\t\\t// Iterate through scrape results and send the metric\\n\\t\\t\\tfor key, results := range scrapeResults {\\n\\t\\t\\t\\tfor _, result := range results {\\n\\t\\t\\t\\t\\tch <- prometheus.MustNewConstMetric(scraper.Metrics[key].metric, result.Type, result.Value, result.Labels...)\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tlog.Debugf(\\\"Scrape completed: %s\\\", scraper.ID)\\n\\t\\t}(scraper)\\n\\t}\\n\\t// Wait\\n\\twg.Wait()\\n}\",\n \"func (e *Exporter) collect(ch chan<- prometheus.Metric) error {\\n\\tvar mempct, memtot, memfree float64\\n\\tif v, e := mem.VirtualMemory(); e == nil {\\n\\t\\tmempct = v.UsedPercent\\n\\t\\tmemtot = float64(v.Total)\\n\\t\\tmemfree = float64(v.Free)\\n\\t}\\n\\tvar swappct, swaptot, swapfree float64\\n\\tif v, e := mem.SwapMemory(); e == nil {\\n\\t\\tswappct = v.UsedPercent\\n\\t\\tswaptot = float64(v.Total)\\n\\t\\tswapfree = float64(v.Free)\\n\\t}\\n\\tvar cpupct float64\\n\\tif c, e := cpu.Percent(time.Millisecond, false); e == nil {\\n\\t\\tcpupct = c[0] // one value since we didn't ask per cpu\\n\\t}\\n\\tvar load1, load5, load15 float64\\n\\tif l, e := load.Avg(); e == nil {\\n\\t\\tload1 = l.Load1\\n\\t\\tload5 = l.Load5\\n\\t\\tload15 = l.Load15\\n\\t}\\n\\n\\tvar cpuTotal, vsize, rss, openFDs, maxFDs, maxVsize float64\\n\\tif proc, err := procfs.NewProc(int(*pid)); err == nil {\\n\\t\\tif stat, err := proc.NewStat(); err == nil {\\n\\t\\t\\tcpuTotal = float64(stat.CPUTime())\\n\\t\\t\\tvsize = float64(stat.VirtualMemory())\\n\\t\\t\\trss = float64(stat.ResidentMemory())\\n\\t\\t}\\n\\t\\tif fds, err := proc.FileDescriptorsLen(); err == nil {\\n\\t\\t\\topenFDs = float64(fds)\\n\\t\\t}\\n\\t\\tif limits, err := proc.NewLimits(); err == nil {\\n\\t\\t\\tmaxFDs = float64(limits.OpenFiles)\\n\\t\\t\\tmaxVsize = float64(limits.AddressSpace)\\n\\t\\t}\\n\\t}\\n\\n\\tvar procCpu, procMem float64\\n\\tvar estCon, lisCon, othCon, totCon, closeCon, timeCon, openFiles float64\\n\\tvar nThreads float64\\n\\tif proc, err := process.NewProcess(int32(*pid)); err == nil {\\n\\t\\tif v, e := proc.CPUPercent(); e == nil {\\n\\t\\t\\tprocCpu = float64(v)\\n\\t\\t}\\n\\t\\tif v, e := proc.MemoryPercent(); e == nil {\\n\\t\\t\\tprocMem = float64(v)\\n\\t\\t}\\n\\n\\t\\tif v, e := proc.NumThreads(); e == nil {\\n\\t\\t\\tnThreads = float64(v)\\n\\t\\t}\\n\\t\\tif connections, e := proc.Connections(); e == nil {\\n\\t\\t\\tfor _, v := range connections {\\n\\t\\t\\t\\tif v.Status == \\\"LISTEN\\\" {\\n\\t\\t\\t\\t\\tlisCon += 1\\n\\t\\t\\t\\t} else if v.Status == \\\"ESTABLISHED\\\" {\\n\\t\\t\\t\\t\\testCon += 1\\n\\t\\t\\t\\t} else if v.Status == \\\"TIME_WAIT\\\" {\\n\\t\\t\\t\\t\\ttimeCon += 1\\n\\t\\t\\t\\t} else if v.Status == \\\"CLOSE_WAIT\\\" {\\n\\t\\t\\t\\t\\tcloseCon += 1\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tothCon += 1\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\ttotCon = lisCon + estCon + timeCon + closeCon + othCon\\n\\t\\t}\\n\\t\\tif oFiles, e := proc.OpenFiles(); e == nil {\\n\\t\\t\\topenFiles = float64(len(oFiles))\\n\\t\\t}\\n\\t}\\n\\n\\t// metrics from process collector\\n\\tch <- prometheus.MustNewConstMetric(e.cpuTotal, prometheus.CounterValue, cpuTotal)\\n\\tch <- prometheus.MustNewConstMetric(e.openFDs, prometheus.CounterValue, openFDs)\\n\\tch <- prometheus.MustNewConstMetric(e.maxFDs, prometheus.CounterValue, maxFDs)\\n\\tch <- prometheus.MustNewConstMetric(e.vsize, prometheus.CounterValue, vsize)\\n\\tch <- prometheus.MustNewConstMetric(e.maxVsize, prometheus.CounterValue, maxVsize)\\n\\tch <- prometheus.MustNewConstMetric(e.rss, prometheus.CounterValue, rss)\\n\\t// node specific metrics\\n\\tch <- prometheus.MustNewConstMetric(e.memPercent, prometheus.CounterValue, mempct)\\n\\tch <- prometheus.MustNewConstMetric(e.memTotal, prometheus.CounterValue, memtot)\\n\\tch <- prometheus.MustNewConstMetric(e.memFree, prometheus.CounterValue, memfree)\\n\\tch <- prometheus.MustNewConstMetric(e.swapPercent, prometheus.CounterValue, swappct)\\n\\tch <- prometheus.MustNewConstMetric(e.swapTotal, prometheus.CounterValue, swaptot)\\n\\tch <- prometheus.MustNewConstMetric(e.swapFree, prometheus.CounterValue, swapfree)\\n\\tch <- prometheus.MustNewConstMetric(e.numCpus, prometheus.CounterValue, float64(runtime.NumCPU()))\\n\\tch <- prometheus.MustNewConstMetric(e.load1, prometheus.CounterValue, load1)\\n\\tch <- prometheus.MustNewConstMetric(e.load5, prometheus.CounterValue, load5)\\n\\tch <- prometheus.MustNewConstMetric(e.load15, prometheus.CounterValue, load15)\\n\\t// process specific metrics\\n\\tch <- prometheus.MustNewConstMetric(e.procCpu, prometheus.CounterValue, procCpu)\\n\\tch <- prometheus.MustNewConstMetric(e.procMem, prometheus.CounterValue, procMem)\\n\\tch <- prometheus.MustNewConstMetric(e.numThreads, prometheus.CounterValue, nThreads)\\n\\tch <- prometheus.MustNewConstMetric(e.cpuPercent, prometheus.CounterValue, cpupct)\\n\\tch <- prometheus.MustNewConstMetric(e.openFiles, prometheus.CounterValue, openFiles)\\n\\tch <- prometheus.MustNewConstMetric(e.totCon, prometheus.CounterValue, totCon)\\n\\tch <- prometheus.MustNewConstMetric(e.lisCon, prometheus.CounterValue, lisCon)\\n\\tch <- prometheus.MustNewConstMetric(e.estCon, prometheus.CounterValue, estCon)\\n\\tch <- prometheus.MustNewConstMetric(e.closeCon, prometheus.CounterValue, closeCon)\\n\\tch <- prometheus.MustNewConstMetric(e.timeCon, prometheus.CounterValue, timeCon)\\n\\treturn nil\\n}\",\n \"func (o *requestMetrics) Collect(ch chan<- prometheus.Metric) {\\n\\tmetricFamilies, err := o.stStore.GetPromDirectMetrics()\\n\\tif err != nil {\\n\\t\\tklog.Errorf(\\\"fetch prometheus metrics failed: %v\\\", err)\\n\\t\\treturn\\n\\t}\\n\\to.handleMetrics(metricFamilies, ch)\\n}\",\n \"func (e *ebpfConntracker) Collect(ch chan<- prometheus.Metric) {\\n\\tebpfTelemetry := &netebpf.ConntrackTelemetry{}\\n\\tif err := e.telemetryMap.Lookup(unsafe.Pointer(&zero), unsafe.Pointer(ebpfTelemetry)); err != nil {\\n\\t\\tlog.Tracef(\\\"error retrieving the telemetry struct: %s\\\", err)\\n\\t} else {\\n\\t\\tdelta := ebpfTelemetry.Registers - conntrackerTelemetry.lastRegisters\\n\\t\\tconntrackerTelemetry.lastRegisters = ebpfTelemetry.Registers\\n\\t\\tch <- prometheus.MustNewConstMetric(conntrackerTelemetry.registersTotal, prometheus.CounterValue, float64(delta))\\n\\t}\\n}\",\n \"func (c *MSCluster_ClusterCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) error {\\n\\tvar dst []MSCluster_Cluster\\n\\tq := queryAll(&dst, c.logger)\\n\\tif err := wmi.QueryNamespace(q, &dst, \\\"root/MSCluster\\\"); err != nil {\\n\\t\\treturn err\\n\\t}\\n\\n\\tfor _, v := range dst {\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.AddEvictDelay,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.AddEvictDelay),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.AdminAccessPoint,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.AdminAccessPoint),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.AutoAssignNodeSite,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.AutoAssignNodeSite),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.AutoBalancerLevel,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.AutoBalancerLevel),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.AutoBalancerMode,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.AutoBalancerMode),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.BackupInProgress,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.BackupInProgress),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.BlockCacheSize,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.BlockCacheSize),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.ClusSvcHangTimeout,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.ClusSvcHangTimeout),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.ClusSvcRegroupOpeningTimeout,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.ClusSvcRegroupOpeningTimeout),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.ClusSvcRegroupPruningTimeout,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.ClusSvcRegroupPruningTimeout),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.ClusSvcRegroupStageTimeout,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.ClusSvcRegroupStageTimeout),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.ClusSvcRegroupTickInMilliseconds,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.ClusSvcRegroupTickInMilliseconds),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.ClusterEnforcedAntiAffinity,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.ClusterEnforcedAntiAffinity),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.ClusterFunctionalLevel,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.ClusterFunctionalLevel),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.ClusterGroupWaitDelay,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.ClusterGroupWaitDelay),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.ClusterLogLevel,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.ClusterLogLevel),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.ClusterLogSize,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.ClusterLogSize),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.ClusterUpgradeVersion,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.ClusterUpgradeVersion),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.CrossSiteDelay,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.CrossSiteDelay),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.CrossSiteThreshold,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.CrossSiteThreshold),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.CrossSubnetDelay,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.CrossSubnetDelay),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.CrossSubnetThreshold,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.CrossSubnetThreshold),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.CsvBalancer,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.CsvBalancer),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.DatabaseReadWriteMode,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.DatabaseReadWriteMode),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.DefaultNetworkRole,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.DefaultNetworkRole),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.DetectedCloudPlatform,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.DetectedCloudPlatform),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.DetectManagedEvents,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.DetectManagedEvents),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.DetectManagedEventsThreshold,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.DetectManagedEventsThreshold),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.DisableGroupPreferredOwnerRandomization,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.DisableGroupPreferredOwnerRandomization),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.DrainOnShutdown,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.DrainOnShutdown),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.DynamicQuorumEnabled,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.DynamicQuorumEnabled),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.EnableSharedVolumes,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.EnableSharedVolumes),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.FixQuorum,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.FixQuorum),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.GracePeriodEnabled,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.GracePeriodEnabled),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.GracePeriodTimeout,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.GracePeriodTimeout),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.GroupDependencyTimeout,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.GroupDependencyTimeout),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.HangRecoveryAction,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.HangRecoveryAction),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.IgnorePersistentStateOnStartup,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.IgnorePersistentStateOnStartup),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.LogResourceControls,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.LogResourceControls),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.LowerQuorumPriorityNodeId,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.LowerQuorumPriorityNodeId),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.MaxNumberOfNodes,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.MaxNumberOfNodes),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.MessageBufferLength,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.MessageBufferLength),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.MinimumNeverPreemptPriority,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.MinimumNeverPreemptPriority),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.MinimumPreemptorPriority,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.MinimumPreemptorPriority),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.NetftIPSecEnabled,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.NetftIPSecEnabled),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.PlacementOptions,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.PlacementOptions),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.PlumbAllCrossSubnetRoutes,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.PlumbAllCrossSubnetRoutes),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.PreventQuorum,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.PreventQuorum),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.QuarantineDuration,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.QuarantineDuration),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.QuarantineThreshold,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.QuarantineThreshold),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.QuorumArbitrationTimeMax,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.QuorumArbitrationTimeMax),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.QuorumArbitrationTimeMin,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.QuorumArbitrationTimeMin),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.QuorumLogFileSize,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.QuorumLogFileSize),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.QuorumTypeValue,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.QuorumTypeValue),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.RequestReplyTimeout,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.RequestReplyTimeout),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.ResiliencyDefaultPeriod,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.ResiliencyDefaultPeriod),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.ResiliencyLevel,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.ResiliencyLevel),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.ResourceDllDeadlockPeriod,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.ResourceDllDeadlockPeriod),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.RootMemoryReserved,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.RootMemoryReserved),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.RouteHistoryLength,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.RouteHistoryLength),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.S2DBusTypes,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.S2DBusTypes),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.S2DCacheDesiredState,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.S2DCacheDesiredState),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.S2DCacheFlashReservePercent,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.S2DCacheFlashReservePercent),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.S2DCachePageSizeKBytes,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.S2DCachePageSizeKBytes),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.S2DEnabled,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.S2DEnabled),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.S2DIOLatencyThreshold,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.S2DIOLatencyThreshold),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.S2DOptimizations,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.S2DOptimizations),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.SameSubnetDelay,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.SameSubnetDelay),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.SameSubnetThreshold,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.SameSubnetThreshold),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.SecurityLevel,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.SecurityLevel),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.SecurityLevelForStorage,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.SecurityLevelForStorage),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.SharedVolumeVssWriterOperationTimeout,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.SharedVolumeVssWriterOperationTimeout),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.ShutdownTimeoutInMinutes,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.ShutdownTimeoutInMinutes),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.UseClientAccessNetworksForSharedVolumes,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.UseClientAccessNetworksForSharedVolumes),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.WitnessDatabaseWriteTimeout,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.WitnessDatabaseWriteTimeout),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.WitnessDynamicWeight,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.WitnessDynamicWeight),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.WitnessRestartInterval,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(v.WitnessRestartInterval),\\n\\t\\t\\tv.Name,\\n\\t\\t)\\n\\n\\t}\\n\\n\\treturn nil\\n}\",\n \"func (c *TeamsCollector) Collect(ch chan<- prometheus.Metric) {\\n\\n\\tteams := getTotalTeams()\\n\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.totalTeamsGaugeDesc,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(teams),\\n\\t)\\n}\",\n \"func (p *plug) Collect(ch chan<- prometheus.Metric) {\\n\\tp.doStats(ch, doMetric)\\n}\",\n \"func (p *ProcMetrics) Collect() {\\n\\tif m, err := CollectProcInfo(p.pid); err == nil {\\n\\t\\tnow := time.Now()\\n\\n\\t\\tif !p.lastTime.IsZero() {\\n\\t\\t\\tratio := 1.0\\n\\t\\t\\tswitch {\\n\\t\\t\\tcase m.CPU.Period > 0 && m.CPU.Quota > 0:\\n\\t\\t\\t\\tratio = float64(m.CPU.Quota) / float64(m.CPU.Period)\\n\\t\\t\\tcase m.CPU.Shares > 0:\\n\\t\\t\\t\\tratio = float64(m.CPU.Shares) / 1024\\n\\t\\t\\tdefault:\\n\\t\\t\\t\\tratio = 1 / float64(runtime.NumCPU())\\n\\t\\t\\t}\\n\\n\\t\\t\\tinterval := ratio * float64(now.Sub(p.lastTime))\\n\\n\\t\\t\\tp.cpu.user.time = m.CPU.User - p.last.CPU.User\\n\\t\\t\\tp.cpu.user.percent = 100 * float64(p.cpu.user.time) / interval\\n\\n\\t\\t\\tp.cpu.system.time = m.CPU.Sys - p.last.CPU.Sys\\n\\t\\t\\tp.cpu.system.percent = 100 * float64(p.cpu.system.time) / interval\\n\\n\\t\\t\\tp.cpu.total.time = (m.CPU.User + m.CPU.Sys) - (p.last.CPU.User + p.last.CPU.Sys)\\n\\t\\t\\tp.cpu.total.percent = 100 * float64(p.cpu.total.time) / interval\\n\\t\\t}\\n\\n\\t\\tp.memory.available = m.Memory.Available\\n\\t\\tp.memory.size = m.Memory.Size\\n\\t\\tp.memory.resident.usage = m.Memory.Resident\\n\\t\\tp.memory.resident.percent = 100 * float64(p.memory.resident.usage) / float64(p.memory.available)\\n\\t\\tp.memory.shared.usage = m.Memory.Shared\\n\\t\\tp.memory.text.usage = m.Memory.Text\\n\\t\\tp.memory.data.usage = m.Memory.Data\\n\\t\\tp.memory.pagefault.major.count = m.Memory.MajorPageFaults - p.last.Memory.MajorPageFaults\\n\\t\\tp.memory.pagefault.minor.count = m.Memory.MinorPageFaults - p.last.Memory.MinorPageFaults\\n\\n\\t\\tp.files.open = m.Files.Open\\n\\t\\tp.files.max = m.Files.Max\\n\\n\\t\\tp.threads.num = m.Threads.Num\\n\\t\\tp.threads.switches.voluntary.count = m.Threads.VoluntaryContextSwitches - p.last.Threads.VoluntaryContextSwitches\\n\\t\\tp.threads.switches.involuntary.count = m.Threads.InvoluntaryContextSwitches - p.last.Threads.InvoluntaryContextSwitches\\n\\n\\t\\tp.last = m\\n\\t\\tp.lastTime = now\\n\\t\\tp.engine.Report(p)\\n\\t}\\n}\",\n \"func (b *EBPFTelemetry) Collect(ch chan<- prometheus.Metric) {\\n\\tb.getHelpersTelemetry(ch)\\n\\tb.getMapsTelemetry(ch)\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\te.withCollectors(func(cs []prometheus.Collector) {\\n\\t\\tfor _, c := range cs {\\n\\t\\t\\tc.Collect(ch)\\n\\t\\t}\\n\\t})\\n}\",\n \"func (dc *daemonsetCollector) Collect(ch chan<- prometheus.Metric) {\\n\\tdss, err := dc.store.List()\\n\\tif err != nil {\\n\\t\\tScrapeErrorTotalMetric.With(prometheus.Labels{\\\"resource\\\": \\\"daemonset\\\"}).Inc()\\n\\t\\tglog.Errorf(\\\"listing daemonsets failed: %s\\\", err)\\n\\t\\treturn\\n\\t}\\n\\tScrapeErrorTotalMetric.With(prometheus.Labels{\\\"resource\\\": \\\"daemonset\\\"}).Add(0)\\n\\n\\tResourcesPerScrapeMetric.With(prometheus.Labels{\\\"resource\\\": \\\"daemonset\\\"}).Observe(float64(len(dss)))\\n\\tfor _, d := range dss {\\n\\t\\tdc.collectDaemonSet(ch, d)\\n\\t}\\n\\n\\tglog.V(4).Infof(\\\"collected %d daemonsets\\\", len(dss))\\n}\",\n \"func (h *Metrics) Collect(in chan<- prometheus.Metric) {\\n\\th.duration.Collect(in)\\n\\th.totalRequests.Collect(in)\\n\\th.requestSize.Collect(in)\\n\\th.responseSize.Collect(in)\\n\\th.handlerStatuses.Collect(in)\\n\\th.responseTime.Collect(in)\\n}\",\n \"func (coll WmiCollector) Collect(ch chan<- prometheus.Metric) {\\n\\tdefer trace()()\\n\\twg := sync.WaitGroup{}\\n\\twg.Add(len(coll.collectors))\\n\\tfor name, c := range coll.collectors {\\n\\t\\tgo func(name string, c collector.Collector) {\\n\\t\\t\\texecute(name, c, ch)\\n\\t\\t\\twg.Done()\\n\\t\\t}(name, c)\\n\\t}\\n\\twg.Wait()\\n\\tscrapeDurations.Collect(ch)\\n}\",\n \"func (e *exporter) Collect(ch chan<- prometheus.Metric) {\\n\\twg := sync.WaitGroup{}\\n\\twg.Add(len(e.Collectors))\\n\\tfor name, c := range e.Collectors {\\n\\t\\tgo func(name string, c Collector) {\\n\\t\\t\\texecute(name, c, ch)\\n\\t\\t\\twg.Done()\\n\\t\\t}(name, c)\\n\\t}\\n\\twg.Wait()\\n}\",\n \"func (c *collector) Collect(ch chan<- prometheus.Metric) {\\n\\tstart := time.Now()\\n\\n\\tp := \\\"Chassis/1\\\"\\n\\terr := power.Collect(p, c.cl, ch)\\n\\tif err != nil {\\n\\t\\tlogrus.Error(err)\\n\\t}\\n\\n\\terr = thermal.Collect(p, c.cl, ch)\\n\\tif err != nil {\\n\\t\\tlogrus.Error(err)\\n\\t}\\n\\n\\tduration := time.Now().Sub(start).Seconds()\\n\\tch <- prometheus.MustNewConstMetric(scrapeDurationDesc, prometheus.GaugeValue, duration, c.cl.HostName())\\n}\",\n \"func (t *File_summary_by_instance) Collect(dbh *sql.DB) {\\n\\tstart := time.Now()\\n\\t// UPDATE current from db handle\\n\\tt.current = merge_by_table_name(select_fsbi_rows(dbh), t.global_variables)\\n\\n\\t// copy in initial data if it was not there\\n\\tif len(t.initial) == 0 && len(t.current) > 0 {\\n\\t\\tt.initial = make(file_summary_by_instance_rows, len(t.current))\\n\\t\\tcopy(t.initial, t.current)\\n\\t}\\n\\n\\t// check for reload initial characteristics\\n\\tif t.initial.needs_refresh(t.current) {\\n\\t\\tt.initial = make(file_summary_by_instance_rows, len(t.current))\\n\\t\\tcopy(t.initial, t.current)\\n\\t}\\n\\n\\t// update results to current value\\n\\tt.results = make(file_summary_by_instance_rows, len(t.current))\\n\\tcopy(t.results, t.current)\\n\\n\\t// make relative if need be\\n\\tif t.WantRelativeStats() {\\n\\t\\tt.results.subtract(t.initial)\\n\\t}\\n\\n\\t// sort the results\\n\\tt.results.sort()\\n\\n\\t// setup the totals\\n\\tt.totals = t.results.totals()\\n\\tlib.Logger.Println(\\\"File_summary_by_instance.Collect() took:\\\", time.Duration(time.Since(start)).String())\\n}\",\n \"func (n NodeCollector) Collect(ch chan<- prometheus.Metric) {\\n\\twg := sync.WaitGroup{}\\n\\twg.Add(len(n.collectors))\\n\\tfor name, c := range n.collectors {\\n\\t\\tgo func(name string, c collector.Collector) {\\n\\t\\t\\texecute(name, c, ch)\\n\\t\\t\\twg.Done()\\n\\t\\t}(name, c)\\n\\t}\\n\\twg.Wait()\\n\\tscrapeDurations.Collect(ch)\\n}\",\n \"func (c *StatsCollector) Collect(metricChannel chan<- prometheus.Metric) {\\n\\t// read all stats from Kamailio\\n\\tif completeStatMap, err := c.fetchStats(); err == nil {\\n\\t\\t// and produce various prometheus.Metric for well-known stats\\n\\t\\tproduceMetrics(completeStatMap, metricChannel)\\n\\t\\t// produce prometheus.Metric objects for scripted stats (if any)\\n\\t\\tconvertScriptedMetrics(completeStatMap, metricChannel)\\n\\t} else {\\n\\t\\t// something went wrong\\n\\t\\t// TODO: add a error metric\\n\\t\\tlog.Error(\\\"Could not fetch values from kamailio\\\", err)\\n\\t}\\n}\",\n \"func (c *ImageCollector) Collect(ch chan<- prometheus.Metric) {\\n\\tctx, cancel := context.WithTimeout(context.Background(), c.config.Timeout)\\n\\tdefer cancel()\\n\\n\\tnow := time.Now()\\n\\timages, err := c.client.Image.All(ctx)\\n\\n\\tif err != nil {\\n\\t\\tlevel.Error(c.logger).Log(\\n\\t\\t\\t\\\"msg\\\", \\\"Failed to fetch images\\\",\\n\\t\\t\\t\\\"err\\\", err,\\n\\t\\t)\\n\\n\\t\\tc.failures.WithLabelValues(\\\"image\\\").Inc()\\n\\t\\treturn\\n\\t}\\n\\n\\tlevel.Debug(c.logger).Log(\\n\\t\\t\\\"msg\\\", \\\"Fetched images\\\",\\n\\t\\t\\\"count\\\", len(images),\\n\\t)\\n\\n\\tfor _, image := range images {\\n\\t\\tvar (\\n\\t\\t\\tactive float64\\n\\t\\t\\tname string\\n\\t\\t\\tdeprecated float64\\n\\t\\t)\\n\\n\\t\\tif image.CreatedFrom != nil {\\n\\t\\t\\tname = image.CreatedFrom.Name\\n\\t\\t}\\n\\n\\t\\tif image.BoundTo != nil && image.BoundTo.Name != \\\"\\\" {\\n\\t\\t\\tactive = 1.0\\n\\t\\t\\tname = image.BoundTo.Name\\n\\t\\t}\\n\\n\\t\\tlabels := []string{\\n\\t\\t\\tstrconv.FormatInt(image.ID, 10),\\n\\t\\t\\timage.Name,\\n\\t\\t\\tstring(image.Type),\\n\\t\\t\\tname,\\n\\t\\t\\timage.OSFlavor,\\n\\t\\t\\timage.OSVersion,\\n\\t\\t}\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.Active,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tactive,\\n\\t\\t\\tlabels...,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.ImageSize,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(image.ImageSize*1024*1024),\\n\\t\\t\\tlabels...,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.DiskSize,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(image.DiskSize*1024*1024),\\n\\t\\t\\tlabels...,\\n\\t\\t)\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.Created,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(image.Created.Unix()),\\n\\t\\t\\tlabels...,\\n\\t\\t)\\n\\n\\t\\tif !image.Deprecated.IsZero() {\\n\\t\\t\\tdeprecated = float64(image.Deprecated.Unix())\\n\\t\\t}\\n\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.Deprecated,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tdeprecated,\\n\\t\\t\\tlabels...,\\n\\t\\t)\\n\\t}\\n\\n\\tlevel.Debug(c.logger).Log(\\n\\t\\t\\\"msg\\\", \\\"Processed image collector\\\",\\n\\t\\t\\\"duration\\\", time.Since(now),\\n\\t)\\n\\n\\tc.duration.WithLabelValues(\\\"image\\\").Observe(time.Since(now).Seconds())\\n}\",\n \"func (c *grpcClientManagerCollector) Collect(ch chan<- prometheus.Metric) {\\n\\tfor _, con := range c.cm.Metrics().Connections {\\n\\t\\tl := []string{con.Target}\\n\\t\\tch <- prometheus.MustNewConstMetric(connectionStateDesc, prometheus.GaugeValue, float64(con.State), l...)\\n\\t}\\n}\",\n \"func (c *SchedulerController) CollectMetrics(ch chan<- prometheus.Metric) {\\n\\tmetric, err := prometheus.NewConstMetric(scheduler.ControllerWorkerSum, prometheus.GaugeValue, float64(c.RunningWorkers()), \\\"seed\\\")\\n\\tif err != nil {\\n\\t\\tscheduler.ScrapeFailures.With(prometheus.Labels{\\\"kind\\\": \\\"gardener-shoot-scheduler\\\"}).Inc()\\n\\t\\treturn\\n\\t}\\n\\tch <- metric\\n}\",\n \"func (pc *PBSCollector) Collect(ch chan<- prometheus.Metric) {\\n\\tpc.mutex.Lock()\\n\\tdefer pc.mutex.Unlock()\\n\\tlog.Debugf(\\\"Time since last scrape: %f seconds\\\", time.Since(pc.lastScrape).Seconds())\\n\\n\\tif time.Since(pc.lastScrape).Seconds() > float64(pc.scrapeInterval) {\\n\\t\\tpc.updateDynamicJobIds()\\n\\t\\tvar err error\\n\\t\\tpc.sshClient, err = pc.sshConfig.NewClient()\\n\\t\\tif err != nil {\\n\\t\\t\\tlog.Errorf(\\\"Creating SSH client: %s\\\", err.Error())\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tdefer pc.sshClient.Close()\\n\\t\\tlog.Infof(\\\"Collecting metrics from PBS...\\\")\\n\\t\\tpc.trackedJobs = make(map[string]bool)\\n\\t\\tif pc.targetJobIds != \\\"\\\" {\\n\\t\\t\\tpc.collectJobs(ch)\\n\\t\\t}\\n\\t\\tif !pc.skipInfra {\\n\\t\\t\\tpc.collectQueues(ch)\\n\\t\\t}\\n\\t\\tpc.lastScrape = time.Now()\\n\\t}\\n\\tpc.updateMetrics(ch)\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\tupValue := 1\\n\\n\\tif err := e.collect(ch); err != nil {\\n\\t\\tlog.Printf(\\\"Error scraping clickhouse: %s\\\", err)\\n\\t\\te.scrapeFailures.Inc()\\n\\t\\te.scrapeFailures.Collect(ch)\\n\\n\\t\\tupValue = 0\\n\\t}\\n\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tprometheus.NewDesc(\\n\\t\\t\\tprometheus.BuildFQName(namespace, \\\"\\\", \\\"up\\\"),\\n\\t\\t\\t\\\"Was the last query of ClickHouse successful.\\\",\\n\\t\\t\\tnil, nil,\\n\\t\\t),\\n\\t\\tprometheus.GaugeValue, float64(upValue),\\n\\t)\\n\\n}\",\n \"func (cpuCollector *CPUCollector) Collect() {\\n\\tcpuCollector.cpuStats.GetCPUStats()\\n\\n\\tcpuCollector.cpuMetrics.cpuTotal.Set(float64(cpuCollector.cpuStats.Total))\\n\\tcpuCollector.cpuMetrics.cupIdle.Set(float64(cpuCollector.cpuStats.Idle))\\n\\tcpuCollector.cpuMetrics.cpuUtilization.Set(cpuCollector.cpuStats.Utilization)\\n}\",\n \"func (e Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\tctx := context.Background()\\n\\n\\tcontainerService, err := container.NewService(ctx)\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n\\n\\tcloudresourcemanagerService, err := cloudresourcemanager.NewService(ctx)\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n\\n\\tprojectsListResponse, err := cloudresourcemanagerService.Projects.List().Filter(\\\"lifecycleState:ACTIVE\\\").Context(ctx).Do()\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n\\n\\tlog.Infof(\\\"Found %d projects\\\", len(projectsListResponse.Projects))\\n\\n\\tvar mutex = &sync.Mutex{}\\n\\tvar wg sync.WaitGroup\\n\\twg.Add(len(projectsListResponse.Projects))\\n\\n\\tvalidMasterVersions := map[string][]string{}\\n\\tmasterVersionCount := map[string]float64{}\\n\\n\\tfor _, p := range projectsListResponse.Projects {\\n\\t\\tgo func(p *cloudresourcemanager.Project) {\\n\\t\\t\\tdefer wg.Done()\\n\\t\\t\\tresp, err := containerService.Projects.Locations.Clusters.List(\\\"projects/\\\" + p.ProjectId + \\\"/locations/-\\\").Context(ctx).Do()\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tif ae, ok := err.(*googleapi.Error); ok && ae.Code == http.StatusForbidden {\\n\\t\\t\\t\\t\\tlog.Warnf(\\\"Missing roles/container.clusterViewer on %s (%s)\\\", p.Name, p.ProjectId)\\n\\t\\t\\t\\t\\treturn\\n\\t\\t\\t\\t} else if ae, ok := err.(*googleapi.Error); ok && ae.Code == http.StatusTooManyRequests {\\n\\t\\t\\t\\t\\tlog.Warn(\\\"Quota exceeded\\\")\\n\\t\\t\\t\\t\\treturn\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tlog.Fatal(err)\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\n\\t\\t\\tfor _, c := range resp.Clusters {\\n\\t\\t\\t\\tmutex.Lock()\\n\\t\\t\\t\\tif _, ok := validMasterVersions[c.Location]; !ok {\\n\\t\\t\\t\\t\\tlog.Infof(\\\"Pulling server configs for location %s\\\", c.Location)\\n\\t\\t\\t\\t\\tserverConfig, err := containerService.Projects.Locations.GetServerConfig(\\\"projects/\\\" + p.ProjectId + \\\"/locations/\\\" + c.Location).Do()\\n\\t\\t\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t\\t\\tif ae, ok := err.(*googleapi.Error); ok && ae.Code == http.StatusTooManyRequests {\\n\\t\\t\\t\\t\\t\\t\\tlog.Warn(\\\"Quota exceeded\\\")\\n\\t\\t\\t\\t\\t\\t\\treturn\\n\\t\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\t\\tlog.Fatal(err)\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t\\tvalidMasterVersions[c.Location] = serverConfig.ValidMasterVersions\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\tif _, ok := masterVersionCount[c.CurrentMasterVersion]; !ok {\\n\\t\\t\\t\\t\\tmasterVersionCount[c.CurrentMasterVersion] = 1\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tmasterVersionCount[c.CurrentMasterVersion]++\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tmutex.Unlock()\\n\\n\\t\\t\\t\\tif !contains(c.CurrentMasterVersion, validMasterVersions[c.Location]) {\\n\\t\\t\\t\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\t\\t\\t\\te.Metrics[\\\"gkeUnsupportedMasterVersion\\\"],\\n\\t\\t\\t\\t\\t\\tprometheus.CounterValue,\\n\\t\\t\\t\\t\\t\\t1,\\n\\t\\t\\t\\t\\t\\t[]string{\\n\\t\\t\\t\\t\\t\\t\\tc.CurrentMasterVersion,\\n\\t\\t\\t\\t\\t\\t\\tp.ProjectId,\\n\\t\\t\\t\\t\\t\\t\\tp.Name,\\n\\t\\t\\t\\t\\t\\t\\tc.Name,\\n\\t\\t\\t\\t\\t\\t\\tc.Location,\\n\\t\\t\\t\\t\\t\\t}...,\\n\\t\\t\\t\\t\\t)\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}(p)\\n\\t}\\n\\n\\twg.Wait()\\n\\n\\tfor version, cnt := range masterVersionCount {\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\te.Metrics[\\\"gkeMasterVersion\\\"],\\n\\t\\t\\tprometheus.CounterValue,\\n\\t\\t\\tcnt,\\n\\t\\t\\t[]string{\\n\\t\\t\\t\\tversion,\\n\\t\\t\\t}...,\\n\\t\\t)\\n\\t}\\n\\n\\tlog.Info(\\\"Done\\\")\\n}\",\n \"func (o *observer) Collect(ch chan<- prometheus.Metric) {\\n\\to.updateError.Collect(ch)\\n\\to.verifyError.Collect(ch)\\n\\to.expiration.Collect(ch)\\n}\",\n \"func collectMetrics(db *sql.DB, populaterWg *sync.WaitGroup, i *integration.Integration, instanceLookUp map[string]string) {\\n\\tdefer populaterWg.Done()\\n\\n\\tvar collectorWg sync.WaitGroup\\n\\tmetricChan := make(chan newrelicMetricSender, 100) // large buffer for speed\\n\\n\\t// Create a goroutine for each of the metric groups to collect\\n\\tcollectorWg.Add(5)\\n\\tgo oracleReadWriteMetrics.Collect(db, &collectorWg, metricChan)\\n\\tgo oraclePgaMetrics.Collect(db, &collectorWg, metricChan)\\n\\tgo oracleSysMetrics.Collect(db, &collectorWg, metricChan)\\n\\tgo globalNameInstanceMetric.Collect(db, &collectorWg, metricChan)\\n\\tgo dbIDInstanceMetric.Collect(db, &collectorWg, metricChan)\\n\\n\\t// Separate logic is needed to see if we should even collect tablespaces\\n\\tcollectTableSpaces(db, &collectorWg, metricChan)\\n\\n\\t// When the metric groups are finished collecting, close the channel\\n\\tgo func() {\\n\\t\\tcollectorWg.Wait()\\n\\t\\tclose(metricChan)\\n\\t}()\\n\\n\\t// Create a goroutine to read from the metric channel and insert the metrics\\n\\tpopulateMetrics(metricChan, i, instanceLookUp)\\n}\",\n \"func (e *Exporter) Collect(ch chan<- prometheus.Metric) {\\n\\te.mutex.Lock() // To protect metrics from concurrent collects.\\n\\tdefer e.mutex.Unlock()\\n\\n\\tfor _, pool := range *e.zpools {\\n\\t\\tpool.getStatus()\\n\\n\\t\\tpoolUsage := prometheus.NewGauge(prometheus.GaugeOpts{\\n\\t\\t\\tName: \\\"zpool_capacity_percentage\\\",\\n\\t\\t\\tHelp: \\\"Current zpool capacity level\\\",\\n\\t\\t\\tConstLabels: prometheus.Labels{\\n\\t\\t\\t\\t\\\"name\\\": pool.name,\\n\\t\\t\\t},\\n\\t\\t})\\n\\t\\tpoolUsage.Set(float64(pool.capacity))\\n\\t\\tch <- poolUsage\\n\\n\\t\\tprovidersOnline := prometheus.NewGauge(prometheus.GaugeOpts{\\n\\t\\t\\tName: \\\"zpool_online_providers_count\\\",\\n\\t\\t\\tHelp: \\\"Number of ONLINE zpool providers (disks)\\\",\\n\\t\\t\\tConstLabels: prometheus.Labels{\\n\\t\\t\\t\\t\\\"name\\\": pool.name,\\n\\t\\t\\t},\\n\\t\\t})\\n\\t\\tprovidersOnline.Set(float64(pool.online))\\n\\t\\tch <- providersOnline\\n\\n\\t\\tprovidersFaulted := prometheus.NewGauge(prometheus.GaugeOpts{\\n\\t\\t\\tName: \\\"zpool_faulted_providers_count\\\",\\n\\t\\t\\tHelp: \\\"Number of FAULTED/UNAVAIL zpool providers (disks)\\\",\\n\\t\\t\\tConstLabels: prometheus.Labels{\\n\\t\\t\\t\\t\\\"name\\\": pool.name,\\n\\t\\t\\t},\\n\\t\\t})\\n\\t\\tprovidersFaulted.Set(float64(pool.faulted))\\n\\t\\tch <- providersFaulted\\n\\t}\\n\\n}\",\n \"func (c *solarCollector) collect(ch chan<- prometheus.Metric) error {\\n\\t// fetch the status of the controller\\n\\ttracer, err := gotracer.Status(\\\"/dev/ttyUSB0\\\")\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\n\\t/*\\n\\t * report the collected data\\n\\t */\\n\\n\\t// store boolean values as a float (1 == true, 0 == false)\\n\\tvar loadIsActive float64\\n\\t// Panel array\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.panelVoltage,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.ArrayVoltage),\\n\\t)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.panelCurrent,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.ArrayCurrent),\\n\\t)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.panelPower,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.ArrayPower),\\n\\t)\\n\\n\\t// Batteries\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.batteryCurrent,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.BatteryCurrent),\\n\\t)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.batteryVoltage,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.BatteryVoltage),\\n\\t)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.batterySOC,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.BatterySOC),\\n\\t)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.batteryTemp,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.BatteryTemp),\\n\\t)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.batteryMinVoltage,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.BatteryMinVoltage),\\n\\t)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.batteryMaxVoltage,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.BatteryMaxVoltage),\\n\\t)\\n\\n\\t// Load output\\n\\tif tracer.Load {\\n\\t\\tloadIsActive = 1\\n\\t}\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.loadActive,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tloadIsActive,\\n\\t)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.loadVoltage,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.LoadVoltage),\\n\\t)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.loadCurrent,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.LoadCurrent),\\n\\t)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.loadPower,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.LoadPower),\\n\\t)\\n\\n\\t// controller infos\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.deviceTemp,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.DeviceTemp),\\n\\t)\\n\\n\\t// energy consumed\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.energyConsumedDaily,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.EnergyConsumedDaily),\\n\\t)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.energyConsumedMonthly,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.EnergyConsumedMonthly),\\n\\t)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.energyConsumedAnnual,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.EnergyConsumedAnnual),\\n\\t)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.energyConsumedTotal,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.EnergyConsumedTotal),\\n\\t)\\n\\t// energy generated\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.energyGeneratedDaily,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.EnergyGeneratedDaily),\\n\\t)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.energyGeneratedMonthly,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.EnergyGeneratedMonthly),\\n\\t)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.energyGeneratedAnnual,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.EnergyGeneratedAnnual),\\n\\t)\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.energyGeneratedTotal,\\n\\t\\tprometheus.GaugeValue,\\n\\t\\tfloat64(tracer.EnergyGeneratedTotal),\\n\\t)\\n\\n\\treturn nil\\n}\",\n \"func (e *PostfixExporter) Collect(ch chan<- prometheus.Metric) {\\n\\terr := CollectShowqFromSocket(e.showqPath, ch)\\n\\tif err == nil {\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tpostfixUpDesc,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\t1.0,\\n\\t\\t\\te.showqPath)\\n\\t} else {\\n\\t\\tlog.Printf(\\\"Failed to scrape showq socket: %s\\\", err)\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tpostfixUpDesc,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\t0.0,\\n\\t\\t\\te.showqPath)\\n\\t}\\n\\n\\terr = e.CollectLogfileFromFile(e.logfilePath)\\n\\tif err == nil {\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tpostfixUpDesc,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\t1.0,\\n\\t\\t\\te.logfilePath)\\n\\t} else {\\n\\t\\tlog.Printf(\\\"Failed to scrape logfile: %s\\\", err)\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tpostfixUpDesc,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\t0.0,\\n\\t\\t\\te.logfilePath)\\n\\t}\\n\\n\\tch <- e.cleanupProcesses\\n\\tch <- e.cleanupRejects\\n\\te.lmtpDelays.Collect(ch)\\n\\te.pipeDelays.Collect(ch)\\n\\tch <- e.qmgrInsertsNrcpt\\n\\tch <- e.qmgrInsertsSize\\n\\tch <- e.qmgrRemoves\\n\\te.smtpDelays.Collect(ch)\\n\\te.smtpTLSConnects.Collect(ch)\\n\\tch <- e.smtpdConnects\\n\\tch <- e.smtpdDisconnects\\n\\tch <- e.smtpdFCrDNSErrors\\n\\te.smtpdLostConnections.Collect(ch)\\n\\te.smtpdProcesses.Collect(ch)\\n\\te.smtpdRejects.Collect(ch)\\n\\tch <- e.smtpdSASLAuthenticationFailures\\n\\te.smtpdTLSConnects.Collect(ch)\\n\\te.unsupportedLogEntries.Collect(ch)\\n}\",\n \"func (coll WmiCollector) Collect(ch chan<- prometheus.Metric) {\\n\\texecute(coll.collector, ch)\\n}\",\n \"func (m *MeterImpl) collect(ctx context.Context, labels []attribute.KeyValue, measurements []Measurement) {\\n\\tm.provider.addMeasurement(Batch{\\n\\t\\tCtx: ctx,\\n\\t\\tLabels: labels,\\n\\t\\tMeasurements: measurements,\\n\\t\\tLibrary: m.library,\\n\\t})\\n}\",\n \"func (c *libbeatCollector) Collect(ch chan<- prometheus.Metric) {\\n\\n\\tfor _, i := range c.metrics {\\n\\t\\tch <- prometheus.MustNewConstMetric(i.desc, i.valType, i.eval(c.stats))\\n\\t}\\n\\n\\t// output.type with dynamic label\\n\\tch <- prometheus.MustNewConstMetric(libbeatOutputType, prometheus.CounterValue, float64(1), c.stats.LibBeat.Output.Type)\\n\\n}\",\n \"func (c *Client) Collect(ch chan<- prometheus.Metric) {\\n\\tc.metrics.functionInvocation.Collect(ch)\\n\\tc.metrics.functionsHistogram.Collect(ch)\\n\\tc.metrics.queueHistogram.Collect(ch)\\n\\tc.metrics.functionInvocationStarted.Collect(ch)\\n\\tc.metrics.serviceReplicasGauge.Reset()\\n\\tfor _, service := range c.services {\\n\\t\\tvar serviceName string\\n\\t\\tif len(service.Namespace) > 0 {\\n\\t\\t\\tserviceName = fmt.Sprintf(\\\"%s.%s\\\", service.Name, service.Namespace)\\n\\t\\t} else {\\n\\t\\t\\tserviceName = service.Name\\n\\t\\t}\\n\\t\\tc.metrics.serviceReplicasGauge.\\n\\t\\t\\tWithLabelValues(serviceName).\\n\\t\\t\\tSet(float64(service.Replicas))\\n\\t}\\n\\tc.metrics.serviceReplicasGauge.Collect(ch)\\n}\",\n \"func appStatsCollect(ctx *zedrouterContext) {\\n\\tlog.Infof(\\\"appStatsCollect: containerStats, started\\\")\\n\\tappStatsCollectTimer := time.NewTimer(time.Duration(ctx.appStatsInterval) * time.Second)\\n\\tfor {\\n\\t\\tselect {\\n\\t\\tcase <-appStatsCollectTimer.C:\\n\\t\\t\\titems, stopped := checkAppStopStatsCollect(ctx)\\n\\t\\t\\tif stopped {\\n\\t\\t\\t\\treturn\\n\\t\\t\\t}\\n\\n\\t\\t\\tcollectTime := time.Now() // all apps collection assign the same timestamp\\n\\t\\t\\tfor _, st := range items {\\n\\t\\t\\t\\tstatus := st.(types.AppNetworkStatus)\\n\\t\\t\\t\\tif status.GetStatsIPAddr != nil {\\n\\t\\t\\t\\t\\tacMetrics, err := appContainerGetStats(status.GetStatsIPAddr)\\n\\t\\t\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t\\t\\tlog.Errorf(\\\"appStatsCollect: can't get App %s Container Metrics on %s, %v\\\",\\n\\t\\t\\t\\t\\t\\t\\tstatus.UUIDandVersion.UUID.String(), status.GetStatsIPAddr.String(), err)\\n\\t\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\tacMetrics.UUIDandVersion = status.UUIDandVersion\\n\\t\\t\\t\\t\\tacMetrics.CollectTime = collectTime\\n\\t\\t\\t\\t\\tctx.pubAppContainerMetrics.Publish(acMetrics.Key(), acMetrics)\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tappStatsCollectTimer = time.NewTimer(time.Duration(ctx.appStatsInterval) * time.Second)\\n\\t\\t}\\n\\t}\\n}\",\n \"func (c *SVCResponse) Collect(ch chan<- prometheus.Metric) {\\n\\tvar err error\\n\\tc.totalScrapes.Inc()\\n\\tdefer func() {\\n\\t\\tch <- c.up\\n\\t\\tch <- c.totalScrapes\\n\\t\\tch <- c.jsonParseFailures\\n\\t}()\\n\\n\\tSVCResp, err := c.fetchDataAndDecode()\\n\\tif err != nil {\\n\\t\\tc.up.Set(0)\\n\\t\\t_ = level.Warn(*c.logger).Log(\\n\\t\\t\\t\\\"msg\\\", \\\"failed to fetch and decode data\\\",\\n\\t\\t\\t\\\"err\\\", err,\\n\\t\\t)\\n\\t\\treturn\\n\\t}\\n\\tc.up.Set(1)\\n\\n\\tfor _, metric := range c.metrics {\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tmetric.Desc,\\n\\t\\t\\tmetric.Type,\\n\\t\\t\\tmetric.Value(&SVCResp),\\n\\t\\t)\\n\\t}\\n\\n\\tch <- prometheus.MustNewConstMetric(\\n\\t\\tc.data.Desc,\\n\\t\\tc.data.Type,\\n\\t\\tc.data.Value(&SVCResp),\\n\\t\\tSVCResp.UniqueID, SVCResp.Version, SVCResp.LongVersion, SVCResp.Platform,\\n\\t)\\n}\",\n \"func (s *stats) collect() {\\n\\truntime.GC()\\n\\truntime.Gosched()\\n\\n\\tm := new(runtime.MemStats)\\n\\truntime.ReadMemStats(m)\\n\\n\\tg := runtime.NumGoroutine()\\n\\tp := player.PlayerList.Length()\\n\\n\\t// Calculate difference in resources since last run\\n\\tΔa := int64(m.Alloc - s.Alloc)\\n\\tΔh := int(m.HeapObjects - s.HeapObjects)\\n\\tΔg := g - s.Goroutines\\n\\n\\t// Calculate max players\\n\\tmaxPlayers := s.MaxPlayers\\n\\tif s.MaxPlayers < p {\\n\\t\\tmaxPlayers = p\\n\\t}\\n\\n\\t// Calculate scaled numeric and prefix parts of Alloc and Alloc difference\\n\\tan, ap := uscale(m.Alloc)\\n\\tΔan, Δap := scale(Δa)\\n\\n\\tlog.Printf(\\\"A[%4d%-2s %+5d%-2s] HO[%14d %+9d] GO[%6d %+6d] PL %d/%d\\\",\\n\\t\\tan, ap, Δan, Δap, m.HeapObjects, Δh, g, Δg, p, maxPlayers,\\n\\t)\\n\\n\\t// Save current stats\\n\\ts.Alloc = m.Alloc\\n\\ts.HeapObjects = m.HeapObjects\\n\\ts.Goroutines = g\\n\\ts.MaxPlayers = maxPlayers\\n}\",\n \"func (c *ledCollector) Collect(ch chan<- prometheus.Metric) {\\n\\tfor _, led := range c.leds {\\n\\t\\tn := name(led.Name())\\n\\t\\tbrightness, err := led.Brightness()\\n\\t\\tif err != nil {\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.brightness,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(brightness),\\n\\t\\t\\tn,\\n\\t\\t)\\n\\t\\tmaxBrightness, err := led.MaxBrightness()\\n\\t\\tif err != nil {\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\t\\tch <- prometheus.MustNewConstMetric(\\n\\t\\t\\tc.maxBrightness,\\n\\t\\t\\tprometheus.GaugeValue,\\n\\t\\t\\tfloat64(maxBrightness),\\n\\t\\t\\tn,\\n\\t\\t)\\n\\t}\\n}\",\n \"func (a collectorAdapter) Collect(ch chan<- prometheus.Metric) {\\n\\tif err := a.Update(ch); err != nil {\\n\\t\\tpanic(fmt.Sprintf(\\\"failed to update collector: %v\\\", err))\\n\\t}\\n}\"\n]"},"negative_scores":{"kind":"list like","value":["0.7183592","0.71742594","0.7162346","0.70565355","0.70360357","0.69982564","0.6949635","0.6914864","0.6885865","0.6879976","0.68548733","0.68540335","0.6808158","0.68029076","0.68007356","0.67698246","0.67640656","0.67620915","0.6753656","0.6752293","0.6744237","0.6739006","0.67390007","0.67380345","0.6727125","0.6726372","0.67184454","0.671359","0.6706968","0.67049974","0.6698012","0.6693244","0.66925627","0.6678655","0.666336","0.6661282","0.66609734","0.666035","0.6656762","0.6652841","0.66519517","0.66454893","0.6627886","0.66224986","0.6615926","0.660144","0.658763","0.657078","0.6568967","0.65557","0.65522474","0.65458155","0.65399355","0.65399355","0.65392137","0.6536364","0.6521162","0.651431","0.6498718","0.6489084","0.64823884","0.6482232","0.64529246","0.64494044","0.64492226","0.6437596","0.6432558","0.6420688","0.64153194","0.64046174","0.638546","0.6368604","0.6366169","0.63609284","0.63548523","0.63504416","0.6345726","0.63364065","0.6330194","0.63286954","0.6309989","0.6309755","0.62939787","0.62667626","0.6266644","0.6260426","0.62584746","0.6253893","0.6250315","0.6233216","0.6231679","0.6228766","0.6226484","0.6220888","0.6218559","0.6217337","0.621059","0.6208171","0.6202584","0.6197745"],"string":"[\n \"0.7183592\",\n \"0.71742594\",\n \"0.7162346\",\n \"0.70565355\",\n \"0.70360357\",\n \"0.69982564\",\n \"0.6949635\",\n \"0.6914864\",\n \"0.6885865\",\n \"0.6879976\",\n \"0.68548733\",\n \"0.68540335\",\n \"0.6808158\",\n \"0.68029076\",\n \"0.68007356\",\n \"0.67698246\",\n \"0.67640656\",\n \"0.67620915\",\n \"0.6753656\",\n \"0.6752293\",\n \"0.6744237\",\n \"0.6739006\",\n \"0.67390007\",\n \"0.67380345\",\n \"0.6727125\",\n \"0.6726372\",\n \"0.67184454\",\n \"0.671359\",\n \"0.6706968\",\n \"0.67049974\",\n \"0.6698012\",\n \"0.6693244\",\n \"0.66925627\",\n \"0.6678655\",\n \"0.666336\",\n \"0.6661282\",\n \"0.66609734\",\n \"0.666035\",\n \"0.6656762\",\n \"0.6652841\",\n \"0.66519517\",\n \"0.66454893\",\n \"0.6627886\",\n \"0.66224986\",\n \"0.6615926\",\n \"0.660144\",\n \"0.658763\",\n \"0.657078\",\n \"0.6568967\",\n \"0.65557\",\n \"0.65522474\",\n \"0.65458155\",\n \"0.65399355\",\n \"0.65399355\",\n \"0.65392137\",\n \"0.6536364\",\n \"0.6521162\",\n \"0.651431\",\n \"0.6498718\",\n \"0.6489084\",\n \"0.64823884\",\n \"0.6482232\",\n \"0.64529246\",\n \"0.64494044\",\n \"0.64492226\",\n \"0.6437596\",\n \"0.6432558\",\n \"0.6420688\",\n \"0.64153194\",\n \"0.64046174\",\n \"0.638546\",\n \"0.6368604\",\n \"0.6366169\",\n \"0.63609284\",\n \"0.63548523\",\n \"0.63504416\",\n \"0.6345726\",\n \"0.63364065\",\n \"0.6330194\",\n \"0.63286954\",\n \"0.6309989\",\n \"0.6309755\",\n \"0.62939787\",\n \"0.62667626\",\n \"0.6266644\",\n \"0.6260426\",\n \"0.62584746\",\n \"0.6253893\",\n \"0.6250315\",\n \"0.6233216\",\n \"0.6231679\",\n \"0.6228766\",\n \"0.6226484\",\n \"0.6220888\",\n \"0.6218559\",\n \"0.6217337\",\n \"0.621059\",\n \"0.6208171\",\n \"0.6202584\",\n \"0.6197745\"\n]"},"document_score":{"kind":"string","value":"0.7495119"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":105059,"cells":{"query":{"kind":"string","value":"NewCustomLambda creates a new lambda that has a custom command"},"document":{"kind":"string","value":"func NewCustomLambda(name, command string) *CustomLambda {\n\treturn &CustomLambda{\n\t\tname: name,\n\t\tcommand: command,\n\t}\n}"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["func NewLambda(vs []Argument, u bool, as []Argument, e Expression, t types.Type) Lambda {\n\treturn Lambda{as, e, t, vs, u}\n}","func NewLambda(label string, t Term, body Term) Lambda {\n\treturn Lambda{\n\t\tLabel: label,\n\t\tType: t,\n\t\tBody: body,\n\t}\n}","func New(cfg *config.Config) *Lambda {\n\n\treturn &Lambda{\n\t\tConfig: cfg,\n\t\tService: service.New(cfg),\n\t\tFileTransfer: filetransfer.New(cfg),\n\t}\n}","func NewCmd(o *Options) *cobra.Command {\n\tc := command{\n\t\tCommand: cli.Command{Options: o.Options},\n\t\topts: o,\n\t}\n\n\tcmd := &cobra.Command{\n\t\tUse: \"new-lambda\",\n\t\tShort: \"New local Lambda Function\",\n\t\tLong: `Creates a new local lambda function setup to start development`,\n\t\tRunE: func(_ *cobra.Command, args []string) error { return c.Run(args) },\n\t}\n\n\tcmd.Args = cobra.ExactArgs(1)\n\n\tcmd.Flags().StringVarP(&o.Namespace, \"namespace\", \"n\", \"default\", \"Namespace to bind\")\n\tcmd.Flags().BoolVar(&o.Expose, \"expose\", false, \"Create the namespace if not existing\")\n\tcmd.Flags().StringVar(&o.ClusterDomain, \"cluster-domain\", \"\", \"Cluster Domain of your cluster\")\n\n\treturn cmd\n}","func createLambdaFunction(ctx *pulumi.Context, role *iam.Role, logPolicy *iam.RolePolicy, route APIRoute, method string) (*lambda.Function, error) {\n\t// Determine the language of the function.\n\tlambdaFilePath := path.Join(route.PathToFiles, method)\n\tlambdaLanguage, err := detectLambdaLanguage(lambdaFilePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Determine the Lambda runtime to use.\n\tvar lambdaRuntime string\n\tvar handlerName string\n\tvar handlerZipFile string\n\tswitch lambdaLanguage {\n\tcase \"typescript\":\n\t\tlambdaRuntime = \"nodejs12.x\"\n\t\thandlerName = fmt.Sprintf(\"%s-%s-handler.%sHandler\", route.Name, method, method)\n\t\thandlerZipFile, err = PackageTypeScriptLambda(tmpDirName, route.Name, method)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tbreak\n\tcase \"go\":\n\t\tlambdaRuntime = \"go1.x\"\n\t\thandlerName = fmt.Sprintf(\"%s-%s-handler\", route.Name, method)\n\t\thandlerZipFile, err = PackageGoLambda(tmpDirName, route.Name, method)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase \"dotnet\":\n\t\tlambdaRuntime = \"dotnetcore3.1\"\n\t\thandlerName = fmt.Sprintf(\"app::app.Functions::%s\", utils.DashCaseToSentenceCase(method))\n\t\thandlerZipFile, err = PackageDotNetLambda(tmpDirName, route.Name, method)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"Unsupported runtime detected.\")\n\t}\n\n\tcurrentWorkingDirectory, err := os.Getwd()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\thandlerFileName := path.Join(currentWorkingDirectory, handlerZipFile)\n\targs := &lambda.FunctionArgs{\n\t\tHandler: pulumi.String(handlerName),\n\t\tRole: role.Arn,\n\t\tRuntime: pulumi.String(lambdaRuntime),\n\t\tCode: pulumi.NewFileArchive(handlerFileName),\n\t}\n\n\t// Create the lambda using the args.\n\tfunction, err := lambda.NewFunction(\n\t\tctx,\n\t\tfmt.Sprintf(\"%s-%s-lambda-function\", route.Name, method),\n\t\targs,\n\t\tpulumi.DependsOn([]pulumi.Resource{logPolicy}),\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error updating lambda for file [%s]: %v\", handlerFileName, err)\n\t}\n\n\treturn function, nil\n}","func NewLambdaFromJSON(json jsoniter.Any) (*Lambda, error) {\n\tif json.Get(\"type\").ToUint() != TypeLambda {\n\t\treturn nil, ErrInvalidJSON\n\t}\n\n\tvar jsonParameters []jsoniter.Any\n\tjson.Get(\"parameters\").ToVal(&jsonParameters)\n\n\tparameters := make([]*ID, len(jsonParameters))\n\tfor i, json := range jsonParameters {\n\t\tp, err := NewIDFromJSON(json)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tparameters[i] = p\n\t}\n\n\texpression, err := NewExpressionFromJSON(json.Get(\"expression\"))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Lambda{\n\t\tParameters: parameters,\n\t\tExpression: expression,\n\t}, nil\n}","func New(h HandlerFunc) lambda.Handler {\n\treturn NewWithConfig(Config{}, h)\n}","func (c *Client) NewCreateLambdaRequest(ctx context.Context, path string, payload *LambdaPayload, contentType string) (*http.Request, error) {\n\tvar body bytes.Buffer\n\tif contentType == \"\" {\n\t\tcontentType = \"*/*\" // Use default encoder\n\t}\n\terr := c.Encoder.Encode(payload, &body, contentType)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to encode body: %s\", err)\n\t}\n\tscheme := c.Scheme\n\tif scheme == \"\" {\n\t\tscheme = \"http\"\n\t}\n\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\n\treq, err := http.NewRequest(\"POST\", u.String(), &body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\theader := req.Header\n\tif contentType == \"*/*\" {\n\t\theader.Set(\"Content-Type\", \"application/json\")\n\t} else {\n\t\theader.Set(\"Content-Type\", contentType)\n\t}\n\treturn req, nil\n}","func main() {\n\tlambda.Start(handler)\n}","func main() {\n\tlambda.Start(handler)\n}","func createNewPythonProxyEntry(lambdaInfo *LambdaAWSInfo, logger *logrus.Logger) string {\n\tlogger.WithFields(logrus.Fields{\n\t\t\"FunctionName\": lambdaInfo.lambdaFunctionName(),\n\t\t\"ScriptName\": lambdaInfo.scriptExportHandlerName(),\n\t}).Info(\"Registering Sparta Python function\")\n\n\tprimaryEntry := fmt.Sprintf(`def %s(event, context):\n\t\treturn lambda_handler(%s, event, context)\n\t`,\n\t\tlambdaInfo.scriptExportHandlerName(),\n\t\tlambdaInfo.lambdaFunctionName())\n\treturn primaryEntry\n}","func NewLambdaInvocationMetricEvaluator(queries []awsv2CWTypes.MetricDataQuery,\n\tmetricEvaluator MetricEvaluator) CloudEvaluator {\n\tnowTime := time.Now()\n\n\t// We won't get initialized before the trigger function is called, so ensure there's\n\t// enough buffer for a lower bound\n\taddDuration, _ := time.ParseDuration(\"2s\")\n\treturn &lambdaInvocationMetricEvaluator{\n\t\tinitTime: nowTime.Add(-addDuration),\n\t\tqueries: queries,\n\t\tmetricEvaluator: metricEvaluator,\n\t}\n}","func (l *CustomLambda) Execute(stdin io.Reader, args []string) (string, error) {\n\targsStr := strings.TrimSpace(strings.Join(args, \" \"))\n\tif argsStr != \"\" {\n\t\targsStr = \" \" + argsStr\n\t}\n\n\tcmd := exec.Command(\"bash\", \"-c\", l.command+argsStr)\n\n\t// pass through some stdin goodness\n\tcmd.Stdin = stdin\n\n\t// for those who are about to rock, I salute you.\n\tstdoutStderr, err := cmd.CombinedOutput()\n\n\tif err == nil {\n\t\t// noiiiice!\n\t\tlog.WithFields(log.Fields{\"name\": l.Name(), \"command\": l.command}).Info(\"Lambda Execution\")\n\t\treturn strings.TrimSpace(string(stdoutStderr)), nil\n\t}\n\n\t// *sigh*\n\tlog.WithFields(log.Fields{\"name\": l.Name(), \"command\": l.command}).Error(\"Lambda Execution\")\n\treturn string(stdoutStderr), errors.New(\"Error running command\")\n}","func main() {\n\n\t// Test code\n\t// p := InputParameters{\n\t// \tStackID: \"MaxEdge-ddc65b40-5d03-4827-8bf9-2957903600ca-test-2m\",\n\t// \tSourceIP: \"EC2AMAZ-5EEVEUI\",\n\t// \tSourcePort: \"5450\",\n\t// \tDestinationIP: \"10.0.4.53\",\n\t// \tDestinationPort: \"5450\",\n\t// \tPiList: []string{\"tag1\", \"tag2\", \"tag3\", \"tag4\", \"tag5\", \"tag6\", \"endTag117\"},\n\t// }\n\t//LambdaHandler(p)\n\n\tlambda.Start(LambdaHandler)\n}","func TestLambda(t *testing.T) {\n\tctx := context.Background()\n\n\tconst functionName = \"TestFunctionName\"\n\tt.Setenv(awsLambdaFunctionNameEnvVar, functionName)\n\n\t// Call Lambda Resource detector to detect resources\n\tlambdaDetector, err := NewDetector(processortest.NewNopCreateSettings(), CreateDefaultConfig())\n\trequire.NoError(t, err)\n\tres, _, err := lambdaDetector.Detect(ctx)\n\trequire.NoError(t, err)\n\trequire.NotNil(t, res)\n\n\tassert.Equal(t, map[string]interface{}{\n\t\tconventions.AttributeCloudProvider: conventions.AttributeCloudProviderAWS,\n\t\tconventions.AttributeCloudPlatform: conventions.AttributeCloudPlatformAWSLambda,\n\t\tconventions.AttributeFaaSName: functionName,\n\t}, res.Attributes().AsRaw(), \"Resource object returned is incorrect\")\n}","func resourceAwsLambdaFunctionCreate(d *schema.ResourceData, meta interface{}) error {\n\tconn := meta.(*AWSClient).lambdaconn\n\n\tfunctionName := d.Get(\"function_name\").(string)\n\treservedConcurrentExecutions := d.Get(\"reserved_concurrent_executions\").(int)\n\tiamRole := d.Get(\"role\").(string)\n\n\tlog.Printf(\"[DEBUG] Creating Lambda Function %s with role %s\", functionName, iamRole)\n\n\tfilename, hasFilename := d.GetOk(\"filename\")\n\ts3Bucket, bucketOk := d.GetOk(\"s3_bucket\")\n\ts3Key, keyOk := d.GetOk(\"s3_key\")\n\ts3ObjectVersion, versionOk := d.GetOk(\"s3_object_version\")\n\n\tif !hasFilename && !bucketOk && !keyOk && !versionOk {\n\t\treturn errors.New(\"filename or s3_* attributes must be set\")\n\t}\n\n\tvar functionCode *lambda.FunctionCode\n\tif hasFilename {\n\t\t// Grab an exclusive lock so that we're only reading one function into\n\t\t// memory at a time.\n\t\t// See https://github.com/hashicorp/terraform/issues/9364\n\t\tawsMutexKV.Lock(awsMutexLambdaKey)\n\t\tdefer awsMutexKV.Unlock(awsMutexLambdaKey)\n\t\tfile, err := loadFileContent(filename.(string))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Unable to load %q: %s\", filename.(string), err)\n\t\t}\n\t\tfunctionCode = &lambda.FunctionCode{\n\t\t\tZipFile: file,\n\t\t}\n\t} else {\n\t\tif !bucketOk || !keyOk {\n\t\t\treturn errors.New(\"s3_bucket and s3_key must all be set while using S3 code source\")\n\t\t}\n\t\tfunctionCode = &lambda.FunctionCode{\n\t\t\tS3Bucket: aws.String(s3Bucket.(string)),\n\t\t\tS3Key: aws.String(s3Key.(string)),\n\t\t}\n\t\tif versionOk {\n\t\t\tfunctionCode.S3ObjectVersion = aws.String(s3ObjectVersion.(string))\n\t\t}\n\t}\n\n\tparams := &lambda.CreateFunctionInput{\n\t\tCode: functionCode,\n\t\tDescription: aws.String(d.Get(\"description\").(string)),\n\t\tFunctionName: aws.String(functionName),\n\t\tHandler: aws.String(d.Get(\"handler\").(string)),\n\t\tMemorySize: aws.Int64(int64(d.Get(\"memory_size\").(int))),\n\t\tRole: aws.String(iamRole),\n\t\tRuntime: aws.String(d.Get(\"runtime\").(string)),\n\t\tTimeout: aws.Int64(int64(d.Get(\"timeout\").(int))),\n\t\tPublish: aws.Bool(d.Get(\"publish\").(bool)),\n\t}\n\n\tif v, ok := d.GetOk(\"dead_letter_config\"); ok {\n\t\tdlcMaps := v.([]interface{})\n\t\tif len(dlcMaps) == 1 { // Schema guarantees either 0 or 1\n\t\t\t// Prevent panic on nil dead_letter_config. See GH-14961\n\t\t\tif dlcMaps[0] == nil {\n\t\t\t\treturn fmt.Errorf(\"Nil dead_letter_config supplied for function: %s\", functionName)\n\t\t\t}\n\t\t\tdlcMap := dlcMaps[0].(map[string]interface{})\n\t\t\tparams.DeadLetterConfig = &lambda.DeadLetterConfig{\n\t\t\t\tTargetArn: aws.String(dlcMap[\"target_arn\"].(string)),\n\t\t\t}\n\t\t}\n\t}\n\n\tif v, ok := d.GetOk(\"vpc_config\"); ok {\n\n\t\tconfigs := v.([]interface{})\n\t\tconfig, ok := configs[0].(map[string]interface{})\n\n\t\tif !ok {\n\t\t\treturn errors.New(\"vpc_config is \")\n\t\t}\n\n\t\tif config != nil {\n\t\t\tvar subnetIds []*string\n\t\t\tfor _, id := range config[\"subnet_ids\"].(*schema.Set).List() {\n\t\t\t\tsubnetIds = append(subnetIds, aws.String(id.(string)))\n\t\t\t}\n\n\t\t\tvar securityGroupIds []*string\n\t\t\tfor _, id := range config[\"security_group_ids\"].(*schema.Set).List() {\n\t\t\t\tsecurityGroupIds = append(securityGroupIds, aws.String(id.(string)))\n\t\t\t}\n\n\t\t\tparams.VpcConfig = &lambda.VpcConfig{\n\t\t\t\tSubnetIds: subnetIds,\n\t\t\t\tSecurityGroupIds: securityGroupIds,\n\t\t\t}\n\t\t}\n\t}\n\n\tif v, ok := d.GetOk(\"tracing_config\"); ok {\n\t\ttracingConfig := v.([]interface{})\n\t\ttracing := tracingConfig[0].(map[string]interface{})\n\t\tparams.TracingConfig = &lambda.TracingConfig{\n\t\t\tMode: aws.String(tracing[\"mode\"].(string)),\n\t\t}\n\t}\n\n\tif v, ok := d.GetOk(\"environment\"); ok {\n\t\tenvironments := v.([]interface{})\n\t\tenvironment, ok := environments[0].(map[string]interface{})\n\t\tif !ok {\n\t\t\treturn errors.New(\"At least one field is expected inside environment\")\n\t\t}\n\n\t\tif environmentVariables, ok := environment[\"variables\"]; ok {\n\t\t\tvariables := readEnvironmentVariables(environmentVariables.(map[string]interface{}))\n\n\t\t\tparams.Environment = &lambda.Environment{\n\t\t\t\tVariables: aws.StringMap(variables),\n\t\t\t}\n\t\t}\n\t}\n\n\tif v, ok := d.GetOk(\"kms_key_arn\"); ok {\n\t\tparams.KMSKeyArn = aws.String(v.(string))\n\t}\n\n\tif v, exists := d.GetOk(\"tags\"); exists {\n\t\tparams.Tags = tagsFromMapGeneric(v.(map[string]interface{}))\n\t}\n\n\t// IAM profiles can take ~10 seconds to propagate in AWS:\n\t// http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#launch-instance-with-role-console\n\t// Error creating Lambda function: InvalidParameterValueException: The role defined for the task cannot be assumed by Lambda.\n\terr := resource.Retry(10*time.Minute, func() *resource.RetryError {\n\t\t_, err := conn.CreateFunction(params)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"[DEBUG] Error creating Lambda Function: %s\", err)\n\n\t\t\tif isAWSErr(err, \"InvalidParameterValueException\", \"The role defined for the function cannot be assumed by Lambda\") {\n\t\t\t\tlog.Printf(\"[DEBUG] Received %s, retrying CreateFunction\", err)\n\t\t\t\treturn resource.RetryableError(err)\n\t\t\t}\n\t\t\tif isAWSErr(err, \"InvalidParameterValueException\", \"The provided execution role does not have permissions\") {\n\t\t\t\tlog.Printf(\"[DEBUG] Received %s, retrying CreateFunction\", err)\n\t\t\t\treturn resource.RetryableError(err)\n\t\t\t}\n\t\t\tif isAWSErr(err, \"InvalidParameterValueException\", \"Your request has been throttled by EC2\") {\n\t\t\t\tlog.Printf(\"[DEBUG] Received %s, retrying CreateFunction\", err)\n\t\t\t\treturn resource.RetryableError(err)\n\t\t\t}\n\n\t\t\treturn resource.NonRetryableError(err)\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error creating Lambda function: %s\", err)\n\t}\n\n\tif reservedConcurrentExecutions > 0 {\n\n\t\tlog.Printf(\"[DEBUG] Setting Concurrency to %d for the Lambda Function %s\", reservedConcurrentExecutions, functionName)\n\n\t\tconcurrencyParams := &lambda.PutFunctionConcurrencyInput{\n\t\t\tFunctionName: aws.String(functionName),\n\t\t\tReservedConcurrentExecutions: aws.Int64(int64(reservedConcurrentExecutions)),\n\t\t}\n\n\t\t_, err := conn.PutFunctionConcurrency(concurrencyParams)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Error setting concurrency for Lambda %s: %s\", functionName, err)\n\t\t}\n\t}\n\n\td.SetId(d.Get(\"function_name\").(string))\n\n\treturn resourceAwsLambdaFunctionRead(d, meta)\n}","func (c *Client) NewCodeLambdaRequest(ctx context.Context, path string) (*http.Request, error) {\n\tscheme := c.Scheme\n\tif scheme == \"\" {\n\t\tscheme = \"http\"\n\t}\n\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}","func execNewFunc(_ int, p *gop.Context) {\n\targs := p.GetArgs(4)\n\tret := types.NewFunc(token.Pos(args[0].(int)), args[1].(*types.Package), args[2].(string), args[3].(*types.Signature))\n\tp.Ret(4, ret)\n}","func CreateLambdaPath() string {\n\n\treturn fmt.Sprintf(\"/p7/lambdas\")\n}","func NewCustomExecutor(commandMap stringmap.StringMap) *CustomExecutor {\n\treturn &CustomExecutor{commandMap: commandMap}\n}","func main() {\n\tlambda.Start(wflambda.Wrapper(handler))\n}","func main() {\n\tlambda.Start(wflambda.Wrapper(handler))\n}","func main() {\n\tlambda.Start(wflambda.Wrapper(handler))\n}","func main() {\n\t/* Run shellscript: `$ sh create-lambda.sh` for docker deploy */\n\tlambda.Start(HandleRequest)\n\t// HandleRequest() // \ttesting:\n}","func (c *Client) NewRunLambdaRequest(ctx context.Context, path string) (*http.Request, error) {\n\tscheme := c.Scheme\n\tif scheme == \"\" {\n\t\tscheme = \"http\"\n\t}\n\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}","func NewAdd(f func(string, string) (proto.Message, error)) *cobra.Command {\n\tvar (\n\t\trole string\n\t\tuser string\n\t)\n\n\tcmd := template.NewArg0Proto(\"add\", \"Add a new role binding\", func(cmd *cobra.Command) (proto.Message, error) {\n\t\treturn f(role, user)\n\t})\n\n\tcmd.Flags().StringVar(&role, \"role\", \"\", \"role name\")\n\tcmd.Flags().StringVar(&user, \"user\", \"\", \"user name\")\n\n\treturn cmd\n}","func main() {\n\n\tlambda.Start(LambdaHandler)\n}","func NewMessageFromLambda(content []byte, origin *Origin, status string, utcTime time.Time, ARN, reqID string, ingestionTimestamp int64) *Message {\n\treturn &Message{\n\t\tContent: content,\n\t\tOrigin: origin,\n\t\tStatus: status,\n\t\tIngestionTimestamp: ingestionTimestamp,\n\t\tServerlessExtra: ServerlessExtra{\n\t\t\tTimestamp: utcTime,\n\t\t\tLambda: &Lambda{\n\t\t\t\tARN: ARN,\n\t\t\t\tRequestID: reqID,\n\t\t\t},\n\t\t},\n\t}\n}","func (machine *Dishwasher) RunCustomCommand(custom string) {\r\n machine.Append(func() (string, error) {\r\n var output string = \"\"\r\n var oops error = nil\r\n\r\n custom = strings.TrimSpace(custom)\r\n if custom[len(custom)-1] == '$' {\r\n go RunCommand(custom)\r\n } else {\r\n output, oops = RunCommand(custom)\r\n machine.SideEffect(output, oops)\r\n }\r\n\r\n return output, oops\r\n })\r\n}","func (t *LambdaFactory) New(config *trigger.Config) (trigger.Trigger, error) {\n\n\tif singleton == nil {\n\t\tsingleton = &LambdaTrigger{}\n\t\treturn singleton, nil\n\t}\n\n\tlog.RootLogger().Warn(\"Only one lambda trigger instance can be instantiated\")\n\n\treturn nil, nil\n}","func NewLambdaAlias(properties LambdaAliasProperties, deps ...interface{}) LambdaAlias {\n\treturn LambdaAlias{\n\t\tType: \"AWS::Lambda::Alias\",\n\t\tProperties: properties,\n\t\tDependsOn: deps,\n\t}\n}","func (c *Client) CodeLambda(ctx context.Context, path string) (*http.Response, error) {\n\treq, err := c.NewCodeLambdaRequest(ctx, path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn c.Client.Do(ctx, req)\n}","func LambdaApplication_FromLambdaApplicationName(scope constructs.Construct, id *string, lambdaApplicationName *string) ILambdaApplication {\n\t_init_.Initialize()\n\n\tvar returns ILambdaApplication\n\n\t_jsii_.StaticInvoke(\n\t\t\"monocdk.aws_codedeploy.LambdaApplication\",\n\t\t\"fromLambdaApplicationName\",\n\t\t[]interface{}{scope, id, lambdaApplicationName},\n\t\t&returns,\n\t)\n\n\treturn returns\n}","func (a *QueryLambdasApiService) CreateQueryLambdaExecute(r ApiCreateQueryLambdaRequest) (*QueryLambdaVersionResponse, *http.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = http.MethodPost\n\t\tlocalVarPostBody interface{}\n\t\tformFiles []formFile\n\t\tlocalVarReturnValue *QueryLambdaVersionResponse\n\t)\n\n\tlocalBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, \"QueryLambdasApiService.CreateQueryLambda\")\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/v1/orgs/self/ws/{workspace}/lambdas\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"workspace\"+\"}\", url.PathEscape(parameterValueToString(r.workspace, \"workspace\")), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\tif r.body == nil {\n\t\treturn localVarReturnValue, nil, reportError(\"body is required and must be specified\")\n\t}\n\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{\"application/json\"}\n\n\t// set Content-Type header\n\tlocalVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)\n\tif localVarHTTPContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHTTPContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHTTPHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\n\t// body params\n\tlocalVarPostBody = r.body\n\treq, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(req)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := io.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tlocalVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))\n\tif err != nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tif localVarHTTPResponse.StatusCode >= 300 {\n\t\tnewErr := &GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHTTPResponse.Status,\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 400 {\n\t\t\tvar v ErrorModel\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\t\t\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\n\t\t\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 401 {\n\t\t\tvar v ErrorModel\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\t\t\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\n\t\t\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 403 {\n\t\t\tvar v ErrorModel\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\t\t\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\n\t\t\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 404 {\n\t\t\tvar v ErrorModel\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\t\t\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\n\t\t\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 405 {\n\t\t\tvar v ErrorModel\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\t\t\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\n\t\t\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 406 {\n\t\t\tvar v ErrorModel\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\t\t\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\n\t\t\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 408 {\n\t\t\tvar v ErrorModel\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\t\t\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\n\t\t\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 409 {\n\t\t\tvar v ErrorModel\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\t\t\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\n\t\t\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 415 {\n\t\t\tvar v ErrorModel\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\t\t\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\n\t\t\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 429 {\n\t\t\tvar v ErrorModel\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\t\t\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\n\t\t\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 500 {\n\t\t\tvar v ErrorModel\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\t\t\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\n\t\t\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 501 {\n\t\t\tvar v ErrorModel\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\t\t\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\n\t\t\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 502 {\n\t\t\tvar v ErrorModel\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\t\t\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\n\t\t\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 503 {\n\t\t\tvar v ErrorModel\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\t\t\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\n\t\t\t\t\tnewErr.model = v\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\tif err != nil {\n\t\tnewErr := &GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: err.Error(),\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHTTPResponse, nil\n}","func createNewNodeJSProxyEntry(lambdaInfo *LambdaAWSInfo, logger *logrus.Logger) string {\n\tlogger.WithFields(logrus.Fields{\n\t\t\"FunctionName\": lambdaInfo.lambdaFunctionName(),\n\t\t\"ScriptName\": lambdaInfo.scriptExportHandlerName(),\n\t}).Info(\"Registering Sparta JS function\")\n\n\t// We do know the CF resource name here - could write this into\n\t// index.js and expose a GET localhost:9000/lambdaMetadata\n\t// which wraps up DescribeStackResource for the running\n\t// lambda function\n\tprimaryEntry := fmt.Sprintf(\"exports[\\\"%s\\\"] = createForwarder(\\\"/%s\\\");\\n\",\n\t\tlambdaInfo.scriptExportHandlerName(),\n\t\tlambdaInfo.lambdaFunctionName())\n\treturn primaryEntry\n}","func (s *BaseBundListener) EnterLambda_term(ctx *Lambda_termContext) {}","func (l *LambdaClient) createFunction(function *FunctionConfig, code []byte) error {\n\tfuncCode := &lambda.FunctionCode{\n\t\tZipFile: code,\n\t}\n\n\tcreateArgs := &lambda.CreateFunctionInput{\n\t\tCode: funcCode,\n\t\tFunctionName: aws.String(function.Name),\n\t\tHandler: aws.String(\"main\"),\n\t\tRuntime: aws.String(lambda.RuntimeGo1X),\n\t\tRole: aws.String(function.RoleARN),\n\t\tTimeout: aws.Int64(function.Timeout),\n\t\tMemorySize: aws.Int64(function.MemorySize),\n\t}\n\n\t_, err := l.Client.CreateFunction(createArgs)\n\treturn err\n}","func NewCustom(fieldName string, fullPath bool) logrus.Hook {\n\treturn &customCallerHook{fieldName: fieldName, fullPath: fullPath}\n}","func (l *CustomLambda) Name() string {\n\treturn l.name\n}","func lambdaHandler(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {\n\t// Validate RPC request\n\treq := json.GetRPCRequestFromJSON(request.Body)\n\tif method := request.QueryStringParameters[ParamFuncName]; method != \"\" {\n\t\treq.Method = method\n\t} else if method := request.PathParameters[ParamFuncName]; method != \"\" {\n\t\treq.Method = method\n\t}\n\n\trespBody, statusCode := handler(req)\n\treturn events.APIGatewayProxyResponse{Headers: lambdaHeaders, Body: respBody, StatusCode: statusCode}, nil\n}","func main() {\n\tlambda.Start(handleRequest)\n}","func createCommand(t *runner.Task, actionFunc func(*cli.Context) error) *cli.Command {\n\tcommand := &cli.Command{\n\t\tName: t.Name,\n\t\tUsage: strings.TrimSpace(t.Usage),\n\t\tDescription: strings.TrimSpace(t.Description),\n\t\tAction: actionFunc,\n\t}\n\n\tfor _, arg := range t.Args {\n\t\tcommand.ArgsUsage += fmt.Sprintf(\"<%s> \", arg.Name)\n\t}\n\n\tcommand.CustomHelpTemplate = createCommandHelp(t)\n\n\treturn command\n}","func execNewNamed(_ int, p *gop.Context) {\n\targs := p.GetArgs(3)\n\tret := types.NewNamed(args[0].(*types.TypeName), args[1].(types.Type), args[2].([]*types.Func))\n\tp.Ret(3, ret)\n}","func (c *Client) NewDeleteLambdaRequest(ctx context.Context, path string) (*http.Request, error) {\n\tscheme := c.Scheme\n\tif scheme == \"\" {\n\t\tscheme = \"http\"\n\t}\n\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\n\treq, err := http.NewRequest(\"DELETE\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}","func createIAMLambdaRole(ctx *pulumi.Context, name string) (*iam.Role, error) {\n\troleName := fmt.Sprintf(\"%s-task-exec-role\", name)\n\n\trole, err := iam.NewRole(ctx, roleName, &iam.RoleArgs{\n\t\tAssumeRolePolicy: pulumi.String(`{\n\t\t\t\"Version\": \"2012-10-17\",\n\t\t\t\"Statement\": [{\n\t\t\t\t\"Sid\": \"\",\n\t\t\t\t\"Effect\": \"Allow\",\n\t\t\t\t\"Principal\": {\n\t\t\t\t\t\"Service\": \"lambda.amazonaws.com\"\n\t\t\t\t},\n\t\t\t\t\"Action\": \"sts:AssumeRole\"\n\t\t\t}]\n\t\t}`),\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error create IAM role for %s: %v\", name, err)\n\t}\n\n\treturn role, nil\n}","func (a *QueryLambdasApiService) CreateQueryLambda(ctx context.Context, workspace string) ApiCreateQueryLambdaRequest {\n\treturn ApiCreateQueryLambdaRequest{\n\t\tApiService: a,\n\t\tctx: ctx,\n\t\tworkspace: workspace,\n\t}\n}","func GenerateNewLambdaRoleName(region, name *string) string {\n\treturn fmt.Sprintf(\"%s-%s-%s\", constants.CommonNamePrefix, *name, *region)\n}","func new_(e interface{}) func() Event {\n\ttyp := reflect.TypeOf(e)\n\treturn func() Event {\n\t\treturn reflect.New(typ).Interface().(Event)\n\t}\n}","func newLogClosure(c func() string) logClosure {\n\treturn logClosure(c)\n}","func main() {\n // Initialize a session\n sess := session.Must(session.NewSessionWithOptions(session.Options{\n SharedConfigState: session.SharedConfigEnable,\n }))\n\n // Create Lambda service client\n svc := lambda.New(sess, &aws.Config{Region: aws.String(\"us-west-2\")})\n\n result, err := svc.ListFunctions(nil)\n if err != nil {\n fmt.Println(\"Cannot list functions\")\n os.Exit(0)\n }\n\n fmt.Println(\"Functions:\")\n\n for _, f := range result.Functions {\n fmt.Println(\"Name: \" + aws.StringValue(f.FunctionName))\n fmt.Println(\"Description: \" + aws.StringValue(f.Description))\n fmt.Println(\"\")\n }\n}","func newPipelineCommandHandler(repository eventstore.Repository) *pipelineCommandHandler {\n\treturn &pipelineCommandHandler{\n\t\trepository: repository,\n\t}\n}","func NewExternalCmd(name string) Callable {\n\treturn externalCmd{name}\n}","func NewProfile(name string) {\n\tpath := name\n\tif !IsLambdaDir() {\n\t\tpath = \"lambdas/\" + name + \".json\"\n\t}\n\tf, err := os.Create(path)\n\tif err != nil {\n\t\tfmt.Println(\"ERROR Creating file \", err)\n\t\treturn\n\t}\n\tdefer f.Close()\n\n\tl := Lambda{\n\t\tName: name,\n\t\tTriggers: []string{\"api\", \"event\", \"invoke\", \"sns\", \"sqs\"},\n\t\tStages: []string{\"dev\", \"qa\", \"uat\", \"prod\"},\n\t}\n\tprfl := Folder{\n\t\tLambda: l,\n\t}\n\n\tjs, err := json.Marshal(prfl)\n\tif err != nil {\n\t\tfmt.Println(\"ERROR Marshalling \", err)\n\t\treturn\n\t}\n\n\t_, err = f.Write(pretty.Pretty(js))\n\tif err != nil {\n\t\tfmt.Println(\"ERROR Writing file \", err)\n\t}\n}","func CreatePrintFunction(custom string) Printer {\n\treturn func(s string) {\n\t\tfmt.Println(s + custom)\n\t}\n}","func (c *Client) NewShowLambdaRequest(ctx context.Context, path string) (*http.Request, error) {\n\tscheme := c.Scheme\n\tif scheme == \"\" {\n\t\tscheme = \"http\"\n\t}\n\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}","func NewFunctionCreateCommand(c cli.Interface) *cobra.Command {\n\treturn &cobra.Command{\n\t\tUse: \"create FUNCTION IMAGE\",\n\t\tShort: \"Create function\",\n\t\tPreRunE: cli.ExactArgs(2),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\topts := &createFunctionOpts{}\n\t\t\topts.name = args[0]\n\t\t\topts.image = args[1]\n\t\t\treturn createFunction(c, opts)\n\t\t},\n\t}\n}","func createPackageStep() workflowStep {\n\n\treturn func(ctx *workflowContext) (workflowStep, error) {\n\t\t// Compile the source to linux...\n\t\tsanitizedServiceName := sanitizedName(ctx.serviceName)\n\t\texecutableOutput := fmt.Sprintf(\"%s.lambda.amd64\", sanitizedServiceName)\n\t\tcmd := exec.Command(\"go\", \"build\", \"-o\", executableOutput, \"-tags\", \"lambdabinary\", \".\")\n\t\tctx.logger.Debug(\"Building application binary: \", cmd.Args)\n\t\tcmd.Env = os.Environ()\n\t\tcmd.Env = append(cmd.Env, \"GOOS=linux\", \"GOARCH=amd64\", \"GO15VENDOREXPERIMENT=1\")\n\t\tctx.logger.Info(\"Compiling binary: \", executableOutput)\n\n\t\toutputWriter := ctx.logger.Writer()\n\t\tdefer outputWriter.Close()\n\t\tcmd.Stdout = outputWriter\n\t\tcmd.Stderr = outputWriter\n\n\t\terr := cmd.Run()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer os.Remove(executableOutput)\n\n\t\t// Binary size\n\t\tstat, err := os.Stat(executableOutput)\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"Failed to stat build output\")\n\t\t}\n\t\t// Minimum hello world size is 2.3M\n\t\t// Minimum HTTP hello world is 6.3M\n\t\tctx.logger.Info(\"Executable binary size (MB): \", stat.Size()/(1024*1024))\n\n\t\tworkingDir, err := os.Getwd()\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"Failed to retrieve working directory\")\n\t\t}\n\t\ttmpFile, err := ioutil.TempFile(workingDir, sanitizedServiceName)\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"Failed to create temporary file\")\n\t\t}\n\n\t\tdefer func() {\n\t\t\ttmpFile.Close()\n\t\t}()\n\n\t\tctx.logger.Info(\"Creating ZIP archive for upload: \", tmpFile.Name())\n\t\tlambdaArchive := zip.NewWriter(tmpFile)\n\t\tdefer lambdaArchive.Close()\n\n\t\t// File info for the binary executable\n\t\tbinaryWriter, err := lambdaArchive.Create(filepath.Base(executableOutput))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Failed to create ZIP entry: %s\", filepath.Base(executableOutput))\n\t\t}\n\t\treader, err := os.Open(executableOutput)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Failed to open file: %s\", executableOutput)\n\t\t}\n\t\tdefer reader.Close()\n\t\tio.Copy(binaryWriter, reader)\n\n\t\t// Add the string literal adapter, which requires us to add exported\n\t\t// functions to the end of index.js\n\t\tnodeJSWriter, err := lambdaArchive.Create(\"index.js\")\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"Failed to create ZIP entry: index.js\")\n\t\t}\n\t\tnodeJSSource := _escFSMustString(false, \"/resources/index.js\")\n\t\tnodeJSSource += \"\\n// DO NOT EDIT - CONTENT UNTIL EOF IS AUTOMATICALLY GENERATED\\n\"\n\t\tfor _, eachLambda := range ctx.lambdaAWSInfos {\n\t\t\tnodeJSSource += createNewNodeJSProxyEntry(eachLambda, ctx.logger)\n\t\t}\n\t\t// Finally, replace\n\t\t// \tSPARTA_BINARY_NAME = 'Sparta.lambda.amd64';\n\t\t// with the service binary name\n\t\tnodeJSSource += fmt.Sprintf(\"SPARTA_BINARY_NAME='%s';\\n\", executableOutput)\n\t\tctx.logger.Debug(\"Dynamically generated NodeJS adapter:\\n\", nodeJSSource)\n\t\tstringReader := strings.NewReader(nodeJSSource)\n\t\tio.Copy(nodeJSWriter, stringReader)\n\n\t\t// Also embed the custom resource creation scripts\n\t\tfor _, eachName := range customResourceScripts {\n\t\t\tresourceName := fmt.Sprintf(\"/resources/provision/%s\", eachName)\n\t\t\tresourceContent := _escFSMustString(false, resourceName)\n\t\t\tstringReader := strings.NewReader(resourceContent)\n\t\t\tembedWriter, err := lambdaArchive.Create(eachName)\n\t\t\tif nil != err {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tctx.logger.Info(\"Embedding CustomResource script: \", eachName)\n\t\t\tio.Copy(embedWriter, stringReader)\n\t\t}\n\n\t\t// And finally, if there is a node_modules.zip file, then include it.\n\t\tnodeModuleBytes, err := _escFSByte(false, \"/resources/provision/node_modules.zip\")\n\t\tif nil == err {\n\t\t\tnodeModuleReader, err := zip.NewReader(bytes.NewReader(nodeModuleBytes), int64(len(nodeModuleBytes)))\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tfor _, zipFile := range nodeModuleReader.File {\n\t\t\t\tembedWriter, err := lambdaArchive.Create(zipFile.Name)\n\t\t\t\tif nil != err {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tctx.logger.Debug(\"Copying node_module file: \", zipFile.Name)\n\t\t\t\tsourceReader, err := zipFile.Open()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tio.Copy(embedWriter, sourceReader)\n\t\t\t}\n\t\t} else {\n\t\t\tctx.logger.Warn(\"Failed to load /resources/provision/node_modules.zip for embedding\", err)\n\t\t}\n\t\treturn createUploadStep(tmpFile.Name()), nil\n\t}\n}","func newLogClosure(\n\tc func() string) logClosure {\n\treturn logClosure(c)\n}","func main() {\n\tf := GetFlags()\n\tif f.Test {\n\t\tif err := RunTest(f); err != nil {\n\t\t\tfmt.Println(err.Error())\n\t\t}\n\t\treturn\n\t}\n\n\tlambda.Start(HandleRequest)\n}","func CommandFunc(f func(args []string) error) flags.Commander {\n\treturn &funcCommand{fn: f}\n}","func NewLambdaFunctionMetricQuery(invocationMetricName MetricName) *awsv2CWTypes.MetricDataQuery {\n\treturn &awsv2CWTypes.MetricDataQuery{\n\t\tId: awsv2.String(strings.ToLower(string(invocationMetricName))),\n\t\tMetricStat: &awsv2CWTypes.MetricStat{\n\t\t\tPeriod: awsv2.Int32(30),\n\t\t\tStat: awsv2.String(string(awsv2CWTypes.StatisticSum)),\n\t\t\tUnit: awsv2CWTypes.StandardUnitCount,\n\t\t\tMetric: &awsv2CWTypes.Metric{\n\t\t\t\tNamespace: awsv2.String(\"AWS/Lambda\"),\n\t\t\t\tMetricName: awsv2.String(string(invocationMetricName)),\n\t\t\t\tDimensions: []awsv2CWTypes.Dimension{\n\t\t\t\t\t{\n\t\t\t\t\t\tName: awsv2.String(\"FunctionName\"),\n\t\t\t\t\t\tValue: nil,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n}","func NewTask(f func(int64)) *StdTask {\n t := new(StdTask)\n t.F = f\n return t\n}","func NewPluginCommand(cmd *cobra.Command, dockerCli *client.DockerCli) {\n}","func NewCfnCustomResource(scope constructs.Construct, id *string, props *CfnCustomResourceProps) CfnCustomResource {\n\t_init_.Initialize()\n\n\tj := jsiiProxy_CfnCustomResource{}\n\n\t_jsii_.Create(\n\t\t\"aws-cdk-lib.aws_cloudformation.CfnCustomResource\",\n\t\t[]interface{}{scope, id, props},\n\t\t&j,\n\t)\n\n\treturn &j\n}","func main() {\n\tcfg, err := config.Load()\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to load config: %v\\n\", err)\n\t}\n\n\tdb, err := database.SetUp(cfg)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to connect to database: %v\\n\", err)\n\t}\n\n\tjwtManager, err := auth.NewJWTManager(cfg.SecretKey, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create JWT manager: %v\\n\", err)\n\t}\n\n\ts := services.SetUp(db, jwtManager)\n\tr := router.SetUp(s, cfg)\n\tl = chiadapter.New(r)\n\n\tlambda.Start(lambdaHandler)\n}","func New(spec *Spec) Function {\n\tf := Function{\n\t\tspec: spec,\n\t}\n\treturn f\n}","func NewCmdCreateEventHandler(f cmdutil.Factory, out io.Writer) *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: \"handler\",\n\t\tShort: \"Create event handler\",\n\t\tRun: func(cmd *cobra.Command, args []string) {\n\t\t\tRunCreateEventHandler(f, out, cmd)\n\t\t},\n\t}\n\tcmd.Flags().StringP(\"source\", \"s\", \"\", \"File containing event handler source code\")\n\tcmd.Flags().StringP(\"frontend\", \"f\", \"\", \"Event handler frontend\")\n\tcmd.Flags().StringP(\"url\", \"u\", \"\", \"URL of event handler source code\")\n\tcmd.Flags().StringP(\"version\", \"v\", \"1.0\", \"Event handler version\")\n\tcmd.Flags().StringP(\"dependencies-file\", \"d\", \"\", \"File containing event handler dependencies\")\n\tcmd.Flags().StringP(\"dependencies-url\", \"l\", \"\", \"URL of event handler source dependencies\")\n\n\treturn cmd\n}","func myPrintFunction(custom string) myPrintType{\nreturn func(s string){\nfmt.Println(s +custom)\n}\n}","func spartaCustomResourceForwarder(event *json.RawMessage,\n\tcontext *LambdaContext,\n\tw http.ResponseWriter,\n\tlogger *logrus.Logger) {\n\n\tvar rawProps map[string]interface{}\n\tjson.Unmarshal([]byte(*event), &rawProps)\n\n\tvar lambdaEvent cloudformationresources.CloudFormationLambdaEvent\n\tjsonErr := json.Unmarshal([]byte(*event), &lambdaEvent)\n\tif jsonErr != nil {\n\t\tlogger.WithFields(logrus.Fields{\n\t\t\t\"RawEvent\": rawProps,\n\t\t\t\"UnmarshalError\": jsonErr,\n\t\t}).Warn(\"Raw event data\")\n\t\thttp.Error(w, jsonErr.Error(), http.StatusInternalServerError)\n\t}\n\n\tlogger.WithFields(logrus.Fields{\n\t\t\"LambdaEvent\": lambdaEvent,\n\t}).Debug(\"CloudFormation Lambda event\")\n\n\t// Setup the request and send it off\n\tcustomResourceRequest := &cloudformationresources.CustomResourceRequest{}\n\tcustomResourceRequest.RequestType = lambdaEvent.RequestType\n\tcustomResourceRequest.ResponseURL = lambdaEvent.ResponseURL\n\tcustomResourceRequest.StackID = lambdaEvent.StackID\n\tcustomResourceRequest.RequestID = lambdaEvent.RequestID\n\tcustomResourceRequest.LogicalResourceID = lambdaEvent.LogicalResourceID\n\tcustomResourceRequest.PhysicalResourceID = lambdaEvent.PhysicalResourceID\n\tcustomResourceRequest.LogGroupName = context.LogGroupName\n\tcustomResourceRequest.LogStreamName = context.LogStreamName\n\tcustomResourceRequest.ResourceProperties = lambdaEvent.ResourceProperties\n\tif \"\" == customResourceRequest.PhysicalResourceID {\n\t\tcustomResourceRequest.PhysicalResourceID = fmt.Sprintf(\"LogStreamName: %s\", context.LogStreamName)\n\t}\n\n\trequestErr := cloudformationresources.Handle(customResourceRequest, logger)\n\tif requestErr != nil {\n\t\thttp.Error(w, requestErr.Error(), http.StatusInternalServerError)\n\t} else {\n\t\tfmt.Fprint(w, \"CustomResource handled: \"+lambdaEvent.LogicalResourceID)\n\t}\n}","func TestNotLambda(t *testing.T) {\n\tctx := context.Background()\n\tlambdaDetector, err := NewDetector(processortest.NewNopCreateSettings(), CreateDefaultConfig())\n\trequire.NoError(t, err)\n\tres, _, err := lambdaDetector.Detect(ctx)\n\trequire.NoError(t, err)\n\trequire.NotNil(t, res)\n\n\tassert.Equal(t, 0, res.Attributes().Len(), \"Resource object should be empty\")\n}","func NewCustomAccessPackageWorkflowExtension()(*CustomAccessPackageWorkflowExtension) {\n m := &CustomAccessPackageWorkflowExtension{\n CustomCalloutExtension: *NewCustomCalloutExtension(),\n }\n odataTypeValue := \"#microsoft.graph.customAccessPackageWorkflowExtension\"\n m.SetOdataType(&odataTypeValue)\n return m\n}","func CodeLambdaPath(lambdaID int) string {\n\tparam0 := strconv.Itoa(lambdaID)\n\n\treturn fmt.Sprintf(\"/p7/lambdas/%s/actions/code\", param0)\n}","func NewCustomParser(commandMap stringmap.StringMap) *CustomParser {\n\treturn &CustomParser{\n\t\tcommandMap: commandMap,\n\t}\n}","func CustomGenerateTagFunc(name, typ, tag string) string {\n\treturn fmt.Sprintf(\"json:\\\"%s\\\"\", tag)\n}","func LambdaHandler(functionName string,\n\tlogLevel string,\n\teventJSON string,\n\tawsCredentials *credentials.Credentials) ([]byte, http.Header, error) {\n\tstartTime := time.Now()\n\n\treadableBody := bytes.NewReader([]byte(eventJSON))\n\treadbleBodyCloser := ioutil.NopCloser(readableBody)\n\t// Update the credentials\n\tmuCredentials.Lock()\n\tvalue, valueErr := awsCredentials.Get()\n\tif nil != valueErr {\n\t\tmuCredentials.Unlock()\n\t\treturn nil, nil, valueErr\n\t}\n\tpythonCredentialsValue.AccessKeyID = value.AccessKeyID\n\tpythonCredentialsValue.SecretAccessKey = value.SecretAccessKey\n\tpythonCredentialsValue.SessionToken = value.SessionToken\n\tpythonCredentialsValue.ProviderName = \"PythonCGO\"\n\tmuCredentials.Unlock()\n\n\t// Unpack the JSON request, turn it into a proto here and pass it\n\t// into the handler...\n\n\t// Update the credentials in the HTTP handler\n\t// in case we're ultimately forwarding to a custom\n\t// resource provider\n\tcgoLambdaHTTPAdapter.lambdaHTTPHandlerInstance.Credentials(pythonCredentialsValue)\n\tlogrusLevel, logrusLevelErr := logrus.ParseLevel(logLevel)\n\tif logrusLevelErr == nil {\n\t\tcgoLambdaHTTPAdapter.logger.SetLevel(logrusLevel)\n\t}\n\tcgoLambdaHTTPAdapter.logger.WithFields(logrus.Fields{\n\t\t\"Resource\": functionName,\n\t\t\"Request\": eventJSON,\n\t}).Debug(\"Making request\")\n\n\t// Make the request...\n\tresponse, header, err := makeRequest(functionName, readbleBodyCloser, int64(len(eventJSON)))\n\n\t// TODO: Consider go routine\n\tpostMetrics(awsCredentials, functionName, len(response), time.Since(startTime))\n\n\tcgoLambdaHTTPAdapter.logger.WithFields(logrus.Fields{\n\t\t\"Header\": header,\n\t\t\"Error\": err,\n\t}).Debug(\"Request response\")\n\n\treturn response, header, err\n}","func NewCustomEvent(userID, sessionID, context string) CustomEvent {\n\treturn CustomEvent{\n\t\tEventMeta: logger.NewEventMeta(logger.Flag(\"custom_event\")),\n\t\tUserID: userID,\n\t\tSessionID: sessionID,\n\t\tContext: context,\n\t}\n}","func NewCommandFromPayload(contract string, payload []byte) (domain.Command, error) {\n\tswitch contract {\n\tcase RegisterUserWithEmail:\n\t\tcommand := RegisterWithEmail{}\n\t\tif err := json.Unmarshal(payload, &command); err != nil {\n\t\t\treturn command, apperrors.Wrap(err)\n\t\t}\n\n\t\treturn command, nil\n\tcase RegisterUserWithGoogle:\n\t\tcommand := RegisterWithGoogle{}\n\t\tif err := json.Unmarshal(payload, &command); err != nil {\n\t\t\treturn command, apperrors.Wrap(err)\n\t\t}\n\n\t\treturn command, nil\n\tcase RegisterUserWithFacebook:\n\t\tcommand := RegisterWithFacebook{}\n\t\tif err := json.Unmarshal(payload, &command); err != nil {\n\t\t\treturn command, apperrors.Wrap(err)\n\t\t}\n\n\t\treturn command, nil\n\tcase ChangeUserEmailAddress:\n\t\tcommand := ChangeEmailAddress{}\n\t\tif err := json.Unmarshal(payload, &command); err != nil {\n\t\t\treturn command, apperrors.Wrap(err)\n\t\t}\n\n\t\treturn command, nil\n\tdefault:\n\t\treturn nil, apperrors.Wrap(fmt.Errorf(\"invalid command contract: %s\", contract))\n\t}\n}","func NewCustomServer(c func() Codec, listener net.Listener) *Server {\n\treturn &Server{\n\t\tcodec: c,\n\t\tlistener: &onceCloseListener{Listener: listener},\n\t}\n}","func HandleLambdaEvent(event MyEvent) (MyResponse, error) {\n\tfmt.Printf(\"event argument: %#v\", event)\n\treturn MyResponse{Message: fmt.Sprintf(\"%s is %d years old!\", event.Name, event.Age)}, nil\n}","func LambdaHandler(user string) (ResponseData, error) {\n\n\tvar res ResponseData\n\tvar accessSecret secretParameters\n\n\t// Connection information\n\tsess := session.Must(session.NewSessionWithOptions(session.Options{\n\t\tSharedConfigState: session.SharedConfigEnable,\n\t}))\n\n\tvuser, e := createUser(sess, user)\n\n\tif e != nil {\n\t\tfmt.Println(e.Error())\n\t\treturn res, e\n\t}\n\n\tres.ResponseMessage = fmt.Sprintln(\"User created:\", user)\n\n\tif _, e := createAccessKey(sess, vuser); e != nil {\n\t\tfmt.Println(e.Error())\n\t\treturn res, e\n\t}\n\n\tres.ResponseMessage = fmt.Sprintln(\"Access Key created:\", accessSecret.AccessKey)\n\n\treturn res, nil\n\n}","func (c *Client) RunLambda(ctx context.Context, path string) (*http.Response, error) {\n\treq, err := c.NewRunLambdaRequest(ctx, path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn c.Client.Do(ctx, req)\n}","func New(repo eventsource.Repository, preprocessors ...Preprocessor) Dispatcher {\n\treturn dispatchFunc(func(ctx context.Context, cmd Interface) error {\n\t\tfor _, p := range preprocessors {\n\t\t\terr := p.Before(ctx, cmd)\n\t\t\tif err != nil {\n\t\t\t\treturn eventsource.NewError(err, CodePreprocessorErr, \"processor failed on command, %#v\", cmd)\n\t\t\t}\n\t\t}\n\n\t\tvar aggregate eventsource.Aggregate\n\t\tif v, ok := cmd.(Constructor); ok && v.New() {\n\t\t\taggregate = repo.New()\n\n\t\t} else {\n\t\t\taggregateID := cmd.AggregateID()\n\t\t\tv, err := repo.Load(ctx, aggregateID)\n\t\t\tif err != nil {\n\t\t\t\treturn eventsource.NewError(err, CodeEventLoadErr, \"Unable to load %v [%v]\", typeOf(repo.New()), aggregateID)\n\t\t\t}\n\t\t\taggregate = v\n\t\t}\n\n\t\thandler, ok := aggregate.(Handler)\n\t\tif !ok {\n\t\t\treturn eventsource.NewError(nil, CodeAggregateNotCommandHandler, \"%#v does not implement command.Handler\", typeOf(aggregate))\n\t\t}\n\n\t\tevents, err := handler.Apply(ctx, cmd)\n\t\tif err != nil {\n\t\t\treturn eventsource.NewError(err, CodeHandlerErr, \"Failed to apply command, %v, to aggregate, %v\", typeOf(cmd), typeOf(aggregate))\n\t\t}\n\n\t\terr = repo.Save(ctx, events...)\n\t\tif err != nil {\n\t\t\treturn eventsource.NewError(err, CodeSaveErr, \"Failed to save events for %v, %v\", typeOf(aggregate), cmd.AggregateID())\n\t\t}\n\n\t\treturn nil\n\t})\n}","func NewSDKActor(execute func(string) string) SDKActor {\n sdkActor := SDKActor{}\n sdkActor.connector = newConnector()\n sdkActor.execute = execute\n return sdkActor\n}","func addCloudformationLambdaFunctions(template *cloudformation.Template, functions map[string]cloudformation.AWSServerlessFunction) {\n\t// convert all lambda functions to serverless functions so that invoke works for them\n\tfor n, f := range template.GetAllAWSLambdaFunctionResources() {\n\t\tif _, found := functions[n]; !found {\n\t\t\tfunctions[n] = lambdaToServerless(f)\n\t\t}\n\t}\n}","func NewCreate(f func(string, string, []string) (proto.Message, error)) *cobra.Command {\n\tvar (\n\t\tdisplayName string\n\t\tpermissionIDs []string\n\t)\n\n\tcmd := template.NewArg1Proto(\"create ROLE_ID\", \"Create a new role\", func(cmd *cobra.Command, arg string) (proto.Message, error) {\n\t\tvar names []string\n\t\tfor _, p := range permissionIDs {\n\t\t\tnames = append(names, fmt.Sprintf(\"permissions/%s\", p))\n\t\t}\n\t\treturn f(arg, displayName, names)\n\t})\n\n\tcmd.Flags().StringVar(&displayName, \"display-name\", \"\", \"display name\")\n\tcmd.Flags().StringSliceVar(&permissionIDs, \"permission-ids\", nil, \"permission ids\")\n\n\treturn cmd\n}","func NewCustom(executor executor.Executor) executor.Launcher {\n\treturn New(executor, fmt.Sprintf(\"stress-ng-custom %s\", StressngCustomArguments.Value()), StressngCustomArguments.Value())\n}","func NewFunction(ctx *pulumi.Context,\n\tname string, args *FunctionArgs, opts ...pulumi.ResourceOption) (*Function, error) {\n\tif args == nil {\n\t\targs = &FunctionArgs{}\n\t}\n\n\treplaceOnChanges := pulumi.ReplaceOnChanges([]string{\n\t\t\"location\",\n\t\t\"project\",\n\t})\n\topts = append(opts, replaceOnChanges)\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource Function\n\terr := ctx.RegisterResource(\"google-native:cloudfunctions/v2:Function\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}","func toFunc(commandName string) (Command, error) {\n\tswitch strings.ToLower(commandName) {\n\tdefault:\n\t\treturn nil, errors.New(\"invalid command.\")\n\tcase \".quit\":\n\t\treturn Quit, nil\n\tcase \".kick\":\n\t\treturn KickOut, nil\n\tcase \".dm\":\n\t\treturn DM, nil\n\tcase \".list\":\n\t\treturn ListMembers, nil\n\tcase \".msg\":\n\t\treturn Message, nil\n\t}\n}","func NewLambdaClient(opt Options) *lambdaClient {\n\treturn &lambdaClient{\n\t\topt: opt,\n\t}\n}","func NewInvokeRequestWithoutParam() *InvokeRequest {\n\n return &InvokeRequest{\n JDCloudRequest: core.JDCloudRequest{\n URL: \"/regions/{regionId}/functions/{functionName}/versions/{versionName}:invoke\",\n Method: \"POST\",\n Header: nil,\n Version: \"v1\",\n },\n }\n}","func CreateLambdaCloudwatchAlarm(region string, functionName string, metricName string, namespace string, threshold float64, action string) bool {\n\tawsSession, _ := InitAwsSession(region)\n\tsvc := cloudwatch.New(awsSession)\n\tinput := &cloudwatch.PutMetricAlarmInput{\n\t\tAlarmName: aws.String(fmt.Sprintf(\"%v on %v\", metricName, functionName)),\n\t\tComparisonOperator: aws.String(cloudwatch.ComparisonOperatorGreaterThanOrEqualToThreshold),\n\t\tEvaluationPeriods: aws.Int64(1),\n\t\tMetricName: aws.String(metricName),\n\t\tNamespace: aws.String(namespace),\n\t\tPeriod: aws.Int64(60),\n\t\tStatistic: aws.String(cloudwatch.StatisticSum),\n\t\tThreshold: aws.Float64(threshold),\n\t\tActionsEnabled: aws.Bool(true),\n\t\tAlarmDescription: aws.String(fmt.Sprintf(\"%v on %v greater than %v\", metricName, functionName, threshold)),\n\n\t\tDimensions: []*cloudwatch.Dimension{\n\t\t\t{\n\t\t\t\tName: aws.String(\"FunctionName\"),\n\t\t\t\tValue: aws.String(functionName),\n\t\t\t},\n\t\t},\n\n\t\tAlarmActions: []*string{\n\t\t\taws.String(action),\n\t\t},\n\t}\n\n\t// Debug input\n\t// fmt.Println(input)\n\n\t_, err := svc.PutMetricAlarm(input)\n\tif err != nil {\n\t\tfmt.Println(\"Error\", err)\n\t\treturn false\n\t}\n\n\treturn true\n}","func lambdaToServerless(lambda cloudformation.AWSLambdaFunction) (serverless cloudformation.AWSServerlessFunction) {\n\t// serverless policies are not needed because lambdas have a role\n\tserverless.Policies = nil\n\n\t// no events are associated with the function\n\tserverless.Events = nil\n\n\t// codeUri is set to nil in order to get the code locally and not from a remote source\n\tserverless.CodeUri = nil\n\n\tserverless.FunctionName = lambda.FunctionName\n\tserverless.Description = lambda.Description\n\tserverless.Handler = lambda.Handler\n\tserverless.Timeout = lambda.Timeout\n\tserverless.KmsKeyArn = lambda.KmsKeyArn\n\tserverless.Role = lambda.Role\n\tserverless.Runtime = lambda.Runtime\n\tserverless.MemorySize = lambda.MemorySize\n\n\tif lambda.DeadLetterConfig != nil {\n\t\tdlqType := \"SQS\"\n\t\tmatch := dlqTypeEx.FindAllStringSubmatch(lambda.DeadLetterConfig.TargetArn, -1)\n\t\tif len(match) > 0 {\n\t\t\tdlqType = match[0][1]\n\t\t}\n\n\t\tserverless.DeadLetterQueue = &cloudformation.AWSServerlessFunction_DeadLetterQueue{\n\t\t\tTargetArn: lambda.DeadLetterConfig.TargetArn,\n\t\t\tType: strings.ToUpper(dlqType),\n\t\t}\n\t}\n\n\tif len(lambda.Tags) > 0 {\n\t\ttags := make(map[string]string)\n\t\tfor _, t := range lambda.Tags {\n\t\t\ttags[t.Key] = t.Value\n\t\t}\n\t\tserverless.Tags = tags\n\t}\n\n\tif lambda.TracingConfig != nil {\n\t\tserverless.Tracing = lambda.TracingConfig.Mode\n\t}\n\n\tif lambda.Environment != nil {\n\t\tserverless.Environment = &cloudformation.AWSServerlessFunction_FunctionEnvironment{\n\t\t\tVariables: lambda.Environment.Variables,\n\t\t}\n\t}\n\n\tif lambda.VpcConfig != nil {\n\t\tserverless.VpcConfig = &cloudformation.AWSServerlessFunction_VpcConfig{\n\t\t\tSecurityGroupIds: lambda.VpcConfig.SecurityGroupIds,\n\t\t\tSubnetIds: lambda.VpcConfig.SubnetIds,\n\t\t}\n\t}\n\n\treturn\n}","func newEventHandler(fn interface{}, configurators []EventConfigurator) *eventHandler {\n\te := &eventHandler{\n\t\tcallBack: reflect.ValueOf(fn),\n\t\tMutex: sync.Mutex{},\n\t}\n\t// config\n\tfor i := range configurators {\n\t\tconfigurators[i](e)\n\t}\n\treturn e\n}","func ClosureNew(f interface{}) *C.GClosure {\n\tclosure := C._g_closure_new()\n\tclosures.Lock()\n\tclosures.m[closure] = reflect.ValueOf(f)\n\tclosures.Unlock()\n\treturn closure\n}","func newSshNativeTask(host string, cmd string, opt Options) func() (interface{}, error) {\n\tstate := &sshNativeTask{\n\t\tHost: host,\n\t\tCmd: cmd,\n\t\tOpts: opt,\n\t}\n\treturn state.run\n}","func (c *Client) NewListLambdaRequest(ctx context.Context, path string) (*http.Request, error) {\n\tscheme := c.Scheme\n\tif scheme == \"\" {\n\t\tscheme = \"http\"\n\t}\n\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}","func (s *SimilarityLMJelinekMercer) Lambda(lambda float32) *SimilarityLMJelinekMercer {\n\ts.lambda = &lambda\n\treturn s\n}","func NewQueryLambdaSql(query string) *QueryLambdaSql {\n\tthis := QueryLambdaSql{}\n\tthis.Query = query\n\treturn &this\n}","func NewUrl(ctx *pulumi.Context,\n\tname string, args *UrlArgs, opts ...pulumi.ResourceOption) (*Url, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.AuthType == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'AuthType'\")\n\t}\n\tif args.TargetFunctionArn == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'TargetFunctionArn'\")\n\t}\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource Url\n\terr := ctx.RegisterResource(\"aws-native:lambda:Url\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}","func LambdaHref(lambdaID interface{}) string {\n\tparamlambdaID := strings.TrimLeftFunc(fmt.Sprintf(\"%v\", lambdaID), func(r rune) bool { return r == '/' })\n\treturn fmt.Sprintf(\"/p7/lambdas/%v\", paramlambdaID)\n}"],"string":"[\n \"func NewLambda(vs []Argument, u bool, as []Argument, e Expression, t types.Type) Lambda {\\n\\treturn Lambda{as, e, t, vs, u}\\n}\",\n \"func NewLambda(label string, t Term, body Term) Lambda {\\n\\treturn Lambda{\\n\\t\\tLabel: label,\\n\\t\\tType: t,\\n\\t\\tBody: body,\\n\\t}\\n}\",\n \"func New(cfg *config.Config) *Lambda {\\n\\n\\treturn &Lambda{\\n\\t\\tConfig: cfg,\\n\\t\\tService: service.New(cfg),\\n\\t\\tFileTransfer: filetransfer.New(cfg),\\n\\t}\\n}\",\n \"func NewCmd(o *Options) *cobra.Command {\\n\\tc := command{\\n\\t\\tCommand: cli.Command{Options: o.Options},\\n\\t\\topts: o,\\n\\t}\\n\\n\\tcmd := &cobra.Command{\\n\\t\\tUse: \\\"new-lambda\\\",\\n\\t\\tShort: \\\"New local Lambda Function\\\",\\n\\t\\tLong: `Creates a new local lambda function setup to start development`,\\n\\t\\tRunE: func(_ *cobra.Command, args []string) error { return c.Run(args) },\\n\\t}\\n\\n\\tcmd.Args = cobra.ExactArgs(1)\\n\\n\\tcmd.Flags().StringVarP(&o.Namespace, \\\"namespace\\\", \\\"n\\\", \\\"default\\\", \\\"Namespace to bind\\\")\\n\\tcmd.Flags().BoolVar(&o.Expose, \\\"expose\\\", false, \\\"Create the namespace if not existing\\\")\\n\\tcmd.Flags().StringVar(&o.ClusterDomain, \\\"cluster-domain\\\", \\\"\\\", \\\"Cluster Domain of your cluster\\\")\\n\\n\\treturn cmd\\n}\",\n \"func createLambdaFunction(ctx *pulumi.Context, role *iam.Role, logPolicy *iam.RolePolicy, route APIRoute, method string) (*lambda.Function, error) {\\n\\t// Determine the language of the function.\\n\\tlambdaFilePath := path.Join(route.PathToFiles, method)\\n\\tlambdaLanguage, err := detectLambdaLanguage(lambdaFilePath)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\t// Determine the Lambda runtime to use.\\n\\tvar lambdaRuntime string\\n\\tvar handlerName string\\n\\tvar handlerZipFile string\\n\\tswitch lambdaLanguage {\\n\\tcase \\\"typescript\\\":\\n\\t\\tlambdaRuntime = \\\"nodejs12.x\\\"\\n\\t\\thandlerName = fmt.Sprintf(\\\"%s-%s-handler.%sHandler\\\", route.Name, method, method)\\n\\t\\thandlerZipFile, err = PackageTypeScriptLambda(tmpDirName, route.Name, method)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t\\tbreak\\n\\tcase \\\"go\\\":\\n\\t\\tlambdaRuntime = \\\"go1.x\\\"\\n\\t\\thandlerName = fmt.Sprintf(\\\"%s-%s-handler\\\", route.Name, method)\\n\\t\\thandlerZipFile, err = PackageGoLambda(tmpDirName, route.Name, method)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\tcase \\\"dotnet\\\":\\n\\t\\tlambdaRuntime = \\\"dotnetcore3.1\\\"\\n\\t\\thandlerName = fmt.Sprintf(\\\"app::app.Functions::%s\\\", utils.DashCaseToSentenceCase(method))\\n\\t\\thandlerZipFile, err = PackageDotNetLambda(tmpDirName, route.Name, method)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\tdefault:\\n\\t\\treturn nil, fmt.Errorf(\\\"Unsupported runtime detected.\\\")\\n\\t}\\n\\n\\tcurrentWorkingDirectory, err := os.Getwd()\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\thandlerFileName := path.Join(currentWorkingDirectory, handlerZipFile)\\n\\targs := &lambda.FunctionArgs{\\n\\t\\tHandler: pulumi.String(handlerName),\\n\\t\\tRole: role.Arn,\\n\\t\\tRuntime: pulumi.String(lambdaRuntime),\\n\\t\\tCode: pulumi.NewFileArchive(handlerFileName),\\n\\t}\\n\\n\\t// Create the lambda using the args.\\n\\tfunction, err := lambda.NewFunction(\\n\\t\\tctx,\\n\\t\\tfmt.Sprintf(\\\"%s-%s-lambda-function\\\", route.Name, method),\\n\\t\\targs,\\n\\t\\tpulumi.DependsOn([]pulumi.Resource{logPolicy}),\\n\\t)\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"Error updating lambda for file [%s]: %v\\\", handlerFileName, err)\\n\\t}\\n\\n\\treturn function, nil\\n}\",\n \"func NewLambdaFromJSON(json jsoniter.Any) (*Lambda, error) {\\n\\tif json.Get(\\\"type\\\").ToUint() != TypeLambda {\\n\\t\\treturn nil, ErrInvalidJSON\\n\\t}\\n\\n\\tvar jsonParameters []jsoniter.Any\\n\\tjson.Get(\\\"parameters\\\").ToVal(&jsonParameters)\\n\\n\\tparameters := make([]*ID, len(jsonParameters))\\n\\tfor i, json := range jsonParameters {\\n\\t\\tp, err := NewIDFromJSON(json)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t\\tparameters[i] = p\\n\\t}\\n\\n\\texpression, err := NewExpressionFromJSON(json.Get(\\\"expression\\\"))\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\treturn &Lambda{\\n\\t\\tParameters: parameters,\\n\\t\\tExpression: expression,\\n\\t}, nil\\n}\",\n \"func New(h HandlerFunc) lambda.Handler {\\n\\treturn NewWithConfig(Config{}, h)\\n}\",\n \"func (c *Client) NewCreateLambdaRequest(ctx context.Context, path string, payload *LambdaPayload, contentType string) (*http.Request, error) {\\n\\tvar body bytes.Buffer\\n\\tif contentType == \\\"\\\" {\\n\\t\\tcontentType = \\\"*/*\\\" // Use default encoder\\n\\t}\\n\\terr := c.Encoder.Encode(payload, &body, contentType)\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"failed to encode body: %s\\\", err)\\n\\t}\\n\\tscheme := c.Scheme\\n\\tif scheme == \\\"\\\" {\\n\\t\\tscheme = \\\"http\\\"\\n\\t}\\n\\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\\n\\treq, err := http.NewRequest(\\\"POST\\\", u.String(), &body)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\theader := req.Header\\n\\tif contentType == \\\"*/*\\\" {\\n\\t\\theader.Set(\\\"Content-Type\\\", \\\"application/json\\\")\\n\\t} else {\\n\\t\\theader.Set(\\\"Content-Type\\\", contentType)\\n\\t}\\n\\treturn req, nil\\n}\",\n \"func main() {\\n\\tlambda.Start(handler)\\n}\",\n \"func main() {\\n\\tlambda.Start(handler)\\n}\",\n \"func createNewPythonProxyEntry(lambdaInfo *LambdaAWSInfo, logger *logrus.Logger) string {\\n\\tlogger.WithFields(logrus.Fields{\\n\\t\\t\\\"FunctionName\\\": lambdaInfo.lambdaFunctionName(),\\n\\t\\t\\\"ScriptName\\\": lambdaInfo.scriptExportHandlerName(),\\n\\t}).Info(\\\"Registering Sparta Python function\\\")\\n\\n\\tprimaryEntry := fmt.Sprintf(`def %s(event, context):\\n\\t\\treturn lambda_handler(%s, event, context)\\n\\t`,\\n\\t\\tlambdaInfo.scriptExportHandlerName(),\\n\\t\\tlambdaInfo.lambdaFunctionName())\\n\\treturn primaryEntry\\n}\",\n \"func NewLambdaInvocationMetricEvaluator(queries []awsv2CWTypes.MetricDataQuery,\\n\\tmetricEvaluator MetricEvaluator) CloudEvaluator {\\n\\tnowTime := time.Now()\\n\\n\\t// We won't get initialized before the trigger function is called, so ensure there's\\n\\t// enough buffer for a lower bound\\n\\taddDuration, _ := time.ParseDuration(\\\"2s\\\")\\n\\treturn &lambdaInvocationMetricEvaluator{\\n\\t\\tinitTime: nowTime.Add(-addDuration),\\n\\t\\tqueries: queries,\\n\\t\\tmetricEvaluator: metricEvaluator,\\n\\t}\\n}\",\n \"func (l *CustomLambda) Execute(stdin io.Reader, args []string) (string, error) {\\n\\targsStr := strings.TrimSpace(strings.Join(args, \\\" \\\"))\\n\\tif argsStr != \\\"\\\" {\\n\\t\\targsStr = \\\" \\\" + argsStr\\n\\t}\\n\\n\\tcmd := exec.Command(\\\"bash\\\", \\\"-c\\\", l.command+argsStr)\\n\\n\\t// pass through some stdin goodness\\n\\tcmd.Stdin = stdin\\n\\n\\t// for those who are about to rock, I salute you.\\n\\tstdoutStderr, err := cmd.CombinedOutput()\\n\\n\\tif err == nil {\\n\\t\\t// noiiiice!\\n\\t\\tlog.WithFields(log.Fields{\\\"name\\\": l.Name(), \\\"command\\\": l.command}).Info(\\\"Lambda Execution\\\")\\n\\t\\treturn strings.TrimSpace(string(stdoutStderr)), nil\\n\\t}\\n\\n\\t// *sigh*\\n\\tlog.WithFields(log.Fields{\\\"name\\\": l.Name(), \\\"command\\\": l.command}).Error(\\\"Lambda Execution\\\")\\n\\treturn string(stdoutStderr), errors.New(\\\"Error running command\\\")\\n}\",\n \"func main() {\\n\\n\\t// Test code\\n\\t// p := InputParameters{\\n\\t// \\tStackID: \\\"MaxEdge-ddc65b40-5d03-4827-8bf9-2957903600ca-test-2m\\\",\\n\\t// \\tSourceIP: \\\"EC2AMAZ-5EEVEUI\\\",\\n\\t// \\tSourcePort: \\\"5450\\\",\\n\\t// \\tDestinationIP: \\\"10.0.4.53\\\",\\n\\t// \\tDestinationPort: \\\"5450\\\",\\n\\t// \\tPiList: []string{\\\"tag1\\\", \\\"tag2\\\", \\\"tag3\\\", \\\"tag4\\\", \\\"tag5\\\", \\\"tag6\\\", \\\"endTag117\\\"},\\n\\t// }\\n\\t//LambdaHandler(p)\\n\\n\\tlambda.Start(LambdaHandler)\\n}\",\n \"func TestLambda(t *testing.T) {\\n\\tctx := context.Background()\\n\\n\\tconst functionName = \\\"TestFunctionName\\\"\\n\\tt.Setenv(awsLambdaFunctionNameEnvVar, functionName)\\n\\n\\t// Call Lambda Resource detector to detect resources\\n\\tlambdaDetector, err := NewDetector(processortest.NewNopCreateSettings(), CreateDefaultConfig())\\n\\trequire.NoError(t, err)\\n\\tres, _, err := lambdaDetector.Detect(ctx)\\n\\trequire.NoError(t, err)\\n\\trequire.NotNil(t, res)\\n\\n\\tassert.Equal(t, map[string]interface{}{\\n\\t\\tconventions.AttributeCloudProvider: conventions.AttributeCloudProviderAWS,\\n\\t\\tconventions.AttributeCloudPlatform: conventions.AttributeCloudPlatformAWSLambda,\\n\\t\\tconventions.AttributeFaaSName: functionName,\\n\\t}, res.Attributes().AsRaw(), \\\"Resource object returned is incorrect\\\")\\n}\",\n \"func resourceAwsLambdaFunctionCreate(d *schema.ResourceData, meta interface{}) error {\\n\\tconn := meta.(*AWSClient).lambdaconn\\n\\n\\tfunctionName := d.Get(\\\"function_name\\\").(string)\\n\\treservedConcurrentExecutions := d.Get(\\\"reserved_concurrent_executions\\\").(int)\\n\\tiamRole := d.Get(\\\"role\\\").(string)\\n\\n\\tlog.Printf(\\\"[DEBUG] Creating Lambda Function %s with role %s\\\", functionName, iamRole)\\n\\n\\tfilename, hasFilename := d.GetOk(\\\"filename\\\")\\n\\ts3Bucket, bucketOk := d.GetOk(\\\"s3_bucket\\\")\\n\\ts3Key, keyOk := d.GetOk(\\\"s3_key\\\")\\n\\ts3ObjectVersion, versionOk := d.GetOk(\\\"s3_object_version\\\")\\n\\n\\tif !hasFilename && !bucketOk && !keyOk && !versionOk {\\n\\t\\treturn errors.New(\\\"filename or s3_* attributes must be set\\\")\\n\\t}\\n\\n\\tvar functionCode *lambda.FunctionCode\\n\\tif hasFilename {\\n\\t\\t// Grab an exclusive lock so that we're only reading one function into\\n\\t\\t// memory at a time.\\n\\t\\t// See https://github.com/hashicorp/terraform/issues/9364\\n\\t\\tawsMutexKV.Lock(awsMutexLambdaKey)\\n\\t\\tdefer awsMutexKV.Unlock(awsMutexLambdaKey)\\n\\t\\tfile, err := loadFileContent(filename.(string))\\n\\t\\tif err != nil {\\n\\t\\t\\treturn fmt.Errorf(\\\"Unable to load %q: %s\\\", filename.(string), err)\\n\\t\\t}\\n\\t\\tfunctionCode = &lambda.FunctionCode{\\n\\t\\t\\tZipFile: file,\\n\\t\\t}\\n\\t} else {\\n\\t\\tif !bucketOk || !keyOk {\\n\\t\\t\\treturn errors.New(\\\"s3_bucket and s3_key must all be set while using S3 code source\\\")\\n\\t\\t}\\n\\t\\tfunctionCode = &lambda.FunctionCode{\\n\\t\\t\\tS3Bucket: aws.String(s3Bucket.(string)),\\n\\t\\t\\tS3Key: aws.String(s3Key.(string)),\\n\\t\\t}\\n\\t\\tif versionOk {\\n\\t\\t\\tfunctionCode.S3ObjectVersion = aws.String(s3ObjectVersion.(string))\\n\\t\\t}\\n\\t}\\n\\n\\tparams := &lambda.CreateFunctionInput{\\n\\t\\tCode: functionCode,\\n\\t\\tDescription: aws.String(d.Get(\\\"description\\\").(string)),\\n\\t\\tFunctionName: aws.String(functionName),\\n\\t\\tHandler: aws.String(d.Get(\\\"handler\\\").(string)),\\n\\t\\tMemorySize: aws.Int64(int64(d.Get(\\\"memory_size\\\").(int))),\\n\\t\\tRole: aws.String(iamRole),\\n\\t\\tRuntime: aws.String(d.Get(\\\"runtime\\\").(string)),\\n\\t\\tTimeout: aws.Int64(int64(d.Get(\\\"timeout\\\").(int))),\\n\\t\\tPublish: aws.Bool(d.Get(\\\"publish\\\").(bool)),\\n\\t}\\n\\n\\tif v, ok := d.GetOk(\\\"dead_letter_config\\\"); ok {\\n\\t\\tdlcMaps := v.([]interface{})\\n\\t\\tif len(dlcMaps) == 1 { // Schema guarantees either 0 or 1\\n\\t\\t\\t// Prevent panic on nil dead_letter_config. See GH-14961\\n\\t\\t\\tif dlcMaps[0] == nil {\\n\\t\\t\\t\\treturn fmt.Errorf(\\\"Nil dead_letter_config supplied for function: %s\\\", functionName)\\n\\t\\t\\t}\\n\\t\\t\\tdlcMap := dlcMaps[0].(map[string]interface{})\\n\\t\\t\\tparams.DeadLetterConfig = &lambda.DeadLetterConfig{\\n\\t\\t\\t\\tTargetArn: aws.String(dlcMap[\\\"target_arn\\\"].(string)),\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tif v, ok := d.GetOk(\\\"vpc_config\\\"); ok {\\n\\n\\t\\tconfigs := v.([]interface{})\\n\\t\\tconfig, ok := configs[0].(map[string]interface{})\\n\\n\\t\\tif !ok {\\n\\t\\t\\treturn errors.New(\\\"vpc_config is \\\")\\n\\t\\t}\\n\\n\\t\\tif config != nil {\\n\\t\\t\\tvar subnetIds []*string\\n\\t\\t\\tfor _, id := range config[\\\"subnet_ids\\\"].(*schema.Set).List() {\\n\\t\\t\\t\\tsubnetIds = append(subnetIds, aws.String(id.(string)))\\n\\t\\t\\t}\\n\\n\\t\\t\\tvar securityGroupIds []*string\\n\\t\\t\\tfor _, id := range config[\\\"security_group_ids\\\"].(*schema.Set).List() {\\n\\t\\t\\t\\tsecurityGroupIds = append(securityGroupIds, aws.String(id.(string)))\\n\\t\\t\\t}\\n\\n\\t\\t\\tparams.VpcConfig = &lambda.VpcConfig{\\n\\t\\t\\t\\tSubnetIds: subnetIds,\\n\\t\\t\\t\\tSecurityGroupIds: securityGroupIds,\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tif v, ok := d.GetOk(\\\"tracing_config\\\"); ok {\\n\\t\\ttracingConfig := v.([]interface{})\\n\\t\\ttracing := tracingConfig[0].(map[string]interface{})\\n\\t\\tparams.TracingConfig = &lambda.TracingConfig{\\n\\t\\t\\tMode: aws.String(tracing[\\\"mode\\\"].(string)),\\n\\t\\t}\\n\\t}\\n\\n\\tif v, ok := d.GetOk(\\\"environment\\\"); ok {\\n\\t\\tenvironments := v.([]interface{})\\n\\t\\tenvironment, ok := environments[0].(map[string]interface{})\\n\\t\\tif !ok {\\n\\t\\t\\treturn errors.New(\\\"At least one field is expected inside environment\\\")\\n\\t\\t}\\n\\n\\t\\tif environmentVariables, ok := environment[\\\"variables\\\"]; ok {\\n\\t\\t\\tvariables := readEnvironmentVariables(environmentVariables.(map[string]interface{}))\\n\\n\\t\\t\\tparams.Environment = &lambda.Environment{\\n\\t\\t\\t\\tVariables: aws.StringMap(variables),\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tif v, ok := d.GetOk(\\\"kms_key_arn\\\"); ok {\\n\\t\\tparams.KMSKeyArn = aws.String(v.(string))\\n\\t}\\n\\n\\tif v, exists := d.GetOk(\\\"tags\\\"); exists {\\n\\t\\tparams.Tags = tagsFromMapGeneric(v.(map[string]interface{}))\\n\\t}\\n\\n\\t// IAM profiles can take ~10 seconds to propagate in AWS:\\n\\t// http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#launch-instance-with-role-console\\n\\t// Error creating Lambda function: InvalidParameterValueException: The role defined for the task cannot be assumed by Lambda.\\n\\terr := resource.Retry(10*time.Minute, func() *resource.RetryError {\\n\\t\\t_, err := conn.CreateFunction(params)\\n\\t\\tif err != nil {\\n\\t\\t\\tlog.Printf(\\\"[DEBUG] Error creating Lambda Function: %s\\\", err)\\n\\n\\t\\t\\tif isAWSErr(err, \\\"InvalidParameterValueException\\\", \\\"The role defined for the function cannot be assumed by Lambda\\\") {\\n\\t\\t\\t\\tlog.Printf(\\\"[DEBUG] Received %s, retrying CreateFunction\\\", err)\\n\\t\\t\\t\\treturn resource.RetryableError(err)\\n\\t\\t\\t}\\n\\t\\t\\tif isAWSErr(err, \\\"InvalidParameterValueException\\\", \\\"The provided execution role does not have permissions\\\") {\\n\\t\\t\\t\\tlog.Printf(\\\"[DEBUG] Received %s, retrying CreateFunction\\\", err)\\n\\t\\t\\t\\treturn resource.RetryableError(err)\\n\\t\\t\\t}\\n\\t\\t\\tif isAWSErr(err, \\\"InvalidParameterValueException\\\", \\\"Your request has been throttled by EC2\\\") {\\n\\t\\t\\t\\tlog.Printf(\\\"[DEBUG] Received %s, retrying CreateFunction\\\", err)\\n\\t\\t\\t\\treturn resource.RetryableError(err)\\n\\t\\t\\t}\\n\\n\\t\\t\\treturn resource.NonRetryableError(err)\\n\\t\\t}\\n\\t\\treturn nil\\n\\t})\\n\\tif err != nil {\\n\\t\\treturn fmt.Errorf(\\\"Error creating Lambda function: %s\\\", err)\\n\\t}\\n\\n\\tif reservedConcurrentExecutions > 0 {\\n\\n\\t\\tlog.Printf(\\\"[DEBUG] Setting Concurrency to %d for the Lambda Function %s\\\", reservedConcurrentExecutions, functionName)\\n\\n\\t\\tconcurrencyParams := &lambda.PutFunctionConcurrencyInput{\\n\\t\\t\\tFunctionName: aws.String(functionName),\\n\\t\\t\\tReservedConcurrentExecutions: aws.Int64(int64(reservedConcurrentExecutions)),\\n\\t\\t}\\n\\n\\t\\t_, err := conn.PutFunctionConcurrency(concurrencyParams)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn fmt.Errorf(\\\"Error setting concurrency for Lambda %s: %s\\\", functionName, err)\\n\\t\\t}\\n\\t}\\n\\n\\td.SetId(d.Get(\\\"function_name\\\").(string))\\n\\n\\treturn resourceAwsLambdaFunctionRead(d, meta)\\n}\",\n \"func (c *Client) NewCodeLambdaRequest(ctx context.Context, path string) (*http.Request, error) {\\n\\tscheme := c.Scheme\\n\\tif scheme == \\\"\\\" {\\n\\t\\tscheme = \\\"http\\\"\\n\\t}\\n\\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\\n\\treq, err := http.NewRequest(\\\"GET\\\", u.String(), nil)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn req, nil\\n}\",\n \"func execNewFunc(_ int, p *gop.Context) {\\n\\targs := p.GetArgs(4)\\n\\tret := types.NewFunc(token.Pos(args[0].(int)), args[1].(*types.Package), args[2].(string), args[3].(*types.Signature))\\n\\tp.Ret(4, ret)\\n}\",\n \"func CreateLambdaPath() string {\\n\\n\\treturn fmt.Sprintf(\\\"/p7/lambdas\\\")\\n}\",\n \"func NewCustomExecutor(commandMap stringmap.StringMap) *CustomExecutor {\\n\\treturn &CustomExecutor{commandMap: commandMap}\\n}\",\n \"func main() {\\n\\tlambda.Start(wflambda.Wrapper(handler))\\n}\",\n \"func main() {\\n\\tlambda.Start(wflambda.Wrapper(handler))\\n}\",\n \"func main() {\\n\\tlambda.Start(wflambda.Wrapper(handler))\\n}\",\n \"func main() {\\n\\t/* Run shellscript: `$ sh create-lambda.sh` for docker deploy */\\n\\tlambda.Start(HandleRequest)\\n\\t// HandleRequest() // \\ttesting:\\n}\",\n \"func (c *Client) NewRunLambdaRequest(ctx context.Context, path string) (*http.Request, error) {\\n\\tscheme := c.Scheme\\n\\tif scheme == \\\"\\\" {\\n\\t\\tscheme = \\\"http\\\"\\n\\t}\\n\\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\\n\\treq, err := http.NewRequest(\\\"GET\\\", u.String(), nil)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn req, nil\\n}\",\n \"func NewAdd(f func(string, string) (proto.Message, error)) *cobra.Command {\\n\\tvar (\\n\\t\\trole string\\n\\t\\tuser string\\n\\t)\\n\\n\\tcmd := template.NewArg0Proto(\\\"add\\\", \\\"Add a new role binding\\\", func(cmd *cobra.Command) (proto.Message, error) {\\n\\t\\treturn f(role, user)\\n\\t})\\n\\n\\tcmd.Flags().StringVar(&role, \\\"role\\\", \\\"\\\", \\\"role name\\\")\\n\\tcmd.Flags().StringVar(&user, \\\"user\\\", \\\"\\\", \\\"user name\\\")\\n\\n\\treturn cmd\\n}\",\n \"func main() {\\n\\n\\tlambda.Start(LambdaHandler)\\n}\",\n \"func NewMessageFromLambda(content []byte, origin *Origin, status string, utcTime time.Time, ARN, reqID string, ingestionTimestamp int64) *Message {\\n\\treturn &Message{\\n\\t\\tContent: content,\\n\\t\\tOrigin: origin,\\n\\t\\tStatus: status,\\n\\t\\tIngestionTimestamp: ingestionTimestamp,\\n\\t\\tServerlessExtra: ServerlessExtra{\\n\\t\\t\\tTimestamp: utcTime,\\n\\t\\t\\tLambda: &Lambda{\\n\\t\\t\\t\\tARN: ARN,\\n\\t\\t\\t\\tRequestID: reqID,\\n\\t\\t\\t},\\n\\t\\t},\\n\\t}\\n}\",\n \"func (machine *Dishwasher) RunCustomCommand(custom string) {\\r\\n machine.Append(func() (string, error) {\\r\\n var output string = \\\"\\\"\\r\\n var oops error = nil\\r\\n\\r\\n custom = strings.TrimSpace(custom)\\r\\n if custom[len(custom)-1] == '$' {\\r\\n go RunCommand(custom)\\r\\n } else {\\r\\n output, oops = RunCommand(custom)\\r\\n machine.SideEffect(output, oops)\\r\\n }\\r\\n\\r\\n return output, oops\\r\\n })\\r\\n}\",\n \"func (t *LambdaFactory) New(config *trigger.Config) (trigger.Trigger, error) {\\n\\n\\tif singleton == nil {\\n\\t\\tsingleton = &LambdaTrigger{}\\n\\t\\treturn singleton, nil\\n\\t}\\n\\n\\tlog.RootLogger().Warn(\\\"Only one lambda trigger instance can be instantiated\\\")\\n\\n\\treturn nil, nil\\n}\",\n \"func NewLambdaAlias(properties LambdaAliasProperties, deps ...interface{}) LambdaAlias {\\n\\treturn LambdaAlias{\\n\\t\\tType: \\\"AWS::Lambda::Alias\\\",\\n\\t\\tProperties: properties,\\n\\t\\tDependsOn: deps,\\n\\t}\\n}\",\n \"func (c *Client) CodeLambda(ctx context.Context, path string) (*http.Response, error) {\\n\\treq, err := c.NewCodeLambdaRequest(ctx, path)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn c.Client.Do(ctx, req)\\n}\",\n \"func LambdaApplication_FromLambdaApplicationName(scope constructs.Construct, id *string, lambdaApplicationName *string) ILambdaApplication {\\n\\t_init_.Initialize()\\n\\n\\tvar returns ILambdaApplication\\n\\n\\t_jsii_.StaticInvoke(\\n\\t\\t\\\"monocdk.aws_codedeploy.LambdaApplication\\\",\\n\\t\\t\\\"fromLambdaApplicationName\\\",\\n\\t\\t[]interface{}{scope, id, lambdaApplicationName},\\n\\t\\t&returns,\\n\\t)\\n\\n\\treturn returns\\n}\",\n \"func (a *QueryLambdasApiService) CreateQueryLambdaExecute(r ApiCreateQueryLambdaRequest) (*QueryLambdaVersionResponse, *http.Response, error) {\\n\\tvar (\\n\\t\\tlocalVarHTTPMethod = http.MethodPost\\n\\t\\tlocalVarPostBody interface{}\\n\\t\\tformFiles []formFile\\n\\t\\tlocalVarReturnValue *QueryLambdaVersionResponse\\n\\t)\\n\\n\\tlocalBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, \\\"QueryLambdasApiService.CreateQueryLambda\\\")\\n\\tif err != nil {\\n\\t\\treturn localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}\\n\\t}\\n\\n\\tlocalVarPath := localBasePath + \\\"/v1/orgs/self/ws/{workspace}/lambdas\\\"\\n\\tlocalVarPath = strings.Replace(localVarPath, \\\"{\\\"+\\\"workspace\\\"+\\\"}\\\", url.PathEscape(parameterValueToString(r.workspace, \\\"workspace\\\")), -1)\\n\\n\\tlocalVarHeaderParams := make(map[string]string)\\n\\tlocalVarQueryParams := url.Values{}\\n\\tlocalVarFormParams := url.Values{}\\n\\tif r.body == nil {\\n\\t\\treturn localVarReturnValue, nil, reportError(\\\"body is required and must be specified\\\")\\n\\t}\\n\\n\\t// to determine the Content-Type header\\n\\tlocalVarHTTPContentTypes := []string{\\\"application/json\\\"}\\n\\n\\t// set Content-Type header\\n\\tlocalVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)\\n\\tif localVarHTTPContentType != \\\"\\\" {\\n\\t\\tlocalVarHeaderParams[\\\"Content-Type\\\"] = localVarHTTPContentType\\n\\t}\\n\\n\\t// to determine the Accept header\\n\\tlocalVarHTTPHeaderAccepts := []string{\\\"application/json\\\"}\\n\\n\\t// set Accept header\\n\\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\\n\\tif localVarHTTPHeaderAccept != \\\"\\\" {\\n\\t\\tlocalVarHeaderParams[\\\"Accept\\\"] = localVarHTTPHeaderAccept\\n\\t}\\n\\t// body params\\n\\tlocalVarPostBody = r.body\\n\\treq, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)\\n\\tif err != nil {\\n\\t\\treturn localVarReturnValue, nil, err\\n\\t}\\n\\n\\tlocalVarHTTPResponse, err := a.client.callAPI(req)\\n\\tif err != nil || localVarHTTPResponse == nil {\\n\\t\\treturn localVarReturnValue, localVarHTTPResponse, err\\n\\t}\\n\\n\\tlocalVarBody, err := io.ReadAll(localVarHTTPResponse.Body)\\n\\tlocalVarHTTPResponse.Body.Close()\\n\\tlocalVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))\\n\\tif err != nil {\\n\\t\\treturn localVarReturnValue, localVarHTTPResponse, err\\n\\t}\\n\\n\\tif localVarHTTPResponse.StatusCode >= 300 {\\n\\t\\tnewErr := &GenericOpenAPIError{\\n\\t\\t\\tbody: localVarBody,\\n\\t\\t\\terror: localVarHTTPResponse.Status,\\n\\t\\t}\\n\\t\\tif localVarHTTPResponse.StatusCode == 400 {\\n\\t\\t\\tvar v ErrorModel\\n\\t\\t\\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\\\"Content-Type\\\"))\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tnewErr.error = err.Error()\\n\\t\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t\\t}\\n\\t\\t\\t\\t\\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\\n\\t\\t\\t\\t\\tnewErr.model = v\\n\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t}\\n\\t\\tif localVarHTTPResponse.StatusCode == 401 {\\n\\t\\t\\tvar v ErrorModel\\n\\t\\t\\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\\\"Content-Type\\\"))\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tnewErr.error = err.Error()\\n\\t\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t\\t}\\n\\t\\t\\t\\t\\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\\n\\t\\t\\t\\t\\tnewErr.model = v\\n\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t}\\n\\t\\tif localVarHTTPResponse.StatusCode == 403 {\\n\\t\\t\\tvar v ErrorModel\\n\\t\\t\\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\\\"Content-Type\\\"))\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tnewErr.error = err.Error()\\n\\t\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t\\t}\\n\\t\\t\\t\\t\\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\\n\\t\\t\\t\\t\\tnewErr.model = v\\n\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t}\\n\\t\\tif localVarHTTPResponse.StatusCode == 404 {\\n\\t\\t\\tvar v ErrorModel\\n\\t\\t\\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\\\"Content-Type\\\"))\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tnewErr.error = err.Error()\\n\\t\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t\\t}\\n\\t\\t\\t\\t\\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\\n\\t\\t\\t\\t\\tnewErr.model = v\\n\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t}\\n\\t\\tif localVarHTTPResponse.StatusCode == 405 {\\n\\t\\t\\tvar v ErrorModel\\n\\t\\t\\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\\\"Content-Type\\\"))\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tnewErr.error = err.Error()\\n\\t\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t\\t}\\n\\t\\t\\t\\t\\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\\n\\t\\t\\t\\t\\tnewErr.model = v\\n\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t}\\n\\t\\tif localVarHTTPResponse.StatusCode == 406 {\\n\\t\\t\\tvar v ErrorModel\\n\\t\\t\\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\\\"Content-Type\\\"))\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tnewErr.error = err.Error()\\n\\t\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t\\t}\\n\\t\\t\\t\\t\\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\\n\\t\\t\\t\\t\\tnewErr.model = v\\n\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t}\\n\\t\\tif localVarHTTPResponse.StatusCode == 408 {\\n\\t\\t\\tvar v ErrorModel\\n\\t\\t\\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\\\"Content-Type\\\"))\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tnewErr.error = err.Error()\\n\\t\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t\\t}\\n\\t\\t\\t\\t\\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\\n\\t\\t\\t\\t\\tnewErr.model = v\\n\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t}\\n\\t\\tif localVarHTTPResponse.StatusCode == 409 {\\n\\t\\t\\tvar v ErrorModel\\n\\t\\t\\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\\\"Content-Type\\\"))\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tnewErr.error = err.Error()\\n\\t\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t\\t}\\n\\t\\t\\t\\t\\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\\n\\t\\t\\t\\t\\tnewErr.model = v\\n\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t}\\n\\t\\tif localVarHTTPResponse.StatusCode == 415 {\\n\\t\\t\\tvar v ErrorModel\\n\\t\\t\\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\\\"Content-Type\\\"))\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tnewErr.error = err.Error()\\n\\t\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t\\t}\\n\\t\\t\\t\\t\\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\\n\\t\\t\\t\\t\\tnewErr.model = v\\n\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t}\\n\\t\\tif localVarHTTPResponse.StatusCode == 429 {\\n\\t\\t\\tvar v ErrorModel\\n\\t\\t\\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\\\"Content-Type\\\"))\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tnewErr.error = err.Error()\\n\\t\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t\\t}\\n\\t\\t\\t\\t\\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\\n\\t\\t\\t\\t\\tnewErr.model = v\\n\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t}\\n\\t\\tif localVarHTTPResponse.StatusCode == 500 {\\n\\t\\t\\tvar v ErrorModel\\n\\t\\t\\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\\\"Content-Type\\\"))\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tnewErr.error = err.Error()\\n\\t\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t\\t}\\n\\t\\t\\t\\t\\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\\n\\t\\t\\t\\t\\tnewErr.model = v\\n\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t}\\n\\t\\tif localVarHTTPResponse.StatusCode == 501 {\\n\\t\\t\\tvar v ErrorModel\\n\\t\\t\\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\\\"Content-Type\\\"))\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tnewErr.error = err.Error()\\n\\t\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t\\t}\\n\\t\\t\\t\\t\\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\\n\\t\\t\\t\\t\\tnewErr.model = v\\n\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t}\\n\\t\\tif localVarHTTPResponse.StatusCode == 502 {\\n\\t\\t\\tvar v ErrorModel\\n\\t\\t\\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\\\"Content-Type\\\"))\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tnewErr.error = err.Error()\\n\\t\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t\\t}\\n\\t\\t\\t\\t\\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\\n\\t\\t\\t\\t\\tnewErr.model = v\\n\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t}\\n\\t\\tif localVarHTTPResponse.StatusCode == 503 {\\n\\t\\t\\tvar v ErrorModel\\n\\t\\t\\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\\\"Content-Type\\\"))\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tnewErr.error = err.Error()\\n\\t\\t\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t\\t\\t}\\n\\t\\t\\t\\t\\tnewErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\\n\\t\\t\\t\\t\\tnewErr.model = v\\n\\t\\t}\\n\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t}\\n\\n\\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get(\\\"Content-Type\\\"))\\n\\tif err != nil {\\n\\t\\tnewErr := &GenericOpenAPIError{\\n\\t\\t\\tbody: localVarBody,\\n\\t\\t\\terror: err.Error(),\\n\\t\\t}\\n\\t\\treturn localVarReturnValue, localVarHTTPResponse, newErr\\n\\t}\\n\\n\\treturn localVarReturnValue, localVarHTTPResponse, nil\\n}\",\n \"func createNewNodeJSProxyEntry(lambdaInfo *LambdaAWSInfo, logger *logrus.Logger) string {\\n\\tlogger.WithFields(logrus.Fields{\\n\\t\\t\\\"FunctionName\\\": lambdaInfo.lambdaFunctionName(),\\n\\t\\t\\\"ScriptName\\\": lambdaInfo.scriptExportHandlerName(),\\n\\t}).Info(\\\"Registering Sparta JS function\\\")\\n\\n\\t// We do know the CF resource name here - could write this into\\n\\t// index.js and expose a GET localhost:9000/lambdaMetadata\\n\\t// which wraps up DescribeStackResource for the running\\n\\t// lambda function\\n\\tprimaryEntry := fmt.Sprintf(\\\"exports[\\\\\\\"%s\\\\\\\"] = createForwarder(\\\\\\\"/%s\\\\\\\");\\\\n\\\",\\n\\t\\tlambdaInfo.scriptExportHandlerName(),\\n\\t\\tlambdaInfo.lambdaFunctionName())\\n\\treturn primaryEntry\\n}\",\n \"func (s *BaseBundListener) EnterLambda_term(ctx *Lambda_termContext) {}\",\n \"func (l *LambdaClient) createFunction(function *FunctionConfig, code []byte) error {\\n\\tfuncCode := &lambda.FunctionCode{\\n\\t\\tZipFile: code,\\n\\t}\\n\\n\\tcreateArgs := &lambda.CreateFunctionInput{\\n\\t\\tCode: funcCode,\\n\\t\\tFunctionName: aws.String(function.Name),\\n\\t\\tHandler: aws.String(\\\"main\\\"),\\n\\t\\tRuntime: aws.String(lambda.RuntimeGo1X),\\n\\t\\tRole: aws.String(function.RoleARN),\\n\\t\\tTimeout: aws.Int64(function.Timeout),\\n\\t\\tMemorySize: aws.Int64(function.MemorySize),\\n\\t}\\n\\n\\t_, err := l.Client.CreateFunction(createArgs)\\n\\treturn err\\n}\",\n \"func NewCustom(fieldName string, fullPath bool) logrus.Hook {\\n\\treturn &customCallerHook{fieldName: fieldName, fullPath: fullPath}\\n}\",\n \"func (l *CustomLambda) Name() string {\\n\\treturn l.name\\n}\",\n \"func lambdaHandler(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {\\n\\t// Validate RPC request\\n\\treq := json.GetRPCRequestFromJSON(request.Body)\\n\\tif method := request.QueryStringParameters[ParamFuncName]; method != \\\"\\\" {\\n\\t\\treq.Method = method\\n\\t} else if method := request.PathParameters[ParamFuncName]; method != \\\"\\\" {\\n\\t\\treq.Method = method\\n\\t}\\n\\n\\trespBody, statusCode := handler(req)\\n\\treturn events.APIGatewayProxyResponse{Headers: lambdaHeaders, Body: respBody, StatusCode: statusCode}, nil\\n}\",\n \"func main() {\\n\\tlambda.Start(handleRequest)\\n}\",\n \"func createCommand(t *runner.Task, actionFunc func(*cli.Context) error) *cli.Command {\\n\\tcommand := &cli.Command{\\n\\t\\tName: t.Name,\\n\\t\\tUsage: strings.TrimSpace(t.Usage),\\n\\t\\tDescription: strings.TrimSpace(t.Description),\\n\\t\\tAction: actionFunc,\\n\\t}\\n\\n\\tfor _, arg := range t.Args {\\n\\t\\tcommand.ArgsUsage += fmt.Sprintf(\\\"<%s> \\\", arg.Name)\\n\\t}\\n\\n\\tcommand.CustomHelpTemplate = createCommandHelp(t)\\n\\n\\treturn command\\n}\",\n \"func execNewNamed(_ int, p *gop.Context) {\\n\\targs := p.GetArgs(3)\\n\\tret := types.NewNamed(args[0].(*types.TypeName), args[1].(types.Type), args[2].([]*types.Func))\\n\\tp.Ret(3, ret)\\n}\",\n \"func (c *Client) NewDeleteLambdaRequest(ctx context.Context, path string) (*http.Request, error) {\\n\\tscheme := c.Scheme\\n\\tif scheme == \\\"\\\" {\\n\\t\\tscheme = \\\"http\\\"\\n\\t}\\n\\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\\n\\treq, err := http.NewRequest(\\\"DELETE\\\", u.String(), nil)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn req, nil\\n}\",\n \"func createIAMLambdaRole(ctx *pulumi.Context, name string) (*iam.Role, error) {\\n\\troleName := fmt.Sprintf(\\\"%s-task-exec-role\\\", name)\\n\\n\\trole, err := iam.NewRole(ctx, roleName, &iam.RoleArgs{\\n\\t\\tAssumeRolePolicy: pulumi.String(`{\\n\\t\\t\\t\\\"Version\\\": \\\"2012-10-17\\\",\\n\\t\\t\\t\\\"Statement\\\": [{\\n\\t\\t\\t\\t\\\"Sid\\\": \\\"\\\",\\n\\t\\t\\t\\t\\\"Effect\\\": \\\"Allow\\\",\\n\\t\\t\\t\\t\\\"Principal\\\": {\\n\\t\\t\\t\\t\\t\\\"Service\\\": \\\"lambda.amazonaws.com\\\"\\n\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\\"Action\\\": \\\"sts:AssumeRole\\\"\\n\\t\\t\\t}]\\n\\t\\t}`),\\n\\t})\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"Error create IAM role for %s: %v\\\", name, err)\\n\\t}\\n\\n\\treturn role, nil\\n}\",\n \"func (a *QueryLambdasApiService) CreateQueryLambda(ctx context.Context, workspace string) ApiCreateQueryLambdaRequest {\\n\\treturn ApiCreateQueryLambdaRequest{\\n\\t\\tApiService: a,\\n\\t\\tctx: ctx,\\n\\t\\tworkspace: workspace,\\n\\t}\\n}\",\n \"func GenerateNewLambdaRoleName(region, name *string) string {\\n\\treturn fmt.Sprintf(\\\"%s-%s-%s\\\", constants.CommonNamePrefix, *name, *region)\\n}\",\n \"func new_(e interface{}) func() Event {\\n\\ttyp := reflect.TypeOf(e)\\n\\treturn func() Event {\\n\\t\\treturn reflect.New(typ).Interface().(Event)\\n\\t}\\n}\",\n \"func newLogClosure(c func() string) logClosure {\\n\\treturn logClosure(c)\\n}\",\n \"func main() {\\n // Initialize a session\\n sess := session.Must(session.NewSessionWithOptions(session.Options{\\n SharedConfigState: session.SharedConfigEnable,\\n }))\\n\\n // Create Lambda service client\\n svc := lambda.New(sess, &aws.Config{Region: aws.String(\\\"us-west-2\\\")})\\n\\n result, err := svc.ListFunctions(nil)\\n if err != nil {\\n fmt.Println(\\\"Cannot list functions\\\")\\n os.Exit(0)\\n }\\n\\n fmt.Println(\\\"Functions:\\\")\\n\\n for _, f := range result.Functions {\\n fmt.Println(\\\"Name: \\\" + aws.StringValue(f.FunctionName))\\n fmt.Println(\\\"Description: \\\" + aws.StringValue(f.Description))\\n fmt.Println(\\\"\\\")\\n }\\n}\",\n \"func newPipelineCommandHandler(repository eventstore.Repository) *pipelineCommandHandler {\\n\\treturn &pipelineCommandHandler{\\n\\t\\trepository: repository,\\n\\t}\\n}\",\n \"func NewExternalCmd(name string) Callable {\\n\\treturn externalCmd{name}\\n}\",\n \"func NewProfile(name string) {\\n\\tpath := name\\n\\tif !IsLambdaDir() {\\n\\t\\tpath = \\\"lambdas/\\\" + name + \\\".json\\\"\\n\\t}\\n\\tf, err := os.Create(path)\\n\\tif err != nil {\\n\\t\\tfmt.Println(\\\"ERROR Creating file \\\", err)\\n\\t\\treturn\\n\\t}\\n\\tdefer f.Close()\\n\\n\\tl := Lambda{\\n\\t\\tName: name,\\n\\t\\tTriggers: []string{\\\"api\\\", \\\"event\\\", \\\"invoke\\\", \\\"sns\\\", \\\"sqs\\\"},\\n\\t\\tStages: []string{\\\"dev\\\", \\\"qa\\\", \\\"uat\\\", \\\"prod\\\"},\\n\\t}\\n\\tprfl := Folder{\\n\\t\\tLambda: l,\\n\\t}\\n\\n\\tjs, err := json.Marshal(prfl)\\n\\tif err != nil {\\n\\t\\tfmt.Println(\\\"ERROR Marshalling \\\", err)\\n\\t\\treturn\\n\\t}\\n\\n\\t_, err = f.Write(pretty.Pretty(js))\\n\\tif err != nil {\\n\\t\\tfmt.Println(\\\"ERROR Writing file \\\", err)\\n\\t}\\n}\",\n \"func CreatePrintFunction(custom string) Printer {\\n\\treturn func(s string) {\\n\\t\\tfmt.Println(s + custom)\\n\\t}\\n}\",\n \"func (c *Client) NewShowLambdaRequest(ctx context.Context, path string) (*http.Request, error) {\\n\\tscheme := c.Scheme\\n\\tif scheme == \\\"\\\" {\\n\\t\\tscheme = \\\"http\\\"\\n\\t}\\n\\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\\n\\treq, err := http.NewRequest(\\\"GET\\\", u.String(), nil)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn req, nil\\n}\",\n \"func NewFunctionCreateCommand(c cli.Interface) *cobra.Command {\\n\\treturn &cobra.Command{\\n\\t\\tUse: \\\"create FUNCTION IMAGE\\\",\\n\\t\\tShort: \\\"Create function\\\",\\n\\t\\tPreRunE: cli.ExactArgs(2),\\n\\t\\tRunE: func(cmd *cobra.Command, args []string) error {\\n\\t\\t\\topts := &createFunctionOpts{}\\n\\t\\t\\topts.name = args[0]\\n\\t\\t\\topts.image = args[1]\\n\\t\\t\\treturn createFunction(c, opts)\\n\\t\\t},\\n\\t}\\n}\",\n \"func createPackageStep() workflowStep {\\n\\n\\treturn func(ctx *workflowContext) (workflowStep, error) {\\n\\t\\t// Compile the source to linux...\\n\\t\\tsanitizedServiceName := sanitizedName(ctx.serviceName)\\n\\t\\texecutableOutput := fmt.Sprintf(\\\"%s.lambda.amd64\\\", sanitizedServiceName)\\n\\t\\tcmd := exec.Command(\\\"go\\\", \\\"build\\\", \\\"-o\\\", executableOutput, \\\"-tags\\\", \\\"lambdabinary\\\", \\\".\\\")\\n\\t\\tctx.logger.Debug(\\\"Building application binary: \\\", cmd.Args)\\n\\t\\tcmd.Env = os.Environ()\\n\\t\\tcmd.Env = append(cmd.Env, \\\"GOOS=linux\\\", \\\"GOARCH=amd64\\\", \\\"GO15VENDOREXPERIMENT=1\\\")\\n\\t\\tctx.logger.Info(\\\"Compiling binary: \\\", executableOutput)\\n\\n\\t\\toutputWriter := ctx.logger.Writer()\\n\\t\\tdefer outputWriter.Close()\\n\\t\\tcmd.Stdout = outputWriter\\n\\t\\tcmd.Stderr = outputWriter\\n\\n\\t\\terr := cmd.Run()\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t\\tdefer os.Remove(executableOutput)\\n\\n\\t\\t// Binary size\\n\\t\\tstat, err := os.Stat(executableOutput)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, errors.New(\\\"Failed to stat build output\\\")\\n\\t\\t}\\n\\t\\t// Minimum hello world size is 2.3M\\n\\t\\t// Minimum HTTP hello world is 6.3M\\n\\t\\tctx.logger.Info(\\\"Executable binary size (MB): \\\", stat.Size()/(1024*1024))\\n\\n\\t\\tworkingDir, err := os.Getwd()\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, errors.New(\\\"Failed to retrieve working directory\\\")\\n\\t\\t}\\n\\t\\ttmpFile, err := ioutil.TempFile(workingDir, sanitizedServiceName)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, errors.New(\\\"Failed to create temporary file\\\")\\n\\t\\t}\\n\\n\\t\\tdefer func() {\\n\\t\\t\\ttmpFile.Close()\\n\\t\\t}()\\n\\n\\t\\tctx.logger.Info(\\\"Creating ZIP archive for upload: \\\", tmpFile.Name())\\n\\t\\tlambdaArchive := zip.NewWriter(tmpFile)\\n\\t\\tdefer lambdaArchive.Close()\\n\\n\\t\\t// File info for the binary executable\\n\\t\\tbinaryWriter, err := lambdaArchive.Create(filepath.Base(executableOutput))\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, fmt.Errorf(\\\"Failed to create ZIP entry: %s\\\", filepath.Base(executableOutput))\\n\\t\\t}\\n\\t\\treader, err := os.Open(executableOutput)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, fmt.Errorf(\\\"Failed to open file: %s\\\", executableOutput)\\n\\t\\t}\\n\\t\\tdefer reader.Close()\\n\\t\\tio.Copy(binaryWriter, reader)\\n\\n\\t\\t// Add the string literal adapter, which requires us to add exported\\n\\t\\t// functions to the end of index.js\\n\\t\\tnodeJSWriter, err := lambdaArchive.Create(\\\"index.js\\\")\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, errors.New(\\\"Failed to create ZIP entry: index.js\\\")\\n\\t\\t}\\n\\t\\tnodeJSSource := _escFSMustString(false, \\\"/resources/index.js\\\")\\n\\t\\tnodeJSSource += \\\"\\\\n// DO NOT EDIT - CONTENT UNTIL EOF IS AUTOMATICALLY GENERATED\\\\n\\\"\\n\\t\\tfor _, eachLambda := range ctx.lambdaAWSInfos {\\n\\t\\t\\tnodeJSSource += createNewNodeJSProxyEntry(eachLambda, ctx.logger)\\n\\t\\t}\\n\\t\\t// Finally, replace\\n\\t\\t// \\tSPARTA_BINARY_NAME = 'Sparta.lambda.amd64';\\n\\t\\t// with the service binary name\\n\\t\\tnodeJSSource += fmt.Sprintf(\\\"SPARTA_BINARY_NAME='%s';\\\\n\\\", executableOutput)\\n\\t\\tctx.logger.Debug(\\\"Dynamically generated NodeJS adapter:\\\\n\\\", nodeJSSource)\\n\\t\\tstringReader := strings.NewReader(nodeJSSource)\\n\\t\\tio.Copy(nodeJSWriter, stringReader)\\n\\n\\t\\t// Also embed the custom resource creation scripts\\n\\t\\tfor _, eachName := range customResourceScripts {\\n\\t\\t\\tresourceName := fmt.Sprintf(\\\"/resources/provision/%s\\\", eachName)\\n\\t\\t\\tresourceContent := _escFSMustString(false, resourceName)\\n\\t\\t\\tstringReader := strings.NewReader(resourceContent)\\n\\t\\t\\tembedWriter, err := lambdaArchive.Create(eachName)\\n\\t\\t\\tif nil != err {\\n\\t\\t\\t\\treturn nil, err\\n\\t\\t\\t}\\n\\t\\t\\tctx.logger.Info(\\\"Embedding CustomResource script: \\\", eachName)\\n\\t\\t\\tio.Copy(embedWriter, stringReader)\\n\\t\\t}\\n\\n\\t\\t// And finally, if there is a node_modules.zip file, then include it.\\n\\t\\tnodeModuleBytes, err := _escFSByte(false, \\\"/resources/provision/node_modules.zip\\\")\\n\\t\\tif nil == err {\\n\\t\\t\\tnodeModuleReader, err := zip.NewReader(bytes.NewReader(nodeModuleBytes), int64(len(nodeModuleBytes)))\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\treturn nil, err\\n\\t\\t\\t}\\n\\t\\t\\tfor _, zipFile := range nodeModuleReader.File {\\n\\t\\t\\t\\tembedWriter, err := lambdaArchive.Create(zipFile.Name)\\n\\t\\t\\t\\tif nil != err {\\n\\t\\t\\t\\t\\treturn nil, err\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tctx.logger.Debug(\\\"Copying node_module file: \\\", zipFile.Name)\\n\\t\\t\\t\\tsourceReader, err := zipFile.Open()\\n\\t\\t\\t\\tif err != nil {\\n\\t\\t\\t\\t\\treturn nil, err\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tio.Copy(embedWriter, sourceReader)\\n\\t\\t\\t}\\n\\t\\t} else {\\n\\t\\t\\tctx.logger.Warn(\\\"Failed to load /resources/provision/node_modules.zip for embedding\\\", err)\\n\\t\\t}\\n\\t\\treturn createUploadStep(tmpFile.Name()), nil\\n\\t}\\n}\",\n \"func newLogClosure(\\n\\tc func() string) logClosure {\\n\\treturn logClosure(c)\\n}\",\n \"func main() {\\n\\tf := GetFlags()\\n\\tif f.Test {\\n\\t\\tif err := RunTest(f); err != nil {\\n\\t\\t\\tfmt.Println(err.Error())\\n\\t\\t}\\n\\t\\treturn\\n\\t}\\n\\n\\tlambda.Start(HandleRequest)\\n}\",\n \"func CommandFunc(f func(args []string) error) flags.Commander {\\n\\treturn &funcCommand{fn: f}\\n}\",\n \"func NewLambdaFunctionMetricQuery(invocationMetricName MetricName) *awsv2CWTypes.MetricDataQuery {\\n\\treturn &awsv2CWTypes.MetricDataQuery{\\n\\t\\tId: awsv2.String(strings.ToLower(string(invocationMetricName))),\\n\\t\\tMetricStat: &awsv2CWTypes.MetricStat{\\n\\t\\t\\tPeriod: awsv2.Int32(30),\\n\\t\\t\\tStat: awsv2.String(string(awsv2CWTypes.StatisticSum)),\\n\\t\\t\\tUnit: awsv2CWTypes.StandardUnitCount,\\n\\t\\t\\tMetric: &awsv2CWTypes.Metric{\\n\\t\\t\\t\\tNamespace: awsv2.String(\\\"AWS/Lambda\\\"),\\n\\t\\t\\t\\tMetricName: awsv2.String(string(invocationMetricName)),\\n\\t\\t\\t\\tDimensions: []awsv2CWTypes.Dimension{\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\tName: awsv2.String(\\\"FunctionName\\\"),\\n\\t\\t\\t\\t\\t\\tValue: nil,\\n\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t},\\n\\t\\t\\t},\\n\\t\\t},\\n\\t}\\n}\",\n \"func NewTask(f func(int64)) *StdTask {\\n t := new(StdTask)\\n t.F = f\\n return t\\n}\",\n \"func NewPluginCommand(cmd *cobra.Command, dockerCli *client.DockerCli) {\\n}\",\n \"func NewCfnCustomResource(scope constructs.Construct, id *string, props *CfnCustomResourceProps) CfnCustomResource {\\n\\t_init_.Initialize()\\n\\n\\tj := jsiiProxy_CfnCustomResource{}\\n\\n\\t_jsii_.Create(\\n\\t\\t\\\"aws-cdk-lib.aws_cloudformation.CfnCustomResource\\\",\\n\\t\\t[]interface{}{scope, id, props},\\n\\t\\t&j,\\n\\t)\\n\\n\\treturn &j\\n}\",\n \"func main() {\\n\\tcfg, err := config.Load()\\n\\tif err != nil {\\n\\t\\tlog.Fatalf(\\\"failed to load config: %v\\\\n\\\", err)\\n\\t}\\n\\n\\tdb, err := database.SetUp(cfg)\\n\\tif err != nil {\\n\\t\\tlog.Fatalf(\\\"failed to connect to database: %v\\\\n\\\", err)\\n\\t}\\n\\n\\tjwtManager, err := auth.NewJWTManager(cfg.SecretKey, nil)\\n\\tif err != nil {\\n\\t\\tlog.Fatalf(\\\"failed to create JWT manager: %v\\\\n\\\", err)\\n\\t}\\n\\n\\ts := services.SetUp(db, jwtManager)\\n\\tr := router.SetUp(s, cfg)\\n\\tl = chiadapter.New(r)\\n\\n\\tlambda.Start(lambdaHandler)\\n}\",\n \"func New(spec *Spec) Function {\\n\\tf := Function{\\n\\t\\tspec: spec,\\n\\t}\\n\\treturn f\\n}\",\n \"func NewCmdCreateEventHandler(f cmdutil.Factory, out io.Writer) *cobra.Command {\\n\\tcmd := &cobra.Command{\\n\\t\\tUse: \\\"handler\\\",\\n\\t\\tShort: \\\"Create event handler\\\",\\n\\t\\tRun: func(cmd *cobra.Command, args []string) {\\n\\t\\t\\tRunCreateEventHandler(f, out, cmd)\\n\\t\\t},\\n\\t}\\n\\tcmd.Flags().StringP(\\\"source\\\", \\\"s\\\", \\\"\\\", \\\"File containing event handler source code\\\")\\n\\tcmd.Flags().StringP(\\\"frontend\\\", \\\"f\\\", \\\"\\\", \\\"Event handler frontend\\\")\\n\\tcmd.Flags().StringP(\\\"url\\\", \\\"u\\\", \\\"\\\", \\\"URL of event handler source code\\\")\\n\\tcmd.Flags().StringP(\\\"version\\\", \\\"v\\\", \\\"1.0\\\", \\\"Event handler version\\\")\\n\\tcmd.Flags().StringP(\\\"dependencies-file\\\", \\\"d\\\", \\\"\\\", \\\"File containing event handler dependencies\\\")\\n\\tcmd.Flags().StringP(\\\"dependencies-url\\\", \\\"l\\\", \\\"\\\", \\\"URL of event handler source dependencies\\\")\\n\\n\\treturn cmd\\n}\",\n \"func myPrintFunction(custom string) myPrintType{\\nreturn func(s string){\\nfmt.Println(s +custom)\\n}\\n}\",\n \"func spartaCustomResourceForwarder(event *json.RawMessage,\\n\\tcontext *LambdaContext,\\n\\tw http.ResponseWriter,\\n\\tlogger *logrus.Logger) {\\n\\n\\tvar rawProps map[string]interface{}\\n\\tjson.Unmarshal([]byte(*event), &rawProps)\\n\\n\\tvar lambdaEvent cloudformationresources.CloudFormationLambdaEvent\\n\\tjsonErr := json.Unmarshal([]byte(*event), &lambdaEvent)\\n\\tif jsonErr != nil {\\n\\t\\tlogger.WithFields(logrus.Fields{\\n\\t\\t\\t\\\"RawEvent\\\": rawProps,\\n\\t\\t\\t\\\"UnmarshalError\\\": jsonErr,\\n\\t\\t}).Warn(\\\"Raw event data\\\")\\n\\t\\thttp.Error(w, jsonErr.Error(), http.StatusInternalServerError)\\n\\t}\\n\\n\\tlogger.WithFields(logrus.Fields{\\n\\t\\t\\\"LambdaEvent\\\": lambdaEvent,\\n\\t}).Debug(\\\"CloudFormation Lambda event\\\")\\n\\n\\t// Setup the request and send it off\\n\\tcustomResourceRequest := &cloudformationresources.CustomResourceRequest{}\\n\\tcustomResourceRequest.RequestType = lambdaEvent.RequestType\\n\\tcustomResourceRequest.ResponseURL = lambdaEvent.ResponseURL\\n\\tcustomResourceRequest.StackID = lambdaEvent.StackID\\n\\tcustomResourceRequest.RequestID = lambdaEvent.RequestID\\n\\tcustomResourceRequest.LogicalResourceID = lambdaEvent.LogicalResourceID\\n\\tcustomResourceRequest.PhysicalResourceID = lambdaEvent.PhysicalResourceID\\n\\tcustomResourceRequest.LogGroupName = context.LogGroupName\\n\\tcustomResourceRequest.LogStreamName = context.LogStreamName\\n\\tcustomResourceRequest.ResourceProperties = lambdaEvent.ResourceProperties\\n\\tif \\\"\\\" == customResourceRequest.PhysicalResourceID {\\n\\t\\tcustomResourceRequest.PhysicalResourceID = fmt.Sprintf(\\\"LogStreamName: %s\\\", context.LogStreamName)\\n\\t}\\n\\n\\trequestErr := cloudformationresources.Handle(customResourceRequest, logger)\\n\\tif requestErr != nil {\\n\\t\\thttp.Error(w, requestErr.Error(), http.StatusInternalServerError)\\n\\t} else {\\n\\t\\tfmt.Fprint(w, \\\"CustomResource handled: \\\"+lambdaEvent.LogicalResourceID)\\n\\t}\\n}\",\n \"func TestNotLambda(t *testing.T) {\\n\\tctx := context.Background()\\n\\tlambdaDetector, err := NewDetector(processortest.NewNopCreateSettings(), CreateDefaultConfig())\\n\\trequire.NoError(t, err)\\n\\tres, _, err := lambdaDetector.Detect(ctx)\\n\\trequire.NoError(t, err)\\n\\trequire.NotNil(t, res)\\n\\n\\tassert.Equal(t, 0, res.Attributes().Len(), \\\"Resource object should be empty\\\")\\n}\",\n \"func NewCustomAccessPackageWorkflowExtension()(*CustomAccessPackageWorkflowExtension) {\\n m := &CustomAccessPackageWorkflowExtension{\\n CustomCalloutExtension: *NewCustomCalloutExtension(),\\n }\\n odataTypeValue := \\\"#microsoft.graph.customAccessPackageWorkflowExtension\\\"\\n m.SetOdataType(&odataTypeValue)\\n return m\\n}\",\n \"func CodeLambdaPath(lambdaID int) string {\\n\\tparam0 := strconv.Itoa(lambdaID)\\n\\n\\treturn fmt.Sprintf(\\\"/p7/lambdas/%s/actions/code\\\", param0)\\n}\",\n \"func NewCustomParser(commandMap stringmap.StringMap) *CustomParser {\\n\\treturn &CustomParser{\\n\\t\\tcommandMap: commandMap,\\n\\t}\\n}\",\n \"func CustomGenerateTagFunc(name, typ, tag string) string {\\n\\treturn fmt.Sprintf(\\\"json:\\\\\\\"%s\\\\\\\"\\\", tag)\\n}\",\n \"func LambdaHandler(functionName string,\\n\\tlogLevel string,\\n\\teventJSON string,\\n\\tawsCredentials *credentials.Credentials) ([]byte, http.Header, error) {\\n\\tstartTime := time.Now()\\n\\n\\treadableBody := bytes.NewReader([]byte(eventJSON))\\n\\treadbleBodyCloser := ioutil.NopCloser(readableBody)\\n\\t// Update the credentials\\n\\tmuCredentials.Lock()\\n\\tvalue, valueErr := awsCredentials.Get()\\n\\tif nil != valueErr {\\n\\t\\tmuCredentials.Unlock()\\n\\t\\treturn nil, nil, valueErr\\n\\t}\\n\\tpythonCredentialsValue.AccessKeyID = value.AccessKeyID\\n\\tpythonCredentialsValue.SecretAccessKey = value.SecretAccessKey\\n\\tpythonCredentialsValue.SessionToken = value.SessionToken\\n\\tpythonCredentialsValue.ProviderName = \\\"PythonCGO\\\"\\n\\tmuCredentials.Unlock()\\n\\n\\t// Unpack the JSON request, turn it into a proto here and pass it\\n\\t// into the handler...\\n\\n\\t// Update the credentials in the HTTP handler\\n\\t// in case we're ultimately forwarding to a custom\\n\\t// resource provider\\n\\tcgoLambdaHTTPAdapter.lambdaHTTPHandlerInstance.Credentials(pythonCredentialsValue)\\n\\tlogrusLevel, logrusLevelErr := logrus.ParseLevel(logLevel)\\n\\tif logrusLevelErr == nil {\\n\\t\\tcgoLambdaHTTPAdapter.logger.SetLevel(logrusLevel)\\n\\t}\\n\\tcgoLambdaHTTPAdapter.logger.WithFields(logrus.Fields{\\n\\t\\t\\\"Resource\\\": functionName,\\n\\t\\t\\\"Request\\\": eventJSON,\\n\\t}).Debug(\\\"Making request\\\")\\n\\n\\t// Make the request...\\n\\tresponse, header, err := makeRequest(functionName, readbleBodyCloser, int64(len(eventJSON)))\\n\\n\\t// TODO: Consider go routine\\n\\tpostMetrics(awsCredentials, functionName, len(response), time.Since(startTime))\\n\\n\\tcgoLambdaHTTPAdapter.logger.WithFields(logrus.Fields{\\n\\t\\t\\\"Header\\\": header,\\n\\t\\t\\\"Error\\\": err,\\n\\t}).Debug(\\\"Request response\\\")\\n\\n\\treturn response, header, err\\n}\",\n \"func NewCustomEvent(userID, sessionID, context string) CustomEvent {\\n\\treturn CustomEvent{\\n\\t\\tEventMeta: logger.NewEventMeta(logger.Flag(\\\"custom_event\\\")),\\n\\t\\tUserID: userID,\\n\\t\\tSessionID: sessionID,\\n\\t\\tContext: context,\\n\\t}\\n}\",\n \"func NewCommandFromPayload(contract string, payload []byte) (domain.Command, error) {\\n\\tswitch contract {\\n\\tcase RegisterUserWithEmail:\\n\\t\\tcommand := RegisterWithEmail{}\\n\\t\\tif err := json.Unmarshal(payload, &command); err != nil {\\n\\t\\t\\treturn command, apperrors.Wrap(err)\\n\\t\\t}\\n\\n\\t\\treturn command, nil\\n\\tcase RegisterUserWithGoogle:\\n\\t\\tcommand := RegisterWithGoogle{}\\n\\t\\tif err := json.Unmarshal(payload, &command); err != nil {\\n\\t\\t\\treturn command, apperrors.Wrap(err)\\n\\t\\t}\\n\\n\\t\\treturn command, nil\\n\\tcase RegisterUserWithFacebook:\\n\\t\\tcommand := RegisterWithFacebook{}\\n\\t\\tif err := json.Unmarshal(payload, &command); err != nil {\\n\\t\\t\\treturn command, apperrors.Wrap(err)\\n\\t\\t}\\n\\n\\t\\treturn command, nil\\n\\tcase ChangeUserEmailAddress:\\n\\t\\tcommand := ChangeEmailAddress{}\\n\\t\\tif err := json.Unmarshal(payload, &command); err != nil {\\n\\t\\t\\treturn command, apperrors.Wrap(err)\\n\\t\\t}\\n\\n\\t\\treturn command, nil\\n\\tdefault:\\n\\t\\treturn nil, apperrors.Wrap(fmt.Errorf(\\\"invalid command contract: %s\\\", contract))\\n\\t}\\n}\",\n \"func NewCustomServer(c func() Codec, listener net.Listener) *Server {\\n\\treturn &Server{\\n\\t\\tcodec: c,\\n\\t\\tlistener: &onceCloseListener{Listener: listener},\\n\\t}\\n}\",\n \"func HandleLambdaEvent(event MyEvent) (MyResponse, error) {\\n\\tfmt.Printf(\\\"event argument: %#v\\\", event)\\n\\treturn MyResponse{Message: fmt.Sprintf(\\\"%s is %d years old!\\\", event.Name, event.Age)}, nil\\n}\",\n \"func LambdaHandler(user string) (ResponseData, error) {\\n\\n\\tvar res ResponseData\\n\\tvar accessSecret secretParameters\\n\\n\\t// Connection information\\n\\tsess := session.Must(session.NewSessionWithOptions(session.Options{\\n\\t\\tSharedConfigState: session.SharedConfigEnable,\\n\\t}))\\n\\n\\tvuser, e := createUser(sess, user)\\n\\n\\tif e != nil {\\n\\t\\tfmt.Println(e.Error())\\n\\t\\treturn res, e\\n\\t}\\n\\n\\tres.ResponseMessage = fmt.Sprintln(\\\"User created:\\\", user)\\n\\n\\tif _, e := createAccessKey(sess, vuser); e != nil {\\n\\t\\tfmt.Println(e.Error())\\n\\t\\treturn res, e\\n\\t}\\n\\n\\tres.ResponseMessage = fmt.Sprintln(\\\"Access Key created:\\\", accessSecret.AccessKey)\\n\\n\\treturn res, nil\\n\\n}\",\n \"func (c *Client) RunLambda(ctx context.Context, path string) (*http.Response, error) {\\n\\treq, err := c.NewRunLambdaRequest(ctx, path)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn c.Client.Do(ctx, req)\\n}\",\n \"func New(repo eventsource.Repository, preprocessors ...Preprocessor) Dispatcher {\\n\\treturn dispatchFunc(func(ctx context.Context, cmd Interface) error {\\n\\t\\tfor _, p := range preprocessors {\\n\\t\\t\\terr := p.Before(ctx, cmd)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\treturn eventsource.NewError(err, CodePreprocessorErr, \\\"processor failed on command, %#v\\\", cmd)\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\tvar aggregate eventsource.Aggregate\\n\\t\\tif v, ok := cmd.(Constructor); ok && v.New() {\\n\\t\\t\\taggregate = repo.New()\\n\\n\\t\\t} else {\\n\\t\\t\\taggregateID := cmd.AggregateID()\\n\\t\\t\\tv, err := repo.Load(ctx, aggregateID)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\treturn eventsource.NewError(err, CodeEventLoadErr, \\\"Unable to load %v [%v]\\\", typeOf(repo.New()), aggregateID)\\n\\t\\t\\t}\\n\\t\\t\\taggregate = v\\n\\t\\t}\\n\\n\\t\\thandler, ok := aggregate.(Handler)\\n\\t\\tif !ok {\\n\\t\\t\\treturn eventsource.NewError(nil, CodeAggregateNotCommandHandler, \\\"%#v does not implement command.Handler\\\", typeOf(aggregate))\\n\\t\\t}\\n\\n\\t\\tevents, err := handler.Apply(ctx, cmd)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn eventsource.NewError(err, CodeHandlerErr, \\\"Failed to apply command, %v, to aggregate, %v\\\", typeOf(cmd), typeOf(aggregate))\\n\\t\\t}\\n\\n\\t\\terr = repo.Save(ctx, events...)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn eventsource.NewError(err, CodeSaveErr, \\\"Failed to save events for %v, %v\\\", typeOf(aggregate), cmd.AggregateID())\\n\\t\\t}\\n\\n\\t\\treturn nil\\n\\t})\\n}\",\n \"func NewSDKActor(execute func(string) string) SDKActor {\\n sdkActor := SDKActor{}\\n sdkActor.connector = newConnector()\\n sdkActor.execute = execute\\n return sdkActor\\n}\",\n \"func addCloudformationLambdaFunctions(template *cloudformation.Template, functions map[string]cloudformation.AWSServerlessFunction) {\\n\\t// convert all lambda functions to serverless functions so that invoke works for them\\n\\tfor n, f := range template.GetAllAWSLambdaFunctionResources() {\\n\\t\\tif _, found := functions[n]; !found {\\n\\t\\t\\tfunctions[n] = lambdaToServerless(f)\\n\\t\\t}\\n\\t}\\n}\",\n \"func NewCreate(f func(string, string, []string) (proto.Message, error)) *cobra.Command {\\n\\tvar (\\n\\t\\tdisplayName string\\n\\t\\tpermissionIDs []string\\n\\t)\\n\\n\\tcmd := template.NewArg1Proto(\\\"create ROLE_ID\\\", \\\"Create a new role\\\", func(cmd *cobra.Command, arg string) (proto.Message, error) {\\n\\t\\tvar names []string\\n\\t\\tfor _, p := range permissionIDs {\\n\\t\\t\\tnames = append(names, fmt.Sprintf(\\\"permissions/%s\\\", p))\\n\\t\\t}\\n\\t\\treturn f(arg, displayName, names)\\n\\t})\\n\\n\\tcmd.Flags().StringVar(&displayName, \\\"display-name\\\", \\\"\\\", \\\"display name\\\")\\n\\tcmd.Flags().StringSliceVar(&permissionIDs, \\\"permission-ids\\\", nil, \\\"permission ids\\\")\\n\\n\\treturn cmd\\n}\",\n \"func NewCustom(executor executor.Executor) executor.Launcher {\\n\\treturn New(executor, fmt.Sprintf(\\\"stress-ng-custom %s\\\", StressngCustomArguments.Value()), StressngCustomArguments.Value())\\n}\",\n \"func NewFunction(ctx *pulumi.Context,\\n\\tname string, args *FunctionArgs, opts ...pulumi.ResourceOption) (*Function, error) {\\n\\tif args == nil {\\n\\t\\targs = &FunctionArgs{}\\n\\t}\\n\\n\\treplaceOnChanges := pulumi.ReplaceOnChanges([]string{\\n\\t\\t\\\"location\\\",\\n\\t\\t\\\"project\\\",\\n\\t})\\n\\topts = append(opts, replaceOnChanges)\\n\\topts = internal.PkgResourceDefaultOpts(opts)\\n\\tvar resource Function\\n\\terr := ctx.RegisterResource(\\\"google-native:cloudfunctions/v2:Function\\\", name, args, &resource, opts...)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn &resource, nil\\n}\",\n \"func toFunc(commandName string) (Command, error) {\\n\\tswitch strings.ToLower(commandName) {\\n\\tdefault:\\n\\t\\treturn nil, errors.New(\\\"invalid command.\\\")\\n\\tcase \\\".quit\\\":\\n\\t\\treturn Quit, nil\\n\\tcase \\\".kick\\\":\\n\\t\\treturn KickOut, nil\\n\\tcase \\\".dm\\\":\\n\\t\\treturn DM, nil\\n\\tcase \\\".list\\\":\\n\\t\\treturn ListMembers, nil\\n\\tcase \\\".msg\\\":\\n\\t\\treturn Message, nil\\n\\t}\\n}\",\n \"func NewLambdaClient(opt Options) *lambdaClient {\\n\\treturn &lambdaClient{\\n\\t\\topt: opt,\\n\\t}\\n}\",\n \"func NewInvokeRequestWithoutParam() *InvokeRequest {\\n\\n return &InvokeRequest{\\n JDCloudRequest: core.JDCloudRequest{\\n URL: \\\"/regions/{regionId}/functions/{functionName}/versions/{versionName}:invoke\\\",\\n Method: \\\"POST\\\",\\n Header: nil,\\n Version: \\\"v1\\\",\\n },\\n }\\n}\",\n \"func CreateLambdaCloudwatchAlarm(region string, functionName string, metricName string, namespace string, threshold float64, action string) bool {\\n\\tawsSession, _ := InitAwsSession(region)\\n\\tsvc := cloudwatch.New(awsSession)\\n\\tinput := &cloudwatch.PutMetricAlarmInput{\\n\\t\\tAlarmName: aws.String(fmt.Sprintf(\\\"%v on %v\\\", metricName, functionName)),\\n\\t\\tComparisonOperator: aws.String(cloudwatch.ComparisonOperatorGreaterThanOrEqualToThreshold),\\n\\t\\tEvaluationPeriods: aws.Int64(1),\\n\\t\\tMetricName: aws.String(metricName),\\n\\t\\tNamespace: aws.String(namespace),\\n\\t\\tPeriod: aws.Int64(60),\\n\\t\\tStatistic: aws.String(cloudwatch.StatisticSum),\\n\\t\\tThreshold: aws.Float64(threshold),\\n\\t\\tActionsEnabled: aws.Bool(true),\\n\\t\\tAlarmDescription: aws.String(fmt.Sprintf(\\\"%v on %v greater than %v\\\", metricName, functionName, threshold)),\\n\\n\\t\\tDimensions: []*cloudwatch.Dimension{\\n\\t\\t\\t{\\n\\t\\t\\t\\tName: aws.String(\\\"FunctionName\\\"),\\n\\t\\t\\t\\tValue: aws.String(functionName),\\n\\t\\t\\t},\\n\\t\\t},\\n\\n\\t\\tAlarmActions: []*string{\\n\\t\\t\\taws.String(action),\\n\\t\\t},\\n\\t}\\n\\n\\t// Debug input\\n\\t// fmt.Println(input)\\n\\n\\t_, err := svc.PutMetricAlarm(input)\\n\\tif err != nil {\\n\\t\\tfmt.Println(\\\"Error\\\", err)\\n\\t\\treturn false\\n\\t}\\n\\n\\treturn true\\n}\",\n \"func lambdaToServerless(lambda cloudformation.AWSLambdaFunction) (serverless cloudformation.AWSServerlessFunction) {\\n\\t// serverless policies are not needed because lambdas have a role\\n\\tserverless.Policies = nil\\n\\n\\t// no events are associated with the function\\n\\tserverless.Events = nil\\n\\n\\t// codeUri is set to nil in order to get the code locally and not from a remote source\\n\\tserverless.CodeUri = nil\\n\\n\\tserverless.FunctionName = lambda.FunctionName\\n\\tserverless.Description = lambda.Description\\n\\tserverless.Handler = lambda.Handler\\n\\tserverless.Timeout = lambda.Timeout\\n\\tserverless.KmsKeyArn = lambda.KmsKeyArn\\n\\tserverless.Role = lambda.Role\\n\\tserverless.Runtime = lambda.Runtime\\n\\tserverless.MemorySize = lambda.MemorySize\\n\\n\\tif lambda.DeadLetterConfig != nil {\\n\\t\\tdlqType := \\\"SQS\\\"\\n\\t\\tmatch := dlqTypeEx.FindAllStringSubmatch(lambda.DeadLetterConfig.TargetArn, -1)\\n\\t\\tif len(match) > 0 {\\n\\t\\t\\tdlqType = match[0][1]\\n\\t\\t}\\n\\n\\t\\tserverless.DeadLetterQueue = &cloudformation.AWSServerlessFunction_DeadLetterQueue{\\n\\t\\t\\tTargetArn: lambda.DeadLetterConfig.TargetArn,\\n\\t\\t\\tType: strings.ToUpper(dlqType),\\n\\t\\t}\\n\\t}\\n\\n\\tif len(lambda.Tags) > 0 {\\n\\t\\ttags := make(map[string]string)\\n\\t\\tfor _, t := range lambda.Tags {\\n\\t\\t\\ttags[t.Key] = t.Value\\n\\t\\t}\\n\\t\\tserverless.Tags = tags\\n\\t}\\n\\n\\tif lambda.TracingConfig != nil {\\n\\t\\tserverless.Tracing = lambda.TracingConfig.Mode\\n\\t}\\n\\n\\tif lambda.Environment != nil {\\n\\t\\tserverless.Environment = &cloudformation.AWSServerlessFunction_FunctionEnvironment{\\n\\t\\t\\tVariables: lambda.Environment.Variables,\\n\\t\\t}\\n\\t}\\n\\n\\tif lambda.VpcConfig != nil {\\n\\t\\tserverless.VpcConfig = &cloudformation.AWSServerlessFunction_VpcConfig{\\n\\t\\t\\tSecurityGroupIds: lambda.VpcConfig.SecurityGroupIds,\\n\\t\\t\\tSubnetIds: lambda.VpcConfig.SubnetIds,\\n\\t\\t}\\n\\t}\\n\\n\\treturn\\n}\",\n \"func newEventHandler(fn interface{}, configurators []EventConfigurator) *eventHandler {\\n\\te := &eventHandler{\\n\\t\\tcallBack: reflect.ValueOf(fn),\\n\\t\\tMutex: sync.Mutex{},\\n\\t}\\n\\t// config\\n\\tfor i := range configurators {\\n\\t\\tconfigurators[i](e)\\n\\t}\\n\\treturn e\\n}\",\n \"func ClosureNew(f interface{}) *C.GClosure {\\n\\tclosure := C._g_closure_new()\\n\\tclosures.Lock()\\n\\tclosures.m[closure] = reflect.ValueOf(f)\\n\\tclosures.Unlock()\\n\\treturn closure\\n}\",\n \"func newSshNativeTask(host string, cmd string, opt Options) func() (interface{}, error) {\\n\\tstate := &sshNativeTask{\\n\\t\\tHost: host,\\n\\t\\tCmd: cmd,\\n\\t\\tOpts: opt,\\n\\t}\\n\\treturn state.run\\n}\",\n \"func (c *Client) NewListLambdaRequest(ctx context.Context, path string) (*http.Request, error) {\\n\\tscheme := c.Scheme\\n\\tif scheme == \\\"\\\" {\\n\\t\\tscheme = \\\"http\\\"\\n\\t}\\n\\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\\n\\treq, err := http.NewRequest(\\\"GET\\\", u.String(), nil)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn req, nil\\n}\",\n \"func (s *SimilarityLMJelinekMercer) Lambda(lambda float32) *SimilarityLMJelinekMercer {\\n\\ts.lambda = &lambda\\n\\treturn s\\n}\",\n \"func NewQueryLambdaSql(query string) *QueryLambdaSql {\\n\\tthis := QueryLambdaSql{}\\n\\tthis.Query = query\\n\\treturn &this\\n}\",\n \"func NewUrl(ctx *pulumi.Context,\\n\\tname string, args *UrlArgs, opts ...pulumi.ResourceOption) (*Url, error) {\\n\\tif args == nil {\\n\\t\\treturn nil, errors.New(\\\"missing one or more required arguments\\\")\\n\\t}\\n\\n\\tif args.AuthType == nil {\\n\\t\\treturn nil, errors.New(\\\"invalid value for required argument 'AuthType'\\\")\\n\\t}\\n\\tif args.TargetFunctionArn == nil {\\n\\t\\treturn nil, errors.New(\\\"invalid value for required argument 'TargetFunctionArn'\\\")\\n\\t}\\n\\topts = internal.PkgResourceDefaultOpts(opts)\\n\\tvar resource Url\\n\\terr := ctx.RegisterResource(\\\"aws-native:lambda:Url\\\", name, args, &resource, opts...)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn &resource, nil\\n}\",\n \"func LambdaHref(lambdaID interface{}) string {\\n\\tparamlambdaID := strings.TrimLeftFunc(fmt.Sprintf(\\\"%v\\\", lambdaID), func(r rune) bool { return r == '/' })\\n\\treturn fmt.Sprintf(\\\"/p7/lambdas/%v\\\", paramlambdaID)\\n}\"\n]"},"negative_scores":{"kind":"list like","value":["0.6809891","0.6555737","0.6116072","0.60545045","0.5895499","0.5475411","0.5467674","0.5454632","0.5418645","0.5418645","0.538186","0.53744304","0.5372076","0.536581","0.5345117","0.53066945","0.5267985","0.52672946","0.5256035","0.5200754","0.5184864","0.5184864","0.5184864","0.51721776","0.51703125","0.51580137","0.51187295","0.50939065","0.506364","0.49800122","0.49760208","0.49675593","0.49281847","0.48972243","0.4870489","0.4867049","0.4863693","0.48613295","0.485114","0.4850815","0.48295268","0.48227012","0.48200744","0.48112348","0.4787294","0.47851422","0.47829318","0.47767264","0.47541043","0.47314","0.47302604","0.47238705","0.47221518","0.47174153","0.46917486","0.46753088","0.46611547","0.4649559","0.46482468","0.46479818","0.4639956","0.4621591","0.46049756","0.4593627","0.45899028","0.45727336","0.45695084","0.45656455","0.45638037","0.45586723","0.45384824","0.45354882","0.45279256","0.4519368","0.4516676","0.45063096","0.44951943","0.44897914","0.4486728","0.44761276","0.44690752","0.4468953","0.4456732","0.4453384","0.44310603","0.44280532","0.44229728","0.44188035","0.44161516","0.44130284","0.4410222","0.44100836","0.44069695","0.44022852","0.43979096","0.43900245","0.43812287","0.4378663","0.43775675","0.4374682"],"string":"[\n \"0.6809891\",\n \"0.6555737\",\n \"0.6116072\",\n \"0.60545045\",\n \"0.5895499\",\n \"0.5475411\",\n \"0.5467674\",\n \"0.5454632\",\n \"0.5418645\",\n \"0.5418645\",\n \"0.538186\",\n \"0.53744304\",\n \"0.5372076\",\n \"0.536581\",\n \"0.5345117\",\n \"0.53066945\",\n \"0.5267985\",\n \"0.52672946\",\n \"0.5256035\",\n \"0.5200754\",\n \"0.5184864\",\n \"0.5184864\",\n \"0.5184864\",\n \"0.51721776\",\n \"0.51703125\",\n \"0.51580137\",\n \"0.51187295\",\n \"0.50939065\",\n \"0.506364\",\n \"0.49800122\",\n \"0.49760208\",\n \"0.49675593\",\n \"0.49281847\",\n \"0.48972243\",\n \"0.4870489\",\n \"0.4867049\",\n \"0.4863693\",\n \"0.48613295\",\n \"0.485114\",\n \"0.4850815\",\n \"0.48295268\",\n \"0.48227012\",\n \"0.48200744\",\n \"0.48112348\",\n \"0.4787294\",\n \"0.47851422\",\n \"0.47829318\",\n \"0.47767264\",\n \"0.47541043\",\n \"0.47314\",\n \"0.47302604\",\n \"0.47238705\",\n \"0.47221518\",\n \"0.47174153\",\n \"0.46917486\",\n \"0.46753088\",\n \"0.46611547\",\n \"0.4649559\",\n \"0.46482468\",\n \"0.46479818\",\n \"0.4639956\",\n \"0.4621591\",\n \"0.46049756\",\n \"0.4593627\",\n \"0.45899028\",\n \"0.45727336\",\n \"0.45695084\",\n \"0.45656455\",\n \"0.45638037\",\n \"0.45586723\",\n \"0.45384824\",\n \"0.45354882\",\n \"0.45279256\",\n \"0.4519368\",\n \"0.4516676\",\n \"0.45063096\",\n \"0.44951943\",\n \"0.44897914\",\n \"0.4486728\",\n \"0.44761276\",\n \"0.44690752\",\n \"0.4468953\",\n \"0.4456732\",\n \"0.4453384\",\n \"0.44310603\",\n \"0.44280532\",\n \"0.44229728\",\n \"0.44188035\",\n \"0.44161516\",\n \"0.44130284\",\n \"0.4410222\",\n \"0.44100836\",\n \"0.44069695\",\n \"0.44022852\",\n \"0.43979096\",\n \"0.43900245\",\n \"0.43812287\",\n \"0.4378663\",\n \"0.43775675\",\n \"0.4374682\"\n]"},"document_score":{"kind":"string","value":"0.8538253"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":105060,"cells":{"query":{"kind":"string","value":"Name returns the custom lambda's name"},"document":{"kind":"string","value":"func (l *CustomLambda) Name() string {\n\treturn l.name\n}"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["func Name(ctx context.Context) string {\n\tf, ok := ctx.Value(stateKey).(*Func)\n\tif !ok {\n\t\treturn \"\"\n\t}\n\tname := runtime.FuncForPC(reflect.ValueOf(*f).Pointer()).Name()\n\treturn strings.TrimRight(nameRe.FindStringSubmatch(name)[1], \")\")\n}","func (m Function) Name() string {\n\treturn m.name\n}","func (n *BindFnNode) Name() string { return n.name }","func (t *Test) Name() string {\n\treturn t.callable.Name()\n}","func (f *Function) Name() string {\n\treturn \"\"\n}","func (o FunctionOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Function) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}","func (f *Function) Name() string {\n\treturn f.name\n}","func (v *Function) GetName() (o string) {\n\tif v != nil {\n\t\to = v.Name\n\t}\n\treturn\n}","func (r *AwsCloudwatchLogGroupLambdaRetentionRule) Name() string {\n\treturn \"aws_cloudwatch_log_group_lambda_retention\"\n}","func (n *FnInvNode) Name() string {\n\treturn n.name\n}","func (mg MessageHandler) Name() string {\n\treturn nameFromFunc(mg)\n}","func (f LetFunction) Name() string {\n\treturn f.name\n}","func (oe *OraErr) FunName() string { return oe.funName }","func (fnGet) Name() string {\n\treturn \"get\"\n}","func (x InfrastructureAwsLambdaFunctionEntity) GetName() string {\n\treturn x.Name\n}","func (m Method) Name() string {\n\treturn m.function.name\n}","func (c criterionFunc) Name() string {\n\treturn c.name\n}","func (dlmg RawMessageHandler) Name() string {\n\treturn nameFromFunc(dlmg)\n}","func FuncName(i interface{}) string {\n\treturn runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()\n}","func NewCustomLambda(name, command string) *CustomLambda {\n\treturn &CustomLambda{\n\t\tname: name,\n\t\tcommand: command,\n\t}\n}","func (maxFn) Name() string {\n\treturn \"max\"\n}","func (p *PropertyGenerator) getFnName(i int) string {\n\tif len(p.Kinds) == 1 {\n\t\treturn getMethod\n\t}\n\treturn fmt.Sprintf(\"%s%s\", getMethod, p.kindCamelName(i))\n}","func (*FunctionLength) Name() string {\n\treturn \"function-length\"\n}","func (o RegistryTaskSourceTriggerOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v RegistryTaskSourceTrigger) string { return v.Name }).(pulumi.StringOutput)\n}","func (n *ExceptionNamer) Name(t *types.Type) string {\n\tkey := n.KeyFunc(t)\n\tif exception, ok := n.Exceptions[key]; ok {\n\t\treturn exception\n\t}\n\treturn n.Delegate.Name(t)\n}","func (f Function) GetName() string {\n\treturn f.ident.String()\n}","func (o AzureFunctionOutputDataSourceOutput) FunctionName() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v AzureFunctionOutputDataSource) *string { return v.FunctionName }).(pulumi.StringPtrOutput)\n}","func (DetectedAWSLambda) TableName() string {\n\treturn \"aws_lambda\"\n}","func (fva *FunctionVisibilityAnalyzer) Name() string {\n\treturn \"function visibility\"\n}","func (collector *CollectorV2[T]) Name() string {\n\treturn collector.name\n}","func (o RegistryTaskTimerTriggerOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v RegistryTaskTimerTrigger) string { return v.Name }).(pulumi.StringOutput)\n}","func NameFunc(name string, fn func(ctx context.Context) error) NamedRunner {\n\treturn Name(name, RunnerFunc(fn))\n}","func Name(v interface{}) string {\n\treturn New(v).Name()\n}","func (o AzureFunctionOutputDataSourceResponseOutput) FunctionName() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v AzureFunctionOutputDataSourceResponse) *string { return v.FunctionName }).(pulumi.StringPtrOutput)\n}","func (f *Function) Name() string {\n\tcstr := C.EnvGetDeffunctionName(f.env.env, f.fptr)\n\treturn C.GoString(cstr)\n}","func (a *RedisAction) Name() string {\n\treturn a.name\n}","func (p *FuncInfo) Name() string {\n\treturn p.name\n}","func funcName(f interface{}) string {\n\tfi := ess.GetFunctionInfo(f)\n\treturn fi.Name\n}","func (c *Event) Name() string {\n\treturn c.name\n}","func (d *Decoder) NameFunc(n func(field string, locations []int) string) {\n\td.cache.nameFunc = n\n}","func (o *CreateEventPayloadActions) GetName() string {\n\tif o == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\n\treturn o.Name\n}","func (action *scheduleRoutineAction) Name() string {\n\treturn \"schedule-routine\"\n}","func (action *scheduleRoutineAction) Name() string {\n\treturn \"schedule-routine\"\n}","func (e *BasicEvent) Name() string {\n\treturn e.name\n}","func (sqs *SQS) Name() string {\n\treturn strings.Split(sqs.Arn, \":\")[5]\n}","func (l *littr) GetFuncName(i int) string {\n\treturn l.code[i+5 : i+strings.Index(l.code[i:], \"(\")]\n}","func (f frame) name() string {\n\tfn := runtime.FuncForPC(f.pc())\n\tif fn == nil {\n\t\treturn \"unknown\"\n\t}\n\treturn fn.Name()\n}","func functionName(i func(int, int) (int, error)) string {\n\treturn runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()\n}","func (getEnvPropertyValueFn) Name() string {\n\treturn \"getEnvPropertyValue\"\n}","func (_FCToken *FCTokenCaller) Name(opts *bind.CallOpts) (string, error) {\n\tvar out []interface{}\n\terr := _FCToken.contract.Call(opts, &out, \"name\")\n\n\tif err != nil {\n\t\treturn *new(string), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(string)).(*string)\n\n\treturn out0, err\n\n}","func (x InfrastructureAwsLambdaFunctionEntityOutline) GetName() string {\n\treturn x.Name\n}","func (e *binaryExprEvaluator) name() string { return \"\" }","func (Functions) NameOf(obj interface{}) string {\n\treturn nameOf(obj)\n}","func (g Generator) InvocationName() string {\n\treturn \"action\"\n}","func (_ EventFilterAliases) Name(p graphql.ResolveParams) (string, error) {\n\tval, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)\n\tret, ok := val.(string)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\tif !ok {\n\t\treturn ret, errors.New(\"unable to coerce value for field 'name'\")\n\t}\n\treturn ret, err\n}","func (d *ActionRename) Name() string {\n\treturn renameAction\n}","func (o TriggerOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Trigger) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}","func (t Type) Name() string {\n\treturn schemas[t%EvCount].Name\n}","func (s *NamespaceWebhook) Name() string { return WebhookName }","func (e *EDNS) Name() string { return name }","func (o MethodOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v Method) *string { return v.Name }).(pulumi.StringPtrOutput)\n}","func (f nullFunc) name() name {\n\treturn null\n}","func (c *withNameAndCode) Name() string {\n\treturn c.name\n}","func (f *NamedFunction) NameString() string {\n\treturn f.Name.String()\n}","func (s *StopEvent) Name() string {\n\treturn s.name\n}","func (t *LogProviderHandler) Name() string {\n\treturn LogProvider\n}","func (e *Executor) Name() string {\n\treturn OperationName\n}","func (handler *ConsoleLogHandler) Name() string {\r\n return \"console\"\r\n}","func nameOfFunction(f interface{}) string {\n\tfun := runtime.FuncForPC(reflect.ValueOf(f).Pointer())\n\ttokenized := strings.Split(fun.Name(), \".\")\n\tlast := tokenized[len(tokenized)-1]\n\tlast = strings.TrimSuffix(last, \")·fm\") // < Go 1.5\n\tlast = strings.TrimSuffix(last, \")-fm\") // Go 1.5\n\tlast = strings.TrimSuffix(last, \"·fm\") // < Go 1.5\n\tlast = strings.TrimSuffix(last, \"-fm\") // Go 1.5\n\tif last == \"func1\" { // this could mean conflicts in API docs\n\t\tval := atomic.AddInt32(&anonymousFuncCount, 1)\n\t\tlast = \"func\" + fmt.Sprintf(\"%d\", val)\n\t\tatomic.StoreInt32(&anonymousFuncCount, val)\n\t}\n\treturn last\n}","func (n *SQSNotify) Name() string {\n\treturn n.name\n}","func (m *MockJob) Name() string {\n\tr0 := m.NameFunc.nextHook()()\n\tm.NameFunc.appendCall(JobNameFuncCall{r0})\n\treturn r0\n}","func (o *EventTypeIn) GetName() string {\n\tif o == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\n\treturn o.Name\n}","func (_ElvToken *ElvTokenCaller) Name(opts *bind.CallOpts) (string, error) {\n\tvar out []interface{}\n\terr := _ElvToken.contract.Call(opts, &out, \"name\")\n\n\tif err != nil {\n\t\treturn *new(string), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(string)).(*string)\n\n\treturn out0, err\n\n}","func NameOfEvent(t uint32) string {\n\tswitch t {\n\tcase SessionCreate:\n\t\treturn \"SessionCreate\"\n\tcase SessionDestroy:\n\t\treturn \"SessionDestroy\"\n\tcase TopicPublish:\n\t\treturn \"TopicPublish\"\n\tcase TopicSubscribe:\n\t\treturn \"TopicSubscribe\"\n\tcase TopicUnsubscribe:\n\t\treturn \"TopicUnsubscribe\"\n\tcase QutoChange:\n\t\treturn \"QutoChange\"\n\tcase SessionResume:\n\t\treturn \"SessionResume\"\n\tcase AuthChange:\n\t\treturn \"AuthChange\"\n\tdefault:\n\t\treturn \"Unknown\"\n\t}\n}","func (app *App) Name(name func(string) string) *App {\n\tapp.name = name\n\treturn app\n}","func (ext *GetExtendedResourcesFunction) Name() string {\n\treturn \"GetExtendedResources\"\n}","func (t EventType) GetName() string {\n\treturn C.GoString((*C.char)(C.gst_event_type_get_name(C.GstEventType(t))))\n}","func (f Frame) name() string {\n\tfn := runtime.FuncForPC(f.pc())\n\tif fn == nil {\n\t\treturn \"unknown\"\n\t}\n\treturn fn.Name()\n}","func (o OrganizationJobTriggerOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *OrganizationJobTrigger) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}","func (fn *Func) FuncName() string {\n\treturn fn.fnName\n}","func (method *Method) GetName() string { return method.Name }","func (g Generator) Name() string {\n\treturn \"buffalo/generate-action\"\n}","func (o TriggerGithubOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v TriggerGithub) *string { return v.Name }).(pulumi.StringPtrOutput)\n}","func (ctx *Context) HandlerName() string {\n\treturn nameOfFunction(ctx.handlers.last())\n}","func (p *PropertyGenerator) deserializeFnName() string {\n\tif p.asIterator {\n\t\treturn fmt.Sprintf(\"%s%s\", deserializeIteratorMethod, p.Name.CamelName)\n\t}\n\treturn fmt.Sprintf(\"%s%sProperty\", deserializeMethod, p.Name.CamelName)\n}","func (_ZKOnacci *ZKOnacciCaller) Name(opts *bind.CallOpts) (string, error) {\n\tvar out []interface{}\n\terr := _ZKOnacci.contract.Call(opts, &out, \"name\")\n\n\tif err != nil {\n\t\treturn *new(string), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(string)).(*string)\n\n\treturn out0, err\n\n}","func name(obj, eventType, eventSource string) string {\n\t// Pod names need to be lowercase. We might have an eventType as Any, that is why we lowercase them.\n\tif eventType == \"\" {\n\t\teventType = \"testany\"\n\t}\n\tif eventSource == \"\" {\n\t\teventSource = \"testany\"\n\t}\n\treturn strings.ToLower(fmt.Sprintf(\"%s-%s-%s\", obj, eventType, eventSource))\n}","func (t Scalar) Name() string {\n\treturn strings.Title(t.Type)\n}","func (o EventIntegrationOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *EventIntegration) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}","func (p *PropertyGenerator) serializeFnName() string {\n\tif p.asIterator {\n\t\treturn serializeIteratorMethod\n\t}\n\treturn serializeMethod\n}","func (v ValidationFilter) Name() string {\r\n\treturn FilterValidation\r\n}","func (*unifinames) Name() string { return \"unifi-names\" }","func (pc *HTTPProxyClient) GetFunctionName(r *http.Request) string {\n\tvars := mux.Vars(r)\n\treturn vars[\"name\"]\n}","func (o LookupListenerResultOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v LookupListenerResult) string { return v.Name }).(pulumi.StringOutput)\n}","func (s *Instruction) FuncName() string {\n\tif name, ok := protoNameToFuncName[s.Protobuf.TypeName]; ok {\n\t\treturn name\n\t}\n\treturn \"?\"\n}","func (Functions) CommandName(obj interface{}) string {\n\treturn nameOptions{}.convert(nameOf(obj))\n}","func (e *ChainEncryptor) Name() string {\n\treturn e.name\n}","func FuncName(frame *govulncheck.StackFrame) string {\n\tswitch {\n\tcase frame.Receiver != \"\":\n\t\treturn fmt.Sprintf(\"%s.%s\", strings.TrimPrefix(frame.Receiver, \"*\"), frame.Function)\n\tcase frame.Package != \"\":\n\t\treturn fmt.Sprintf(\"%s.%s\", frame.Package, frame.Function)\n\tdefault:\n\t\treturn frame.Function\n\t}\n}","func (c Code) Name() string {\n\treturn codeName[c]\n}","func (of OperatorFactory) Name() string {\n\treturn operatorName\n}"],"string":"[\n \"func Name(ctx context.Context) string {\\n\\tf, ok := ctx.Value(stateKey).(*Func)\\n\\tif !ok {\\n\\t\\treturn \\\"\\\"\\n\\t}\\n\\tname := runtime.FuncForPC(reflect.ValueOf(*f).Pointer()).Name()\\n\\treturn strings.TrimRight(nameRe.FindStringSubmatch(name)[1], \\\")\\\")\\n}\",\n \"func (m Function) Name() string {\\n\\treturn m.name\\n}\",\n \"func (n *BindFnNode) Name() string { return n.name }\",\n \"func (t *Test) Name() string {\\n\\treturn t.callable.Name()\\n}\",\n \"func (f *Function) Name() string {\\n\\treturn \\\"\\\"\\n}\",\n \"func (o FunctionOutput) Name() pulumi.StringOutput {\\n\\treturn o.ApplyT(func(v *Function) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\\n}\",\n \"func (f *Function) Name() string {\\n\\treturn f.name\\n}\",\n \"func (v *Function) GetName() (o string) {\\n\\tif v != nil {\\n\\t\\to = v.Name\\n\\t}\\n\\treturn\\n}\",\n \"func (r *AwsCloudwatchLogGroupLambdaRetentionRule) Name() string {\\n\\treturn \\\"aws_cloudwatch_log_group_lambda_retention\\\"\\n}\",\n \"func (n *FnInvNode) Name() string {\\n\\treturn n.name\\n}\",\n \"func (mg MessageHandler) Name() string {\\n\\treturn nameFromFunc(mg)\\n}\",\n \"func (f LetFunction) Name() string {\\n\\treturn f.name\\n}\",\n \"func (oe *OraErr) FunName() string { return oe.funName }\",\n \"func (fnGet) Name() string {\\n\\treturn \\\"get\\\"\\n}\",\n \"func (x InfrastructureAwsLambdaFunctionEntity) GetName() string {\\n\\treturn x.Name\\n}\",\n \"func (m Method) Name() string {\\n\\treturn m.function.name\\n}\",\n \"func (c criterionFunc) Name() string {\\n\\treturn c.name\\n}\",\n \"func (dlmg RawMessageHandler) Name() string {\\n\\treturn nameFromFunc(dlmg)\\n}\",\n \"func FuncName(i interface{}) string {\\n\\treturn runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()\\n}\",\n \"func NewCustomLambda(name, command string) *CustomLambda {\\n\\treturn &CustomLambda{\\n\\t\\tname: name,\\n\\t\\tcommand: command,\\n\\t}\\n}\",\n \"func (maxFn) Name() string {\\n\\treturn \\\"max\\\"\\n}\",\n \"func (p *PropertyGenerator) getFnName(i int) string {\\n\\tif len(p.Kinds) == 1 {\\n\\t\\treturn getMethod\\n\\t}\\n\\treturn fmt.Sprintf(\\\"%s%s\\\", getMethod, p.kindCamelName(i))\\n}\",\n \"func (*FunctionLength) Name() string {\\n\\treturn \\\"function-length\\\"\\n}\",\n \"func (o RegistryTaskSourceTriggerOutput) Name() pulumi.StringOutput {\\n\\treturn o.ApplyT(func(v RegistryTaskSourceTrigger) string { return v.Name }).(pulumi.StringOutput)\\n}\",\n \"func (n *ExceptionNamer) Name(t *types.Type) string {\\n\\tkey := n.KeyFunc(t)\\n\\tif exception, ok := n.Exceptions[key]; ok {\\n\\t\\treturn exception\\n\\t}\\n\\treturn n.Delegate.Name(t)\\n}\",\n \"func (f Function) GetName() string {\\n\\treturn f.ident.String()\\n}\",\n \"func (o AzureFunctionOutputDataSourceOutput) FunctionName() pulumi.StringPtrOutput {\\n\\treturn o.ApplyT(func(v AzureFunctionOutputDataSource) *string { return v.FunctionName }).(pulumi.StringPtrOutput)\\n}\",\n \"func (DetectedAWSLambda) TableName() string {\\n\\treturn \\\"aws_lambda\\\"\\n}\",\n \"func (fva *FunctionVisibilityAnalyzer) Name() string {\\n\\treturn \\\"function visibility\\\"\\n}\",\n \"func (collector *CollectorV2[T]) Name() string {\\n\\treturn collector.name\\n}\",\n \"func (o RegistryTaskTimerTriggerOutput) Name() pulumi.StringOutput {\\n\\treturn o.ApplyT(func(v RegistryTaskTimerTrigger) string { return v.Name }).(pulumi.StringOutput)\\n}\",\n \"func NameFunc(name string, fn func(ctx context.Context) error) NamedRunner {\\n\\treturn Name(name, RunnerFunc(fn))\\n}\",\n \"func Name(v interface{}) string {\\n\\treturn New(v).Name()\\n}\",\n \"func (o AzureFunctionOutputDataSourceResponseOutput) FunctionName() pulumi.StringPtrOutput {\\n\\treturn o.ApplyT(func(v AzureFunctionOutputDataSourceResponse) *string { return v.FunctionName }).(pulumi.StringPtrOutput)\\n}\",\n \"func (f *Function) Name() string {\\n\\tcstr := C.EnvGetDeffunctionName(f.env.env, f.fptr)\\n\\treturn C.GoString(cstr)\\n}\",\n \"func (a *RedisAction) Name() string {\\n\\treturn a.name\\n}\",\n \"func (p *FuncInfo) Name() string {\\n\\treturn p.name\\n}\",\n \"func funcName(f interface{}) string {\\n\\tfi := ess.GetFunctionInfo(f)\\n\\treturn fi.Name\\n}\",\n \"func (c *Event) Name() string {\\n\\treturn c.name\\n}\",\n \"func (d *Decoder) NameFunc(n func(field string, locations []int) string) {\\n\\td.cache.nameFunc = n\\n}\",\n \"func (o *CreateEventPayloadActions) GetName() string {\\n\\tif o == nil {\\n\\t\\tvar ret string\\n\\t\\treturn ret\\n\\t}\\n\\n\\treturn o.Name\\n}\",\n \"func (action *scheduleRoutineAction) Name() string {\\n\\treturn \\\"schedule-routine\\\"\\n}\",\n \"func (action *scheduleRoutineAction) Name() string {\\n\\treturn \\\"schedule-routine\\\"\\n}\",\n \"func (e *BasicEvent) Name() string {\\n\\treturn e.name\\n}\",\n \"func (sqs *SQS) Name() string {\\n\\treturn strings.Split(sqs.Arn, \\\":\\\")[5]\\n}\",\n \"func (l *littr) GetFuncName(i int) string {\\n\\treturn l.code[i+5 : i+strings.Index(l.code[i:], \\\"(\\\")]\\n}\",\n \"func (f frame) name() string {\\n\\tfn := runtime.FuncForPC(f.pc())\\n\\tif fn == nil {\\n\\t\\treturn \\\"unknown\\\"\\n\\t}\\n\\treturn fn.Name()\\n}\",\n \"func functionName(i func(int, int) (int, error)) string {\\n\\treturn runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()\\n}\",\n \"func (getEnvPropertyValueFn) Name() string {\\n\\treturn \\\"getEnvPropertyValue\\\"\\n}\",\n \"func (_FCToken *FCTokenCaller) Name(opts *bind.CallOpts) (string, error) {\\n\\tvar out []interface{}\\n\\terr := _FCToken.contract.Call(opts, &out, \\\"name\\\")\\n\\n\\tif err != nil {\\n\\t\\treturn *new(string), err\\n\\t}\\n\\n\\tout0 := *abi.ConvertType(out[0], new(string)).(*string)\\n\\n\\treturn out0, err\\n\\n}\",\n \"func (x InfrastructureAwsLambdaFunctionEntityOutline) GetName() string {\\n\\treturn x.Name\\n}\",\n \"func (e *binaryExprEvaluator) name() string { return \\\"\\\" }\",\n \"func (Functions) NameOf(obj interface{}) string {\\n\\treturn nameOf(obj)\\n}\",\n \"func (g Generator) InvocationName() string {\\n\\treturn \\\"action\\\"\\n}\",\n \"func (_ EventFilterAliases) Name(p graphql.ResolveParams) (string, error) {\\n\\tval, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)\\n\\tret, ok := val.(string)\\n\\tif err != nil {\\n\\t\\treturn ret, err\\n\\t}\\n\\tif !ok {\\n\\t\\treturn ret, errors.New(\\\"unable to coerce value for field 'name'\\\")\\n\\t}\\n\\treturn ret, err\\n}\",\n \"func (d *ActionRename) Name() string {\\n\\treturn renameAction\\n}\",\n \"func (o TriggerOutput) Name() pulumi.StringOutput {\\n\\treturn o.ApplyT(func(v *Trigger) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\\n}\",\n \"func (t Type) Name() string {\\n\\treturn schemas[t%EvCount].Name\\n}\",\n \"func (s *NamespaceWebhook) Name() string { return WebhookName }\",\n \"func (e *EDNS) Name() string { return name }\",\n \"func (o MethodOutput) Name() pulumi.StringPtrOutput {\\n\\treturn o.ApplyT(func(v Method) *string { return v.Name }).(pulumi.StringPtrOutput)\\n}\",\n \"func (f nullFunc) name() name {\\n\\treturn null\\n}\",\n \"func (c *withNameAndCode) Name() string {\\n\\treturn c.name\\n}\",\n \"func (f *NamedFunction) NameString() string {\\n\\treturn f.Name.String()\\n}\",\n \"func (s *StopEvent) Name() string {\\n\\treturn s.name\\n}\",\n \"func (t *LogProviderHandler) Name() string {\\n\\treturn LogProvider\\n}\",\n \"func (e *Executor) Name() string {\\n\\treturn OperationName\\n}\",\n \"func (handler *ConsoleLogHandler) Name() string {\\r\\n return \\\"console\\\"\\r\\n}\",\n \"func nameOfFunction(f interface{}) string {\\n\\tfun := runtime.FuncForPC(reflect.ValueOf(f).Pointer())\\n\\ttokenized := strings.Split(fun.Name(), \\\".\\\")\\n\\tlast := tokenized[len(tokenized)-1]\\n\\tlast = strings.TrimSuffix(last, \\\")·fm\\\") // < Go 1.5\\n\\tlast = strings.TrimSuffix(last, \\\")-fm\\\") // Go 1.5\\n\\tlast = strings.TrimSuffix(last, \\\"·fm\\\") // < Go 1.5\\n\\tlast = strings.TrimSuffix(last, \\\"-fm\\\") // Go 1.5\\n\\tif last == \\\"func1\\\" { // this could mean conflicts in API docs\\n\\t\\tval := atomic.AddInt32(&anonymousFuncCount, 1)\\n\\t\\tlast = \\\"func\\\" + fmt.Sprintf(\\\"%d\\\", val)\\n\\t\\tatomic.StoreInt32(&anonymousFuncCount, val)\\n\\t}\\n\\treturn last\\n}\",\n \"func (n *SQSNotify) Name() string {\\n\\treturn n.name\\n}\",\n \"func (m *MockJob) Name() string {\\n\\tr0 := m.NameFunc.nextHook()()\\n\\tm.NameFunc.appendCall(JobNameFuncCall{r0})\\n\\treturn r0\\n}\",\n \"func (o *EventTypeIn) GetName() string {\\n\\tif o == nil {\\n\\t\\tvar ret string\\n\\t\\treturn ret\\n\\t}\\n\\n\\treturn o.Name\\n}\",\n \"func (_ElvToken *ElvTokenCaller) Name(opts *bind.CallOpts) (string, error) {\\n\\tvar out []interface{}\\n\\terr := _ElvToken.contract.Call(opts, &out, \\\"name\\\")\\n\\n\\tif err != nil {\\n\\t\\treturn *new(string), err\\n\\t}\\n\\n\\tout0 := *abi.ConvertType(out[0], new(string)).(*string)\\n\\n\\treturn out0, err\\n\\n}\",\n \"func NameOfEvent(t uint32) string {\\n\\tswitch t {\\n\\tcase SessionCreate:\\n\\t\\treturn \\\"SessionCreate\\\"\\n\\tcase SessionDestroy:\\n\\t\\treturn \\\"SessionDestroy\\\"\\n\\tcase TopicPublish:\\n\\t\\treturn \\\"TopicPublish\\\"\\n\\tcase TopicSubscribe:\\n\\t\\treturn \\\"TopicSubscribe\\\"\\n\\tcase TopicUnsubscribe:\\n\\t\\treturn \\\"TopicUnsubscribe\\\"\\n\\tcase QutoChange:\\n\\t\\treturn \\\"QutoChange\\\"\\n\\tcase SessionResume:\\n\\t\\treturn \\\"SessionResume\\\"\\n\\tcase AuthChange:\\n\\t\\treturn \\\"AuthChange\\\"\\n\\tdefault:\\n\\t\\treturn \\\"Unknown\\\"\\n\\t}\\n}\",\n \"func (app *App) Name(name func(string) string) *App {\\n\\tapp.name = name\\n\\treturn app\\n}\",\n \"func (ext *GetExtendedResourcesFunction) Name() string {\\n\\treturn \\\"GetExtendedResources\\\"\\n}\",\n \"func (t EventType) GetName() string {\\n\\treturn C.GoString((*C.char)(C.gst_event_type_get_name(C.GstEventType(t))))\\n}\",\n \"func (f Frame) name() string {\\n\\tfn := runtime.FuncForPC(f.pc())\\n\\tif fn == nil {\\n\\t\\treturn \\\"unknown\\\"\\n\\t}\\n\\treturn fn.Name()\\n}\",\n \"func (o OrganizationJobTriggerOutput) Name() pulumi.StringOutput {\\n\\treturn o.ApplyT(func(v *OrganizationJobTrigger) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\\n}\",\n \"func (fn *Func) FuncName() string {\\n\\treturn fn.fnName\\n}\",\n \"func (method *Method) GetName() string { return method.Name }\",\n \"func (g Generator) Name() string {\\n\\treturn \\\"buffalo/generate-action\\\"\\n}\",\n \"func (o TriggerGithubOutput) Name() pulumi.StringPtrOutput {\\n\\treturn o.ApplyT(func(v TriggerGithub) *string { return v.Name }).(pulumi.StringPtrOutput)\\n}\",\n \"func (ctx *Context) HandlerName() string {\\n\\treturn nameOfFunction(ctx.handlers.last())\\n}\",\n \"func (p *PropertyGenerator) deserializeFnName() string {\\n\\tif p.asIterator {\\n\\t\\treturn fmt.Sprintf(\\\"%s%s\\\", deserializeIteratorMethod, p.Name.CamelName)\\n\\t}\\n\\treturn fmt.Sprintf(\\\"%s%sProperty\\\", deserializeMethod, p.Name.CamelName)\\n}\",\n \"func (_ZKOnacci *ZKOnacciCaller) Name(opts *bind.CallOpts) (string, error) {\\n\\tvar out []interface{}\\n\\terr := _ZKOnacci.contract.Call(opts, &out, \\\"name\\\")\\n\\n\\tif err != nil {\\n\\t\\treturn *new(string), err\\n\\t}\\n\\n\\tout0 := *abi.ConvertType(out[0], new(string)).(*string)\\n\\n\\treturn out0, err\\n\\n}\",\n \"func name(obj, eventType, eventSource string) string {\\n\\t// Pod names need to be lowercase. We might have an eventType as Any, that is why we lowercase them.\\n\\tif eventType == \\\"\\\" {\\n\\t\\teventType = \\\"testany\\\"\\n\\t}\\n\\tif eventSource == \\\"\\\" {\\n\\t\\teventSource = \\\"testany\\\"\\n\\t}\\n\\treturn strings.ToLower(fmt.Sprintf(\\\"%s-%s-%s\\\", obj, eventType, eventSource))\\n}\",\n \"func (t Scalar) Name() string {\\n\\treturn strings.Title(t.Type)\\n}\",\n \"func (o EventIntegrationOutput) Name() pulumi.StringOutput {\\n\\treturn o.ApplyT(func(v *EventIntegration) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\\n}\",\n \"func (p *PropertyGenerator) serializeFnName() string {\\n\\tif p.asIterator {\\n\\t\\treturn serializeIteratorMethod\\n\\t}\\n\\treturn serializeMethod\\n}\",\n \"func (v ValidationFilter) Name() string {\\r\\n\\treturn FilterValidation\\r\\n}\",\n \"func (*unifinames) Name() string { return \\\"unifi-names\\\" }\",\n \"func (pc *HTTPProxyClient) GetFunctionName(r *http.Request) string {\\n\\tvars := mux.Vars(r)\\n\\treturn vars[\\\"name\\\"]\\n}\",\n \"func (o LookupListenerResultOutput) Name() pulumi.StringOutput {\\n\\treturn o.ApplyT(func(v LookupListenerResult) string { return v.Name }).(pulumi.StringOutput)\\n}\",\n \"func (s *Instruction) FuncName() string {\\n\\tif name, ok := protoNameToFuncName[s.Protobuf.TypeName]; ok {\\n\\t\\treturn name\\n\\t}\\n\\treturn \\\"?\\\"\\n}\",\n \"func (Functions) CommandName(obj interface{}) string {\\n\\treturn nameOptions{}.convert(nameOf(obj))\\n}\",\n \"func (e *ChainEncryptor) Name() string {\\n\\treturn e.name\\n}\",\n \"func FuncName(frame *govulncheck.StackFrame) string {\\n\\tswitch {\\n\\tcase frame.Receiver != \\\"\\\":\\n\\t\\treturn fmt.Sprintf(\\\"%s.%s\\\", strings.TrimPrefix(frame.Receiver, \\\"*\\\"), frame.Function)\\n\\tcase frame.Package != \\\"\\\":\\n\\t\\treturn fmt.Sprintf(\\\"%s.%s\\\", frame.Package, frame.Function)\\n\\tdefault:\\n\\t\\treturn frame.Function\\n\\t}\\n}\",\n \"func (c Code) Name() string {\\n\\treturn codeName[c]\\n}\",\n \"func (of OperatorFactory) Name() string {\\n\\treturn operatorName\\n}\"\n]"},"negative_scores":{"kind":"list like","value":["0.6796825","0.6480836","0.64511144","0.6372886","0.634839","0.6304672","0.6254236","0.6149269","0.61243826","0.61201745","0.6118296","0.6099602","0.60856926","0.60603654","0.60352004","0.5990408","0.5978422","0.5950406","0.59426147","0.59111196","0.58902586","0.5882737","0.5870252","0.5851591","0.58515304","0.5845814","0.5795807","0.57876956","0.5781971","0.5765038","0.5753295","0.57274544","0.5719827","0.5709263","0.5698399","0.5698169","0.56962085","0.56902117","0.5680151","0.56630594","0.5653816","0.56482834","0.56482834","0.5642264","0.56355757","0.563449","0.563033","0.5625635","0.5623006","0.5605839","0.5603614","0.5597817","0.55963653","0.5579961","0.5577877","0.5572013","0.5559147","0.5553601","0.55510265","0.5540461","0.55336654","0.55315393","0.55162746","0.55139023","0.5510225","0.5507841","0.5505278","0.5498224","0.5494786","0.5489895","0.548717","0.5485834","0.5482287","0.5482223","0.5481784","0.5470104","0.54659325","0.54625463","0.5461361","0.545628","0.5451694","0.54310024","0.5430077","0.54255646","0.542518","0.5423737","0.54219913","0.5420114","0.5418339","0.5418298","0.5417198","0.5414539","0.54127324","0.5410634","0.5408961","0.540808","0.54013073","0.54006517","0.539913","0.5392102"],"string":"[\n \"0.6796825\",\n \"0.6480836\",\n \"0.64511144\",\n \"0.6372886\",\n \"0.634839\",\n \"0.6304672\",\n \"0.6254236\",\n \"0.6149269\",\n \"0.61243826\",\n \"0.61201745\",\n \"0.6118296\",\n \"0.6099602\",\n \"0.60856926\",\n \"0.60603654\",\n \"0.60352004\",\n \"0.5990408\",\n \"0.5978422\",\n \"0.5950406\",\n \"0.59426147\",\n \"0.59111196\",\n \"0.58902586\",\n \"0.5882737\",\n \"0.5870252\",\n \"0.5851591\",\n \"0.58515304\",\n \"0.5845814\",\n \"0.5795807\",\n \"0.57876956\",\n \"0.5781971\",\n \"0.5765038\",\n \"0.5753295\",\n \"0.57274544\",\n \"0.5719827\",\n \"0.5709263\",\n \"0.5698399\",\n \"0.5698169\",\n \"0.56962085\",\n \"0.56902117\",\n \"0.5680151\",\n \"0.56630594\",\n \"0.5653816\",\n \"0.56482834\",\n \"0.56482834\",\n \"0.5642264\",\n \"0.56355757\",\n \"0.563449\",\n \"0.563033\",\n \"0.5625635\",\n \"0.5623006\",\n \"0.5605839\",\n \"0.5603614\",\n \"0.5597817\",\n \"0.55963653\",\n \"0.5579961\",\n \"0.5577877\",\n \"0.5572013\",\n \"0.5559147\",\n \"0.5553601\",\n \"0.55510265\",\n \"0.5540461\",\n \"0.55336654\",\n \"0.55315393\",\n \"0.55162746\",\n \"0.55139023\",\n \"0.5510225\",\n \"0.5507841\",\n \"0.5505278\",\n \"0.5498224\",\n \"0.5494786\",\n \"0.5489895\",\n \"0.548717\",\n \"0.5485834\",\n \"0.5482287\",\n \"0.5482223\",\n \"0.5481784\",\n \"0.5470104\",\n \"0.54659325\",\n \"0.54625463\",\n \"0.5461361\",\n \"0.545628\",\n \"0.5451694\",\n \"0.54310024\",\n \"0.5430077\",\n \"0.54255646\",\n \"0.542518\",\n \"0.5423737\",\n \"0.54219913\",\n \"0.5420114\",\n \"0.5418339\",\n \"0.5418298\",\n \"0.5417198\",\n \"0.5414539\",\n \"0.54127324\",\n \"0.5410634\",\n \"0.5408961\",\n \"0.540808\",\n \"0.54013073\",\n \"0.54006517\",\n \"0.539913\",\n \"0.5392102\"\n]"},"document_score":{"kind":"string","value":"0.83328086"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":105061,"cells":{"query":{"kind":"string","value":"Execute executes the custom lambda command"},"document":{"kind":"string","value":"func (l *CustomLambda) Execute(stdin io.Reader, args []string) (string, error) {\n\targsStr := strings.TrimSpace(strings.Join(args, \" \"))\n\tif argsStr != \"\" {\n\t\targsStr = \" \" + argsStr\n\t}\n\n\tcmd := exec.Command(\"bash\", \"-c\", l.command+argsStr)\n\n\t// pass through some stdin goodness\n\tcmd.Stdin = stdin\n\n\t// for those who are about to rock, I salute you.\n\tstdoutStderr, err := cmd.CombinedOutput()\n\n\tif err == nil {\n\t\t// noiiiice!\n\t\tlog.WithFields(log.Fields{\"name\": l.Name(), \"command\": l.command}).Info(\"Lambda Execution\")\n\t\treturn strings.TrimSpace(string(stdoutStderr)), nil\n\t}\n\n\t// *sigh*\n\tlog.WithFields(log.Fields{\"name\": l.Name(), \"command\": l.command}).Error(\"Lambda Execution\")\n\treturn string(stdoutStderr), errors.New(\"Error running command\")\n}"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["func (_Vault *VaultTransactor) Execute(opts *bind.TransactOpts, token common.Address, amount *big.Int, recipientToken common.Address, exchangeAddress common.Address, callData []byte, timestamp []byte, signData []byte) (*types.Transaction, error) {\n\treturn _Vault.contract.Transact(opts, \"execute\", token, amount, recipientToken, exchangeAddress, callData, timestamp, signData)\n}","func Execute(ctx context.Context, version string) {\n\tvar rootCmd = &cobra.Command{\n\t\tUse: \"act [event name to run]\",\n\t\tShort: \"Run Github actions locally by specifying the event name (e.g. `push`) or an action name directly.\",\n\t\tArgs: cobra.MaximumNArgs(1),\n\t\tRunE: newRunAction(ctx),\n\t\tVersion: version,\n\t\tSilenceUsage: true,\n\t}\n\trootCmd.Flags().BoolVarP(&list, \"list\", \"l\", false, \"list actions\")\n\trootCmd.Flags().StringVarP(&actionName, \"action\", \"a\", \"\", \"run action\")\n\trootCmd.Flags().StringVarP(&eventPath, \"event\", \"e\", \"\", \"path to event JSON file\")\n\trootCmd.PersistentFlags().BoolVarP(&dryrun, \"dryrun\", \"n\", false, \"dryrun mode\")\n\trootCmd.PersistentFlags().BoolVarP(&verbose, \"verbose\", \"v\", false, \"verbose output\")\n\trootCmd.PersistentFlags().StringVarP(&workflowPath, \"file\", \"f\", \"./.github/main.workflow\", \"path to workflow file\")\n\trootCmd.PersistentFlags().StringVarP(&workingDir, \"directory\", \"C\", \".\", \"working directory\")\n\tif err := rootCmd.Execute(); err != nil {\n\t\tos.Exit(1)\n\t}\n\n}","func (e *EvaluatedFunctionExpression) Execute(ctx *Context, args *Values) Value {\n\tctx.SetParent(e.this) // this is how closure works\n\treturn e.fn.Execute(ctx, args)\n}","func Execute(lambdaAWSInfos []*LambdaAWSInfo, port int, parentProcessPID int, logger *logrus.Logger) error {\n\tif port <= 0 {\n\t\tport = defaultHTTPPort\n\t}\n\tlogger.Info(\"Execute!\")\n\n\tlookupMap := make(dispatchMap, 0)\n\tfor _, eachLambdaInfo := range lambdaAWSInfos {\n\t\tlookupMap[eachLambdaInfo.lambdaFnName] = eachLambdaInfo\n\t}\n\tserver := &http.Server{\n\t\tAddr: fmt.Sprintf(\":%d\", port),\n\t\tHandler: &lambdaHandler{lookupMap, logger},\n\t\tReadTimeout: 10 * time.Second,\n\t\tWriteTimeout: 10 * time.Second,\n\t}\n\tif 0 != parentProcessPID {\n\t\tlogger.Debug(\"Sending SIGUSR2 to parent process: \", parentProcessPID)\n\t\tsyscall.Kill(parentProcessPID, syscall.SIGUSR2)\n\t}\n\tlogger.Debug(\"Binding to port: \", port)\n\terr := server.ListenAndServe()\n\tif err != nil {\n\t\tlogger.Error(\"FAILURE: \" + err.Error())\n\t\treturn err\n\t}\n\tlogger.Debug(\"Server available at: \", port)\n\treturn nil\n}","func (c *Command) Execute(user string, msg string, args []string) {\n}","func (_SimpleMultiSig *SimpleMultiSigTransactor) Execute(opts *bind.TransactOpts, bucketIdx uint16, expireTime *big.Int, sigV []uint8, sigR [][32]byte, sigS [][32]byte, destination common.Address, value *big.Int, data []byte, executor common.Address, gasLimit *big.Int) (*types.Transaction, error) {\n\treturn _SimpleMultiSig.contract.Transact(opts, \"execute\", bucketIdx, expireTime, sigV, sigR, sigS, destination, value, data, executor, gasLimit)\n}","func (p *Plugin) Execute(config contracts.Configuration, cancelFlag task.CancelFlag, output iohandler.IOHandler) {\n\tp.execute(config, cancelFlag, output)\n\treturn\n}","func (e *CustomExecutor) Execute(s api.DiscordSession, channel model.Snowflake, command *model.Command) {\n\tif command.Custom == nil {\n\t\tlog.Fatal(\"Incorrectly generated learn command\", errors.New(\"wat\"))\n\t}\n\n\thas, err := e.commandMap.Has(command.Custom.Call)\n\tif err != nil {\n\t\tlog.Fatal(\"Error testing custom feature\", err)\n\t}\n\tif !has {\n\t\tlog.Fatal(\"Accidentally found a mismatched call/response pair\", errors.New(\"call response mismatch\"))\n\t}\n\n\tresponse, err := e.commandMap.Get(command.Custom.Call)\n\tif err != nil {\n\t\tlog.Fatal(\"Error reading custom response\", err)\n\t}\n\n\t// Perform command substitutions.\n\tif strings.Contains(response, \"$1\") {\n\t\tif command.Custom.Args == \"\" {\n\t\t\tresponse = MsgCustomNeedsArgs\n\t\t} else {\n\t\t\tresponse = strings.Replace(response, \"$1\", command.Custom.Args, 4)\n\t\t}\n\t} else if matches := giphyRegexp.FindStringSubmatch(response); len(matches) > 2 {\n\t\turl := matches[2]\n\t\tresponse = fmt.Sprintf(MsgGiphyLink, url)\n\t}\n\n\ts.ChannelMessageSend(channel.Format(), response)\n}","func (h *Handler) Execute(name string, args []string) {\n\tlog.Warn(\"generic doesn't support command execution\")\n}","func (command SimpleCommandTestCommand) execute(notification interfaces.INotification) {\n\tvar vo = notification.Body().(*SimpleCommandTestVO)\n\n\t//Fabricate a result\n\tvo.Result = 2 * vo.Input\n}","func (s *fnSignature) Execute(ctx context.Context) ([]reflect.Value, error) {\n\tglobalBackendStatsClient().TaskExecutionCount().Inc(1)\n\ttargetArgs := make([]reflect.Value, 0, len(s.Args)+1)\n\ttargetArgs = append(targetArgs, reflect.ValueOf(ctx))\n\tfor _, arg := range s.Args {\n\t\ttargetArgs = append(targetArgs, reflect.ValueOf(arg))\n\t}\n\tif fn, ok := fnLookup.getFn(s.FnName); ok {\n\t\tfnValue := reflect.ValueOf(fn)\n\t\treturn fnValue.Call(targetArgs), nil\n\t}\n\treturn nil, fmt.Errorf(\"function: %q not found. Did you forget to register?\", s.FnName)\n}","func (_e *handler_Expecter) Execute(req interface{}, s interface{}) *handler_Execute_Call {\n\treturn &handler_Execute_Call{Call: _e.mock.On(\"Execute\", req, s)}\n}","func (vm *EVM) Execute(st acmstate.ReaderWriter, blockchain engine.Blockchain, eventSink exec.EventSink,\n\tparams engine.CallParams, code []byte) ([]byte, error) {\n\n\t// Make it appear as if natives are stored in state\n\tst = native.NewState(vm.options.Natives, st)\n\n\tstate := engine.State{\n\t\tCallFrame: engine.NewCallFrame(st).WithMaxCallStackDepth(vm.options.CallStackMaxDepth),\n\t\tBlockchain: blockchain,\n\t\tEventSink: eventSink,\n\t}\n\n\toutput, err := vm.Contract(code).Call(state, params)\n\tif err == nil {\n\t\t// Only sync back when there was no exception\n\t\terr = state.CallFrame.Sync()\n\t}\n\t// Always return output - we may have a reverted exception for which the return is meaningful\n\treturn output, err\n}","func (pon *DmiTransceiverPlugIn) Execute(args []string) error {\n\tclient, conn := dmiEventGrpcClient()\n\tdefer conn.Close()\n\n\tctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)\n\tdefer cancel()\n\n\treq := pb.TransceiverRequest{\n\t\tTransceiverId: uint32(pon.Args.TransceiverId),\n\t}\n\n\tres, err := client.PlugInTransceiver(ctx, &req)\n\tif err != nil {\n\t\tlog.Errorf(\"Cannot plug in PON transceiver: %v\", err)\n\t\treturn err\n\t}\n\n\tfmt.Println(fmt.Sprintf(\"[Status: %d] %s\", res.StatusCode, res.Message))\n\treturn nil\n}","func (c *cmdVoteInv) Execute(args []string) error {\n\t_, err := voteInv(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}","func (lambda *Lambda) Execute(reconciliationMetaData *models.ReconciliationMetaData) error {\n\tif reconciliationMetaData.ReconciliationDate == \"\" {\n\n\t\treconciliationDateTime := time.Now()\n\t\treconciliationMetaData.ReconciliationDate = reconciliationDateTime.Format(dateFormat)\n\n\t\tstartTime := reconciliationDateTime.Truncate(24 * time.Hour)\n\t\treconciliationMetaData.StartTime = startTime\n\t\treconciliationMetaData.EndTime = startTime.Add(24 * time.Hour)\n\t} else {\n\n\t\tstartTime, err := time.Parse(dateFormat, reconciliationMetaData.ReconciliationDate)\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\treturn err\n\t\t}\n\n\t\treconciliationMetaData.StartTime = startTime\n\t\treconciliationMetaData.EndTime = startTime.Add(24 * time.Hour)\n\t}\n\n\tlog.Info(\"LFP error reporting lambda executing. Getting penalties with e5 errors for date: \" + reconciliationMetaData.ReconciliationDate + \". Creating lfp CSV.\")\n\n\tlfpCSV, err := lambda.Service.GetLFPCSV(reconciliationMetaData)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn err\n\t}\n\n\tlog.Info(\"LFP CSV constructed.\")\n\tlog.Trace(\"LFP CSV\", log.Data{\"lfp_csv\": lfpCSV})\n\n\terr = lambda.FileTransfer.UploadCSVFiles([]models.CSV{lfpCSV})\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn err\n\t}\n\n\tlog.Info(\"CSV's successfully uploaded. Lambda execution finished.\")\n\n\treturn nil\n}","func (ft *CustomTask) Exec(t *f.TaskNode, p *f.Params, out *io.PipeWriter) {\n\tglog.Info(\"executing custom task \", p.Complete)\n\n\tft.customFunc(t, p, out)\n\n\treturn\n}","func (_Vault *VaultTransactorSession) Execute(token common.Address, amount *big.Int, recipientToken common.Address, exchangeAddress common.Address, callData []byte, timestamp []byte, signData []byte) (*types.Transaction, error) {\n\treturn _Vault.Contract.Execute(&_Vault.TransactOpts, token, amount, recipientToken, exchangeAddress, callData, timestamp, signData)\n}","func (c *Command) Execute(ctx context.Context) error {\n\n\tpctx := &commandContext{\n\t\tdependencyResolver: pipeline.NewDependencyRecorder[*commandContext](),\n\t\tContext: ctx,\n\t}\n\n\tp := pipeline.NewPipeline[*commandContext]().WithBeforeHooks(pipe.DebugLogger[*commandContext](c.Log), pctx.dependencyResolver.Record)\n\tp.WithSteps(\n\t\tp.NewStep(\"create client\", c.createClient),\n\t\tp.NewStep(\"fetch task\", c.fetchTask),\n\t\tp.NewStep(\"list intermediary files\", c.listIntermediaryFiles),\n\t\tp.NewStep(\"delete intermediary files\", c.deleteFiles),\n\t\tp.NewStep(\"delete source file\", c.deleteSourceFile),\n\t)\n\n\treturn p.RunWithContext(pctx)\n}","func (c *CLI) Execute() {\n\tc.LoadCredentials()\n\twr := &workflow.WorkflowResult{}\n\texecHandler := workflow.GetExecutorHandler()\n\texec, err := execHandler.Add(c.Workflow, wr.Callback)\n\tc.exitOnError(err)\n\texec.SetLogListener(c.logListener)\n\tstart := time.Now()\n\texec, err = execHandler.Execute(c.Workflow.WorkflowID)\n\tc.exitOnError(err)\n\tchecks := 0\n\toperation := \"\"\n\tif c.Params.InstallRequest != nil {\n\t\tif c.Params.AppCluster {\n\t\t\toperation = \"Installing application cluster\"\n\t\t} else {\n\t\t\toperation = \"Installing management cluster\"\n\t\t}\n\t} else if c.Params.UninstallRequest != nil {\n\t\tif c.Params.AppCluster {\n\t\t\toperation = \"Uninstalling application cluster\"\n\t\t} else {\n\t\t\toperation = \"Uninstalling management cluster\"\n\t\t}\n\t}\n\tfor !wr.Called {\n\t\ttime.Sleep(time.Second * 15)\n\t\tif checks%4 == 0 {\n\t\t\tfmt.Println(operation, string(exec.State), \"-\", time.Since(start).String())\n\t\t}\n\t\tchecks++\n\t}\n\telapsed := time.Since(start)\n\tfmt.Println(\"Operation took \", elapsed)\n\tif wr.Error != nil {\n\t\tfmt.Println(\"Operation failed due to \", wr.Error.Error())\n\t\tlog.Fatal().Str(\"error\", wr.Error.DebugReport()).Msg(fmt.Sprintf(\"%s failed\", operation))\n\t}\n}","func (p *ContextPlugin) Execute(event *types.Event) *types.Event {\n\tif event.Time == 0 {\n\t\tevent.Time = time.Now().UnixMilli()\n\t}\n\n\tif event.InsertID == \"\" {\n\t\tevent.InsertID = uuid.NewString()\n\t}\n\n\tevent.Library = p.contextString\n\n\treturn event\n}","func (e *EventEmitter) execute(listener *Listener, event *Event) {\n\tdefer e.gracefulWait.Done()\n\n\tfor _, filterFunc := range e.filterFuncs {\n\t\tif !filterFunc(event) {\n\t\t\treturn\n\t\t}\n\t}\n\n\tvar (\n\t\tdata Data\n\t\texecutionTags []string\n\t)\n\n\tif e.mapFunc != nil {\n\t\tdata = e.mapFunc(event)\n\t} else if err := event.Data(&data); err != nil {\n\t\te.app.log.Println(errDecodingEventData{err})\n\t\treturn\n\t}\n\n\tif e.executionTagsFunc != nil {\n\t\texecutionTags = e.executionTagsFunc(event)\n\t}\n\n\tif _, err := e.app.execute(e.taskServiceID, e.taskKey, data, executionTags); err != nil {\n\t\te.app.log.Println(executionError{e.taskKey, err})\n\t}\n}","func (l *Labeler) Execute() error {\n\terr := l.checkPreconditions()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlog.Debugf(\"executing with owner=%s repo=%s event=%s\", *l.Owner, *l.Repo, *l.Event)\n\n\tc, err := l.retrieveConfig()\n\tif err != nil {\n\t\treturn err\n\t}\n\tl.config = c\n\n\tswitch *l.Event {\n\tcase issue:\n\t\terr = l.processIssue()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\tcase pullRequestTarget, pullRequest:\n\t\terr = l.processPullRequest()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}","func Execute(ctx context.Context) error {\n\treturn rootCmd.ExecuteContext(ctx)\n}","func Execute(ctx context.Context, command Command, aggregate Aggregate, metadata Metadata) (Event, error) {\n\ttx := DB.Begin()\n\n\tevent, err := ExecuteTx(ctx, tx, command, aggregate, metadata)\n\tif err != nil {\n\t\ttx.Rollback()\n\t\treturn Event{}, err\n\t}\n\n\tif err = tx.Commit().Error; err != nil {\n\t\ttx.Rollback()\n\t\treturn Event{}, err\n\t}\n\n\treturn event, nil\n}","func (_ERC725 *ERC725Transactor) Execute(opts *bind.TransactOpts, _data []byte) (*types.Transaction, error) {\n\treturn _ERC725.contract.Transact(opts, \"execute\", _data)\n}","func (cmd *command) Execute(ch io.ReadWriter) (err error) {\n\tif cmd.Flags.Source {\n\t\terr = cmd.serveSource(ch)\n\t} else {\n\t\terr = cmd.serveSink(ch)\n\t}\n\tif err != nil {\n\t\treturn trace.Wrap(err)\n\t}\n\treturn nil\n}","func (pon *DmiTransceiverPlugOut) Execute(args []string) error {\n\tclient, conn := dmiEventGrpcClient()\n\tdefer conn.Close()\n\n\tctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)\n\tdefer cancel()\n\n\treq := pb.TransceiverRequest{\n\t\tTransceiverId: uint32(pon.Args.TransceiverId),\n\t}\n\n\tres, err := client.PlugOutTransceiver(ctx, &req)\n\tif err != nil {\n\t\tlog.Errorf(\"Cannot plug out PON transceiver: %v\", err)\n\t\treturn err\n\t}\n\n\tfmt.Println(fmt.Sprintf(\"[Status: %d] %s\", res.StatusCode, res.Message))\n\treturn nil\n}","func executeAction(fn command) cli.ActionFunc {\n\tusername := os.Getenv(\"VOIPMS_USERNAME\")\n\tpassword := os.Getenv(\"VOIPMS_PASSWORD\")\n\tclient := api.NewClient(username, password)\n\treturn func(c *cli.Context) error {\n\t\treturn fn(client, c)\n\t}\n}","func Execute() {\n\tinitHelp()\n\tcontext := InitializeContext()\n\n\tprintLogoWithVersion(os.Stdout)\n\n\tif context.config.trustAll {\n\t\tif !context.config.quiet {\n\t\t\tfmt.Println(\"WARNING: Configured to trust all - means unnown service certificate is accepted. Don't use this in production!\")\n\t\t}\n\t}\n\taction := context.config.action\n\tif action == ActionExecuteSynchron {\n\t\tcommonWayToApprove(context)\n\t\twaitForSecHubJobDoneAndFailOnTrafficLight(context)\n\t\tos.Exit(ExitCodeOK)\n\n\t} else if action == ActionExecuteAsynchron {\n\t\tcommonWayToApprove(context)\n\t\tfmt.Println(context.config.secHubJobUUID)\n\t\tos.Exit(ExitCodeOK)\n\t} else if action == ActionExecuteGetStatus {\n\t\tstate := getSecHubJobState(context, true, false, false)\n\t\tfmt.Println(state)\n\t\tos.Exit(ExitCodeOK)\n\n\t} else if action == ActionExecuteGetReport {\n\t\treport := getSecHubJobReport(context)\n\t\tfmt.Println(report)\n\t\tos.Exit(ExitCodeOK)\n\t}\n\tfmt.Printf(\"Unknown action '%s'\", context.config.action)\n\tos.Exit(ExitCodeIllegalAction)\n}","func Execute() error {\n\treturn cmd.Execute()\n}","func (_Trebuchet *TrebuchetTransactor) Execute(opts *bind.TransactOpts, _data [][]byte) (*types.Transaction, error) {\n\treturn _Trebuchet.contract.Transact(opts, \"execute\", _data)\n}","func (scs *SubCommandStruct) Execute(ctx context.Context, in io.Reader, out, outErr io.Writer) error {\n\tif scs.ExecuteValue != nil {\n\t\treturn scs.ExecuteValue(ctx, in, out, outErr)\n\t}\n\treturn nil\n}","func (e *ldapExecutor) Execute(ctx context.Context, config *ldapconf.Config) error {\n\treturn nil\n}","func (f *FunctionExpression) Execute(ctx *Context, args *Values) Value {\n\tf.params.BindArguments(ctx, args.values...)\n\tf.body.Execute(ctx)\n\tif ctx.hasret {\n\t\treturn ctx.retval\n\t}\n\treturn ValueFromNil()\n}","func Execute(ctx context.OrionContext, action *Base, fn ExecuteFn) errors.Error {\n\t// ctx.StartAction()\n\tevalCtx := ctx.EvalContext()\n\twhen, err := helper.GetExpressionValueAsBool(evalCtx, action.when, true)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !when {\n\t\treturn nil\n\t}\n\tif action.count != nil && !action.count.Range().Empty() {\n\t\treturn doCount(ctx, action, fn)\n\t}\n\tif action.while != nil && !action.while.Range().Empty() {\n\t\treturn doWhile(ctx, action, fn)\n\t}\n\treturn fn(ctx)\n}","func (ctrl *PGCtrl) Execute(q string) error {\n\t_, err := ctrl.conn.Exec(q)\n\treturn err\n}","func (_Vault *VaultSession) Execute(token common.Address, amount *big.Int, recipientToken common.Address, exchangeAddress common.Address, callData []byte, timestamp []byte, signData []byte) (*types.Transaction, error) {\n\treturn _Vault.Contract.Execute(&_Vault.TransactOpts, token, amount, recipientToken, exchangeAddress, callData, timestamp, signData)\n}","func (_m *WorkerHandlerOptionFunc) Execute(_a0 *types.WorkerHandler) {\n\t_m.Called(_a0)\n}","func (r Describe) Execute(name string, out io.Writer, args []string) error {\n\twrap := types.Executor{Name: name, Command: r}\n\tctx := context.WithValue(context.Background(), global.RefRoot, wrap)\n\tcmd := r.NewCommand(ctx, name)\n\tcmd.SetOut(out)\n\tcmd.SetArgs(args)\n\tif err := cmd.Execute(); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}","func (p *PrintCommand) Execute(_ engine.Handler) {\n\tfmt.Println(p.Arg)\n}","func (tx *Hello) Execute(p types.Process, ctw *types.ContextWrapper, index uint16) error {\n\tsp := p.(*HelloWorld)\n\n\treturn sp.vault.WithFee(p, ctw, tx, func() error {\n\t\tif err := sp.AddHelloCount(ctw, tx.To); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}","func (player *Player) ExecAs(commandLine string, callback func(statusCode int)) {\n\tplayer.Exec(fmt.Sprintf(\"execute %v ~ ~ ~ %v\", player.name, commandLine), func(response map[string]interface{}) {\n\t\tcodeInterface, exists := response[\"statusCode\"]\n\t\tif !exists {\n\t\t\tlog.Printf(\"exec as: invalid response JSON\")\n\t\t\treturn\n\t\t}\n\t\tcode, _ := codeInterface.(int)\n\t\tif callback != nil {\n\t\t\tcallback(code)\n\t\t}\n\t})\n}","func (e *Execution) Execute(ctx context.Context) error {\n\n\tvar err error\n\tswitch strings.ToLower(e.Operation.Name) {\n\tcase installOperation, \"standard.create\":\n\t\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\n\t\t\t\"Creating Job %q\", e.NodeName)\n\t\terr = e.createJob(ctx)\n\t\tif err != nil {\n\t\t\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\n\t\t\t\t\"Failed to create Job %q, error %s\", e.NodeName, err.Error())\n\n\t\t}\n\tcase uninstallOperation, \"standard.delete\":\n\t\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\n\t\t\t\"Deleting Job %q\", e.NodeName)\n\t\terr = e.deleteJob(ctx)\n\t\tif err != nil {\n\t\t\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\n\t\t\t\t\"Failed to delete Job %q, error %s\", e.NodeName, err.Error())\n\n\t\t}\n\tcase enableFileTransferOperation:\n\t\terr = e.enableFileTransfer(ctx)\n\t\tif err != nil {\n\t\t\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\n\t\t\t\t\"Failed to enable file transfer for Job %q, error %s\", e.NodeName, err.Error())\n\n\t\t}\n\tcase disableFileTransferOperation:\n\t\terr = e.disableFileTransfer(ctx)\n\t\tif err != nil {\n\t\t\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\n\t\t\t\t\"Failed to disable file transfer for Job %q, error %s\", e.NodeName, err.Error())\n\n\t\t}\n\tcase listChangedFilesOperation:\n\t\terr = e.listChangedFiles(ctx)\n\t\tif err != nil {\n\t\t\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\n\t\t\t\t\"Failed to list changed files for Job %q, error %s\", e.NodeName, err.Error())\n\n\t\t}\n\tcase tosca.RunnableSubmitOperationName:\n\t\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\n\t\t\t\"Submitting Job %q\", e.NodeName)\n\t\terr = e.submitJob(ctx)\n\t\tif err != nil {\n\t\t\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\n\t\t\t\t\"Failed to submit Job %q, error %s\", e.NodeName, err.Error())\n\n\t\t}\n\tcase tosca.RunnableCancelOperationName:\n\t\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\n\t\t\t\"Canceling Job %q\", e.NodeName)\n\t\terr = e.cancelJob(ctx)\n\t\tif err != nil {\n\t\t\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\n\t\t\t\t\"Failed to cancel Job %q, error %s\", e.NodeName, err.Error())\n\n\t\t}\n\tdefault:\n\t\terr = errors.Errorf(\"Unsupported operation %q\", e.Operation.Name)\n\t}\n\n\treturn err\n}","func OnExecute(c *grumble.Context) error {\n\tplanID := c.Flags.Int(\"plan\")\n\tif len(config.AppConfig.Plans) < planID {\n\t\tfmt.Println(\"No plan with ID\", planID, \"exists. Use the command \\\"list\\\" to get a list of available plans.\")\n\t\treturn nil\n\t}\n\tplan := config.AppConfig.Plans[planID-1]\n\n\tfor _, task := range plan.Tasks {\n\t\tresult := task.Execute()\n\n\t\tif result.IsSuccessful {\n\n\t\t\tfmt.Println(result.Message)\n\t\t} else {\n\t\t\tfmt.Println(\"Error:\", result.Message)\n\t\t}\n\t}\n\n\treturn nil\n}","func Execute(contID container.ContainerID, r *scheduledRequest) error {\n\t//log.Printf(\"[%s] Executing on container: %v\", r, contID)\n\n\tvar req executor.InvocationRequest\n\tif r.Fun.Runtime == container.CUSTOM_RUNTIME {\n\t\treq = executor.InvocationRequest{\n\t\t\tParams: r.Params,\n\t\t}\n\t} else {\n\t\tcmd := container.RuntimeToInfo[r.Fun.Runtime].InvocationCmd\n\t\treq = executor.InvocationRequest{\n\t\t\tcmd,\n\t\t\tr.Params,\n\t\t\tr.Fun.Handler,\n\t\t\tHANDLER_DIR,\n\t\t}\n\t}\n\n\tt0 := time.Now()\n\n\tresponse, invocationWait, err := container.Execute(contID, &req)\n\tif err != nil {\n\t\t// notify scheduler\n\t\tcompletions <- &completion{scheduledRequest: r, contID: contID}\n\t\treturn fmt.Errorf(\"[%s] Execution failed: %v\", r, err)\n\t}\n\n\tif !response.Success {\n\t\t// notify scheduler\n\t\tcompletions <- &completion{scheduledRequest: r, contID: contID}\n\t\treturn fmt.Errorf(\"Function execution failed\")\n\t}\n\n\tr.ExecReport.Result = response.Result\n\tr.ExecReport.Duration = time.Now().Sub(t0).Seconds() - invocationWait.Seconds()\n\tr.ExecReport.ResponseTime = time.Now().Sub(r.Arrival).Seconds()\n\n\t// initializing containers may require invocation retries, adding\n\t// latency\n\tr.ExecReport.InitTime += invocationWait.Seconds()\n\n\t// notify scheduler\n\tcompletions <- &completion{scheduledRequest: r, contID: contID}\n\n\treturn nil\n}","func Execute() {\n\tAddCommands()\n\tIpvanishCmd.Execute()\n\t//\tutils.StopOnErr(IpvanishCmd.Execute())\n}","func (self *Controller) ExecuteCommand(notification interfaces.INotification) {\n\tself.commandMapMutex.RLock()\n\tdefer self.commandMapMutex.RUnlock()\n\n\tvar commandFunc = self.commandMap[notification.Name()]\n\tif commandFunc == nil {\n\t\treturn\n\t}\n\tcommandInstance := commandFunc()\n\tcommandInstance.InitializeNotifier(self.Key)\n\tcommandInstance.Execute(notification)\n}","func (i service) Execute(ctx context.Context, to common.Address, contractAbi, methodName string, args ...interface{}) error {\n\tabi, err := abi.JSON(strings.NewReader(contractAbi))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Pack encodes the parameters and additionally checks if the method and arguments are defined correctly\n\tdata, err := abi.Pack(methodName, args...)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn i.RawExecute(ctx, to, data)\n}","func Execute(\n\tctx context.Context,\n\thandler Handler,\n\tabortHandler AbortHandler,\n\trequest interface{}) Awaiter {\n\ttask := &task{\n\t\trequest: request,\n\t\thandler: handler,\n\t\tabortHandler: abortHandler,\n\t\tresultQ: make(chan Response, 1),\n\t\trunning: true,\n\t}\n\tgo task.run(ctx) // run handler asynchronously\n\treturn task\n}","func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {\n\tfunction, args := stub.GetFunctionAndParameters()\n\tif function == \"makeStatement\" {\n\t\tif len(args) != 1 {\n\t\t\treturn shim.Error(\"Incorrect number of arguments: \" + string(len(args)))\n\t\t}\n\t\tstatement := args[0]\n\t\tts, _ := stub.GetTxTimestamp()\n\t\ttxtime := time.Unix(ts.Seconds, int64(ts.Nanos))\n\t\tevent := Event{\n\t\t\tStatement: statement,\n\t\t\tEventTime: txtime,\n\t\t\tTxID: stub.GetTxID(),\n\t\t}\n\t\tevtJson, _ := json.Marshal(event)\n\t\tstub.PutState(stub.GetTxID(), evtJson)\n\t\treturn shim.Success(evtJson)\n\t}\n\tlogger.Errorf(\"invoke did not find func: %s\", function)\n\treturn shim.Error(\"Received unknown function invocation\")\n}","func Execute() {\n\tmainCmd.Execute()\n}","func (f Function) Execute(i Instruction, e Environment, dryRun bool) error {\n\tif err := f.Check(i); err != nil {\n\t\treturn err\n\t}\n\treturn f.Func(i, e, dryRun)\n}","func Execute(context *cli.Context) error {\n\tmanager, err := createManager(context)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmanager.WithTimeout(context.Int(\"timeout\"))\n\n\tfilename := context.Args().First()\n\tif filename == \"\" {\n\t\treturn cli.NewExitError(\"filename argument is required\", 1)\n\t}\n\n\tname := context.String(\"name\")\n\tif name == \"\" {\n\t\tname = strings.TrimSuffix(path.Base(filename), filepath.Ext(filename))\n\t}\n\n\tscript, err := manager.CreateFromFile(name, filename)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"failed to create script %s from %s\", name, filename)\n\t}\n\n\tvar result string\n\tfilePayload := context.String(\"file-payload\")\n\tpayload := context.String(\"payload\")\n\n\tif filePayload != \"\" && payload != \"\" {\n\t\treturn cli.NewExitError(\"only one of the parameters can be used: payload or file-payload\", 2)\n\t}\n\n\tif filePayload != \"\" {\n\t\tresult, err = script.ExecuteWithFilePayload(filePayload)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"execution of script %s with filePayload %s failed\", filename, filePayload)\n\t\t}\n\t} else if payload != \"\" {\n\t\tresult, err = script.ExecuteWithStringPayload(payload)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"execution of script %s failed\", filename)\n\t\t}\n\t} else {\n\t\tresult, err = script.ExecuteWithoutPayload()\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"execution of script %s failed\", filename)\n\t\t}\n\t}\n\n\tfmt.Println(result)\n\n\treturn nil\n}","func (mo *MenuOption) ExecuteCommand(ev chan UIEvent) {\n\tev <- mo.Command()\n}","func Execute() {\n\tif err := RootCommand.Execute(); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"aws-helper error: %s\\n\", err)\n\t\tRootCommand.Usage()\n\t\tos.Exit(1)\n\t}\n}","func Execute(\n\tctx context.Context,\n\tpayload gapir.Payload,\n\thandlePost builder.PostDataHandler,\n\thandleNotification builder.NotificationHandler,\n\tconnection *gapir.Connection,\n\tmemoryLayout *device.MemoryLayout,\n\tos *device.OS) error {\n\n\tctx = status.Start(ctx, \"Execute\")\n\tdefer status.Finish(ctx)\n\n\t// The memoryLayout is specific to the ABI of the requested capture,\n\t// while the OS is not. Thus a device.Configuration is not applicable here.\n\treturn executor{\n\t\tpayload: payload,\n\t\thandlePost: handlePost,\n\t\thandleNotification: handleNotification,\n\t\tmemoryLayout: memoryLayout,\n\t\tOS: os,\n\t}.execute(ctx, connection)\n}","func (c *ToyController) Execute(ctx context.Context) error {\n\tc.le.Debug(\"toy controller executed\")\n\t<-ctx.Done()\n\treturn nil\n}","func (execution *Execution) Execute() (err error) {\n\terr = execution.moveFromPendingToInProgress()\n\tif err != nil {\n\t\treturn\n\t}\n\texecution.ExecutedAt = time.Now()\n\tlog.Println(\"[PROCESSING]\", execution.Task)\n\n\tchannel := execution.Service.TaskSubscriptionChannel()\n\n\tgo pubsub.Publish(channel, execution)\n\treturn\n}","func (_Transactable *TransactableTransactor) Execute(opts *bind.TransactOpts, _guarantor common.Address, _v uint8, _r [32]byte, _s [32]byte, _dest common.Address, _value *big.Int, _ts *big.Int) (*types.Transaction, error) {\n\treturn _Transactable.contract.Transact(opts, \"execute\", _guarantor, _v, _r, _s, _dest, _value, _ts)\n}","func (e *executor) Execute() error {\n\tif len(e.executables) < 1 {\n\t\treturn errors.New(\"nothing to Work\")\n\t}\n\n\tlog(e.id).Infof(\"processing %d item(s)\", len(e.executables))\n\treturn nil\n}","func (t *PulsarTrigger) Execute(ctx context.Context, events map[string]*v1alpha1.Event, resource interface{}) (interface{}, error) {\n\ttrigger, ok := resource.(*v1alpha1.PulsarTrigger)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"failed to interpret the trigger resource\")\n\t}\n\n\tif trigger.Payload == nil {\n\t\treturn nil, fmt.Errorf(\"payload parameters are not specified\")\n\t}\n\n\tpayload, err := triggers.ConstructPayload(events, trigger.Payload)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t_, err = t.Producer.Send(ctx, &pulsar.ProducerMessage{\n\t\tPayload: payload,\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to send message to pulsar, %w\", err)\n\t}\n\n\tt.Logger.Infow(\"successfully produced a message\", zap.Any(\"topic\", trigger.Topic))\n\n\treturn nil, nil\n}","func (_SimpleMultiSig *SimpleMultiSigTransactorSession) Execute(bucketIdx uint16, expireTime *big.Int, sigV []uint8, sigR [][32]byte, sigS [][32]byte, destination common.Address, value *big.Int, data []byte, executor common.Address, gasLimit *big.Int) (*types.Transaction, error) {\n\treturn _SimpleMultiSig.Contract.Execute(&_SimpleMultiSig.TransactOpts, bucketIdx, expireTime, sigV, sigR, sigS, destination, value, data, executor, gasLimit)\n}","func (app *App) Execute(input io.Reader, output io.Writer) error {\n\tdecoder := yaml.NewDecoder(input)\n\tvar data map[string]interface{}\n\tif err := decoder.Decode(&data); err != nil {\n\t\treturn errors.Wrap(err, \"yaml decode\")\n\t}\n\treturn errors.Wrap(app.t.Execute(output, data), \"transform execute\")\n}","func (tasks *TaskFile) Execute(cmd, name, dir string) (out string, err error) {\n\tcommand, err := templates.Expand(cmd, tasks.TemplateVars.Functions)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif tasks.Options.LogLevel {\n\t\tlogger.Info(name, command)\n\t}\n\n\treturn templates.Run(templates.CommandOptions{\n\t\tCmd: command,\n\t\tDir: dir,\n\t\tUseStdOut: true,\n\t})\n}","func (_SimpleMultiSig *SimpleMultiSigFilterer) FilterExecute(opts *bind.FilterOpts) (*SimpleMultiSigExecuteIterator, error) {\n\n\tlogs, sub, err := _SimpleMultiSig.contract.FilterLogs(opts, \"Execute\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &SimpleMultiSigExecuteIterator{contract: _SimpleMultiSig.contract, event: \"Execute\", logs: logs, sub: sub}, nil\n}","func (p *powerEventWatcher) Execute() error {\n\t<-p.interrupt\n\treturn nil\n}","func Execute() {\n\tzk.Execute()\n}","func (c *cmdProposalInv) Execute(args []string) error {\n\t_, err := proposalInv(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}","func Execute() {\n\t// rootCmd.GenZshCompletionFile(\"./_clk\")\n\tcobra.CheckErr(rootCmd.Execute())\n}","func Execute(args []string) (err error) {\n\treturn Cmd.Execute(args)\n}","func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) {\n\tfmt.Println(\"invoke is running \" + function)\n\n\t// Handle different functions\n\tif function == \"init\" {\t\t\t\t\t\t\t\t\t\t\t\t\t//initialize the chaincode state, used as reset\n\t\treturn t.Init(stub, \"init\", args)\n\t}else if function == \"create_event\" {\n return t.create_event(stub, args)\n\t}else if function == \"ping\" {\n return t.ping(stub)\n }\n\t\n\treturn nil, errors.New(\"Received unknown function invocation: \" + function)\n}","func Run(evt event.Event) error {\n\tenvs := env.GetEnvs()\n\tif len(evt.LogLevel) == 0 {\n\t\tevt.LogLevel = constants.DefaultWorkerLogLevel\n\t}\n\n\tif len(envs.Region) == 0 {\n\t\treturn fmt.Errorf(\"region is not specified. please check environment variables\")\n\t}\n\tlogrus.Infof(\"this is lambda function in %s\", envs.Region)\n\n\tswitch envs.Mode {\n\tcase constants.ManagerMode:\n\t\treturn workermanager.New().Run(envs)\n\tcase constants.WorkerMode:\n\t\treturn worker.NewWorker().Run(envs, evt)\n\t}\n\n\treturn nil\n}","func (c *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {\n\tfun, args := stub.GetFunctionAndParameters()\n\n\tfmt.Println(\"Executing => \"+fun)\n\n\tswitch fun{\n\tcase \"AddCpu\":\n\t\treturn c.AddCpu(stub,args)\n\tcase \"GetUsage\":\n\t\treturn c.GetUsage(stub,args)\n\tdefault:\n\t\treturn shim.Error(\"Not a vaild function\")\t\n\t}\n}","func (r *Repository) Execute(command string, args ...interface{}) (middleware.Result, error) {\n\tconn, err := r.Database.Get()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer func() {\n\t\terr = conn.Close()\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"alert DASRepo.Execute(): close database connection failed.\\n%s\", err.Error())\n\t\t}\n\t}()\n\n\treturn conn.Execute(command, args...)\n}","func (c *ConsoleOutput) Execute() {\n\tfmt.Println(c.message)\n}","func (t *TaskChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {\n\tfunction, args := stub.GetFunctionAndParameters()\n\tfmt.Println(\"invoke is running \" + function)\n\n\tif function == \"regist\" {\n\t\treturn t.regist(stub, args)\n\t} else if function == \"pay\" {\n\t\treturn t.pay(stub, args)\n\t} else if function == \"pendingPay\" {\n\t\treturn t.pendingPay(stub, args)\n } else if function == \"confirmPay\" {\n\t\treturn t.confirmPay(stub, args)\n } else if function == \"getBalance\" {\n\t\treturn t.getBalance(stub, args)\n\t} else if function == \"queryPayTxByTaskId\" {\n\t\treturn t.queryPayTxByTaskId(stub, args)\n\t} else if function == \"queryPayTxByPayer\" {\n\t\treturn t.queryPayTxByPayer(stub, args)\n\t} else if function == \"queryPayTxByPayee\" {\n\t\treturn t.queryPayTxByPayee(stub, args)\n\t} else if function == \"queryMembers\" {\n\t\treturn t.queryMembers(stub)\n\t} else {\n\t\treturn shim.Error(\"Function \" + function + \" doesn't exits, make sure function is right!\")\n\t}\n}","func Execute(cfn ConfigFunc) error {\n\trootCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {\n\t\tcfn(rootCmd.PersistentFlags())\n\t}\n\n\treturn rootCmd.Execute()\n}","func (t TaskFunc) Execute() { t() }","func (_SimpleMultiSig *SimpleMultiSigFilterer) WatchExecute(opts *bind.WatchOpts, sink chan<- *SimpleMultiSigExecute) (event.Subscription, error) {\n\n\tlogs, sub, err := _SimpleMultiSig.contract.WatchLogs(opts, \"Execute\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn event.NewSubscription(func(quit <-chan struct{}) error {\n\t\tdefer sub.Unsubscribe()\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase log := <-logs:\n\t\t\t\t// New log arrived, parse the event and forward to the user\n\t\t\t\tevent := new(SimpleMultiSigExecute)\n\t\t\t\tif err := _SimpleMultiSig.contract.UnpackLog(event, \"Execute\", log); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tevent.Raw = log\n\n\t\t\t\tselect {\n\t\t\t\tcase sink <- event:\n\t\t\t\tcase err := <-sub.Err():\n\t\t\t\t\treturn err\n\t\t\t\tcase <-quit:\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\tcase err := <-sub.Err():\n\t\t\t\treturn err\n\t\t\tcase <-quit:\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}), nil\n}","func (e *ExecutableInvoker) Invoke(ctx context.Context, m *Manifest, cfg *InvokerConfig) error {\n\texecPath := path.Join(e.PluginDir, path.Join(m.Command...), m.Exec)\n\tcmd := execCommandContext(ctx, execPath, cfg.Args...)\n\tcmd.Env = append(cmd.Env, cfg.Env...)\n\tcmd.Stdout = os.Stdout\n\tcmd.Stderr = os.Stderr\n\n\treturn cmd.Run()\n}","func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) {\n\tswitch function {\n\n\tcase \"execute\":\n\n\t\tif len(args) < 1 {\n\t\t\treturn nil, errors.New(\"execute operation must include single argument, the base64 encoded form of a bitcoin transaction\")\n\t\t}\n\t\ttxDataBase64 := args[0]\n\t\ttxData, err := base64.StdEncoding.DecodeString(txDataBase64)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Error decoding TX as base64: %s\", err)\n\t\t}\n\n\t\tutxo := util.MakeUTXO(MakeChaincodeStore(stub))\n\t\texecResult, err := utxo.Execute(txData)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Error executing TX: %s\", err)\n\t\t}\n\n\t\tfmt.Printf(\"\\nExecResult: Coinbase: %t, SumInputs %d, SumOutputs %d\\n\\n\", execResult.IsCoinbase, execResult.SumPriorOutputs, execResult.SumCurrentOutputs)\n\n\t\tif execResult.IsCoinbase == false {\n\t\t\tif execResult.SumCurrentOutputs > execResult.SumPriorOutputs {\n\t\t\t\treturn nil, fmt.Errorf(\"sumOfCurrentOutputs > sumOfPriorOutputs: sumOfCurrentOutputs = %d, sumOfPriorOutputs = %d\", execResult.SumCurrentOutputs, execResult.SumPriorOutputs)\n\t\t\t}\n\t\t}\n\n\t\treturn nil, nil\n\n\tdefault:\n\t\treturn nil, errors.New(\"Unsupported operation\")\n\t}\n\n}","func (t *AssetManagementChaincode) Invoke(stub *shim.ChaincodeStub, function string, args []string) ([]byte, error) {\n\n if function == \"create\" {\n // create asset\n return t.create(stub, args)\n } else if function == \"update\" {\n // update asset (transfer ownership etc)\n return t.update(stub, args)\n }\n\n return nil, errors.New(\"Received unknown function invocation\")\n}","func (machine *Dishwasher) RunCustomCommand(custom string) {\r\n machine.Append(func() (string, error) {\r\n var output string = \"\"\r\n var oops error = nil\r\n\r\n custom = strings.TrimSpace(custom)\r\n if custom[len(custom)-1] == '$' {\r\n go RunCommand(custom)\r\n } else {\r\n output, oops = RunCommand(custom)\r\n machine.SideEffect(output, oops)\r\n }\r\n\r\n return output, oops\r\n })\r\n}","func (t *SimpleChaincode) Run(stub *shim.ChaincodeStub, function string, args []string) ([]byte, error) {\n fmt.Printf(\" ############ KIRK ############# chaincode run\") \n fmt.Println(\"run is running \" + function)\n\n // Handle different functions\n if function == \"init\" { //initialize the chaincode state, used as reset\n return t.init(stub, args)\n } else if function == \"delete\" { //deletes an entity from its state\n return t.Delete(stub, args)\n } else if function == \"write\" { //writes a value to the chaincode state\n return t.Write(stub, args)\n } else if function == \"init_term\" { //create a new search term\n return t.init_term(stub, args)\n } else if function == \"set_user\" { //change owner of a search term\n return t.set_user(stub, args)\n }\n fmt.Println(\"run did not find func: \" + function) //error\n\n return nil, errors.New(\"Received unknown function invocation\")\n}","func (m *MockFinder) Execute(ctx context.Context, config *config.Config, query string, from int64, until int64, stat *FinderStat) (err error) {\n\tm.query = query\n\treturn\n}","func Execute(config ManagerConfig) error {\n\treturn execute(config)\n}","func (e *EventEmitter) Execute(serviceID, taskKey string) (*Listener, error) {\n\te.taskServiceID = serviceID\n\te.taskKey = taskKey\n\tlistener := newListener(e.app, e.gracefulWait)\n\tif err := e.app.startServices(e.eventServiceID, serviceID); err != nil {\n\t\treturn nil, err\n\t}\n\tcancel, err := e.listen(listener)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlistener.cancel = cancel\n\te.app.addListener(listener)\n\treturn listener, nil\n}","func (n *scalarNode) Execute(ctx context.Context) error {\n\tbounds := n.timespec.Bounds()\n\n\tblock := block.NewScalar(n.op.val, bounds)\n\tif n.debug {\n\t\t// Ignore any errors\n\t\titer, _ := block.StepIter()\n\t\tif iter != nil {\n\t\t\tlogging.WithContext(ctx).Info(\"scalar node\", zap.Any(\"meta\", iter.Meta()))\n\t\t}\n\t}\n\n\tif err := n.controller.Process(block); err != nil {\n\t\tblock.Close()\n\t\t// Fail on first error\n\t\treturn err\n\t}\n\n\tblock.Close()\n\treturn nil\n}","func (t *evidence_management) Invoke(stub shim.ChaincodeStubInterface) pb.Response {\n\tfunction, args := stub.GetFunctionAndParameters()\n\tfmt.Println(\"function is ==> :\" + function)\n\taction := args[0]\n\tfmt.Println(\" action is ==> :\" + action)\n\tfmt.Println(args)\n\n\tif action == \"queryAsset\" {\n\t\treturn t.queryAsset(stub, args)\n\t} else if action == \"queryAllAsset\" {\n\t\treturn t.queryAllAsset(stub, args)\n\t} else if action == \"getHistoryForRecord\" {\n\t\treturn t.getHistoryForRecord(stub, args)\n\t} else if action == \"createCase\" {\n\t\treturn t.createCase(stub, args)\n\t} else if action == \"updateCase\" {\n\t\treturn t.updateCase(stub, args)\n\t} else if action == \"updateCaseStatus\" {\n\t\treturn t.updateCaseStatus(stub, args)\n\t} else if action == \"createFIR\" {\n\t\treturn t.createFIR(stub, args)\n\t} else if action == \"createDoc\" {\n\t\treturn t.createDoc(stub, args)\n\t} else if action == \"putPrivateData\" {\n\t\treturn t.putPrivateData(stub, args)\n\t} else if action == \"getPrivateData\" {\n\t\treturn t.getPrivateData(stub, args)\n\t} else if action == \"addAccused\" {\n\t\treturn t.addAccused(stub, args)\n\t} else if action == \"addSuspect\" {\n\t\treturn t.addSuspect(stub, args)\n\t} else if action == \"addVictim\" {\n\t\treturn t.addVictim(stub, args)\n\t}\n\n\tfmt.Println(\"invoke did not find func: \" + action) //error\n\n\treturn shim.Error(\"Received unknown function\")\n}","func (_SimpleMultiSig *SimpleMultiSigSession) Execute(bucketIdx uint16, expireTime *big.Int, sigV []uint8, sigR [][32]byte, sigS [][32]byte, destination common.Address, value *big.Int, data []byte, executor common.Address, gasLimit *big.Int) (*types.Transaction, error) {\n\treturn _SimpleMultiSig.Contract.Execute(&_SimpleMultiSig.TransactOpts, bucketIdx, expireTime, sigV, sigR, sigS, destination, value, data, executor, gasLimit)\n}","func Execute(runnable RunnableFn) {\n\tdefer func() {\n\t\tif err := recover(); err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\t}()\n\n\tif runnable != nil {\n\t\trunnable()\n\t}\n}","func (sb *ServerChangeBean) Execute(stringArgs []string, env *map[string]interface{}) error{\n\tif len(stringArgs) != 7 {\n\t\treturn fmt.Errorf(\"arguement error\")\n\t}\n\titerId, _ := strconv.Atoi(stringArgs[4])\n\tst, _ := strconv.Atoi(stringArgs[5])\n\tserverType := db.ServerType(st)\n\treturn sb.change(stringArgs[0], stringArgs[1], stringArgs[2], stringArgs[3], int64(iterId), serverType, env)\n}","func (cli *OpsGenieAlertV2Client) ExecuteCustomAction(req alertsv2.ExecuteCustomActionRequest) (*AsyncRequestResponse, error) {\n\treturn cli.sendAsyncPostRequest(&req)\n}","func Execute() {\n\tctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)\n\tdefer cancel()\n\n\tcobra.OnInitialize(initLogging, initConfig, initSSHFromConfig)\n\n\tif err := rootCommand().ExecuteContext(ctx); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}","func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) {\n\tfmt.Println(\"run is running \" + function)\n\n\t// Handle different functions\n\t// if function == \"init\" { //initialize the chaincode state\n\t// \treturn t.Init(stub, args)\n\t// } else\n\tif function == \"submitTransaction\" { //create a transaction\n\t\treturn t.submitTransaction(stub, args)\n\t} else if function == \"createFinancialInstitution\" { //create a new FinancialInst in ledger\n\t\treturn t.createFinancialInstitution(stub, args)\n\t}\n\n\tfmt.Println(\"run did not find func: \" + function) //error\n\n\treturn nil, errors.New(\"Received unknown function invocation\")\n}","func (c *Command) Execute() {\n\targs := os.Args[1:]\n\tswitch argsLen := len(args); {\n\tcase argsLen == 1:\n\t\tc.Run(args)\n\tdefault:\n\t\tlog.Println(\"our service currently handle 1 command only\")\n\t}\n}","func Execute() {\n\tcmd := arrangeCommands()\n\n\tif err := cmd.Execute(); err != nil {\n\t\tlog.LogError(err)\n\t\tos.Exit(1)\n\t}\n}","func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) {\n if function == \"createAsset\" {\n return t.createAsset(stub, args)\n } else if function == \"updateAsset\" {\n return t.updateAsset(stub, args)\n } else if function == \"deleteAsset\" {\n return t.deleteAsset(stub, args)\n } else if function == \"deleteAllAssets\" {\n return t.deleteAllAssets(stub, args)\n } else if function == \"deletePropertiesFromAsset\" {\n return t.deletePropertiesFromAsset(stub, args)\n } else if function == \"setLoggingLevel\" {\n return nil, t.setLoggingLevel(stub, args)\n } else if function == \"setCreateOnUpdate\" {\n return nil, t.setCreateOnUpdate(stub, args)\n }\n err := fmt.Errorf(\"Invoke received unknown invocation: %s\", function)\n log.Warning(err)\n return nil, err\n}","func Execute(client ioctl.Client,\n\tcmd *cobra.Command,\n\tcontract string,\n\tamount *big.Int,\n\tbytecode []byte,\n\tgasPrice, signer, password string,\n\tnonce, gasLimit uint64,\n\tassumeYes bool,\n) error {\n\tif len(contract) == 0 && len(bytecode) == 0 {\n\t\treturn errors.New(\"failed to deploy contract with empty bytecode\")\n\t}\n\tgasPriceRau, err := gasPriceInRau(client, gasPrice)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to get gas price\")\n\t}\n\tsender, err := Signer(client, signer)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to get signer address\")\n\t}\n\tnonce, err = checkNonce(client, nonce, sender)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to get nonce\")\n\t}\n\ttx, err := action.NewExecution(contract, nonce, amount, gasLimit, gasPriceRau, bytecode)\n\tif err != nil || tx == nil {\n\t\treturn errors.Wrap(err, \"failed to make a Execution instance\")\n\t}\n\tif gasLimit == 0 {\n\t\ttx, err = fixGasLimit(client, sender, tx)\n\t\tif err != nil || tx == nil {\n\t\t\treturn errors.Wrap(err, \"failed to fix Execution gas limit\")\n\t\t}\n\t\tgasLimit = tx.GasLimit()\n\t}\n\treturn SendAction(\n\t\tclient,\n\t\tcmd,\n\t\t(&action.EnvelopeBuilder{}).\n\t\t\tSetNonce(nonce).\n\t\t\tSetGasPrice(gasPriceRau).\n\t\t\tSetGasLimit(gasLimit).\n\t\t\tSetAction(tx).Build(),\n\t\tsender,\n\t\tpassword,\n\t\tnonce,\n\t\tassumeYes,\n\t)\n}"],"string":"[\n \"func (_Vault *VaultTransactor) Execute(opts *bind.TransactOpts, token common.Address, amount *big.Int, recipientToken common.Address, exchangeAddress common.Address, callData []byte, timestamp []byte, signData []byte) (*types.Transaction, error) {\\n\\treturn _Vault.contract.Transact(opts, \\\"execute\\\", token, amount, recipientToken, exchangeAddress, callData, timestamp, signData)\\n}\",\n \"func Execute(ctx context.Context, version string) {\\n\\tvar rootCmd = &cobra.Command{\\n\\t\\tUse: \\\"act [event name to run]\\\",\\n\\t\\tShort: \\\"Run Github actions locally by specifying the event name (e.g. `push`) or an action name directly.\\\",\\n\\t\\tArgs: cobra.MaximumNArgs(1),\\n\\t\\tRunE: newRunAction(ctx),\\n\\t\\tVersion: version,\\n\\t\\tSilenceUsage: true,\\n\\t}\\n\\trootCmd.Flags().BoolVarP(&list, \\\"list\\\", \\\"l\\\", false, \\\"list actions\\\")\\n\\trootCmd.Flags().StringVarP(&actionName, \\\"action\\\", \\\"a\\\", \\\"\\\", \\\"run action\\\")\\n\\trootCmd.Flags().StringVarP(&eventPath, \\\"event\\\", \\\"e\\\", \\\"\\\", \\\"path to event JSON file\\\")\\n\\trootCmd.PersistentFlags().BoolVarP(&dryrun, \\\"dryrun\\\", \\\"n\\\", false, \\\"dryrun mode\\\")\\n\\trootCmd.PersistentFlags().BoolVarP(&verbose, \\\"verbose\\\", \\\"v\\\", false, \\\"verbose output\\\")\\n\\trootCmd.PersistentFlags().StringVarP(&workflowPath, \\\"file\\\", \\\"f\\\", \\\"./.github/main.workflow\\\", \\\"path to workflow file\\\")\\n\\trootCmd.PersistentFlags().StringVarP(&workingDir, \\\"directory\\\", \\\"C\\\", \\\".\\\", \\\"working directory\\\")\\n\\tif err := rootCmd.Execute(); err != nil {\\n\\t\\tos.Exit(1)\\n\\t}\\n\\n}\",\n \"func (e *EvaluatedFunctionExpression) Execute(ctx *Context, args *Values) Value {\\n\\tctx.SetParent(e.this) // this is how closure works\\n\\treturn e.fn.Execute(ctx, args)\\n}\",\n \"func Execute(lambdaAWSInfos []*LambdaAWSInfo, port int, parentProcessPID int, logger *logrus.Logger) error {\\n\\tif port <= 0 {\\n\\t\\tport = defaultHTTPPort\\n\\t}\\n\\tlogger.Info(\\\"Execute!\\\")\\n\\n\\tlookupMap := make(dispatchMap, 0)\\n\\tfor _, eachLambdaInfo := range lambdaAWSInfos {\\n\\t\\tlookupMap[eachLambdaInfo.lambdaFnName] = eachLambdaInfo\\n\\t}\\n\\tserver := &http.Server{\\n\\t\\tAddr: fmt.Sprintf(\\\":%d\\\", port),\\n\\t\\tHandler: &lambdaHandler{lookupMap, logger},\\n\\t\\tReadTimeout: 10 * time.Second,\\n\\t\\tWriteTimeout: 10 * time.Second,\\n\\t}\\n\\tif 0 != parentProcessPID {\\n\\t\\tlogger.Debug(\\\"Sending SIGUSR2 to parent process: \\\", parentProcessPID)\\n\\t\\tsyscall.Kill(parentProcessPID, syscall.SIGUSR2)\\n\\t}\\n\\tlogger.Debug(\\\"Binding to port: \\\", port)\\n\\terr := server.ListenAndServe()\\n\\tif err != nil {\\n\\t\\tlogger.Error(\\\"FAILURE: \\\" + err.Error())\\n\\t\\treturn err\\n\\t}\\n\\tlogger.Debug(\\\"Server available at: \\\", port)\\n\\treturn nil\\n}\",\n \"func (c *Command) Execute(user string, msg string, args []string) {\\n}\",\n \"func (_SimpleMultiSig *SimpleMultiSigTransactor) Execute(opts *bind.TransactOpts, bucketIdx uint16, expireTime *big.Int, sigV []uint8, sigR [][32]byte, sigS [][32]byte, destination common.Address, value *big.Int, data []byte, executor common.Address, gasLimit *big.Int) (*types.Transaction, error) {\\n\\treturn _SimpleMultiSig.contract.Transact(opts, \\\"execute\\\", bucketIdx, expireTime, sigV, sigR, sigS, destination, value, data, executor, gasLimit)\\n}\",\n \"func (p *Plugin) Execute(config contracts.Configuration, cancelFlag task.CancelFlag, output iohandler.IOHandler) {\\n\\tp.execute(config, cancelFlag, output)\\n\\treturn\\n}\",\n \"func (e *CustomExecutor) Execute(s api.DiscordSession, channel model.Snowflake, command *model.Command) {\\n\\tif command.Custom == nil {\\n\\t\\tlog.Fatal(\\\"Incorrectly generated learn command\\\", errors.New(\\\"wat\\\"))\\n\\t}\\n\\n\\thas, err := e.commandMap.Has(command.Custom.Call)\\n\\tif err != nil {\\n\\t\\tlog.Fatal(\\\"Error testing custom feature\\\", err)\\n\\t}\\n\\tif !has {\\n\\t\\tlog.Fatal(\\\"Accidentally found a mismatched call/response pair\\\", errors.New(\\\"call response mismatch\\\"))\\n\\t}\\n\\n\\tresponse, err := e.commandMap.Get(command.Custom.Call)\\n\\tif err != nil {\\n\\t\\tlog.Fatal(\\\"Error reading custom response\\\", err)\\n\\t}\\n\\n\\t// Perform command substitutions.\\n\\tif strings.Contains(response, \\\"$1\\\") {\\n\\t\\tif command.Custom.Args == \\\"\\\" {\\n\\t\\t\\tresponse = MsgCustomNeedsArgs\\n\\t\\t} else {\\n\\t\\t\\tresponse = strings.Replace(response, \\\"$1\\\", command.Custom.Args, 4)\\n\\t\\t}\\n\\t} else if matches := giphyRegexp.FindStringSubmatch(response); len(matches) > 2 {\\n\\t\\turl := matches[2]\\n\\t\\tresponse = fmt.Sprintf(MsgGiphyLink, url)\\n\\t}\\n\\n\\ts.ChannelMessageSend(channel.Format(), response)\\n}\",\n \"func (h *Handler) Execute(name string, args []string) {\\n\\tlog.Warn(\\\"generic doesn't support command execution\\\")\\n}\",\n \"func (command SimpleCommandTestCommand) execute(notification interfaces.INotification) {\\n\\tvar vo = notification.Body().(*SimpleCommandTestVO)\\n\\n\\t//Fabricate a result\\n\\tvo.Result = 2 * vo.Input\\n}\",\n \"func (s *fnSignature) Execute(ctx context.Context) ([]reflect.Value, error) {\\n\\tglobalBackendStatsClient().TaskExecutionCount().Inc(1)\\n\\ttargetArgs := make([]reflect.Value, 0, len(s.Args)+1)\\n\\ttargetArgs = append(targetArgs, reflect.ValueOf(ctx))\\n\\tfor _, arg := range s.Args {\\n\\t\\ttargetArgs = append(targetArgs, reflect.ValueOf(arg))\\n\\t}\\n\\tif fn, ok := fnLookup.getFn(s.FnName); ok {\\n\\t\\tfnValue := reflect.ValueOf(fn)\\n\\t\\treturn fnValue.Call(targetArgs), nil\\n\\t}\\n\\treturn nil, fmt.Errorf(\\\"function: %q not found. Did you forget to register?\\\", s.FnName)\\n}\",\n \"func (_e *handler_Expecter) Execute(req interface{}, s interface{}) *handler_Execute_Call {\\n\\treturn &handler_Execute_Call{Call: _e.mock.On(\\\"Execute\\\", req, s)}\\n}\",\n \"func (vm *EVM) Execute(st acmstate.ReaderWriter, blockchain engine.Blockchain, eventSink exec.EventSink,\\n\\tparams engine.CallParams, code []byte) ([]byte, error) {\\n\\n\\t// Make it appear as if natives are stored in state\\n\\tst = native.NewState(vm.options.Natives, st)\\n\\n\\tstate := engine.State{\\n\\t\\tCallFrame: engine.NewCallFrame(st).WithMaxCallStackDepth(vm.options.CallStackMaxDepth),\\n\\t\\tBlockchain: blockchain,\\n\\t\\tEventSink: eventSink,\\n\\t}\\n\\n\\toutput, err := vm.Contract(code).Call(state, params)\\n\\tif err == nil {\\n\\t\\t// Only sync back when there was no exception\\n\\t\\terr = state.CallFrame.Sync()\\n\\t}\\n\\t// Always return output - we may have a reverted exception for which the return is meaningful\\n\\treturn output, err\\n}\",\n \"func (pon *DmiTransceiverPlugIn) Execute(args []string) error {\\n\\tclient, conn := dmiEventGrpcClient()\\n\\tdefer conn.Close()\\n\\n\\tctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)\\n\\tdefer cancel()\\n\\n\\treq := pb.TransceiverRequest{\\n\\t\\tTransceiverId: uint32(pon.Args.TransceiverId),\\n\\t}\\n\\n\\tres, err := client.PlugInTransceiver(ctx, &req)\\n\\tif err != nil {\\n\\t\\tlog.Errorf(\\\"Cannot plug in PON transceiver: %v\\\", err)\\n\\t\\treturn err\\n\\t}\\n\\n\\tfmt.Println(fmt.Sprintf(\\\"[Status: %d] %s\\\", res.StatusCode, res.Message))\\n\\treturn nil\\n}\",\n \"func (c *cmdVoteInv) Execute(args []string) error {\\n\\t_, err := voteInv(c)\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\treturn nil\\n}\",\n \"func (lambda *Lambda) Execute(reconciliationMetaData *models.ReconciliationMetaData) error {\\n\\tif reconciliationMetaData.ReconciliationDate == \\\"\\\" {\\n\\n\\t\\treconciliationDateTime := time.Now()\\n\\t\\treconciliationMetaData.ReconciliationDate = reconciliationDateTime.Format(dateFormat)\\n\\n\\t\\tstartTime := reconciliationDateTime.Truncate(24 * time.Hour)\\n\\t\\treconciliationMetaData.StartTime = startTime\\n\\t\\treconciliationMetaData.EndTime = startTime.Add(24 * time.Hour)\\n\\t} else {\\n\\n\\t\\tstartTime, err := time.Parse(dateFormat, reconciliationMetaData.ReconciliationDate)\\n\\t\\tif err != nil {\\n\\t\\t\\tlog.Error(err)\\n\\t\\t\\treturn err\\n\\t\\t}\\n\\n\\t\\treconciliationMetaData.StartTime = startTime\\n\\t\\treconciliationMetaData.EndTime = startTime.Add(24 * time.Hour)\\n\\t}\\n\\n\\tlog.Info(\\\"LFP error reporting lambda executing. Getting penalties with e5 errors for date: \\\" + reconciliationMetaData.ReconciliationDate + \\\". Creating lfp CSV.\\\")\\n\\n\\tlfpCSV, err := lambda.Service.GetLFPCSV(reconciliationMetaData)\\n\\tif err != nil {\\n\\t\\tlog.Error(err)\\n\\t\\treturn err\\n\\t}\\n\\n\\tlog.Info(\\\"LFP CSV constructed.\\\")\\n\\tlog.Trace(\\\"LFP CSV\\\", log.Data{\\\"lfp_csv\\\": lfpCSV})\\n\\n\\terr = lambda.FileTransfer.UploadCSVFiles([]models.CSV{lfpCSV})\\n\\tif err != nil {\\n\\t\\tlog.Error(err)\\n\\t\\treturn err\\n\\t}\\n\\n\\tlog.Info(\\\"CSV's successfully uploaded. Lambda execution finished.\\\")\\n\\n\\treturn nil\\n}\",\n \"func (ft *CustomTask) Exec(t *f.TaskNode, p *f.Params, out *io.PipeWriter) {\\n\\tglog.Info(\\\"executing custom task \\\", p.Complete)\\n\\n\\tft.customFunc(t, p, out)\\n\\n\\treturn\\n}\",\n \"func (_Vault *VaultTransactorSession) Execute(token common.Address, amount *big.Int, recipientToken common.Address, exchangeAddress common.Address, callData []byte, timestamp []byte, signData []byte) (*types.Transaction, error) {\\n\\treturn _Vault.Contract.Execute(&_Vault.TransactOpts, token, amount, recipientToken, exchangeAddress, callData, timestamp, signData)\\n}\",\n \"func (c *Command) Execute(ctx context.Context) error {\\n\\n\\tpctx := &commandContext{\\n\\t\\tdependencyResolver: pipeline.NewDependencyRecorder[*commandContext](),\\n\\t\\tContext: ctx,\\n\\t}\\n\\n\\tp := pipeline.NewPipeline[*commandContext]().WithBeforeHooks(pipe.DebugLogger[*commandContext](c.Log), pctx.dependencyResolver.Record)\\n\\tp.WithSteps(\\n\\t\\tp.NewStep(\\\"create client\\\", c.createClient),\\n\\t\\tp.NewStep(\\\"fetch task\\\", c.fetchTask),\\n\\t\\tp.NewStep(\\\"list intermediary files\\\", c.listIntermediaryFiles),\\n\\t\\tp.NewStep(\\\"delete intermediary files\\\", c.deleteFiles),\\n\\t\\tp.NewStep(\\\"delete source file\\\", c.deleteSourceFile),\\n\\t)\\n\\n\\treturn p.RunWithContext(pctx)\\n}\",\n \"func (c *CLI) Execute() {\\n\\tc.LoadCredentials()\\n\\twr := &workflow.WorkflowResult{}\\n\\texecHandler := workflow.GetExecutorHandler()\\n\\texec, err := execHandler.Add(c.Workflow, wr.Callback)\\n\\tc.exitOnError(err)\\n\\texec.SetLogListener(c.logListener)\\n\\tstart := time.Now()\\n\\texec, err = execHandler.Execute(c.Workflow.WorkflowID)\\n\\tc.exitOnError(err)\\n\\tchecks := 0\\n\\toperation := \\\"\\\"\\n\\tif c.Params.InstallRequest != nil {\\n\\t\\tif c.Params.AppCluster {\\n\\t\\t\\toperation = \\\"Installing application cluster\\\"\\n\\t\\t} else {\\n\\t\\t\\toperation = \\\"Installing management cluster\\\"\\n\\t\\t}\\n\\t} else if c.Params.UninstallRequest != nil {\\n\\t\\tif c.Params.AppCluster {\\n\\t\\t\\toperation = \\\"Uninstalling application cluster\\\"\\n\\t\\t} else {\\n\\t\\t\\toperation = \\\"Uninstalling management cluster\\\"\\n\\t\\t}\\n\\t}\\n\\tfor !wr.Called {\\n\\t\\ttime.Sleep(time.Second * 15)\\n\\t\\tif checks%4 == 0 {\\n\\t\\t\\tfmt.Println(operation, string(exec.State), \\\"-\\\", time.Since(start).String())\\n\\t\\t}\\n\\t\\tchecks++\\n\\t}\\n\\telapsed := time.Since(start)\\n\\tfmt.Println(\\\"Operation took \\\", elapsed)\\n\\tif wr.Error != nil {\\n\\t\\tfmt.Println(\\\"Operation failed due to \\\", wr.Error.Error())\\n\\t\\tlog.Fatal().Str(\\\"error\\\", wr.Error.DebugReport()).Msg(fmt.Sprintf(\\\"%s failed\\\", operation))\\n\\t}\\n}\",\n \"func (p *ContextPlugin) Execute(event *types.Event) *types.Event {\\n\\tif event.Time == 0 {\\n\\t\\tevent.Time = time.Now().UnixMilli()\\n\\t}\\n\\n\\tif event.InsertID == \\\"\\\" {\\n\\t\\tevent.InsertID = uuid.NewString()\\n\\t}\\n\\n\\tevent.Library = p.contextString\\n\\n\\treturn event\\n}\",\n \"func (e *EventEmitter) execute(listener *Listener, event *Event) {\\n\\tdefer e.gracefulWait.Done()\\n\\n\\tfor _, filterFunc := range e.filterFuncs {\\n\\t\\tif !filterFunc(event) {\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t}\\n\\n\\tvar (\\n\\t\\tdata Data\\n\\t\\texecutionTags []string\\n\\t)\\n\\n\\tif e.mapFunc != nil {\\n\\t\\tdata = e.mapFunc(event)\\n\\t} else if err := event.Data(&data); err != nil {\\n\\t\\te.app.log.Println(errDecodingEventData{err})\\n\\t\\treturn\\n\\t}\\n\\n\\tif e.executionTagsFunc != nil {\\n\\t\\texecutionTags = e.executionTagsFunc(event)\\n\\t}\\n\\n\\tif _, err := e.app.execute(e.taskServiceID, e.taskKey, data, executionTags); err != nil {\\n\\t\\te.app.log.Println(executionError{e.taskKey, err})\\n\\t}\\n}\",\n \"func (l *Labeler) Execute() error {\\n\\terr := l.checkPreconditions()\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\n\\tlog.Debugf(\\\"executing with owner=%s repo=%s event=%s\\\", *l.Owner, *l.Repo, *l.Event)\\n\\n\\tc, err := l.retrieveConfig()\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\tl.config = c\\n\\n\\tswitch *l.Event {\\n\\tcase issue:\\n\\t\\terr = l.processIssue()\\n\\t\\tif err != nil {\\n\\t\\t\\treturn err\\n\\t\\t}\\n\\tcase pullRequestTarget, pullRequest:\\n\\t\\terr = l.processPullRequest()\\n\\t\\tif err != nil {\\n\\t\\t\\treturn err\\n\\t\\t}\\n\\t}\\n\\n\\treturn nil\\n}\",\n \"func Execute(ctx context.Context) error {\\n\\treturn rootCmd.ExecuteContext(ctx)\\n}\",\n \"func Execute(ctx context.Context, command Command, aggregate Aggregate, metadata Metadata) (Event, error) {\\n\\ttx := DB.Begin()\\n\\n\\tevent, err := ExecuteTx(ctx, tx, command, aggregate, metadata)\\n\\tif err != nil {\\n\\t\\ttx.Rollback()\\n\\t\\treturn Event{}, err\\n\\t}\\n\\n\\tif err = tx.Commit().Error; err != nil {\\n\\t\\ttx.Rollback()\\n\\t\\treturn Event{}, err\\n\\t}\\n\\n\\treturn event, nil\\n}\",\n \"func (_ERC725 *ERC725Transactor) Execute(opts *bind.TransactOpts, _data []byte) (*types.Transaction, error) {\\n\\treturn _ERC725.contract.Transact(opts, \\\"execute\\\", _data)\\n}\",\n \"func (cmd *command) Execute(ch io.ReadWriter) (err error) {\\n\\tif cmd.Flags.Source {\\n\\t\\terr = cmd.serveSource(ch)\\n\\t} else {\\n\\t\\terr = cmd.serveSink(ch)\\n\\t}\\n\\tif err != nil {\\n\\t\\treturn trace.Wrap(err)\\n\\t}\\n\\treturn nil\\n}\",\n \"func (pon *DmiTransceiverPlugOut) Execute(args []string) error {\\n\\tclient, conn := dmiEventGrpcClient()\\n\\tdefer conn.Close()\\n\\n\\tctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)\\n\\tdefer cancel()\\n\\n\\treq := pb.TransceiverRequest{\\n\\t\\tTransceiverId: uint32(pon.Args.TransceiverId),\\n\\t}\\n\\n\\tres, err := client.PlugOutTransceiver(ctx, &req)\\n\\tif err != nil {\\n\\t\\tlog.Errorf(\\\"Cannot plug out PON transceiver: %v\\\", err)\\n\\t\\treturn err\\n\\t}\\n\\n\\tfmt.Println(fmt.Sprintf(\\\"[Status: %d] %s\\\", res.StatusCode, res.Message))\\n\\treturn nil\\n}\",\n \"func executeAction(fn command) cli.ActionFunc {\\n\\tusername := os.Getenv(\\\"VOIPMS_USERNAME\\\")\\n\\tpassword := os.Getenv(\\\"VOIPMS_PASSWORD\\\")\\n\\tclient := api.NewClient(username, password)\\n\\treturn func(c *cli.Context) error {\\n\\t\\treturn fn(client, c)\\n\\t}\\n}\",\n \"func Execute() {\\n\\tinitHelp()\\n\\tcontext := InitializeContext()\\n\\n\\tprintLogoWithVersion(os.Stdout)\\n\\n\\tif context.config.trustAll {\\n\\t\\tif !context.config.quiet {\\n\\t\\t\\tfmt.Println(\\\"WARNING: Configured to trust all - means unnown service certificate is accepted. Don't use this in production!\\\")\\n\\t\\t}\\n\\t}\\n\\taction := context.config.action\\n\\tif action == ActionExecuteSynchron {\\n\\t\\tcommonWayToApprove(context)\\n\\t\\twaitForSecHubJobDoneAndFailOnTrafficLight(context)\\n\\t\\tos.Exit(ExitCodeOK)\\n\\n\\t} else if action == ActionExecuteAsynchron {\\n\\t\\tcommonWayToApprove(context)\\n\\t\\tfmt.Println(context.config.secHubJobUUID)\\n\\t\\tos.Exit(ExitCodeOK)\\n\\t} else if action == ActionExecuteGetStatus {\\n\\t\\tstate := getSecHubJobState(context, true, false, false)\\n\\t\\tfmt.Println(state)\\n\\t\\tos.Exit(ExitCodeOK)\\n\\n\\t} else if action == ActionExecuteGetReport {\\n\\t\\treport := getSecHubJobReport(context)\\n\\t\\tfmt.Println(report)\\n\\t\\tos.Exit(ExitCodeOK)\\n\\t}\\n\\tfmt.Printf(\\\"Unknown action '%s'\\\", context.config.action)\\n\\tos.Exit(ExitCodeIllegalAction)\\n}\",\n \"func Execute() error {\\n\\treturn cmd.Execute()\\n}\",\n \"func (_Trebuchet *TrebuchetTransactor) Execute(opts *bind.TransactOpts, _data [][]byte) (*types.Transaction, error) {\\n\\treturn _Trebuchet.contract.Transact(opts, \\\"execute\\\", _data)\\n}\",\n \"func (scs *SubCommandStruct) Execute(ctx context.Context, in io.Reader, out, outErr io.Writer) error {\\n\\tif scs.ExecuteValue != nil {\\n\\t\\treturn scs.ExecuteValue(ctx, in, out, outErr)\\n\\t}\\n\\treturn nil\\n}\",\n \"func (e *ldapExecutor) Execute(ctx context.Context, config *ldapconf.Config) error {\\n\\treturn nil\\n}\",\n \"func (f *FunctionExpression) Execute(ctx *Context, args *Values) Value {\\n\\tf.params.BindArguments(ctx, args.values...)\\n\\tf.body.Execute(ctx)\\n\\tif ctx.hasret {\\n\\t\\treturn ctx.retval\\n\\t}\\n\\treturn ValueFromNil()\\n}\",\n \"func Execute(ctx context.OrionContext, action *Base, fn ExecuteFn) errors.Error {\\n\\t// ctx.StartAction()\\n\\tevalCtx := ctx.EvalContext()\\n\\twhen, err := helper.GetExpressionValueAsBool(evalCtx, action.when, true)\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\tif !when {\\n\\t\\treturn nil\\n\\t}\\n\\tif action.count != nil && !action.count.Range().Empty() {\\n\\t\\treturn doCount(ctx, action, fn)\\n\\t}\\n\\tif action.while != nil && !action.while.Range().Empty() {\\n\\t\\treturn doWhile(ctx, action, fn)\\n\\t}\\n\\treturn fn(ctx)\\n}\",\n \"func (ctrl *PGCtrl) Execute(q string) error {\\n\\t_, err := ctrl.conn.Exec(q)\\n\\treturn err\\n}\",\n \"func (_Vault *VaultSession) Execute(token common.Address, amount *big.Int, recipientToken common.Address, exchangeAddress common.Address, callData []byte, timestamp []byte, signData []byte) (*types.Transaction, error) {\\n\\treturn _Vault.Contract.Execute(&_Vault.TransactOpts, token, amount, recipientToken, exchangeAddress, callData, timestamp, signData)\\n}\",\n \"func (_m *WorkerHandlerOptionFunc) Execute(_a0 *types.WorkerHandler) {\\n\\t_m.Called(_a0)\\n}\",\n \"func (r Describe) Execute(name string, out io.Writer, args []string) error {\\n\\twrap := types.Executor{Name: name, Command: r}\\n\\tctx := context.WithValue(context.Background(), global.RefRoot, wrap)\\n\\tcmd := r.NewCommand(ctx, name)\\n\\tcmd.SetOut(out)\\n\\tcmd.SetArgs(args)\\n\\tif err := cmd.Execute(); err != nil {\\n\\t\\treturn err\\n\\t}\\n\\treturn nil\\n}\",\n \"func (p *PrintCommand) Execute(_ engine.Handler) {\\n\\tfmt.Println(p.Arg)\\n}\",\n \"func (tx *Hello) Execute(p types.Process, ctw *types.ContextWrapper, index uint16) error {\\n\\tsp := p.(*HelloWorld)\\n\\n\\treturn sp.vault.WithFee(p, ctw, tx, func() error {\\n\\t\\tif err := sp.AddHelloCount(ctw, tx.To); err != nil {\\n\\t\\t\\treturn err\\n\\t\\t}\\n\\n\\t\\treturn nil\\n\\t})\\n}\",\n \"func (player *Player) ExecAs(commandLine string, callback func(statusCode int)) {\\n\\tplayer.Exec(fmt.Sprintf(\\\"execute %v ~ ~ ~ %v\\\", player.name, commandLine), func(response map[string]interface{}) {\\n\\t\\tcodeInterface, exists := response[\\\"statusCode\\\"]\\n\\t\\tif !exists {\\n\\t\\t\\tlog.Printf(\\\"exec as: invalid response JSON\\\")\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tcode, _ := codeInterface.(int)\\n\\t\\tif callback != nil {\\n\\t\\t\\tcallback(code)\\n\\t\\t}\\n\\t})\\n}\",\n \"func (e *Execution) Execute(ctx context.Context) error {\\n\\n\\tvar err error\\n\\tswitch strings.ToLower(e.Operation.Name) {\\n\\tcase installOperation, \\\"standard.create\\\":\\n\\t\\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\\n\\t\\t\\t\\\"Creating Job %q\\\", e.NodeName)\\n\\t\\terr = e.createJob(ctx)\\n\\t\\tif err != nil {\\n\\t\\t\\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\\n\\t\\t\\t\\t\\\"Failed to create Job %q, error %s\\\", e.NodeName, err.Error())\\n\\n\\t\\t}\\n\\tcase uninstallOperation, \\\"standard.delete\\\":\\n\\t\\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\\n\\t\\t\\t\\\"Deleting Job %q\\\", e.NodeName)\\n\\t\\terr = e.deleteJob(ctx)\\n\\t\\tif err != nil {\\n\\t\\t\\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\\n\\t\\t\\t\\t\\\"Failed to delete Job %q, error %s\\\", e.NodeName, err.Error())\\n\\n\\t\\t}\\n\\tcase enableFileTransferOperation:\\n\\t\\terr = e.enableFileTransfer(ctx)\\n\\t\\tif err != nil {\\n\\t\\t\\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\\n\\t\\t\\t\\t\\\"Failed to enable file transfer for Job %q, error %s\\\", e.NodeName, err.Error())\\n\\n\\t\\t}\\n\\tcase disableFileTransferOperation:\\n\\t\\terr = e.disableFileTransfer(ctx)\\n\\t\\tif err != nil {\\n\\t\\t\\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\\n\\t\\t\\t\\t\\\"Failed to disable file transfer for Job %q, error %s\\\", e.NodeName, err.Error())\\n\\n\\t\\t}\\n\\tcase listChangedFilesOperation:\\n\\t\\terr = e.listChangedFiles(ctx)\\n\\t\\tif err != nil {\\n\\t\\t\\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\\n\\t\\t\\t\\t\\\"Failed to list changed files for Job %q, error %s\\\", e.NodeName, err.Error())\\n\\n\\t\\t}\\n\\tcase tosca.RunnableSubmitOperationName:\\n\\t\\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\\n\\t\\t\\t\\\"Submitting Job %q\\\", e.NodeName)\\n\\t\\terr = e.submitJob(ctx)\\n\\t\\tif err != nil {\\n\\t\\t\\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\\n\\t\\t\\t\\t\\\"Failed to submit Job %q, error %s\\\", e.NodeName, err.Error())\\n\\n\\t\\t}\\n\\tcase tosca.RunnableCancelOperationName:\\n\\t\\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\\n\\t\\t\\t\\\"Canceling Job %q\\\", e.NodeName)\\n\\t\\terr = e.cancelJob(ctx)\\n\\t\\tif err != nil {\\n\\t\\t\\tevents.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, e.DeploymentID).Registerf(\\n\\t\\t\\t\\t\\\"Failed to cancel Job %q, error %s\\\", e.NodeName, err.Error())\\n\\n\\t\\t}\\n\\tdefault:\\n\\t\\terr = errors.Errorf(\\\"Unsupported operation %q\\\", e.Operation.Name)\\n\\t}\\n\\n\\treturn err\\n}\",\n \"func OnExecute(c *grumble.Context) error {\\n\\tplanID := c.Flags.Int(\\\"plan\\\")\\n\\tif len(config.AppConfig.Plans) < planID {\\n\\t\\tfmt.Println(\\\"No plan with ID\\\", planID, \\\"exists. Use the command \\\\\\\"list\\\\\\\" to get a list of available plans.\\\")\\n\\t\\treturn nil\\n\\t}\\n\\tplan := config.AppConfig.Plans[planID-1]\\n\\n\\tfor _, task := range plan.Tasks {\\n\\t\\tresult := task.Execute()\\n\\n\\t\\tif result.IsSuccessful {\\n\\n\\t\\t\\tfmt.Println(result.Message)\\n\\t\\t} else {\\n\\t\\t\\tfmt.Println(\\\"Error:\\\", result.Message)\\n\\t\\t}\\n\\t}\\n\\n\\treturn nil\\n}\",\n \"func Execute(contID container.ContainerID, r *scheduledRequest) error {\\n\\t//log.Printf(\\\"[%s] Executing on container: %v\\\", r, contID)\\n\\n\\tvar req executor.InvocationRequest\\n\\tif r.Fun.Runtime == container.CUSTOM_RUNTIME {\\n\\t\\treq = executor.InvocationRequest{\\n\\t\\t\\tParams: r.Params,\\n\\t\\t}\\n\\t} else {\\n\\t\\tcmd := container.RuntimeToInfo[r.Fun.Runtime].InvocationCmd\\n\\t\\treq = executor.InvocationRequest{\\n\\t\\t\\tcmd,\\n\\t\\t\\tr.Params,\\n\\t\\t\\tr.Fun.Handler,\\n\\t\\t\\tHANDLER_DIR,\\n\\t\\t}\\n\\t}\\n\\n\\tt0 := time.Now()\\n\\n\\tresponse, invocationWait, err := container.Execute(contID, &req)\\n\\tif err != nil {\\n\\t\\t// notify scheduler\\n\\t\\tcompletions <- &completion{scheduledRequest: r, contID: contID}\\n\\t\\treturn fmt.Errorf(\\\"[%s] Execution failed: %v\\\", r, err)\\n\\t}\\n\\n\\tif !response.Success {\\n\\t\\t// notify scheduler\\n\\t\\tcompletions <- &completion{scheduledRequest: r, contID: contID}\\n\\t\\treturn fmt.Errorf(\\\"Function execution failed\\\")\\n\\t}\\n\\n\\tr.ExecReport.Result = response.Result\\n\\tr.ExecReport.Duration = time.Now().Sub(t0).Seconds() - invocationWait.Seconds()\\n\\tr.ExecReport.ResponseTime = time.Now().Sub(r.Arrival).Seconds()\\n\\n\\t// initializing containers may require invocation retries, adding\\n\\t// latency\\n\\tr.ExecReport.InitTime += invocationWait.Seconds()\\n\\n\\t// notify scheduler\\n\\tcompletions <- &completion{scheduledRequest: r, contID: contID}\\n\\n\\treturn nil\\n}\",\n \"func Execute() {\\n\\tAddCommands()\\n\\tIpvanishCmd.Execute()\\n\\t//\\tutils.StopOnErr(IpvanishCmd.Execute())\\n}\",\n \"func (self *Controller) ExecuteCommand(notification interfaces.INotification) {\\n\\tself.commandMapMutex.RLock()\\n\\tdefer self.commandMapMutex.RUnlock()\\n\\n\\tvar commandFunc = self.commandMap[notification.Name()]\\n\\tif commandFunc == nil {\\n\\t\\treturn\\n\\t}\\n\\tcommandInstance := commandFunc()\\n\\tcommandInstance.InitializeNotifier(self.Key)\\n\\tcommandInstance.Execute(notification)\\n}\",\n \"func (i service) Execute(ctx context.Context, to common.Address, contractAbi, methodName string, args ...interface{}) error {\\n\\tabi, err := abi.JSON(strings.NewReader(contractAbi))\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\n\\t// Pack encodes the parameters and additionally checks if the method and arguments are defined correctly\\n\\tdata, err := abi.Pack(methodName, args...)\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\treturn i.RawExecute(ctx, to, data)\\n}\",\n \"func Execute(\\n\\tctx context.Context,\\n\\thandler Handler,\\n\\tabortHandler AbortHandler,\\n\\trequest interface{}) Awaiter {\\n\\ttask := &task{\\n\\t\\trequest: request,\\n\\t\\thandler: handler,\\n\\t\\tabortHandler: abortHandler,\\n\\t\\tresultQ: make(chan Response, 1),\\n\\t\\trunning: true,\\n\\t}\\n\\tgo task.run(ctx) // run handler asynchronously\\n\\treturn task\\n}\",\n \"func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {\\n\\tfunction, args := stub.GetFunctionAndParameters()\\n\\tif function == \\\"makeStatement\\\" {\\n\\t\\tif len(args) != 1 {\\n\\t\\t\\treturn shim.Error(\\\"Incorrect number of arguments: \\\" + string(len(args)))\\n\\t\\t}\\n\\t\\tstatement := args[0]\\n\\t\\tts, _ := stub.GetTxTimestamp()\\n\\t\\ttxtime := time.Unix(ts.Seconds, int64(ts.Nanos))\\n\\t\\tevent := Event{\\n\\t\\t\\tStatement: statement,\\n\\t\\t\\tEventTime: txtime,\\n\\t\\t\\tTxID: stub.GetTxID(),\\n\\t\\t}\\n\\t\\tevtJson, _ := json.Marshal(event)\\n\\t\\tstub.PutState(stub.GetTxID(), evtJson)\\n\\t\\treturn shim.Success(evtJson)\\n\\t}\\n\\tlogger.Errorf(\\\"invoke did not find func: %s\\\", function)\\n\\treturn shim.Error(\\\"Received unknown function invocation\\\")\\n}\",\n \"func Execute() {\\n\\tmainCmd.Execute()\\n}\",\n \"func (f Function) Execute(i Instruction, e Environment, dryRun bool) error {\\n\\tif err := f.Check(i); err != nil {\\n\\t\\treturn err\\n\\t}\\n\\treturn f.Func(i, e, dryRun)\\n}\",\n \"func Execute(context *cli.Context) error {\\n\\tmanager, err := createManager(context)\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\n\\tmanager.WithTimeout(context.Int(\\\"timeout\\\"))\\n\\n\\tfilename := context.Args().First()\\n\\tif filename == \\\"\\\" {\\n\\t\\treturn cli.NewExitError(\\\"filename argument is required\\\", 1)\\n\\t}\\n\\n\\tname := context.String(\\\"name\\\")\\n\\tif name == \\\"\\\" {\\n\\t\\tname = strings.TrimSuffix(path.Base(filename), filepath.Ext(filename))\\n\\t}\\n\\n\\tscript, err := manager.CreateFromFile(name, filename)\\n\\tif err != nil {\\n\\t\\treturn errors.Wrapf(err, \\\"failed to create script %s from %s\\\", name, filename)\\n\\t}\\n\\n\\tvar result string\\n\\tfilePayload := context.String(\\\"file-payload\\\")\\n\\tpayload := context.String(\\\"payload\\\")\\n\\n\\tif filePayload != \\\"\\\" && payload != \\\"\\\" {\\n\\t\\treturn cli.NewExitError(\\\"only one of the parameters can be used: payload or file-payload\\\", 2)\\n\\t}\\n\\n\\tif filePayload != \\\"\\\" {\\n\\t\\tresult, err = script.ExecuteWithFilePayload(filePayload)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn errors.Wrapf(err, \\\"execution of script %s with filePayload %s failed\\\", filename, filePayload)\\n\\t\\t}\\n\\t} else if payload != \\\"\\\" {\\n\\t\\tresult, err = script.ExecuteWithStringPayload(payload)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn errors.Wrapf(err, \\\"execution of script %s failed\\\", filename)\\n\\t\\t}\\n\\t} else {\\n\\t\\tresult, err = script.ExecuteWithoutPayload()\\n\\t\\tif err != nil {\\n\\t\\t\\treturn errors.Wrapf(err, \\\"execution of script %s failed\\\", filename)\\n\\t\\t}\\n\\t}\\n\\n\\tfmt.Println(result)\\n\\n\\treturn nil\\n}\",\n \"func (mo *MenuOption) ExecuteCommand(ev chan UIEvent) {\\n\\tev <- mo.Command()\\n}\",\n \"func Execute() {\\n\\tif err := RootCommand.Execute(); err != nil {\\n\\t\\tfmt.Fprintf(os.Stderr, \\\"aws-helper error: %s\\\\n\\\", err)\\n\\t\\tRootCommand.Usage()\\n\\t\\tos.Exit(1)\\n\\t}\\n}\",\n \"func Execute(\\n\\tctx context.Context,\\n\\tpayload gapir.Payload,\\n\\thandlePost builder.PostDataHandler,\\n\\thandleNotification builder.NotificationHandler,\\n\\tconnection *gapir.Connection,\\n\\tmemoryLayout *device.MemoryLayout,\\n\\tos *device.OS) error {\\n\\n\\tctx = status.Start(ctx, \\\"Execute\\\")\\n\\tdefer status.Finish(ctx)\\n\\n\\t// The memoryLayout is specific to the ABI of the requested capture,\\n\\t// while the OS is not. Thus a device.Configuration is not applicable here.\\n\\treturn executor{\\n\\t\\tpayload: payload,\\n\\t\\thandlePost: handlePost,\\n\\t\\thandleNotification: handleNotification,\\n\\t\\tmemoryLayout: memoryLayout,\\n\\t\\tOS: os,\\n\\t}.execute(ctx, connection)\\n}\",\n \"func (c *ToyController) Execute(ctx context.Context) error {\\n\\tc.le.Debug(\\\"toy controller executed\\\")\\n\\t<-ctx.Done()\\n\\treturn nil\\n}\",\n \"func (execution *Execution) Execute() (err error) {\\n\\terr = execution.moveFromPendingToInProgress()\\n\\tif err != nil {\\n\\t\\treturn\\n\\t}\\n\\texecution.ExecutedAt = time.Now()\\n\\tlog.Println(\\\"[PROCESSING]\\\", execution.Task)\\n\\n\\tchannel := execution.Service.TaskSubscriptionChannel()\\n\\n\\tgo pubsub.Publish(channel, execution)\\n\\treturn\\n}\",\n \"func (_Transactable *TransactableTransactor) Execute(opts *bind.TransactOpts, _guarantor common.Address, _v uint8, _r [32]byte, _s [32]byte, _dest common.Address, _value *big.Int, _ts *big.Int) (*types.Transaction, error) {\\n\\treturn _Transactable.contract.Transact(opts, \\\"execute\\\", _guarantor, _v, _r, _s, _dest, _value, _ts)\\n}\",\n \"func (e *executor) Execute() error {\\n\\tif len(e.executables) < 1 {\\n\\t\\treturn errors.New(\\\"nothing to Work\\\")\\n\\t}\\n\\n\\tlog(e.id).Infof(\\\"processing %d item(s)\\\", len(e.executables))\\n\\treturn nil\\n}\",\n \"func (t *PulsarTrigger) Execute(ctx context.Context, events map[string]*v1alpha1.Event, resource interface{}) (interface{}, error) {\\n\\ttrigger, ok := resource.(*v1alpha1.PulsarTrigger)\\n\\tif !ok {\\n\\t\\treturn nil, fmt.Errorf(\\\"failed to interpret the trigger resource\\\")\\n\\t}\\n\\n\\tif trigger.Payload == nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"payload parameters are not specified\\\")\\n\\t}\\n\\n\\tpayload, err := triggers.ConstructPayload(events, trigger.Payload)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\t_, err = t.Producer.Send(ctx, &pulsar.ProducerMessage{\\n\\t\\tPayload: payload,\\n\\t})\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"failed to send message to pulsar, %w\\\", err)\\n\\t}\\n\\n\\tt.Logger.Infow(\\\"successfully produced a message\\\", zap.Any(\\\"topic\\\", trigger.Topic))\\n\\n\\treturn nil, nil\\n}\",\n \"func (_SimpleMultiSig *SimpleMultiSigTransactorSession) Execute(bucketIdx uint16, expireTime *big.Int, sigV []uint8, sigR [][32]byte, sigS [][32]byte, destination common.Address, value *big.Int, data []byte, executor common.Address, gasLimit *big.Int) (*types.Transaction, error) {\\n\\treturn _SimpleMultiSig.Contract.Execute(&_SimpleMultiSig.TransactOpts, bucketIdx, expireTime, sigV, sigR, sigS, destination, value, data, executor, gasLimit)\\n}\",\n \"func (app *App) Execute(input io.Reader, output io.Writer) error {\\n\\tdecoder := yaml.NewDecoder(input)\\n\\tvar data map[string]interface{}\\n\\tif err := decoder.Decode(&data); err != nil {\\n\\t\\treturn errors.Wrap(err, \\\"yaml decode\\\")\\n\\t}\\n\\treturn errors.Wrap(app.t.Execute(output, data), \\\"transform execute\\\")\\n}\",\n \"func (tasks *TaskFile) Execute(cmd, name, dir string) (out string, err error) {\\n\\tcommand, err := templates.Expand(cmd, tasks.TemplateVars.Functions)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\tif tasks.Options.LogLevel {\\n\\t\\tlogger.Info(name, command)\\n\\t}\\n\\n\\treturn templates.Run(templates.CommandOptions{\\n\\t\\tCmd: command,\\n\\t\\tDir: dir,\\n\\t\\tUseStdOut: true,\\n\\t})\\n}\",\n \"func (_SimpleMultiSig *SimpleMultiSigFilterer) FilterExecute(opts *bind.FilterOpts) (*SimpleMultiSigExecuteIterator, error) {\\n\\n\\tlogs, sub, err := _SimpleMultiSig.contract.FilterLogs(opts, \\\"Execute\\\")\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn &SimpleMultiSigExecuteIterator{contract: _SimpleMultiSig.contract, event: \\\"Execute\\\", logs: logs, sub: sub}, nil\\n}\",\n \"func (p *powerEventWatcher) Execute() error {\\n\\t<-p.interrupt\\n\\treturn nil\\n}\",\n \"func Execute() {\\n\\tzk.Execute()\\n}\",\n \"func (c *cmdProposalInv) Execute(args []string) error {\\n\\t_, err := proposalInv(c)\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\treturn nil\\n}\",\n \"func Execute() {\\n\\t// rootCmd.GenZshCompletionFile(\\\"./_clk\\\")\\n\\tcobra.CheckErr(rootCmd.Execute())\\n}\",\n \"func Execute(args []string) (err error) {\\n\\treturn Cmd.Execute(args)\\n}\",\n \"func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) {\\n\\tfmt.Println(\\\"invoke is running \\\" + function)\\n\\n\\t// Handle different functions\\n\\tif function == \\\"init\\\" {\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t//initialize the chaincode state, used as reset\\n\\t\\treturn t.Init(stub, \\\"init\\\", args)\\n\\t}else if function == \\\"create_event\\\" {\\n return t.create_event(stub, args)\\n\\t}else if function == \\\"ping\\\" {\\n return t.ping(stub)\\n }\\n\\t\\n\\treturn nil, errors.New(\\\"Received unknown function invocation: \\\" + function)\\n}\",\n \"func Run(evt event.Event) error {\\n\\tenvs := env.GetEnvs()\\n\\tif len(evt.LogLevel) == 0 {\\n\\t\\tevt.LogLevel = constants.DefaultWorkerLogLevel\\n\\t}\\n\\n\\tif len(envs.Region) == 0 {\\n\\t\\treturn fmt.Errorf(\\\"region is not specified. please check environment variables\\\")\\n\\t}\\n\\tlogrus.Infof(\\\"this is lambda function in %s\\\", envs.Region)\\n\\n\\tswitch envs.Mode {\\n\\tcase constants.ManagerMode:\\n\\t\\treturn workermanager.New().Run(envs)\\n\\tcase constants.WorkerMode:\\n\\t\\treturn worker.NewWorker().Run(envs, evt)\\n\\t}\\n\\n\\treturn nil\\n}\",\n \"func (c *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {\\n\\tfun, args := stub.GetFunctionAndParameters()\\n\\n\\tfmt.Println(\\\"Executing => \\\"+fun)\\n\\n\\tswitch fun{\\n\\tcase \\\"AddCpu\\\":\\n\\t\\treturn c.AddCpu(stub,args)\\n\\tcase \\\"GetUsage\\\":\\n\\t\\treturn c.GetUsage(stub,args)\\n\\tdefault:\\n\\t\\treturn shim.Error(\\\"Not a vaild function\\\")\\t\\n\\t}\\n}\",\n \"func (r *Repository) Execute(command string, args ...interface{}) (middleware.Result, error) {\\n\\tconn, err := r.Database.Get()\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tdefer func() {\\n\\t\\terr = conn.Close()\\n\\t\\tif err != nil {\\n\\t\\t\\tlog.Errorf(\\\"alert DASRepo.Execute(): close database connection failed.\\\\n%s\\\", err.Error())\\n\\t\\t}\\n\\t}()\\n\\n\\treturn conn.Execute(command, args...)\\n}\",\n \"func (c *ConsoleOutput) Execute() {\\n\\tfmt.Println(c.message)\\n}\",\n \"func (t *TaskChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {\\n\\tfunction, args := stub.GetFunctionAndParameters()\\n\\tfmt.Println(\\\"invoke is running \\\" + function)\\n\\n\\tif function == \\\"regist\\\" {\\n\\t\\treturn t.regist(stub, args)\\n\\t} else if function == \\\"pay\\\" {\\n\\t\\treturn t.pay(stub, args)\\n\\t} else if function == \\\"pendingPay\\\" {\\n\\t\\treturn t.pendingPay(stub, args)\\n } else if function == \\\"confirmPay\\\" {\\n\\t\\treturn t.confirmPay(stub, args)\\n } else if function == \\\"getBalance\\\" {\\n\\t\\treturn t.getBalance(stub, args)\\n\\t} else if function == \\\"queryPayTxByTaskId\\\" {\\n\\t\\treturn t.queryPayTxByTaskId(stub, args)\\n\\t} else if function == \\\"queryPayTxByPayer\\\" {\\n\\t\\treturn t.queryPayTxByPayer(stub, args)\\n\\t} else if function == \\\"queryPayTxByPayee\\\" {\\n\\t\\treturn t.queryPayTxByPayee(stub, args)\\n\\t} else if function == \\\"queryMembers\\\" {\\n\\t\\treturn t.queryMembers(stub)\\n\\t} else {\\n\\t\\treturn shim.Error(\\\"Function \\\" + function + \\\" doesn't exits, make sure function is right!\\\")\\n\\t}\\n}\",\n \"func Execute(cfn ConfigFunc) error {\\n\\trootCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {\\n\\t\\tcfn(rootCmd.PersistentFlags())\\n\\t}\\n\\n\\treturn rootCmd.Execute()\\n}\",\n \"func (t TaskFunc) Execute() { t() }\",\n \"func (_SimpleMultiSig *SimpleMultiSigFilterer) WatchExecute(opts *bind.WatchOpts, sink chan<- *SimpleMultiSigExecute) (event.Subscription, error) {\\n\\n\\tlogs, sub, err := _SimpleMultiSig.contract.WatchLogs(opts, \\\"Execute\\\")\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn event.NewSubscription(func(quit <-chan struct{}) error {\\n\\t\\tdefer sub.Unsubscribe()\\n\\t\\tfor {\\n\\t\\t\\tselect {\\n\\t\\t\\tcase log := <-logs:\\n\\t\\t\\t\\t// New log arrived, parse the event and forward to the user\\n\\t\\t\\t\\tevent := new(SimpleMultiSigExecute)\\n\\t\\t\\t\\tif err := _SimpleMultiSig.contract.UnpackLog(event, \\\"Execute\\\", log); err != nil {\\n\\t\\t\\t\\t\\treturn err\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tevent.Raw = log\\n\\n\\t\\t\\t\\tselect {\\n\\t\\t\\t\\tcase sink <- event:\\n\\t\\t\\t\\tcase err := <-sub.Err():\\n\\t\\t\\t\\t\\treturn err\\n\\t\\t\\t\\tcase <-quit:\\n\\t\\t\\t\\t\\treturn nil\\n\\t\\t\\t\\t}\\n\\t\\t\\tcase err := <-sub.Err():\\n\\t\\t\\t\\treturn err\\n\\t\\t\\tcase <-quit:\\n\\t\\t\\t\\treturn nil\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}), nil\\n}\",\n \"func (e *ExecutableInvoker) Invoke(ctx context.Context, m *Manifest, cfg *InvokerConfig) error {\\n\\texecPath := path.Join(e.PluginDir, path.Join(m.Command...), m.Exec)\\n\\tcmd := execCommandContext(ctx, execPath, cfg.Args...)\\n\\tcmd.Env = append(cmd.Env, cfg.Env...)\\n\\tcmd.Stdout = os.Stdout\\n\\tcmd.Stderr = os.Stderr\\n\\n\\treturn cmd.Run()\\n}\",\n \"func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) {\\n\\tswitch function {\\n\\n\\tcase \\\"execute\\\":\\n\\n\\t\\tif len(args) < 1 {\\n\\t\\t\\treturn nil, errors.New(\\\"execute operation must include single argument, the base64 encoded form of a bitcoin transaction\\\")\\n\\t\\t}\\n\\t\\ttxDataBase64 := args[0]\\n\\t\\ttxData, err := base64.StdEncoding.DecodeString(txDataBase64)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, fmt.Errorf(\\\"Error decoding TX as base64: %s\\\", err)\\n\\t\\t}\\n\\n\\t\\tutxo := util.MakeUTXO(MakeChaincodeStore(stub))\\n\\t\\texecResult, err := utxo.Execute(txData)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, fmt.Errorf(\\\"Error executing TX: %s\\\", err)\\n\\t\\t}\\n\\n\\t\\tfmt.Printf(\\\"\\\\nExecResult: Coinbase: %t, SumInputs %d, SumOutputs %d\\\\n\\\\n\\\", execResult.IsCoinbase, execResult.SumPriorOutputs, execResult.SumCurrentOutputs)\\n\\n\\t\\tif execResult.IsCoinbase == false {\\n\\t\\t\\tif execResult.SumCurrentOutputs > execResult.SumPriorOutputs {\\n\\t\\t\\t\\treturn nil, fmt.Errorf(\\\"sumOfCurrentOutputs > sumOfPriorOutputs: sumOfCurrentOutputs = %d, sumOfPriorOutputs = %d\\\", execResult.SumCurrentOutputs, execResult.SumPriorOutputs)\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\treturn nil, nil\\n\\n\\tdefault:\\n\\t\\treturn nil, errors.New(\\\"Unsupported operation\\\")\\n\\t}\\n\\n}\",\n \"func (t *AssetManagementChaincode) Invoke(stub *shim.ChaincodeStub, function string, args []string) ([]byte, error) {\\n\\n if function == \\\"create\\\" {\\n // create asset\\n return t.create(stub, args)\\n } else if function == \\\"update\\\" {\\n // update asset (transfer ownership etc)\\n return t.update(stub, args)\\n }\\n\\n return nil, errors.New(\\\"Received unknown function invocation\\\")\\n}\",\n \"func (machine *Dishwasher) RunCustomCommand(custom string) {\\r\\n machine.Append(func() (string, error) {\\r\\n var output string = \\\"\\\"\\r\\n var oops error = nil\\r\\n\\r\\n custom = strings.TrimSpace(custom)\\r\\n if custom[len(custom)-1] == '$' {\\r\\n go RunCommand(custom)\\r\\n } else {\\r\\n output, oops = RunCommand(custom)\\r\\n machine.SideEffect(output, oops)\\r\\n }\\r\\n\\r\\n return output, oops\\r\\n })\\r\\n}\",\n \"func (t *SimpleChaincode) Run(stub *shim.ChaincodeStub, function string, args []string) ([]byte, error) {\\n fmt.Printf(\\\" ############ KIRK ############# chaincode run\\\") \\n fmt.Println(\\\"run is running \\\" + function)\\n\\n // Handle different functions\\n if function == \\\"init\\\" { //initialize the chaincode state, used as reset\\n return t.init(stub, args)\\n } else if function == \\\"delete\\\" { //deletes an entity from its state\\n return t.Delete(stub, args)\\n } else if function == \\\"write\\\" { //writes a value to the chaincode state\\n return t.Write(stub, args)\\n } else if function == \\\"init_term\\\" { //create a new search term\\n return t.init_term(stub, args)\\n } else if function == \\\"set_user\\\" { //change owner of a search term\\n return t.set_user(stub, args)\\n }\\n fmt.Println(\\\"run did not find func: \\\" + function) //error\\n\\n return nil, errors.New(\\\"Received unknown function invocation\\\")\\n}\",\n \"func (m *MockFinder) Execute(ctx context.Context, config *config.Config, query string, from int64, until int64, stat *FinderStat) (err error) {\\n\\tm.query = query\\n\\treturn\\n}\",\n \"func Execute(config ManagerConfig) error {\\n\\treturn execute(config)\\n}\",\n \"func (e *EventEmitter) Execute(serviceID, taskKey string) (*Listener, error) {\\n\\te.taskServiceID = serviceID\\n\\te.taskKey = taskKey\\n\\tlistener := newListener(e.app, e.gracefulWait)\\n\\tif err := e.app.startServices(e.eventServiceID, serviceID); err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tcancel, err := e.listen(listener)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tlistener.cancel = cancel\\n\\te.app.addListener(listener)\\n\\treturn listener, nil\\n}\",\n \"func (n *scalarNode) Execute(ctx context.Context) error {\\n\\tbounds := n.timespec.Bounds()\\n\\n\\tblock := block.NewScalar(n.op.val, bounds)\\n\\tif n.debug {\\n\\t\\t// Ignore any errors\\n\\t\\titer, _ := block.StepIter()\\n\\t\\tif iter != nil {\\n\\t\\t\\tlogging.WithContext(ctx).Info(\\\"scalar node\\\", zap.Any(\\\"meta\\\", iter.Meta()))\\n\\t\\t}\\n\\t}\\n\\n\\tif err := n.controller.Process(block); err != nil {\\n\\t\\tblock.Close()\\n\\t\\t// Fail on first error\\n\\t\\treturn err\\n\\t}\\n\\n\\tblock.Close()\\n\\treturn nil\\n}\",\n \"func (t *evidence_management) Invoke(stub shim.ChaincodeStubInterface) pb.Response {\\n\\tfunction, args := stub.GetFunctionAndParameters()\\n\\tfmt.Println(\\\"function is ==> :\\\" + function)\\n\\taction := args[0]\\n\\tfmt.Println(\\\" action is ==> :\\\" + action)\\n\\tfmt.Println(args)\\n\\n\\tif action == \\\"queryAsset\\\" {\\n\\t\\treturn t.queryAsset(stub, args)\\n\\t} else if action == \\\"queryAllAsset\\\" {\\n\\t\\treturn t.queryAllAsset(stub, args)\\n\\t} else if action == \\\"getHistoryForRecord\\\" {\\n\\t\\treturn t.getHistoryForRecord(stub, args)\\n\\t} else if action == \\\"createCase\\\" {\\n\\t\\treturn t.createCase(stub, args)\\n\\t} else if action == \\\"updateCase\\\" {\\n\\t\\treturn t.updateCase(stub, args)\\n\\t} else if action == \\\"updateCaseStatus\\\" {\\n\\t\\treturn t.updateCaseStatus(stub, args)\\n\\t} else if action == \\\"createFIR\\\" {\\n\\t\\treturn t.createFIR(stub, args)\\n\\t} else if action == \\\"createDoc\\\" {\\n\\t\\treturn t.createDoc(stub, args)\\n\\t} else if action == \\\"putPrivateData\\\" {\\n\\t\\treturn t.putPrivateData(stub, args)\\n\\t} else if action == \\\"getPrivateData\\\" {\\n\\t\\treturn t.getPrivateData(stub, args)\\n\\t} else if action == \\\"addAccused\\\" {\\n\\t\\treturn t.addAccused(stub, args)\\n\\t} else if action == \\\"addSuspect\\\" {\\n\\t\\treturn t.addSuspect(stub, args)\\n\\t} else if action == \\\"addVictim\\\" {\\n\\t\\treturn t.addVictim(stub, args)\\n\\t}\\n\\n\\tfmt.Println(\\\"invoke did not find func: \\\" + action) //error\\n\\n\\treturn shim.Error(\\\"Received unknown function\\\")\\n}\",\n \"func (_SimpleMultiSig *SimpleMultiSigSession) Execute(bucketIdx uint16, expireTime *big.Int, sigV []uint8, sigR [][32]byte, sigS [][32]byte, destination common.Address, value *big.Int, data []byte, executor common.Address, gasLimit *big.Int) (*types.Transaction, error) {\\n\\treturn _SimpleMultiSig.Contract.Execute(&_SimpleMultiSig.TransactOpts, bucketIdx, expireTime, sigV, sigR, sigS, destination, value, data, executor, gasLimit)\\n}\",\n \"func Execute(runnable RunnableFn) {\\n\\tdefer func() {\\n\\t\\tif err := recover(); err != nil {\\n\\t\\t\\tlog.Error(err)\\n\\t\\t}\\n\\t}()\\n\\n\\tif runnable != nil {\\n\\t\\trunnable()\\n\\t}\\n}\",\n \"func (sb *ServerChangeBean) Execute(stringArgs []string, env *map[string]interface{}) error{\\n\\tif len(stringArgs) != 7 {\\n\\t\\treturn fmt.Errorf(\\\"arguement error\\\")\\n\\t}\\n\\titerId, _ := strconv.Atoi(stringArgs[4])\\n\\tst, _ := strconv.Atoi(stringArgs[5])\\n\\tserverType := db.ServerType(st)\\n\\treturn sb.change(stringArgs[0], stringArgs[1], stringArgs[2], stringArgs[3], int64(iterId), serverType, env)\\n}\",\n \"func (cli *OpsGenieAlertV2Client) ExecuteCustomAction(req alertsv2.ExecuteCustomActionRequest) (*AsyncRequestResponse, error) {\\n\\treturn cli.sendAsyncPostRequest(&req)\\n}\",\n \"func Execute() {\\n\\tctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)\\n\\tdefer cancel()\\n\\n\\tcobra.OnInitialize(initLogging, initConfig, initSSHFromConfig)\\n\\n\\tif err := rootCommand().ExecuteContext(ctx); err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n}\",\n \"func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) {\\n\\tfmt.Println(\\\"run is running \\\" + function)\\n\\n\\t// Handle different functions\\n\\t// if function == \\\"init\\\" { //initialize the chaincode state\\n\\t// \\treturn t.Init(stub, args)\\n\\t// } else\\n\\tif function == \\\"submitTransaction\\\" { //create a transaction\\n\\t\\treturn t.submitTransaction(stub, args)\\n\\t} else if function == \\\"createFinancialInstitution\\\" { //create a new FinancialInst in ledger\\n\\t\\treturn t.createFinancialInstitution(stub, args)\\n\\t}\\n\\n\\tfmt.Println(\\\"run did not find func: \\\" + function) //error\\n\\n\\treturn nil, errors.New(\\\"Received unknown function invocation\\\")\\n}\",\n \"func (c *Command) Execute() {\\n\\targs := os.Args[1:]\\n\\tswitch argsLen := len(args); {\\n\\tcase argsLen == 1:\\n\\t\\tc.Run(args)\\n\\tdefault:\\n\\t\\tlog.Println(\\\"our service currently handle 1 command only\\\")\\n\\t}\\n}\",\n \"func Execute() {\\n\\tcmd := arrangeCommands()\\n\\n\\tif err := cmd.Execute(); err != nil {\\n\\t\\tlog.LogError(err)\\n\\t\\tos.Exit(1)\\n\\t}\\n}\",\n \"func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) {\\n if function == \\\"createAsset\\\" {\\n return t.createAsset(stub, args)\\n } else if function == \\\"updateAsset\\\" {\\n return t.updateAsset(stub, args)\\n } else if function == \\\"deleteAsset\\\" {\\n return t.deleteAsset(stub, args)\\n } else if function == \\\"deleteAllAssets\\\" {\\n return t.deleteAllAssets(stub, args)\\n } else if function == \\\"deletePropertiesFromAsset\\\" {\\n return t.deletePropertiesFromAsset(stub, args)\\n } else if function == \\\"setLoggingLevel\\\" {\\n return nil, t.setLoggingLevel(stub, args)\\n } else if function == \\\"setCreateOnUpdate\\\" {\\n return nil, t.setCreateOnUpdate(stub, args)\\n }\\n err := fmt.Errorf(\\\"Invoke received unknown invocation: %s\\\", function)\\n log.Warning(err)\\n return nil, err\\n}\",\n \"func Execute(client ioctl.Client,\\n\\tcmd *cobra.Command,\\n\\tcontract string,\\n\\tamount *big.Int,\\n\\tbytecode []byte,\\n\\tgasPrice, signer, password string,\\n\\tnonce, gasLimit uint64,\\n\\tassumeYes bool,\\n) error {\\n\\tif len(contract) == 0 && len(bytecode) == 0 {\\n\\t\\treturn errors.New(\\\"failed to deploy contract with empty bytecode\\\")\\n\\t}\\n\\tgasPriceRau, err := gasPriceInRau(client, gasPrice)\\n\\tif err != nil {\\n\\t\\treturn errors.Wrap(err, \\\"failed to get gas price\\\")\\n\\t}\\n\\tsender, err := Signer(client, signer)\\n\\tif err != nil {\\n\\t\\treturn errors.Wrap(err, \\\"failed to get signer address\\\")\\n\\t}\\n\\tnonce, err = checkNonce(client, nonce, sender)\\n\\tif err != nil {\\n\\t\\treturn errors.Wrap(err, \\\"failed to get nonce\\\")\\n\\t}\\n\\ttx, err := action.NewExecution(contract, nonce, amount, gasLimit, gasPriceRau, bytecode)\\n\\tif err != nil || tx == nil {\\n\\t\\treturn errors.Wrap(err, \\\"failed to make a Execution instance\\\")\\n\\t}\\n\\tif gasLimit == 0 {\\n\\t\\ttx, err = fixGasLimit(client, sender, tx)\\n\\t\\tif err != nil || tx == nil {\\n\\t\\t\\treturn errors.Wrap(err, \\\"failed to fix Execution gas limit\\\")\\n\\t\\t}\\n\\t\\tgasLimit = tx.GasLimit()\\n\\t}\\n\\treturn SendAction(\\n\\t\\tclient,\\n\\t\\tcmd,\\n\\t\\t(&action.EnvelopeBuilder{}).\\n\\t\\t\\tSetNonce(nonce).\\n\\t\\t\\tSetGasPrice(gasPriceRau).\\n\\t\\t\\tSetGasLimit(gasLimit).\\n\\t\\t\\tSetAction(tx).Build(),\\n\\t\\tsender,\\n\\t\\tpassword,\\n\\t\\tnonce,\\n\\t\\tassumeYes,\\n\\t)\\n}\"\n]"},"negative_scores":{"kind":"list like","value":["0.61757225","0.60558516","0.600172","0.594281","0.591137","0.58878464","0.5868138","0.5838943","0.5834418","0.5796378","0.57638127","0.569484","0.5669228","0.5649975","0.564762","0.5629406","0.5627392","0.56055653","0.5603532","0.55984074","0.5563326","0.55606407","0.5555603","0.5548418","0.5535985","0.553183","0.5523572","0.5517329","0.55156636","0.55133724","0.5511207","0.5510714","0.55082387","0.54857856","0.54826003","0.5474606","0.5474267","0.5469845","0.5464968","0.54635686","0.5463147","0.5455342","0.54509574","0.54505885","0.5435515","0.5435158","0.54202163","0.5416637","0.5412667","0.54078513","0.5407324","0.54051954","0.5402855","0.5401248","0.54000413","0.5397939","0.5393137","0.53803754","0.5380362","0.5373192","0.53716344","0.5359982","0.53577924","0.5350144","0.5345346","0.5343468","0.5341455","0.5335112","0.53207666","0.5316344","0.5292418","0.52886266","0.52874786","0.52856416","0.52820134","0.5277574","0.5274891","0.52729183","0.52664673","0.52635044","0.52630085","0.5259118","0.525069","0.52491015","0.52483374","0.5247853","0.52466536","0.5243585","0.5238571","0.52345806","0.5233941","0.5232364","0.5226131","0.52223474","0.5219134","0.5217894","0.5214131","0.52138543","0.5209799","0.52058154"],"string":"[\n \"0.61757225\",\n \"0.60558516\",\n \"0.600172\",\n \"0.594281\",\n \"0.591137\",\n \"0.58878464\",\n \"0.5868138\",\n \"0.5838943\",\n \"0.5834418\",\n \"0.5796378\",\n \"0.57638127\",\n \"0.569484\",\n \"0.5669228\",\n \"0.5649975\",\n \"0.564762\",\n \"0.5629406\",\n \"0.5627392\",\n \"0.56055653\",\n \"0.5603532\",\n \"0.55984074\",\n \"0.5563326\",\n \"0.55606407\",\n \"0.5555603\",\n \"0.5548418\",\n \"0.5535985\",\n \"0.553183\",\n \"0.5523572\",\n \"0.5517329\",\n \"0.55156636\",\n \"0.55133724\",\n \"0.5511207\",\n \"0.5510714\",\n \"0.55082387\",\n \"0.54857856\",\n \"0.54826003\",\n \"0.5474606\",\n \"0.5474267\",\n \"0.5469845\",\n \"0.5464968\",\n \"0.54635686\",\n \"0.5463147\",\n \"0.5455342\",\n \"0.54509574\",\n \"0.54505885\",\n \"0.5435515\",\n \"0.5435158\",\n \"0.54202163\",\n \"0.5416637\",\n \"0.5412667\",\n \"0.54078513\",\n \"0.5407324\",\n \"0.54051954\",\n \"0.5402855\",\n \"0.5401248\",\n \"0.54000413\",\n \"0.5397939\",\n \"0.5393137\",\n \"0.53803754\",\n \"0.5380362\",\n \"0.5373192\",\n \"0.53716344\",\n \"0.5359982\",\n \"0.53577924\",\n \"0.5350144\",\n \"0.5345346\",\n \"0.5343468\",\n \"0.5341455\",\n \"0.5335112\",\n \"0.53207666\",\n \"0.5316344\",\n \"0.5292418\",\n \"0.52886266\",\n \"0.52874786\",\n \"0.52856416\",\n \"0.52820134\",\n \"0.5277574\",\n \"0.5274891\",\n \"0.52729183\",\n \"0.52664673\",\n \"0.52635044\",\n \"0.52630085\",\n \"0.5259118\",\n \"0.525069\",\n \"0.52491015\",\n \"0.52483374\",\n \"0.5247853\",\n \"0.52466536\",\n \"0.5243585\",\n \"0.5238571\",\n \"0.52345806\",\n \"0.5233941\",\n \"0.5232364\",\n \"0.5226131\",\n \"0.52223474\",\n \"0.5219134\",\n \"0.5217894\",\n \"0.5214131\",\n \"0.52138543\",\n \"0.5209799\",\n \"0.52058154\"\n]"},"document_score":{"kind":"string","value":"0.7164371"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":105062,"cells":{"query":{"kind":"string","value":"FromBOM returns the charset declared in the BOM of content."},"document":{"kind":"string","value":"func FromBOM(content []byte) string {\n\tfor _, b := range boms {\n\t\tif bytes.HasPrefix(content, b.bom) {\n\t\t\treturn b.enc\n\t\t}\n\t}\n\treturn \"\"\n}"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["func (f *Font) GetCharset() string { return f.charset }","func (lf *localFile) ContentEncoding() string {\n\tif lf.matcher == nil {\n\t\treturn \"\"\n\t}\n\tif lf.matcher.Gzip {\n\t\treturn \"gzip\"\n\t}\n\treturn lf.matcher.ContentEncoding\n}","func BOMReader(ir io.Reader) io.Reader {\n\tr := bufio.NewReader(ir)\n\tb, err := r.Peek(3)\n\tif err != nil {\n\t\treturn r\n\t}\n\tif b[0] == bom0 && b[1] == bom1 && b[2] == bom2 {\n\t\tr.Discard(3)\n\t}\n\treturn r\n}","func (b *Blueprint) GetCharset() string {\n\treturn b.charset\n}","func (ctx *ProxyCtx) Charset() string {\n\tcharsets := charsetFinder.FindStringSubmatch(ctx.Resp.Header.Get(\"Content-Type\"))\n\tif charsets == nil {\n\t\treturn \"\"\n\t}\n\treturn charsets[1]\n}","func (ft *FieldType) GetCharset() string {\n\treturn ft.charset\n}","func (*XMLDocument) Charset() (charset string) {\n\tmacro.Rewrite(\"$_.charset\")\n\treturn charset\n}","func DetectCharset(body []byte, contentType string) (string, error) {\n\t// 1. Use charset.DetermineEncoding\n\t_, name, certain := charset.DetermineEncoding(body, contentType)\n\tif certain {\n\t\treturn name, nil\n\t}\n\n\t// Handle uncertain cases\n\t// 2. Use chardet.Detector.DetectBest\n\tr, err := chardet.NewHtmlDetector().DetectBest(body)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif r.Confidence == 100 {\n\t\treturn strings.ToLower(r.Charset), nil\n\t}\n\n\t// 3. Parse meta tag for Content-Type\n\troot, err := html.Parse(bytes.NewReader(body))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdoc := goquery.NewDocumentFromNode(root)\n\tvar csFromMeta string\n\tdoc.Find(\"meta\").EachWithBreak(func(i int, s *goquery.Selection) bool {\n\t\t// \n\t\tif c, exists := s.Attr(\"content\"); exists && strings.Contains(c, \"charset\") {\n\t\t\tif _, params, err := mime.ParseMediaType(c); err == nil {\n\t\t\t\tif cs, ok := params[\"charset\"]; ok {\n\t\t\t\t\tcsFromMeta = strings.ToLower(cs)\n\t\t\t\t\t// Handle Korean charsets.\n\t\t\t\t\tif csFromMeta == \"ms949\" || csFromMeta == \"cp949\" {\n\t\t\t\t\t\tcsFromMeta = \"euc-kr\"\n\t\t\t\t\t}\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\n\t\t// \n\t\tif c, exists := s.Attr(\"charset\"); exists {\n\t\t\tcsFromMeta = c\n\t\t\treturn false\n\t\t}\n\n\t\treturn true\n\t})\n\n\tif csFromMeta == \"\" {\n\t\treturn \"\", fmt.Errorf(\"failed to detect charset\")\n\t}\n\n\treturn csFromMeta, nil\n}","func ClearBOM(r io.Reader) io.Reader {\n\tbuf := bufio.NewReader(r)\n\tb, err := buf.Peek(3)\n\tif err != nil {\n\t\t// not enough bytes\n\t\treturn buf\n\t}\n\tif b[0] == 0xef && b[1] == 0xbb && b[2] == 0xbf {\n\t\tbuf.Discard(3)\n\t}\n\treturn buf\n}","func FileGuessEncoding(bytes []byte) string {\n\tstrQ := fmt.Sprintf(\"%+q\", bytes)\n\n\t// Clean double quote at the begining & at the end\n\tif strQ[0] == '\"' {\n\t\tstrQ = strQ[1:]\n\t}\n\n\tif strQ[len(strQ)-1] == '\"' {\n\t\tstrQ = strQ[0 : len(strQ)-1]\n\t}\n\n\t// If utf-8-bom, it must start with \\ufeff\n\tre := regexp.MustCompile(`^\\\\ufeff`)\n\n\tfound := re.MatchString(strQ)\n\tif found {\n\t\treturn \"utf-8bom\"\n\t}\n\n\t// If utf-8, it must contain \\uxxxx\n\tre = regexp.MustCompile(`\\\\u[a-z0-9]{4}`)\n\n\tfound = re.MatchString(strQ)\n\tif found {\n\t\treturn \"utf-8\"\n\t}\n\n\t// utf-32be\n\tre = regexp.MustCompile(`^\\\\x00\\\\x00\\\\xfe\\\\xff`)\n\n\tfound = re.MatchString(strQ)\n\tif found {\n\t\treturn \"utf-32be\"\n\t}\n\n\t// utf-32le\n\tre = regexp.MustCompile(`^\\\\xff\\\\xfe\\\\x00\\\\x00`)\n\n\tfound = re.MatchString(strQ)\n\tif found {\n\t\treturn \"utf-32le\"\n\t}\n\n\t// utf-16be\n\tre = regexp.MustCompile(`^\\\\xff\\\\xff`)\n\n\tfound = re.MatchString(strQ)\n\tif found {\n\t\treturn \"utf-16be\"\n\t}\n\n\t// utf-16le\n\tre = regexp.MustCompile(`^\\\\xff\\\\xfe`)\n\n\tfound = re.MatchString(strQ)\n\tif found {\n\t\treturn \"utf-16le\"\n\t}\n\n\t// Check if 0x8{0-F} or 0x9{0-F} is present\n\tre = regexp.MustCompile(`(\\\\x8[0-9a-f]{1}|\\\\x9[0-9a-f]{1})`)\n\n\tfound = re.MatchString(strQ)\n\tif found {\n\t\t// It might be windows-1252 or mac-roman\n\t\t// But at this moment, do not have mean to distinguish both. So fallback to windows-1252\n\t\treturn \"windows-1252\"\n\t}\n\n\t// No 0x8{0-F} or 0x9{0-F} found, it might be iso-8859-xx\n\t// We tried to detect whether it is iso-8859-1 or iso-8859-15\n\t// Check if 0x8{0-F} or 0x9{0-F} is present\n\t//re = regexp.MustCompile(`(\\\\xa[4|6|8]{1}|\\\\xb[4|8|c|d|e]{1})`)\n\n\t//loc := re.FindStringIndex(strQ)\n\t//if loc != nil {\n\t//c := strQ[loc[0]:loc[1]]\n\t//fmt.Printf(\"char %s\\n\", c)\n\t//if enc, err := BytesConvertToUTF8(bytes, \"iso-8859-15\"); err == nil {\n\t//fmt.Println(\"converted bytes\", enc)\n\t//fmt.Printf(\"converted %+q\\n\", enc)\n\t//}\n\n\t// At this moment, we can not detect the difference between iso-8859-x.\n\t// So just return a fallback iso-8859-1\n\treturn \"iso-8859-1\"\n}","func GetBOMByTKRName(ctx context.Context, c client.Client, tkrName string) (*bomtypes.Bom, error) {\n\tconfigMapList := &corev1.ConfigMapList{}\n\tvar bomConfigMap *corev1.ConfigMap\n\tif err := c.List(ctx, configMapList, client.InNamespace(constants.TKGBomNamespace), client.MatchingLabels{constants.TKRLabel: tkrName}); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif len(configMapList.Items) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tbomConfigMap = &configMapList.Items[0]\n\tbomData, ok := bomConfigMap.BinaryData[constants.TKGBomContent]\n\tif !ok {\n\t\tbomDataString, ok := bomConfigMap.Data[constants.TKGBomContent]\n\t\tif !ok {\n\t\t\treturn nil, nil\n\t\t}\n\t\tbomData = []byte(bomDataString)\n\t}\n\n\tbom, err := bomtypes.NewBom(bomData)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &bom, nil\n}","func findCharset(content string) string {\n\tif pos := strings.LastIndex(content, \"charset=\"); pos != -1 {\n\t\treturn content[pos+len(\"charset=\"):]\n\t}\n\treturn \"\"\n}","func (downloader *HTTPDownloader) changeCharsetEncodingAuto(contentTypeStr string, sor io.ReadCloser) string {\r\n\tvar err error\r\n\tdestReader, err := charset.NewReader(sor, contentTypeStr)\r\n\r\n\tif err != nil {\r\n\t\tmlog.LogInst().LogError(err.Error())\r\n\t\tdestReader = sor\r\n\t}\r\n\r\n\tvar sorbody []byte\r\n\tif sorbody, err = ioutil.ReadAll(destReader); err != nil {\r\n\t\tmlog.LogInst().LogError(err.Error())\r\n\t\t// For gb2312, an error will be returned.\r\n\t\t// Error like: simplifiedchinese: invalid GBK encoding\r\n\t\t// return \"\"\r\n\t}\r\n\t//e,name,certain := charset.DetermineEncoding(sorbody,contentTypeStr)\r\n\tbodystr := string(sorbody)\r\n\r\n\treturn bodystr\r\n}","func SkipBOM(r *bufio.Reader) *bufio.Reader {\n\trr, _, err := r.ReadRune()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif rr != '\\uFEFF' {\n\t\tr.UnreadRune() // Not a BOM -- put the rune back\n\t}\n\n\treturn r\n}","func (h *RequestHeader) ContentEncoding() []byte {\n\treturn peekArgBytes(h.h, strContentEncoding)\n}","func hasBom(in []byte) bool {\n\treturn bytes.HasPrefix(in, utf8bom)\n}","func DecodeAutoDetect(src []byte) (string, error) {\n\tfor _, enc := range encodings {\n\t\te, _ := charset.Lookup(enc)\n\t\tif e == nil {\n\t\t\tcontinue\n\t\t}\n\t\tvar buf bytes.Buffer\n\t\tr := transform.NewWriter(&buf, e.NewDecoder())\n\t\t_, err := r.Write(src)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\terr = r.Close()\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tf := buf.Bytes()\n\t\tif isInvalidRune(f) {\n\t\t\tcontinue\n\t\t}\n\t\tif utf8.Valid(f) {\n\t\t\tif hasBom(f) {\n\t\t\t\tf = stripBom(f)\n\t\t\t}\n\t\t\treturn string(f), nil\n\t\t}\n\t}\n\treturn string(src), errors.New(\"could not determine character code\")\n}","func (cs *CsvStructure) checkForConvertToUtf8(textBytes []byte) (outBytes []byte) {\n\tvar strByte []byte\n\tvar err error\n\toutBytes = make([]byte, len(textBytes))\n\tcopy(outBytes, textBytes)\n\t_, cs.Charset, _ = charset.DetermineEncoding(textBytes, \"\")\n\t// fmt.Println(cs.Charset)\n\tif cs.Charset != \"utf-8\" { // convert to UTF-8\n\t\tif reader, err := charset.NewReader(strings.NewReader(string(textBytes)), cs.Charset); err == nil {\n\t\t\tif strByte, err = ioutil.ReadAll(reader); err == nil {\n\t\t\t\toutBytes = make([]byte, len(strByte))\n\t\t\t\tcopy(outBytes, strByte)\n\t\t\t}\n\t\t}\n\t}\n\tif err != nil {\n\t\tfmt.Println(\"Error while trying to convert %s to utf-8: \", cs.Charset)\n\t}\n\treturn outBytes\n}","func DefaultCharsetForType(tp byte) (defaultCharset string, defaultCollation string) {\n\tswitch tp {\n\tcase mysql.TypeVarString, mysql.TypeString, mysql.TypeVarchar:\n\t\t// Default charset for string types is utf8mb4.\n\t\treturn mysql.DefaultCharset, mysql.DefaultCollationName\n\t}\n\treturn charset.CharsetBin, charset.CollationBin\n}","func (o *S3UploadOpts) GetContentEncoding() *string {\n\treturn getStrPtr(o.ContentEncoding)\n}","func (p *Parser) CharsetReader(c string, i io.Reader) (r io.Reader, e error) {\n\tswitch c {\n\tcase \"windows-1251\":\n\t\tr = decodeWin1251(i)\n\t}\n\treturn\n}","func (dr downloadResponse) ContentEncoding() string {\n\treturn dr.rawResponse.Header.Get(\"Content-Encoding\")\n}","func (bgpr BlobsGetPropertiesResponse) ContentEncoding() string {\n\treturn bgpr.rawResponse.Header.Get(\"Content-Encoding\")\n}","func (oie *ObjectInfoExtension) ContentEncoding() string {\n\treturn oie.ObjectInfo.Metadata.Get(\"Content-Encoding\")\n}","func (rpr ReadPathResponse) ContentEncoding() string {\n\treturn rpr.rawResponse.Header.Get(\"Content-Encoding\")\n}","func fromgb(in []byte) string {\n\tout := make([]byte, len(in)*4)\n\n\t_, _, err := iconv.Convert(in, out, \"gb2312\", \"utf-8\")\n\tcheck(err)\n\treturn strings.Trim(string(out), \" \\n\\r\\x00\")\n}","func ConvertToUTF8(source, charset string) (string, error) {\n\tswitch {\n\tcase strings.EqualFold(\"utf-8\", charset):\n\t\treturn source, nil\n\tcase strings.EqualFold(\"iso-8859-1\", charset):\n\t\treturn source, nil\n\tcase strings.EqualFold(\"us-ascii\", charset):\n\t\treturn source, nil\n\tdefault:\n\t\tenc, err := htmlindex.Get(charset)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tin := bytes.NewReader([]byte(source))\n\t\tout := transform.NewReader(in, enc.NewDecoder())\n\t\tresult, err := ioutil.ReadAll(out)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn string(result), nil\n\t}\n}","func (dr DownloadResponse) ContentEncoding() string {\n\treturn dr.dr.ContentEncoding()\n}","func (h *ResponseHeader) ContentEncoding() []byte {\n\treturn h.contentEncoding\n}","func correctEncodingToUtf8(text []byte) []byte {\n\tr, err := charset.NewReader(bytes.NewBuffer(text), \"application/xml\")\n\tif err != nil {\n\t\tfmt.Println(\"Error converting encoding:\", err)\n\t\treturn nil\n\t}\n\ttext, _ = ioutil.ReadAll(r)\n\treturn text\n}","func checkBomSkip(fileJob *FileJob) int {\n\t// UTF-8 BOM which if detected we should skip the BOM as we can then count correctly\n\t// []byte is UTF-8 BOM taken from https://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding\n\tif bytes.HasPrefix(fileJob.Content, []byte{239, 187, 191}) {\n\t\tif Verbose {\n\t\t\tprintWarn(fmt.Sprintf(\"UTF-8 BOM found for file %s skipping 3 bytes\", fileJob.Filename))\n\t\t}\n\t\treturn 3\n\t}\n\n\t// If we have one of the other BOM then we might not be able to count correctly so if verbose let the user know\n\tif Verbose {\n\t\tfor _, v := range ByteOrderMarks {\n\t\t\tif bytes.HasPrefix(fileJob.Content, v) {\n\t\t\t\tprintWarn(fmt.Sprintf(\"BOM found for file %s indicating it is not ASCII/UTF-8 and may be counted incorrectly or ignored as a binary file\", fileJob.Filename))\n\t\t\t}\n\t\t}\n\t}\n\n\treturn 0\n}","func (c *ColumnChunkMetaData) Encodings() []parquet.Encoding { return c.encodings }","func detectCharEncode(body []byte) CharEncode {\n\tdet := chardet.NewTextDetector()\n\tres, err := det.DetectBest(body)\n\tif err != nil {\n\t\treturn CharUnknown\n\t}\n\treturn typeOfCharEncode(res.Charset)\n}","func (this *SIPMessage) GetContentEncoding() header.ContentEncodingHeader {\n\treturn this.GetHeader(core.SIPHeaderNames_CONTENT_ENCODING).(header.ContentEncodingHeader)\n}","func GetUTF8Body(body []byte, contentType string,\n\tignoreInvalidUTF8Chars bool) (string, error) {\n\t// Detect charset.\n\tcs, err := DetectCharset(body, contentType)\n\tif err != nil {\n\t\tif !ignoreInvalidUTF8Chars {\n\t\t\treturn \"\", err\n\t\t}\n\t\tcs = \"utf-8\"\n\t}\n\n\t// Remove utf8.RuneError if ignoreInvalidUTF8Chars is true.\n\tbs := string(body)\n\tif ignoreInvalidUTF8Chars {\n\t\tif !utf8.ValidString(bs) {\n\t\t\tv := make([]rune, 0, len(bs))\n\t\t\tfor i, r := range bs {\n\t\t\t\tif r == utf8.RuneError {\n\t\t\t\t\t_, size := utf8.DecodeRuneInString(bs[i:])\n\t\t\t\t\tif size == 1 {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tv = append(v, r)\n\t\t\t}\n\t\t\tbs = string(v)\n\t\t}\n\t}\n\n\t// Convert body.\n\tconverted, err := iconv.ConvertString(bs, cs, \"utf-8\")\n\tif err != nil && !strings.Contains(converted, \"\") {\n\t\treturn \"\", err\n\t}\n\n\treturn converted, nil\n}","func CodepageDetect(r io.Reader) (IDCodePage, error) {\n\tif r == nil {\n\t\treturn ASCII, nil\n\t}\n\tbuf, err := bufio.NewReader(r).Peek(ReadBufSize)\n\tif (err != nil) && (err != io.EOF) {\n\t\treturn ASCII, err\n\t}\n\t//match code page from BOM, support: utf-8, utf-16le, utf-16be, utf-32le or utf-32be\n\tif idCodePage, ok := CheckBOM(buf); ok {\n\t\treturn idCodePage, nil\n\t}\n\tif ValidUTF8(buf) {\n\t\treturn UTF8, nil\n\t}\n\treturn CodepageAutoDetect(buf), nil\n}","func StringFromCharset(length int, charset string) (string, error) {\n\tresult := make([]byte, length) // Random string to return\n\tcharsetlen := big.NewInt(int64(len(charset)))\n\n\tfor i := 0; i < length; i++ {\n\t\tb, err := rand.Int(rand.Reader, charsetlen)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tr := int(b.Int64())\n\t\tresult[i] = charset[r]\n\t}\n\n\treturn string(result), nil\n}","func (e *HTTPResponseEvent) ContentEncoding() string {\n\treturn e.contentEncoding\n}","func DetectEncoding(b []byte) ([]byte, Encoding) {\n\tif !utf8.Valid(b) {\n\t\treturn b, UnknownEncoding\n\t}\n\n\ts := strings.TrimSpace(string(b))\n\n\ttyp := UnknownEncoding\n\n\tif _, err := ParseID(s); err == nil {\n\t\ttyp = IDEncoding\n\t} else if len(s) < 100 && (strings.HasPrefix(s, \"kex1\") || strings.HasPrefix(s, \"kbx1\")) {\n\t\ttyp = IDEncoding\n\t} else if strings.Contains(s, \"BEGIN \") && strings.Contains(s, \" MESSAGE\") {\n\t\ttyp = SaltpackEncoding\n\t} else if strings.HasPrefix(s, \"-----BEGIN \") {\n\t\ttyp = SSHEncoding\n\t} else if strings.HasPrefix(s, \"ssh-\") {\n\t\ttyp = SSHEncoding\n\t}\n\n\treturn []byte(s), typ\n\n}","func FromPlain(content []byte) string {\n\tif len(content) == 0 {\n\t\treturn \"\"\n\t}\n\tif cset := FromBOM(content); cset != \"\" {\n\t\treturn cset\n\t}\n\torigContent := content\n\t// Try to detect UTF-8.\n\t// First eliminate any partial rune at the end.\n\tfor i := len(content) - 1; i >= 0 && i > len(content)-4; i-- {\n\t\tb := content[i]\n\t\tif b < 0x80 {\n\t\t\tbreak\n\t\t}\n\t\tif utf8.RuneStart(b) {\n\t\t\tcontent = content[:i]\n\t\t\tbreak\n\t\t}\n\t}\n\thasHighBit := false\n\tfor _, c := range content {\n\t\tif c >= 0x80 {\n\t\t\thasHighBit = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif hasHighBit && utf8.Valid(content) {\n\t\treturn \"utf-8\"\n\t}\n\n\t// ASCII is a subset of UTF8. Follow W3C recommendation and replace with UTF8.\n\tif ascii(origContent) {\n\t\treturn \"utf-8\"\n\t}\n\n\treturn latin(origContent)\n}","func (*XMLDocument) InputEncoding() (inputEncoding string) {\n\tmacro.Rewrite(\"$_.inputEncoding\")\n\treturn inputEncoding\n}","func (UTF8Decoder) Name() string { return \"utf-8\" }","func Info(name string) *Charset {\n\tfor _, f := range factories {\n\t\tif info := f.Info(name); info != nil {\n\t\t\treturn info\n\t\t}\n\t}\n\treturn nil\n}","func (gppr GetPathPropertiesResponse) ContentEncoding() string {\n\treturn gppr.rawResponse.Header.Get(\"Content-Encoding\")\n}","func (upr UpdatePathResponse) ContentEncoding() string {\n\treturn upr.rawResponse.Header.Get(\"Content-Encoding\")\n}","func ISO8859_1toUTF8(in string) (out string, err error) {\n\t// create a Reader using the input string as Reader and ISO8859 decoder\n\tdecoded := transform.NewReader(strings.NewReader(in), charmap.ISO8859_1.NewDecoder())\n\tdecodedBytes, err := ioutil.ReadAll(decoded)\n\tif err != nil {\n\t\treturn\n\t}\n\tout = string(decodedBytes)\n\treturn\n}","func (r *RepositoryContent) GetEncoding() string {\n\tif r == nil || r.Encoding == nil {\n\t\treturn \"\"\n\t}\n\treturn *r.Encoding\n}","func HasCharset(ft *FieldType) bool {\n\tswitch ft.GetType() {\n\tcase mysql.TypeVarchar, mysql.TypeString, mysql.TypeVarString, mysql.TypeBlob,\n\t\tmysql.TypeTinyBlob, mysql.TypeMediumBlob, mysql.TypeLongBlob:\n\t\treturn !mysql.HasBinaryFlag(ft.flag)\n\tcase mysql.TypeEnum, mysql.TypeSet:\n\t\treturn true\n\t}\n\treturn false\n}","func UTF82GBK(src string) ([]byte, error) {\n\tGB18030 := simplifiedchinese.All[0]\n\treturn ioutil.ReadAll(transform.NewReader(bytes.NewReader([]byte(src)), GB18030.NewEncoder()))\n}","func (b *Blob) GetEncoding() string {\n\tif b == nil || b.Encoding == nil {\n\t\treturn \"\"\n\t}\n\treturn *b.Encoding\n}","func SystemCodePageToUtf8(text string) (s string, e error) {\r\n\te = ErrInvalidEncoding\r\n\tstr := C.CString(text)\r\n\tdefer C.free(unsafe.Pointer(str)) // #nosec\r\n\r\n\tif wcACPStr, err := mbToWide(C.CP_ACP, str); err == nil {\r\n\t\tif utf8Str, err := wideToMB(C.CP_UTF8, wcACPStr); err == nil {\r\n\t\t\ts, e = utf8Str, nil\r\n\t\t}\r\n\t}\r\n\r\n\treturn\r\n}","func convertCP(in string) (out string) {\n\tbuf := new(bytes.Buffer)\n\tw, err := charset.NewWriter(\"windows-1252\", buf)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Fprintf(w, in)\n\tw.Close()\n\n\tout = fmt.Sprintf(\"%s\", buf)\n\treturn out\n}","func NewReader(r io.Reader, cpn ...string) (io.Reader, error) {\n\tif r == nil {\n\t\treturn r, errInputIsNil\n\t}\n\ttmpReader := bufio.NewReader(r)\n\tvar err error\n\tcp := ASCII\n\tif len(cpn) > 0 {\n\t\tcp = codepageByName(cpn[0])\n\t}\n\tif cp == ASCII {\n\t\tcp, err = CodepageDetect(tmpReader)\n\t}\n\t//TODO внимательно нужно посмотреть что может вернуть CodepageDetect()\n\t//эти случаи обработать, например через func unsupportedCodepageToDecode(cp)\n\tswitch {\n\tcase (cp == UTF32) || (cp == UTF32BE) || (cp == UTF32LE):\n\t\treturn r, errUnsupportedCodepage\n\tcase cp == ASCII: // кодировку определить не удалось, неизвестную кодировку возвращаем как есть\n\t\treturn r, errUnknown\n\tcase err != nil: // и если ошибка при чтении, то возвращаем как есть\n\t\treturn r, err\n\t}\n\n\tif checkBomExist(tmpReader) {\n\t\t//ошибку не обрабатываем, если мы здесь, то эти байты мы уже читали\n\t\ttmpReader.Read(make([]byte, cp.BomLen())) // считываем в никуда количество байт занимаемых BOM этой кодировки\n\t}\n\tif cp == UTF8 {\n\t\treturn tmpReader, nil // когда удалили BOM тогда можно вернуть UTF-8, ведь его конвертировать не нужно\n\t}\n\t//ошибку не обрабатываем, htmlindex.Get() возвращает ошибку только если не найдена кодировка, здесь это уже невозможно\n\t//здесь cp может содержать только кодировки имеющиеся в htmlindex\n\te, _ := htmlindex.Get(cp.String())\n\tr = transform.NewReader(tmpReader, e.NewDecoder())\n\treturn r, nil\n}","func toUtf(input string) string {\n\tsr := strings.NewReader(input)\n\ttr := transform.NewReader(sr, charmap.Windows1251.NewDecoder())\n\tbuf, err := ioutil.ReadAll(tr)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\ts := string(buf)\n\n\treturn s\n}","func _escFSMustByte(useLocal bool, name string) []byte {\n\tb, err := _escFSByte(useLocal, name)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b\n}","func _escFSMustByte(useLocal bool, name string) []byte {\n\tb, err := _escFSByte(useLocal, name)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b\n}","func _escFSMustByte(useLocal bool, name string) []byte {\n\tb, err := _escFSByte(useLocal, name)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b\n}","func _escFSMustByte(useLocal bool, name string) []byte {\n\tb, err := _escFSByte(useLocal, name)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b\n}","func readUtf8(dis *bytes.Buffer) error {\n\n\treturn nil\n}","func (o CsvSerializationOutput) Encoding() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v CsvSerialization) *string { return v.Encoding }).(pulumi.StringPtrOutput)\n}","func (x *Message) getCodec() (encoding.Codec, error) {\n\tv, ok := x.Header[ContentType]\n\tif !ok || v == \"\" {\n\t\treturn encoding.GetCodec(encoding.ContentTypeJSON), nil\n\t}\n\tcts := strings.Split(v, \";\")\n\tct := strings.Split(cts[0], \"/\")\n\tc := ct[0] // in case of codec name\n\tif len(ct) == 2 {\n\t\tc = ct[1] // in case of full content type.\n\t}\n\tcodec := encoding.GetCodec(c)\n\tif codec == nil {\n\t\treturn nil, status.Unimplemented(\"unregistered codec for content-type: %s\", x.GetContentType())\n\t}\n\treturn codec, nil\n}","func (this *Tidy) CharEncoding(val int) (bool, error) {\n\tswitch val {\n\tcase Raw, Ascii, Latin0, Latin1, Utf8, Iso2022, Mac, Win1252, Ibm858, Utf16le, Utf16be, Utf16, Big5, Shiftjis:\n\t\treturn this.optSetInt(C.TidyCharEncoding, (C.ulong)(val))\n\t}\n\treturn false, errors.New(\"Argument val int is out of range (0-13)\")\n}","func Utf8ToSystemCodePage(text string) (s string, e error) {\r\n\te = ErrInvalidEncoding\r\n\tstr := C.CString(text)\r\n\tdefer C.free(unsafe.Pointer(str)) // #nosec\r\n\r\n\tif wcACPStr, err := mbToWide(C.CP_UTF8, str); err == nil {\r\n\t\tif utf8Str, err := wideToMB(C.CP_ACP, wcACPStr); err == nil {\r\n\t\t\ts, e = utf8Str, nil\r\n\t\t}\r\n\t}\r\n\r\n\treturn\r\n}","func readModUTF8(b []byte) rune {\n\tvar res rune\n\tc := b[0] >> 4\n\tif len(b) == 1 {\n\t\tres = rune(c >> 4)\n\t} else if len(b) == 2 {\n\t\tres = rune(((c & 0x1F) << 6) | (b[1] & 0x3F))\n\t} else if len(b) == 3 {\n\t\tfmt.Println(\"case3\")\n\t\t//var j uint16 = ((c & 0x0f) << 12)\n\t\tres = rune(((c & 0x0F) << 12) |\n\t\t\t((b[1] & 0x3F) << 6) |\n\t\t\t((b[2] & 0x3F) << 0))\n\t}\n\treturn res\n}","func (o *Metadata) GetEncoding() string {\n\tif o == nil || o.Encoding == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Encoding\n}","func ContentEncoding(value string) Option {\n\treturn setHeader(\"Content-Encoding\", value)\n}","func decodeMUTF8(bytearr []byte) string {\n\tutflen := len(bytearr)\n\tchararr := make([]uint16, utflen)\n\n\tvar c, char2, char3 uint16\n\tcount := 0\n\tchararr_count := 0\n\n\tfor count < utflen {\n\t\tc = uint16(bytearr[count])\n\t\tif c > 127 {\n\t\t\tbreak\n\t\t}\n\t\tcount++\n\t\tchararr[chararr_count] = c\n\t\tchararr_count++\n\t}\n\n\tfor count < utflen {\n\t\tc = uint16(bytearr[count])\n\t\tswitch c >> 4 {\n\t\tcase 0, 1, 2, 3, 4, 5, 6, 7:\n\t\t\t/* 0xxxxxxx*/\n\t\t\tcount++\n\t\t\tchararr[chararr_count] = c\n\t\t\tchararr_count++\n\t\tcase 12, 13:\n\t\t\t/* 110x xxxx 10xx xxxx*/\n\t\t\tcount += 2\n\t\t\tif count > utflen {\n\t\t\t\tpanic(\"malformed input: partial character at end\")\n\t\t\t}\n\t\t\tchar2 = uint16(bytearr[count-1])\n\t\t\tif char2&0xC0 != 0x80 {\n\t\t\t\tpanic(fmt.Errorf(\"malformed input around byte %v\", count))\n\t\t\t}\n\t\t\tchararr[chararr_count] = c&0x1F<<6 | char2&0x3F\n\t\t\tchararr_count++\n\t\tcase 14:\n\t\t\t/* 1110 xxxx 10xx xxxx 10xx xxxx*/\n\t\t\tcount += 3\n\t\t\tif count > utflen {\n\t\t\t\tpanic(\"malformed input: partial character at end\")\n\t\t\t}\n\t\t\tchar2 = uint16(bytearr[count-2])\n\t\t\tchar3 = uint16(bytearr[count-1])\n\t\t\tif char2&0xC0 != 0x80 || char3&0xC0 != 0x80 {\n\t\t\t\tpanic(fmt.Errorf(\"malformed input around byte %v\", (count - 1)))\n\t\t\t}\n\t\t\tchararr[chararr_count] = c&0x0F<<12 | char2&0x3F<<6 | char3&0x3F<<0\n\t\t\tchararr_count++\n\t\tdefault:\n\t\t\t/* 10xx xxxx, 1111 xxxx */\n\t\t\tpanic(fmt.Errorf(\"malformed input around byte %v\", count))\n\t\t}\n\t}\n\t// The number of chars produced may be less than utflen\n\tchararr = chararr[0:chararr_count]\n\trunes := utf16.Decode(chararr)\n\treturn string(runes)\n}","func correctEncodingField(text []byte) []byte {\n\tbuf := bytes.NewBuffer(make([]byte, 0, len(text)))\n\n\tfor i := 0; i < len(text); i++ {\n\t\tbuf.WriteByte(text[i])\n\n\t\t// If found an encoding field.\n\t\tif text[i] == '=' && i >= 8 && string(text[i-8:i+1]) == \"encoding=\" {\n\t\t\tbuf.WriteString(\"\\\"utf-8\\\"\")\n\n\t\t\t// Advance to after end of field.\n\t\t\ti += 2\n\t\t\tfor text[i] != '\"' {\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\t}\n\n\treturn buf.Bytes()\n}","func (dw *DrawingWand) GetTextEncoding() string {\n\tcstr := C.MagickDrawGetTextEncoding(dw.dw)\n\tdefer C.MagickRelinquishMemory(unsafe.Pointer(cstr))\n\treturn C.GoString(cstr)\n}","func (f MLFindFileStructure) WithCharset(v string) func(*MLFindFileStructureRequest) {\n\treturn func(r *MLFindFileStructureRequest) {\n\t\tr.Charset = v\n\t}\n}","func (o *VolumeLanguageAttributesType) OemCharacterSet() string {\n\tvar r string\n\tif o.OemCharacterSetPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.OemCharacterSetPtr\n\treturn r\n}","func _escFSByte(useLocal bool, name string) ([]byte, error) {\n\tif useLocal {\n\t\tf, err := _escLocal.Open(name)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tb, err := ioutil.ReadAll(f)\n\t\tf.Close()\n\t\treturn b, err\n\t}\n\tf, err := _escStatic.prepare(name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn f.data, nil\n}","func Bech32Decode(bech string) (string, []byte, error) {\n\tfor _, c := range bech {\n\t\tif c < 33 || c > 126 {\n\t\t\treturn \"\", nil, merry.Errorf(\"bech decode: character '%c' not in charset\", c)\n\t\t}\n\t}\n\tbech = strings.ToLower(bech)\n\tpos := strings.LastIndex(bech, \"1\")\n\tif pos < 1 || pos+7 > len(bech) || len(bech) > 90 {\n\t\treturn \"\", nil, merry.Errorf(\"bech decode: invalid hrp end index %d\", pos)\n\t}\n\thrp := bech[:pos]\n\tdataStr := bech[pos+1:]\n\tdata := make([]byte, len(dataStr))\n\tfor i, c := range dataStr {\n\t\tvar ok bool\n\t\tdata[i], ok = CHARSET_MAP[c]\n\t\tif !ok {\n\t\t\treturn \"\", nil, merry.Errorf(\"bech decode: character '%c' not in charset\", c)\n\t\t}\n\t}\n\tif !bech32VerifyChecksum(hrp, data) {\n\t\treturn \"\", nil, merry.Errorf(\"bech decode: checksum mismatch\")\n\t}\n\treturn hrp, data[:len(data)-6], nil\n}","func GbToUtf8(s []byte, encoding string) ([]byte, error) {\n\tvar t transform.Transformer\n\tswitch encoding {\n\tcase \"gbk\":\n\t\tt = simplifiedchinese.GBK.NewDecoder()\n\tcase \"gb18030\":\n\t\tt = simplifiedchinese.GB18030.NewDecoder()\n\t}\n\treader := transform.NewReader(bytes.NewReader(s), t)\n\td, e := ioutil.ReadAll(reader)\n\tif e != nil {\n\t\treturn nil, e\n\t}\n\treturn d, nil\n}","func _escFSByte(useLocal bool, name string) ([]byte, error) {\n\tif useLocal {\n\t\tf, err := _escLocal.Open(name)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tb, err := ioutil.ReadAll(f)\n\t\t_ = f.Close()\n\t\treturn b, err\n\t}\n\tf, err := _escStatic.prepare(name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn f.data, nil\n}","func _escFSByte(useLocal bool, name string) ([]byte, error) {\n\tif useLocal {\n\t\tf, err := _escLocal.Open(name)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tb, err := ioutil.ReadAll(f)\n\t\t_ = f.Close()\n\t\treturn b, err\n\t}\n\tf, err := _escStatic.prepare(name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn f.data, nil\n}","func _escFSByte(useLocal bool, name string) ([]byte, error) {\n\tif useLocal {\n\t\tf, err := _escLocal.Open(name)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tb, err := ioutil.ReadAll(f)\n\t\t_ = f.Close()\n\t\treturn b, err\n\t}\n\tf, err := _escStatic.prepare(name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn f.data, nil\n}","func (a *App) ProcessUTF16be(ctx context.Context, r io.Reader, name, archive string) error {\n\tr = transform.NewReader(r, unicode.UTF16(unicode.BigEndian, unicode.UseBOM).NewDecoder())\n\treturn a.ProcessUTF8(ctx, r, name, archive)\n}","func (r *Response) ContentEncoding(encoding ...string) *Response {\n\topChain := r.chain.enter(\"ContentEncoding()\")\n\tdefer opChain.leave()\n\n\tif opChain.failed() {\n\t\treturn r\n\t}\n\n\tr.checkEqual(opChain, `\"Content-Encoding\" header`,\n\t\tencoding,\n\t\tr.httpResp.Header[\"Content-Encoding\"])\n\n\treturn r\n}","func (m *Gzip) GetContentType() []string {\n\tif m != nil {\n\t\treturn m.ContentType\n\t}\n\treturn nil\n}","func DumpBomAsText(bm *BomMeta, b *Bom, out io.Writer) {\n\tfmt.Fprintln(out)\n\tfmt.Fprintf(out, \"Name:\\t\\t%s\\n\", bm.Name)\n\tfmt.Fprintf(out, \"Version:\\t%s\\n\", b.Version)\n\tfmt.Fprintf(out, \"Creator:\\t%s\\n\", bm.Owner)\n\tfmt.Fprintf(out, \"Timestamp:\\t%s\\n\", b.Created)\n\tif bm.Homepage != \"\" {\n\t\tfmt.Fprintf(out, \"Homepage:\\t%s\\n\", bm.Homepage)\n\t}\n\tif b.Progeny != \"\" {\n\t\tfmt.Fprintf(out, \"Source:\\t\\t%s\\n\", b.Progeny)\n\t}\n\tif bm.Description != \"\" {\n\t\tfmt.Fprintf(out, \"Description:\\t%s\\n\", bm.Description)\n\t}\n\tfmt.Println()\n\ttabWriter := tabwriter.NewWriter(out, 2, 4, 1, ' ', 0)\n\t// \"by line item\", not \"by element\"\n\tfmt.Fprintf(tabWriter, \"qty\\ttag\\tmanufacturer\\tmpn\\t\\tfunction\\t\\tcomment\\n\")\n\tfor _, li := range b.LineItems {\n\t\tfmt.Fprintf(tabWriter, \"%d\\t%s\\t%s\\t%s\\t\\t%s\\t\\t%s\\n\",\n\t\t\tlen(li.Elements),\n\t\t\tli.Tag,\n\t\t\tli.Manufacturer,\n\t\t\tli.Mpn,\n\t\t\tli.Description,\n\t\t\tli.Comment)\n\t}\n\ttabWriter.Flush()\n}","func (o TableExternalDataConfigurationCsvOptionsPtrOutput) Encoding() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *TableExternalDataConfigurationCsvOptions) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Encoding\n\t}).(pulumi.StringPtrOutput)\n}","func (sct *ContentSniffer) ContentType() (string, bool) {\n\tif sct.sniffed {\n\t\treturn sct.ctype, sct.ctype != \"\"\n\t}\n\tsct.sniffed = true\n\t// If ReadAll hits EOF, it returns err==nil.\n\tsct.start, sct.err = ioutil.ReadAll(io.LimitReader(sct.r, sniffBuffSize))\n\n\t// Don't try to detect the content type based on possibly incomplete data.\n\tif sct.err != nil {\n\t\treturn \"\", false\n\t}\n\n\tsct.ctype = http.DetectContentType(sct.start)\n\treturn sct.ctype, true\n}","func ContentTransferEncoding(encoding encoding.ContentTransferType) (string, string) {\n\treturn \"Content-Transfer-Encoding\", string(encoding)\n}","func (this *Tidy) OutputBom(val int) (bool, error) {\n\treturn this.optSetAutoBool(C.TidyOutputBOM, (C.ulong)(val))\n}","func (ft *FieldType) SetCharset(charset string) {\n\tft.charset = charset\n}","func GetTKRNameFromBOMConfigMap(bomConfigMap *corev1.ConfigMap) string {\n\treturn bomConfigMap.Labels[constants.TKRLabel]\n}","func (ft *FieldType) GetCollate() string {\n\treturn ft.collate\n}","func (h *RequestHeader) ContentType() []byte {\n\tif h.disableSpecialHeader {\n\t\treturn peekArgBytes(h.h, []byte(HeaderContentType))\n\t}\n\treturn h.contentType\n}","func (e CharacterEncoding) String() string {\n\tswitch e {\n\tcase EncodingASCII:\n\t\treturn \"ASCII\"\n\tcase EncodingUTF8:\n\t\treturn \"UTF-8\"\n\tcase EncodingUnknown:\n\t\tfallthrough\n\tdefault:\n\t\treturn \"unknown\"\n\t}\n}","func WithCharset(nli int) CharsetOption {\n\treturn CharsetOption{nli}\n}","func getCiliumVersionString(epCHeaderFilePath string) ([]byte, error) {\n\tf, err := os.Open(epCHeaderFilePath)\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\tbr := bufio.NewReader(f)\n\tdefer f.Close()\n\tfor {\n\t\tb, err := br.ReadBytes('\\n')\n\t\tif errors.Is(err, io.EOF) {\n\t\t\treturn []byte{}, nil\n\t\t}\n\t\tif err != nil {\n\t\t\treturn []byte{}, err\n\t\t}\n\t\tif bytes.Contains(b, []byte(ciliumCHeaderPrefix)) {\n\t\t\treturn b, nil\n\t\t}\n\t}\n}","func (o TableExternalDataConfigurationCsvOptionsOutput) Encoding() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v TableExternalDataConfigurationCsvOptions) *string { return v.Encoding }).(pulumi.StringPtrOutput)\n}","func FileConvertToUTF8(file io.Reader, charset string) (io.Reader, error) {\n\tencoding, err := getEncoding(charset)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn encoding.NewDecoder().Reader(file), nil\n}","func (h *ResponseHeader) ContentType() []byte {\n\tcontentType := h.contentType\n\tif !h.noDefaultContentType && len(h.contentType) == 0 {\n\t\tcontentType = defaultContentType\n\t}\n\treturn contentType\n}","func getCE(meth string, ce string) string {\n\tif !(meth == \"POST\" || meth == \"PATCH\" || meth == \"PUT\") {\n\t\treturn \"\"\n\t}\n\t_, ce = split(strings.ToLower(ce), \";\")\n\t_, ce = split(ce, \"charset=\")\n\tce, _ = split(ce, \";\")\n\treturn ce\n}","func (d Decoder) WithCharset(set charset.Decoder) Decoder {\n\td.set = set\n\treturn d\n}","func (j *Env) GetUTF8String() *ObjectRef {\n\tif utf8 == nil {\n\t\tstr, err := j.NewObject(\"java/lang/String\", []byte(\"UTF-8\"))\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tglobal := j.NewGlobalRef(str)\n\t\tj.DeleteLocalRef(str)\n\t\tutf8 = global\n\t}\n\n\treturn utf8\n}","func GetEncoding(r *http.Request, offers []string) (string, error) {\n\tacceptEncoding := r.Header[AcceptEncodingHeaderKey]\n\n\tif len(acceptEncoding) == 0 {\n\t\treturn \"\", ErrResponseNotCompressed\n\t}\n\n\tencoding := negotiateAcceptHeader(acceptEncoding, offers, IDENTITY)\n\tif encoding == \"\" {\n\t\treturn \"\", fmt.Errorf(\"%w: %s\", ErrNotSupportedCompression, encoding)\n\t}\n\n\treturn encoding, nil\n}","func Reader(charset string, input io.Reader) (io.Reader, error) {\n\tcharset = strings.ToLower(charset)\n\t// \"ascii\" is not in the spec but is common\n\tif charset == \"utf-8\" || charset == \"us-ascii\" || charset == \"ascii\" {\n\t\treturn input, nil\n\t}\n\tif enc, ok := charsets[charset]; ok {\n\t\treturn enc.NewDecoder().Reader(input), nil\n\t}\n\treturn nil, fmt.Errorf(\"unhandled charset %q\", charset)\n}"],"string":"[\n \"func (f *Font) GetCharset() string { return f.charset }\",\n \"func (lf *localFile) ContentEncoding() string {\\n\\tif lf.matcher == nil {\\n\\t\\treturn \\\"\\\"\\n\\t}\\n\\tif lf.matcher.Gzip {\\n\\t\\treturn \\\"gzip\\\"\\n\\t}\\n\\treturn lf.matcher.ContentEncoding\\n}\",\n \"func BOMReader(ir io.Reader) io.Reader {\\n\\tr := bufio.NewReader(ir)\\n\\tb, err := r.Peek(3)\\n\\tif err != nil {\\n\\t\\treturn r\\n\\t}\\n\\tif b[0] == bom0 && b[1] == bom1 && b[2] == bom2 {\\n\\t\\tr.Discard(3)\\n\\t}\\n\\treturn r\\n}\",\n \"func (b *Blueprint) GetCharset() string {\\n\\treturn b.charset\\n}\",\n \"func (ctx *ProxyCtx) Charset() string {\\n\\tcharsets := charsetFinder.FindStringSubmatch(ctx.Resp.Header.Get(\\\"Content-Type\\\"))\\n\\tif charsets == nil {\\n\\t\\treturn \\\"\\\"\\n\\t}\\n\\treturn charsets[1]\\n}\",\n \"func (ft *FieldType) GetCharset() string {\\n\\treturn ft.charset\\n}\",\n \"func (*XMLDocument) Charset() (charset string) {\\n\\tmacro.Rewrite(\\\"$_.charset\\\")\\n\\treturn charset\\n}\",\n \"func DetectCharset(body []byte, contentType string) (string, error) {\\n\\t// 1. Use charset.DetermineEncoding\\n\\t_, name, certain := charset.DetermineEncoding(body, contentType)\\n\\tif certain {\\n\\t\\treturn name, nil\\n\\t}\\n\\n\\t// Handle uncertain cases\\n\\t// 2. Use chardet.Detector.DetectBest\\n\\tr, err := chardet.NewHtmlDetector().DetectBest(body)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\tif r.Confidence == 100 {\\n\\t\\treturn strings.ToLower(r.Charset), nil\\n\\t}\\n\\n\\t// 3. Parse meta tag for Content-Type\\n\\troot, err := html.Parse(bytes.NewReader(body))\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\tdoc := goquery.NewDocumentFromNode(root)\\n\\tvar csFromMeta string\\n\\tdoc.Find(\\\"meta\\\").EachWithBreak(func(i int, s *goquery.Selection) bool {\\n\\t\\t// \\n\\t\\tif c, exists := s.Attr(\\\"content\\\"); exists && strings.Contains(c, \\\"charset\\\") {\\n\\t\\t\\tif _, params, err := mime.ParseMediaType(c); err == nil {\\n\\t\\t\\t\\tif cs, ok := params[\\\"charset\\\"]; ok {\\n\\t\\t\\t\\t\\tcsFromMeta = strings.ToLower(cs)\\n\\t\\t\\t\\t\\t// Handle Korean charsets.\\n\\t\\t\\t\\t\\tif csFromMeta == \\\"ms949\\\" || csFromMeta == \\\"cp949\\\" {\\n\\t\\t\\t\\t\\t\\tcsFromMeta = \\\"euc-kr\\\"\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\treturn false\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\treturn true\\n\\t\\t}\\n\\n\\t\\t// \\n\\t\\tif c, exists := s.Attr(\\\"charset\\\"); exists {\\n\\t\\t\\tcsFromMeta = c\\n\\t\\t\\treturn false\\n\\t\\t}\\n\\n\\t\\treturn true\\n\\t})\\n\\n\\tif csFromMeta == \\\"\\\" {\\n\\t\\treturn \\\"\\\", fmt.Errorf(\\\"failed to detect charset\\\")\\n\\t}\\n\\n\\treturn csFromMeta, nil\\n}\",\n \"func ClearBOM(r io.Reader) io.Reader {\\n\\tbuf := bufio.NewReader(r)\\n\\tb, err := buf.Peek(3)\\n\\tif err != nil {\\n\\t\\t// not enough bytes\\n\\t\\treturn buf\\n\\t}\\n\\tif b[0] == 0xef && b[1] == 0xbb && b[2] == 0xbf {\\n\\t\\tbuf.Discard(3)\\n\\t}\\n\\treturn buf\\n}\",\n \"func FileGuessEncoding(bytes []byte) string {\\n\\tstrQ := fmt.Sprintf(\\\"%+q\\\", bytes)\\n\\n\\t// Clean double quote at the begining & at the end\\n\\tif strQ[0] == '\\\"' {\\n\\t\\tstrQ = strQ[1:]\\n\\t}\\n\\n\\tif strQ[len(strQ)-1] == '\\\"' {\\n\\t\\tstrQ = strQ[0 : len(strQ)-1]\\n\\t}\\n\\n\\t// If utf-8-bom, it must start with \\\\ufeff\\n\\tre := regexp.MustCompile(`^\\\\\\\\ufeff`)\\n\\n\\tfound := re.MatchString(strQ)\\n\\tif found {\\n\\t\\treturn \\\"utf-8bom\\\"\\n\\t}\\n\\n\\t// If utf-8, it must contain \\\\uxxxx\\n\\tre = regexp.MustCompile(`\\\\\\\\u[a-z0-9]{4}`)\\n\\n\\tfound = re.MatchString(strQ)\\n\\tif found {\\n\\t\\treturn \\\"utf-8\\\"\\n\\t}\\n\\n\\t// utf-32be\\n\\tre = regexp.MustCompile(`^\\\\\\\\x00\\\\\\\\x00\\\\\\\\xfe\\\\\\\\xff`)\\n\\n\\tfound = re.MatchString(strQ)\\n\\tif found {\\n\\t\\treturn \\\"utf-32be\\\"\\n\\t}\\n\\n\\t// utf-32le\\n\\tre = regexp.MustCompile(`^\\\\\\\\xff\\\\\\\\xfe\\\\\\\\x00\\\\\\\\x00`)\\n\\n\\tfound = re.MatchString(strQ)\\n\\tif found {\\n\\t\\treturn \\\"utf-32le\\\"\\n\\t}\\n\\n\\t// utf-16be\\n\\tre = regexp.MustCompile(`^\\\\\\\\xff\\\\\\\\xff`)\\n\\n\\tfound = re.MatchString(strQ)\\n\\tif found {\\n\\t\\treturn \\\"utf-16be\\\"\\n\\t}\\n\\n\\t// utf-16le\\n\\tre = regexp.MustCompile(`^\\\\\\\\xff\\\\\\\\xfe`)\\n\\n\\tfound = re.MatchString(strQ)\\n\\tif found {\\n\\t\\treturn \\\"utf-16le\\\"\\n\\t}\\n\\n\\t// Check if 0x8{0-F} or 0x9{0-F} is present\\n\\tre = regexp.MustCompile(`(\\\\\\\\x8[0-9a-f]{1}|\\\\\\\\x9[0-9a-f]{1})`)\\n\\n\\tfound = re.MatchString(strQ)\\n\\tif found {\\n\\t\\t// It might be windows-1252 or mac-roman\\n\\t\\t// But at this moment, do not have mean to distinguish both. So fallback to windows-1252\\n\\t\\treturn \\\"windows-1252\\\"\\n\\t}\\n\\n\\t// No 0x8{0-F} or 0x9{0-F} found, it might be iso-8859-xx\\n\\t// We tried to detect whether it is iso-8859-1 or iso-8859-15\\n\\t// Check if 0x8{0-F} or 0x9{0-F} is present\\n\\t//re = regexp.MustCompile(`(\\\\\\\\xa[4|6|8]{1}|\\\\\\\\xb[4|8|c|d|e]{1})`)\\n\\n\\t//loc := re.FindStringIndex(strQ)\\n\\t//if loc != nil {\\n\\t//c := strQ[loc[0]:loc[1]]\\n\\t//fmt.Printf(\\\"char %s\\\\n\\\", c)\\n\\t//if enc, err := BytesConvertToUTF8(bytes, \\\"iso-8859-15\\\"); err == nil {\\n\\t//fmt.Println(\\\"converted bytes\\\", enc)\\n\\t//fmt.Printf(\\\"converted %+q\\\\n\\\", enc)\\n\\t//}\\n\\n\\t// At this moment, we can not detect the difference between iso-8859-x.\\n\\t// So just return a fallback iso-8859-1\\n\\treturn \\\"iso-8859-1\\\"\\n}\",\n \"func GetBOMByTKRName(ctx context.Context, c client.Client, tkrName string) (*bomtypes.Bom, error) {\\n\\tconfigMapList := &corev1.ConfigMapList{}\\n\\tvar bomConfigMap *corev1.ConfigMap\\n\\tif err := c.List(ctx, configMapList, client.InNamespace(constants.TKGBomNamespace), client.MatchingLabels{constants.TKRLabel: tkrName}); err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tif len(configMapList.Items) == 0 {\\n\\t\\treturn nil, nil\\n\\t}\\n\\n\\tbomConfigMap = &configMapList.Items[0]\\n\\tbomData, ok := bomConfigMap.BinaryData[constants.TKGBomContent]\\n\\tif !ok {\\n\\t\\tbomDataString, ok := bomConfigMap.Data[constants.TKGBomContent]\\n\\t\\tif !ok {\\n\\t\\t\\treturn nil, nil\\n\\t\\t}\\n\\t\\tbomData = []byte(bomDataString)\\n\\t}\\n\\n\\tbom, err := bomtypes.NewBom(bomData)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\treturn &bom, nil\\n}\",\n \"func findCharset(content string) string {\\n\\tif pos := strings.LastIndex(content, \\\"charset=\\\"); pos != -1 {\\n\\t\\treturn content[pos+len(\\\"charset=\\\"):]\\n\\t}\\n\\treturn \\\"\\\"\\n}\",\n \"func (downloader *HTTPDownloader) changeCharsetEncodingAuto(contentTypeStr string, sor io.ReadCloser) string {\\r\\n\\tvar err error\\r\\n\\tdestReader, err := charset.NewReader(sor, contentTypeStr)\\r\\n\\r\\n\\tif err != nil {\\r\\n\\t\\tmlog.LogInst().LogError(err.Error())\\r\\n\\t\\tdestReader = sor\\r\\n\\t}\\r\\n\\r\\n\\tvar sorbody []byte\\r\\n\\tif sorbody, err = ioutil.ReadAll(destReader); err != nil {\\r\\n\\t\\tmlog.LogInst().LogError(err.Error())\\r\\n\\t\\t// For gb2312, an error will be returned.\\r\\n\\t\\t// Error like: simplifiedchinese: invalid GBK encoding\\r\\n\\t\\t// return \\\"\\\"\\r\\n\\t}\\r\\n\\t//e,name,certain := charset.DetermineEncoding(sorbody,contentTypeStr)\\r\\n\\tbodystr := string(sorbody)\\r\\n\\r\\n\\treturn bodystr\\r\\n}\",\n \"func SkipBOM(r *bufio.Reader) *bufio.Reader {\\n\\trr, _, err := r.ReadRune()\\n\\tif err != nil {\\n\\t\\tpanic(err)\\n\\t}\\n\\tif rr != '\\\\uFEFF' {\\n\\t\\tr.UnreadRune() // Not a BOM -- put the rune back\\n\\t}\\n\\n\\treturn r\\n}\",\n \"func (h *RequestHeader) ContentEncoding() []byte {\\n\\treturn peekArgBytes(h.h, strContentEncoding)\\n}\",\n \"func hasBom(in []byte) bool {\\n\\treturn bytes.HasPrefix(in, utf8bom)\\n}\",\n \"func DecodeAutoDetect(src []byte) (string, error) {\\n\\tfor _, enc := range encodings {\\n\\t\\te, _ := charset.Lookup(enc)\\n\\t\\tif e == nil {\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\t\\tvar buf bytes.Buffer\\n\\t\\tr := transform.NewWriter(&buf, e.NewDecoder())\\n\\t\\t_, err := r.Write(src)\\n\\t\\tif err != nil {\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\t\\terr = r.Close()\\n\\t\\tif err != nil {\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\t\\tf := buf.Bytes()\\n\\t\\tif isInvalidRune(f) {\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\t\\tif utf8.Valid(f) {\\n\\t\\t\\tif hasBom(f) {\\n\\t\\t\\t\\tf = stripBom(f)\\n\\t\\t\\t}\\n\\t\\t\\treturn string(f), nil\\n\\t\\t}\\n\\t}\\n\\treturn string(src), errors.New(\\\"could not determine character code\\\")\\n}\",\n \"func (cs *CsvStructure) checkForConvertToUtf8(textBytes []byte) (outBytes []byte) {\\n\\tvar strByte []byte\\n\\tvar err error\\n\\toutBytes = make([]byte, len(textBytes))\\n\\tcopy(outBytes, textBytes)\\n\\t_, cs.Charset, _ = charset.DetermineEncoding(textBytes, \\\"\\\")\\n\\t// fmt.Println(cs.Charset)\\n\\tif cs.Charset != \\\"utf-8\\\" { // convert to UTF-8\\n\\t\\tif reader, err := charset.NewReader(strings.NewReader(string(textBytes)), cs.Charset); err == nil {\\n\\t\\t\\tif strByte, err = ioutil.ReadAll(reader); err == nil {\\n\\t\\t\\t\\toutBytes = make([]byte, len(strByte))\\n\\t\\t\\t\\tcopy(outBytes, strByte)\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\tif err != nil {\\n\\t\\tfmt.Println(\\\"Error while trying to convert %s to utf-8: \\\", cs.Charset)\\n\\t}\\n\\treturn outBytes\\n}\",\n \"func DefaultCharsetForType(tp byte) (defaultCharset string, defaultCollation string) {\\n\\tswitch tp {\\n\\tcase mysql.TypeVarString, mysql.TypeString, mysql.TypeVarchar:\\n\\t\\t// Default charset for string types is utf8mb4.\\n\\t\\treturn mysql.DefaultCharset, mysql.DefaultCollationName\\n\\t}\\n\\treturn charset.CharsetBin, charset.CollationBin\\n}\",\n \"func (o *S3UploadOpts) GetContentEncoding() *string {\\n\\treturn getStrPtr(o.ContentEncoding)\\n}\",\n \"func (p *Parser) CharsetReader(c string, i io.Reader) (r io.Reader, e error) {\\n\\tswitch c {\\n\\tcase \\\"windows-1251\\\":\\n\\t\\tr = decodeWin1251(i)\\n\\t}\\n\\treturn\\n}\",\n \"func (dr downloadResponse) ContentEncoding() string {\\n\\treturn dr.rawResponse.Header.Get(\\\"Content-Encoding\\\")\\n}\",\n \"func (bgpr BlobsGetPropertiesResponse) ContentEncoding() string {\\n\\treturn bgpr.rawResponse.Header.Get(\\\"Content-Encoding\\\")\\n}\",\n \"func (oie *ObjectInfoExtension) ContentEncoding() string {\\n\\treturn oie.ObjectInfo.Metadata.Get(\\\"Content-Encoding\\\")\\n}\",\n \"func (rpr ReadPathResponse) ContentEncoding() string {\\n\\treturn rpr.rawResponse.Header.Get(\\\"Content-Encoding\\\")\\n}\",\n \"func fromgb(in []byte) string {\\n\\tout := make([]byte, len(in)*4)\\n\\n\\t_, _, err := iconv.Convert(in, out, \\\"gb2312\\\", \\\"utf-8\\\")\\n\\tcheck(err)\\n\\treturn strings.Trim(string(out), \\\" \\\\n\\\\r\\\\x00\\\")\\n}\",\n \"func ConvertToUTF8(source, charset string) (string, error) {\\n\\tswitch {\\n\\tcase strings.EqualFold(\\\"utf-8\\\", charset):\\n\\t\\treturn source, nil\\n\\tcase strings.EqualFold(\\\"iso-8859-1\\\", charset):\\n\\t\\treturn source, nil\\n\\tcase strings.EqualFold(\\\"us-ascii\\\", charset):\\n\\t\\treturn source, nil\\n\\tdefault:\\n\\t\\tenc, err := htmlindex.Get(charset)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn \\\"\\\", err\\n\\t\\t}\\n\\t\\tin := bytes.NewReader([]byte(source))\\n\\t\\tout := transform.NewReader(in, enc.NewDecoder())\\n\\t\\tresult, err := ioutil.ReadAll(out)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn \\\"\\\", err\\n\\t\\t}\\n\\t\\treturn string(result), nil\\n\\t}\\n}\",\n \"func (dr DownloadResponse) ContentEncoding() string {\\n\\treturn dr.dr.ContentEncoding()\\n}\",\n \"func (h *ResponseHeader) ContentEncoding() []byte {\\n\\treturn h.contentEncoding\\n}\",\n \"func correctEncodingToUtf8(text []byte) []byte {\\n\\tr, err := charset.NewReader(bytes.NewBuffer(text), \\\"application/xml\\\")\\n\\tif err != nil {\\n\\t\\tfmt.Println(\\\"Error converting encoding:\\\", err)\\n\\t\\treturn nil\\n\\t}\\n\\ttext, _ = ioutil.ReadAll(r)\\n\\treturn text\\n}\",\n \"func checkBomSkip(fileJob *FileJob) int {\\n\\t// UTF-8 BOM which if detected we should skip the BOM as we can then count correctly\\n\\t// []byte is UTF-8 BOM taken from https://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding\\n\\tif bytes.HasPrefix(fileJob.Content, []byte{239, 187, 191}) {\\n\\t\\tif Verbose {\\n\\t\\t\\tprintWarn(fmt.Sprintf(\\\"UTF-8 BOM found for file %s skipping 3 bytes\\\", fileJob.Filename))\\n\\t\\t}\\n\\t\\treturn 3\\n\\t}\\n\\n\\t// If we have one of the other BOM then we might not be able to count correctly so if verbose let the user know\\n\\tif Verbose {\\n\\t\\tfor _, v := range ByteOrderMarks {\\n\\t\\t\\tif bytes.HasPrefix(fileJob.Content, v) {\\n\\t\\t\\t\\tprintWarn(fmt.Sprintf(\\\"BOM found for file %s indicating it is not ASCII/UTF-8 and may be counted incorrectly or ignored as a binary file\\\", fileJob.Filename))\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\treturn 0\\n}\",\n \"func (c *ColumnChunkMetaData) Encodings() []parquet.Encoding { return c.encodings }\",\n \"func detectCharEncode(body []byte) CharEncode {\\n\\tdet := chardet.NewTextDetector()\\n\\tres, err := det.DetectBest(body)\\n\\tif err != nil {\\n\\t\\treturn CharUnknown\\n\\t}\\n\\treturn typeOfCharEncode(res.Charset)\\n}\",\n \"func (this *SIPMessage) GetContentEncoding() header.ContentEncodingHeader {\\n\\treturn this.GetHeader(core.SIPHeaderNames_CONTENT_ENCODING).(header.ContentEncodingHeader)\\n}\",\n \"func GetUTF8Body(body []byte, contentType string,\\n\\tignoreInvalidUTF8Chars bool) (string, error) {\\n\\t// Detect charset.\\n\\tcs, err := DetectCharset(body, contentType)\\n\\tif err != nil {\\n\\t\\tif !ignoreInvalidUTF8Chars {\\n\\t\\t\\treturn \\\"\\\", err\\n\\t\\t}\\n\\t\\tcs = \\\"utf-8\\\"\\n\\t}\\n\\n\\t// Remove utf8.RuneError if ignoreInvalidUTF8Chars is true.\\n\\tbs := string(body)\\n\\tif ignoreInvalidUTF8Chars {\\n\\t\\tif !utf8.ValidString(bs) {\\n\\t\\t\\tv := make([]rune, 0, len(bs))\\n\\t\\t\\tfor i, r := range bs {\\n\\t\\t\\t\\tif r == utf8.RuneError {\\n\\t\\t\\t\\t\\t_, size := utf8.DecodeRuneInString(bs[i:])\\n\\t\\t\\t\\t\\tif size == 1 {\\n\\t\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tv = append(v, r)\\n\\t\\t\\t}\\n\\t\\t\\tbs = string(v)\\n\\t\\t}\\n\\t}\\n\\n\\t// Convert body.\\n\\tconverted, err := iconv.ConvertString(bs, cs, \\\"utf-8\\\")\\n\\tif err != nil && !strings.Contains(converted, \\\"\\\") {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\treturn converted, nil\\n}\",\n \"func CodepageDetect(r io.Reader) (IDCodePage, error) {\\n\\tif r == nil {\\n\\t\\treturn ASCII, nil\\n\\t}\\n\\tbuf, err := bufio.NewReader(r).Peek(ReadBufSize)\\n\\tif (err != nil) && (err != io.EOF) {\\n\\t\\treturn ASCII, err\\n\\t}\\n\\t//match code page from BOM, support: utf-8, utf-16le, utf-16be, utf-32le or utf-32be\\n\\tif idCodePage, ok := CheckBOM(buf); ok {\\n\\t\\treturn idCodePage, nil\\n\\t}\\n\\tif ValidUTF8(buf) {\\n\\t\\treturn UTF8, nil\\n\\t}\\n\\treturn CodepageAutoDetect(buf), nil\\n}\",\n \"func StringFromCharset(length int, charset string) (string, error) {\\n\\tresult := make([]byte, length) // Random string to return\\n\\tcharsetlen := big.NewInt(int64(len(charset)))\\n\\n\\tfor i := 0; i < length; i++ {\\n\\t\\tb, err := rand.Int(rand.Reader, charsetlen)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn \\\"\\\", err\\n\\t\\t}\\n\\t\\tr := int(b.Int64())\\n\\t\\tresult[i] = charset[r]\\n\\t}\\n\\n\\treturn string(result), nil\\n}\",\n \"func (e *HTTPResponseEvent) ContentEncoding() string {\\n\\treturn e.contentEncoding\\n}\",\n \"func DetectEncoding(b []byte) ([]byte, Encoding) {\\n\\tif !utf8.Valid(b) {\\n\\t\\treturn b, UnknownEncoding\\n\\t}\\n\\n\\ts := strings.TrimSpace(string(b))\\n\\n\\ttyp := UnknownEncoding\\n\\n\\tif _, err := ParseID(s); err == nil {\\n\\t\\ttyp = IDEncoding\\n\\t} else if len(s) < 100 && (strings.HasPrefix(s, \\\"kex1\\\") || strings.HasPrefix(s, \\\"kbx1\\\")) {\\n\\t\\ttyp = IDEncoding\\n\\t} else if strings.Contains(s, \\\"BEGIN \\\") && strings.Contains(s, \\\" MESSAGE\\\") {\\n\\t\\ttyp = SaltpackEncoding\\n\\t} else if strings.HasPrefix(s, \\\"-----BEGIN \\\") {\\n\\t\\ttyp = SSHEncoding\\n\\t} else if strings.HasPrefix(s, \\\"ssh-\\\") {\\n\\t\\ttyp = SSHEncoding\\n\\t}\\n\\n\\treturn []byte(s), typ\\n\\n}\",\n \"func FromPlain(content []byte) string {\\n\\tif len(content) == 0 {\\n\\t\\treturn \\\"\\\"\\n\\t}\\n\\tif cset := FromBOM(content); cset != \\\"\\\" {\\n\\t\\treturn cset\\n\\t}\\n\\torigContent := content\\n\\t// Try to detect UTF-8.\\n\\t// First eliminate any partial rune at the end.\\n\\tfor i := len(content) - 1; i >= 0 && i > len(content)-4; i-- {\\n\\t\\tb := content[i]\\n\\t\\tif b < 0x80 {\\n\\t\\t\\tbreak\\n\\t\\t}\\n\\t\\tif utf8.RuneStart(b) {\\n\\t\\t\\tcontent = content[:i]\\n\\t\\t\\tbreak\\n\\t\\t}\\n\\t}\\n\\thasHighBit := false\\n\\tfor _, c := range content {\\n\\t\\tif c >= 0x80 {\\n\\t\\t\\thasHighBit = true\\n\\t\\t\\tbreak\\n\\t\\t}\\n\\t}\\n\\tif hasHighBit && utf8.Valid(content) {\\n\\t\\treturn \\\"utf-8\\\"\\n\\t}\\n\\n\\t// ASCII is a subset of UTF8. Follow W3C recommendation and replace with UTF8.\\n\\tif ascii(origContent) {\\n\\t\\treturn \\\"utf-8\\\"\\n\\t}\\n\\n\\treturn latin(origContent)\\n}\",\n \"func (*XMLDocument) InputEncoding() (inputEncoding string) {\\n\\tmacro.Rewrite(\\\"$_.inputEncoding\\\")\\n\\treturn inputEncoding\\n}\",\n \"func (UTF8Decoder) Name() string { return \\\"utf-8\\\" }\",\n \"func Info(name string) *Charset {\\n\\tfor _, f := range factories {\\n\\t\\tif info := f.Info(name); info != nil {\\n\\t\\t\\treturn info\\n\\t\\t}\\n\\t}\\n\\treturn nil\\n}\",\n \"func (gppr GetPathPropertiesResponse) ContentEncoding() string {\\n\\treturn gppr.rawResponse.Header.Get(\\\"Content-Encoding\\\")\\n}\",\n \"func (upr UpdatePathResponse) ContentEncoding() string {\\n\\treturn upr.rawResponse.Header.Get(\\\"Content-Encoding\\\")\\n}\",\n \"func ISO8859_1toUTF8(in string) (out string, err error) {\\n\\t// create a Reader using the input string as Reader and ISO8859 decoder\\n\\tdecoded := transform.NewReader(strings.NewReader(in), charmap.ISO8859_1.NewDecoder())\\n\\tdecodedBytes, err := ioutil.ReadAll(decoded)\\n\\tif err != nil {\\n\\t\\treturn\\n\\t}\\n\\tout = string(decodedBytes)\\n\\treturn\\n}\",\n \"func (r *RepositoryContent) GetEncoding() string {\\n\\tif r == nil || r.Encoding == nil {\\n\\t\\treturn \\\"\\\"\\n\\t}\\n\\treturn *r.Encoding\\n}\",\n \"func HasCharset(ft *FieldType) bool {\\n\\tswitch ft.GetType() {\\n\\tcase mysql.TypeVarchar, mysql.TypeString, mysql.TypeVarString, mysql.TypeBlob,\\n\\t\\tmysql.TypeTinyBlob, mysql.TypeMediumBlob, mysql.TypeLongBlob:\\n\\t\\treturn !mysql.HasBinaryFlag(ft.flag)\\n\\tcase mysql.TypeEnum, mysql.TypeSet:\\n\\t\\treturn true\\n\\t}\\n\\treturn false\\n}\",\n \"func UTF82GBK(src string) ([]byte, error) {\\n\\tGB18030 := simplifiedchinese.All[0]\\n\\treturn ioutil.ReadAll(transform.NewReader(bytes.NewReader([]byte(src)), GB18030.NewEncoder()))\\n}\",\n \"func (b *Blob) GetEncoding() string {\\n\\tif b == nil || b.Encoding == nil {\\n\\t\\treturn \\\"\\\"\\n\\t}\\n\\treturn *b.Encoding\\n}\",\n \"func SystemCodePageToUtf8(text string) (s string, e error) {\\r\\n\\te = ErrInvalidEncoding\\r\\n\\tstr := C.CString(text)\\r\\n\\tdefer C.free(unsafe.Pointer(str)) // #nosec\\r\\n\\r\\n\\tif wcACPStr, err := mbToWide(C.CP_ACP, str); err == nil {\\r\\n\\t\\tif utf8Str, err := wideToMB(C.CP_UTF8, wcACPStr); err == nil {\\r\\n\\t\\t\\ts, e = utf8Str, nil\\r\\n\\t\\t}\\r\\n\\t}\\r\\n\\r\\n\\treturn\\r\\n}\",\n \"func convertCP(in string) (out string) {\\n\\tbuf := new(bytes.Buffer)\\n\\tw, err := charset.NewWriter(\\\"windows-1252\\\", buf)\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n\\tfmt.Fprintf(w, in)\\n\\tw.Close()\\n\\n\\tout = fmt.Sprintf(\\\"%s\\\", buf)\\n\\treturn out\\n}\",\n \"func NewReader(r io.Reader, cpn ...string) (io.Reader, error) {\\n\\tif r == nil {\\n\\t\\treturn r, errInputIsNil\\n\\t}\\n\\ttmpReader := bufio.NewReader(r)\\n\\tvar err error\\n\\tcp := ASCII\\n\\tif len(cpn) > 0 {\\n\\t\\tcp = codepageByName(cpn[0])\\n\\t}\\n\\tif cp == ASCII {\\n\\t\\tcp, err = CodepageDetect(tmpReader)\\n\\t}\\n\\t//TODO внимательно нужно посмотреть что может вернуть CodepageDetect()\\n\\t//эти случаи обработать, например через func unsupportedCodepageToDecode(cp)\\n\\tswitch {\\n\\tcase (cp == UTF32) || (cp == UTF32BE) || (cp == UTF32LE):\\n\\t\\treturn r, errUnsupportedCodepage\\n\\tcase cp == ASCII: // кодировку определить не удалось, неизвестную кодировку возвращаем как есть\\n\\t\\treturn r, errUnknown\\n\\tcase err != nil: // и если ошибка при чтении, то возвращаем как есть\\n\\t\\treturn r, err\\n\\t}\\n\\n\\tif checkBomExist(tmpReader) {\\n\\t\\t//ошибку не обрабатываем, если мы здесь, то эти байты мы уже читали\\n\\t\\ttmpReader.Read(make([]byte, cp.BomLen())) // считываем в никуда количество байт занимаемых BOM этой кодировки\\n\\t}\\n\\tif cp == UTF8 {\\n\\t\\treturn tmpReader, nil // когда удалили BOM тогда можно вернуть UTF-8, ведь его конвертировать не нужно\\n\\t}\\n\\t//ошибку не обрабатываем, htmlindex.Get() возвращает ошибку только если не найдена кодировка, здесь это уже невозможно\\n\\t//здесь cp может содержать только кодировки имеющиеся в htmlindex\\n\\te, _ := htmlindex.Get(cp.String())\\n\\tr = transform.NewReader(tmpReader, e.NewDecoder())\\n\\treturn r, nil\\n}\",\n \"func toUtf(input string) string {\\n\\tsr := strings.NewReader(input)\\n\\ttr := transform.NewReader(sr, charmap.Windows1251.NewDecoder())\\n\\tbuf, err := ioutil.ReadAll(tr)\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n\\n\\ts := string(buf)\\n\\n\\treturn s\\n}\",\n \"func _escFSMustByte(useLocal bool, name string) []byte {\\n\\tb, err := _escFSByte(useLocal, name)\\n\\tif err != nil {\\n\\t\\tpanic(err)\\n\\t}\\n\\treturn b\\n}\",\n \"func _escFSMustByte(useLocal bool, name string) []byte {\\n\\tb, err := _escFSByte(useLocal, name)\\n\\tif err != nil {\\n\\t\\tpanic(err)\\n\\t}\\n\\treturn b\\n}\",\n \"func _escFSMustByte(useLocal bool, name string) []byte {\\n\\tb, err := _escFSByte(useLocal, name)\\n\\tif err != nil {\\n\\t\\tpanic(err)\\n\\t}\\n\\treturn b\\n}\",\n \"func _escFSMustByte(useLocal bool, name string) []byte {\\n\\tb, err := _escFSByte(useLocal, name)\\n\\tif err != nil {\\n\\t\\tpanic(err)\\n\\t}\\n\\treturn b\\n}\",\n \"func readUtf8(dis *bytes.Buffer) error {\\n\\n\\treturn nil\\n}\",\n \"func (o CsvSerializationOutput) Encoding() pulumi.StringPtrOutput {\\n\\treturn o.ApplyT(func(v CsvSerialization) *string { return v.Encoding }).(pulumi.StringPtrOutput)\\n}\",\n \"func (x *Message) getCodec() (encoding.Codec, error) {\\n\\tv, ok := x.Header[ContentType]\\n\\tif !ok || v == \\\"\\\" {\\n\\t\\treturn encoding.GetCodec(encoding.ContentTypeJSON), nil\\n\\t}\\n\\tcts := strings.Split(v, \\\";\\\")\\n\\tct := strings.Split(cts[0], \\\"/\\\")\\n\\tc := ct[0] // in case of codec name\\n\\tif len(ct) == 2 {\\n\\t\\tc = ct[1] // in case of full content type.\\n\\t}\\n\\tcodec := encoding.GetCodec(c)\\n\\tif codec == nil {\\n\\t\\treturn nil, status.Unimplemented(\\\"unregistered codec for content-type: %s\\\", x.GetContentType())\\n\\t}\\n\\treturn codec, nil\\n}\",\n \"func (this *Tidy) CharEncoding(val int) (bool, error) {\\n\\tswitch val {\\n\\tcase Raw, Ascii, Latin0, Latin1, Utf8, Iso2022, Mac, Win1252, Ibm858, Utf16le, Utf16be, Utf16, Big5, Shiftjis:\\n\\t\\treturn this.optSetInt(C.TidyCharEncoding, (C.ulong)(val))\\n\\t}\\n\\treturn false, errors.New(\\\"Argument val int is out of range (0-13)\\\")\\n}\",\n \"func Utf8ToSystemCodePage(text string) (s string, e error) {\\r\\n\\te = ErrInvalidEncoding\\r\\n\\tstr := C.CString(text)\\r\\n\\tdefer C.free(unsafe.Pointer(str)) // #nosec\\r\\n\\r\\n\\tif wcACPStr, err := mbToWide(C.CP_UTF8, str); err == nil {\\r\\n\\t\\tif utf8Str, err := wideToMB(C.CP_ACP, wcACPStr); err == nil {\\r\\n\\t\\t\\ts, e = utf8Str, nil\\r\\n\\t\\t}\\r\\n\\t}\\r\\n\\r\\n\\treturn\\r\\n}\",\n \"func readModUTF8(b []byte) rune {\\n\\tvar res rune\\n\\tc := b[0] >> 4\\n\\tif len(b) == 1 {\\n\\t\\tres = rune(c >> 4)\\n\\t} else if len(b) == 2 {\\n\\t\\tres = rune(((c & 0x1F) << 6) | (b[1] & 0x3F))\\n\\t} else if len(b) == 3 {\\n\\t\\tfmt.Println(\\\"case3\\\")\\n\\t\\t//var j uint16 = ((c & 0x0f) << 12)\\n\\t\\tres = rune(((c & 0x0F) << 12) |\\n\\t\\t\\t((b[1] & 0x3F) << 6) |\\n\\t\\t\\t((b[2] & 0x3F) << 0))\\n\\t}\\n\\treturn res\\n}\",\n \"func (o *Metadata) GetEncoding() string {\\n\\tif o == nil || o.Encoding == nil {\\n\\t\\tvar ret string\\n\\t\\treturn ret\\n\\t}\\n\\treturn *o.Encoding\\n}\",\n \"func ContentEncoding(value string) Option {\\n\\treturn setHeader(\\\"Content-Encoding\\\", value)\\n}\",\n \"func decodeMUTF8(bytearr []byte) string {\\n\\tutflen := len(bytearr)\\n\\tchararr := make([]uint16, utflen)\\n\\n\\tvar c, char2, char3 uint16\\n\\tcount := 0\\n\\tchararr_count := 0\\n\\n\\tfor count < utflen {\\n\\t\\tc = uint16(bytearr[count])\\n\\t\\tif c > 127 {\\n\\t\\t\\tbreak\\n\\t\\t}\\n\\t\\tcount++\\n\\t\\tchararr[chararr_count] = c\\n\\t\\tchararr_count++\\n\\t}\\n\\n\\tfor count < utflen {\\n\\t\\tc = uint16(bytearr[count])\\n\\t\\tswitch c >> 4 {\\n\\t\\tcase 0, 1, 2, 3, 4, 5, 6, 7:\\n\\t\\t\\t/* 0xxxxxxx*/\\n\\t\\t\\tcount++\\n\\t\\t\\tchararr[chararr_count] = c\\n\\t\\t\\tchararr_count++\\n\\t\\tcase 12, 13:\\n\\t\\t\\t/* 110x xxxx 10xx xxxx*/\\n\\t\\t\\tcount += 2\\n\\t\\t\\tif count > utflen {\\n\\t\\t\\t\\tpanic(\\\"malformed input: partial character at end\\\")\\n\\t\\t\\t}\\n\\t\\t\\tchar2 = uint16(bytearr[count-1])\\n\\t\\t\\tif char2&0xC0 != 0x80 {\\n\\t\\t\\t\\tpanic(fmt.Errorf(\\\"malformed input around byte %v\\\", count))\\n\\t\\t\\t}\\n\\t\\t\\tchararr[chararr_count] = c&0x1F<<6 | char2&0x3F\\n\\t\\t\\tchararr_count++\\n\\t\\tcase 14:\\n\\t\\t\\t/* 1110 xxxx 10xx xxxx 10xx xxxx*/\\n\\t\\t\\tcount += 3\\n\\t\\t\\tif count > utflen {\\n\\t\\t\\t\\tpanic(\\\"malformed input: partial character at end\\\")\\n\\t\\t\\t}\\n\\t\\t\\tchar2 = uint16(bytearr[count-2])\\n\\t\\t\\tchar3 = uint16(bytearr[count-1])\\n\\t\\t\\tif char2&0xC0 != 0x80 || char3&0xC0 != 0x80 {\\n\\t\\t\\t\\tpanic(fmt.Errorf(\\\"malformed input around byte %v\\\", (count - 1)))\\n\\t\\t\\t}\\n\\t\\t\\tchararr[chararr_count] = c&0x0F<<12 | char2&0x3F<<6 | char3&0x3F<<0\\n\\t\\t\\tchararr_count++\\n\\t\\tdefault:\\n\\t\\t\\t/* 10xx xxxx, 1111 xxxx */\\n\\t\\t\\tpanic(fmt.Errorf(\\\"malformed input around byte %v\\\", count))\\n\\t\\t}\\n\\t}\\n\\t// The number of chars produced may be less than utflen\\n\\tchararr = chararr[0:chararr_count]\\n\\trunes := utf16.Decode(chararr)\\n\\treturn string(runes)\\n}\",\n \"func correctEncodingField(text []byte) []byte {\\n\\tbuf := bytes.NewBuffer(make([]byte, 0, len(text)))\\n\\n\\tfor i := 0; i < len(text); i++ {\\n\\t\\tbuf.WriteByte(text[i])\\n\\n\\t\\t// If found an encoding field.\\n\\t\\tif text[i] == '=' && i >= 8 && string(text[i-8:i+1]) == \\\"encoding=\\\" {\\n\\t\\t\\tbuf.WriteString(\\\"\\\\\\\"utf-8\\\\\\\"\\\")\\n\\n\\t\\t\\t// Advance to after end of field.\\n\\t\\t\\ti += 2\\n\\t\\t\\tfor text[i] != '\\\"' {\\n\\t\\t\\t\\ti++\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\treturn buf.Bytes()\\n}\",\n \"func (dw *DrawingWand) GetTextEncoding() string {\\n\\tcstr := C.MagickDrawGetTextEncoding(dw.dw)\\n\\tdefer C.MagickRelinquishMemory(unsafe.Pointer(cstr))\\n\\treturn C.GoString(cstr)\\n}\",\n \"func (f MLFindFileStructure) WithCharset(v string) func(*MLFindFileStructureRequest) {\\n\\treturn func(r *MLFindFileStructureRequest) {\\n\\t\\tr.Charset = v\\n\\t}\\n}\",\n \"func (o *VolumeLanguageAttributesType) OemCharacterSet() string {\\n\\tvar r string\\n\\tif o.OemCharacterSetPtr == nil {\\n\\t\\treturn r\\n\\t}\\n\\tr = *o.OemCharacterSetPtr\\n\\treturn r\\n}\",\n \"func _escFSByte(useLocal bool, name string) ([]byte, error) {\\n\\tif useLocal {\\n\\t\\tf, err := _escLocal.Open(name)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t\\tb, err := ioutil.ReadAll(f)\\n\\t\\tf.Close()\\n\\t\\treturn b, err\\n\\t}\\n\\tf, err := _escStatic.prepare(name)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn f.data, nil\\n}\",\n \"func Bech32Decode(bech string) (string, []byte, error) {\\n\\tfor _, c := range bech {\\n\\t\\tif c < 33 || c > 126 {\\n\\t\\t\\treturn \\\"\\\", nil, merry.Errorf(\\\"bech decode: character '%c' not in charset\\\", c)\\n\\t\\t}\\n\\t}\\n\\tbech = strings.ToLower(bech)\\n\\tpos := strings.LastIndex(bech, \\\"1\\\")\\n\\tif pos < 1 || pos+7 > len(bech) || len(bech) > 90 {\\n\\t\\treturn \\\"\\\", nil, merry.Errorf(\\\"bech decode: invalid hrp end index %d\\\", pos)\\n\\t}\\n\\thrp := bech[:pos]\\n\\tdataStr := bech[pos+1:]\\n\\tdata := make([]byte, len(dataStr))\\n\\tfor i, c := range dataStr {\\n\\t\\tvar ok bool\\n\\t\\tdata[i], ok = CHARSET_MAP[c]\\n\\t\\tif !ok {\\n\\t\\t\\treturn \\\"\\\", nil, merry.Errorf(\\\"bech decode: character '%c' not in charset\\\", c)\\n\\t\\t}\\n\\t}\\n\\tif !bech32VerifyChecksum(hrp, data) {\\n\\t\\treturn \\\"\\\", nil, merry.Errorf(\\\"bech decode: checksum mismatch\\\")\\n\\t}\\n\\treturn hrp, data[:len(data)-6], nil\\n}\",\n \"func GbToUtf8(s []byte, encoding string) ([]byte, error) {\\n\\tvar t transform.Transformer\\n\\tswitch encoding {\\n\\tcase \\\"gbk\\\":\\n\\t\\tt = simplifiedchinese.GBK.NewDecoder()\\n\\tcase \\\"gb18030\\\":\\n\\t\\tt = simplifiedchinese.GB18030.NewDecoder()\\n\\t}\\n\\treader := transform.NewReader(bytes.NewReader(s), t)\\n\\td, e := ioutil.ReadAll(reader)\\n\\tif e != nil {\\n\\t\\treturn nil, e\\n\\t}\\n\\treturn d, nil\\n}\",\n \"func _escFSByte(useLocal bool, name string) ([]byte, error) {\\n\\tif useLocal {\\n\\t\\tf, err := _escLocal.Open(name)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t\\tb, err := ioutil.ReadAll(f)\\n\\t\\t_ = f.Close()\\n\\t\\treturn b, err\\n\\t}\\n\\tf, err := _escStatic.prepare(name)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn f.data, nil\\n}\",\n \"func _escFSByte(useLocal bool, name string) ([]byte, error) {\\n\\tif useLocal {\\n\\t\\tf, err := _escLocal.Open(name)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t\\tb, err := ioutil.ReadAll(f)\\n\\t\\t_ = f.Close()\\n\\t\\treturn b, err\\n\\t}\\n\\tf, err := _escStatic.prepare(name)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn f.data, nil\\n}\",\n \"func _escFSByte(useLocal bool, name string) ([]byte, error) {\\n\\tif useLocal {\\n\\t\\tf, err := _escLocal.Open(name)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, err\\n\\t\\t}\\n\\t\\tb, err := ioutil.ReadAll(f)\\n\\t\\t_ = f.Close()\\n\\t\\treturn b, err\\n\\t}\\n\\tf, err := _escStatic.prepare(name)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\treturn f.data, nil\\n}\",\n \"func (a *App) ProcessUTF16be(ctx context.Context, r io.Reader, name, archive string) error {\\n\\tr = transform.NewReader(r, unicode.UTF16(unicode.BigEndian, unicode.UseBOM).NewDecoder())\\n\\treturn a.ProcessUTF8(ctx, r, name, archive)\\n}\",\n \"func (r *Response) ContentEncoding(encoding ...string) *Response {\\n\\topChain := r.chain.enter(\\\"ContentEncoding()\\\")\\n\\tdefer opChain.leave()\\n\\n\\tif opChain.failed() {\\n\\t\\treturn r\\n\\t}\\n\\n\\tr.checkEqual(opChain, `\\\"Content-Encoding\\\" header`,\\n\\t\\tencoding,\\n\\t\\tr.httpResp.Header[\\\"Content-Encoding\\\"])\\n\\n\\treturn r\\n}\",\n \"func (m *Gzip) GetContentType() []string {\\n\\tif m != nil {\\n\\t\\treturn m.ContentType\\n\\t}\\n\\treturn nil\\n}\",\n \"func DumpBomAsText(bm *BomMeta, b *Bom, out io.Writer) {\\n\\tfmt.Fprintln(out)\\n\\tfmt.Fprintf(out, \\\"Name:\\\\t\\\\t%s\\\\n\\\", bm.Name)\\n\\tfmt.Fprintf(out, \\\"Version:\\\\t%s\\\\n\\\", b.Version)\\n\\tfmt.Fprintf(out, \\\"Creator:\\\\t%s\\\\n\\\", bm.Owner)\\n\\tfmt.Fprintf(out, \\\"Timestamp:\\\\t%s\\\\n\\\", b.Created)\\n\\tif bm.Homepage != \\\"\\\" {\\n\\t\\tfmt.Fprintf(out, \\\"Homepage:\\\\t%s\\\\n\\\", bm.Homepage)\\n\\t}\\n\\tif b.Progeny != \\\"\\\" {\\n\\t\\tfmt.Fprintf(out, \\\"Source:\\\\t\\\\t%s\\\\n\\\", b.Progeny)\\n\\t}\\n\\tif bm.Description != \\\"\\\" {\\n\\t\\tfmt.Fprintf(out, \\\"Description:\\\\t%s\\\\n\\\", bm.Description)\\n\\t}\\n\\tfmt.Println()\\n\\ttabWriter := tabwriter.NewWriter(out, 2, 4, 1, ' ', 0)\\n\\t// \\\"by line item\\\", not \\\"by element\\\"\\n\\tfmt.Fprintf(tabWriter, \\\"qty\\\\ttag\\\\tmanufacturer\\\\tmpn\\\\t\\\\tfunction\\\\t\\\\tcomment\\\\n\\\")\\n\\tfor _, li := range b.LineItems {\\n\\t\\tfmt.Fprintf(tabWriter, \\\"%d\\\\t%s\\\\t%s\\\\t%s\\\\t\\\\t%s\\\\t\\\\t%s\\\\n\\\",\\n\\t\\t\\tlen(li.Elements),\\n\\t\\t\\tli.Tag,\\n\\t\\t\\tli.Manufacturer,\\n\\t\\t\\tli.Mpn,\\n\\t\\t\\tli.Description,\\n\\t\\t\\tli.Comment)\\n\\t}\\n\\ttabWriter.Flush()\\n}\",\n \"func (o TableExternalDataConfigurationCsvOptionsPtrOutput) Encoding() pulumi.StringPtrOutput {\\n\\treturn o.ApplyT(func(v *TableExternalDataConfigurationCsvOptions) *string {\\n\\t\\tif v == nil {\\n\\t\\t\\treturn nil\\n\\t\\t}\\n\\t\\treturn v.Encoding\\n\\t}).(pulumi.StringPtrOutput)\\n}\",\n \"func (sct *ContentSniffer) ContentType() (string, bool) {\\n\\tif sct.sniffed {\\n\\t\\treturn sct.ctype, sct.ctype != \\\"\\\"\\n\\t}\\n\\tsct.sniffed = true\\n\\t// If ReadAll hits EOF, it returns err==nil.\\n\\tsct.start, sct.err = ioutil.ReadAll(io.LimitReader(sct.r, sniffBuffSize))\\n\\n\\t// Don't try to detect the content type based on possibly incomplete data.\\n\\tif sct.err != nil {\\n\\t\\treturn \\\"\\\", false\\n\\t}\\n\\n\\tsct.ctype = http.DetectContentType(sct.start)\\n\\treturn sct.ctype, true\\n}\",\n \"func ContentTransferEncoding(encoding encoding.ContentTransferType) (string, string) {\\n\\treturn \\\"Content-Transfer-Encoding\\\", string(encoding)\\n}\",\n \"func (this *Tidy) OutputBom(val int) (bool, error) {\\n\\treturn this.optSetAutoBool(C.TidyOutputBOM, (C.ulong)(val))\\n}\",\n \"func (ft *FieldType) SetCharset(charset string) {\\n\\tft.charset = charset\\n}\",\n \"func GetTKRNameFromBOMConfigMap(bomConfigMap *corev1.ConfigMap) string {\\n\\treturn bomConfigMap.Labels[constants.TKRLabel]\\n}\",\n \"func (ft *FieldType) GetCollate() string {\\n\\treturn ft.collate\\n}\",\n \"func (h *RequestHeader) ContentType() []byte {\\n\\tif h.disableSpecialHeader {\\n\\t\\treturn peekArgBytes(h.h, []byte(HeaderContentType))\\n\\t}\\n\\treturn h.contentType\\n}\",\n \"func (e CharacterEncoding) String() string {\\n\\tswitch e {\\n\\tcase EncodingASCII:\\n\\t\\treturn \\\"ASCII\\\"\\n\\tcase EncodingUTF8:\\n\\t\\treturn \\\"UTF-8\\\"\\n\\tcase EncodingUnknown:\\n\\t\\tfallthrough\\n\\tdefault:\\n\\t\\treturn \\\"unknown\\\"\\n\\t}\\n}\",\n \"func WithCharset(nli int) CharsetOption {\\n\\treturn CharsetOption{nli}\\n}\",\n \"func getCiliumVersionString(epCHeaderFilePath string) ([]byte, error) {\\n\\tf, err := os.Open(epCHeaderFilePath)\\n\\tif err != nil {\\n\\t\\treturn []byte{}, err\\n\\t}\\n\\tbr := bufio.NewReader(f)\\n\\tdefer f.Close()\\n\\tfor {\\n\\t\\tb, err := br.ReadBytes('\\\\n')\\n\\t\\tif errors.Is(err, io.EOF) {\\n\\t\\t\\treturn []byte{}, nil\\n\\t\\t}\\n\\t\\tif err != nil {\\n\\t\\t\\treturn []byte{}, err\\n\\t\\t}\\n\\t\\tif bytes.Contains(b, []byte(ciliumCHeaderPrefix)) {\\n\\t\\t\\treturn b, nil\\n\\t\\t}\\n\\t}\\n}\",\n \"func (o TableExternalDataConfigurationCsvOptionsOutput) Encoding() pulumi.StringPtrOutput {\\n\\treturn o.ApplyT(func(v TableExternalDataConfigurationCsvOptions) *string { return v.Encoding }).(pulumi.StringPtrOutput)\\n}\",\n \"func FileConvertToUTF8(file io.Reader, charset string) (io.Reader, error) {\\n\\tencoding, err := getEncoding(charset)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\treturn encoding.NewDecoder().Reader(file), nil\\n}\",\n \"func (h *ResponseHeader) ContentType() []byte {\\n\\tcontentType := h.contentType\\n\\tif !h.noDefaultContentType && len(h.contentType) == 0 {\\n\\t\\tcontentType = defaultContentType\\n\\t}\\n\\treturn contentType\\n}\",\n \"func getCE(meth string, ce string) string {\\n\\tif !(meth == \\\"POST\\\" || meth == \\\"PATCH\\\" || meth == \\\"PUT\\\") {\\n\\t\\treturn \\\"\\\"\\n\\t}\\n\\t_, ce = split(strings.ToLower(ce), \\\";\\\")\\n\\t_, ce = split(ce, \\\"charset=\\\")\\n\\tce, _ = split(ce, \\\";\\\")\\n\\treturn ce\\n}\",\n \"func (d Decoder) WithCharset(set charset.Decoder) Decoder {\\n\\td.set = set\\n\\treturn d\\n}\",\n \"func (j *Env) GetUTF8String() *ObjectRef {\\n\\tif utf8 == nil {\\n\\t\\tstr, err := j.NewObject(\\\"java/lang/String\\\", []byte(\\\"UTF-8\\\"))\\n\\t\\tif err != nil {\\n\\t\\t\\tpanic(err)\\n\\t\\t}\\n\\t\\tglobal := j.NewGlobalRef(str)\\n\\t\\tj.DeleteLocalRef(str)\\n\\t\\tutf8 = global\\n\\t}\\n\\n\\treturn utf8\\n}\",\n \"func GetEncoding(r *http.Request, offers []string) (string, error) {\\n\\tacceptEncoding := r.Header[AcceptEncodingHeaderKey]\\n\\n\\tif len(acceptEncoding) == 0 {\\n\\t\\treturn \\\"\\\", ErrResponseNotCompressed\\n\\t}\\n\\n\\tencoding := negotiateAcceptHeader(acceptEncoding, offers, IDENTITY)\\n\\tif encoding == \\\"\\\" {\\n\\t\\treturn \\\"\\\", fmt.Errorf(\\\"%w: %s\\\", ErrNotSupportedCompression, encoding)\\n\\t}\\n\\n\\treturn encoding, nil\\n}\",\n \"func Reader(charset string, input io.Reader) (io.Reader, error) {\\n\\tcharset = strings.ToLower(charset)\\n\\t// \\\"ascii\\\" is not in the spec but is common\\n\\tif charset == \\\"utf-8\\\" || charset == \\\"us-ascii\\\" || charset == \\\"ascii\\\" {\\n\\t\\treturn input, nil\\n\\t}\\n\\tif enc, ok := charsets[charset]; ok {\\n\\t\\treturn enc.NewDecoder().Reader(input), nil\\n\\t}\\n\\treturn nil, fmt.Errorf(\\\"unhandled charset %q\\\", charset)\\n}\"\n]"},"negative_scores":{"kind":"list like","value":["0.62555885","0.5955372","0.59179115","0.58235437","0.5750309","0.5729708","0.5658097","0.5573649","0.55022633","0.5491252","0.5472508","0.54424894","0.5424224","0.5221963","0.5099995","0.50891393","0.5028969","0.49343708","0.48285758","0.47922873","0.47917458","0.47826916","0.47747797","0.47706518","0.47669125","0.47379306","0.4710506","0.47085384","0.4668222","0.4664772","0.46549657","0.46532995","0.45682552","0.45119137","0.45072418","0.4464518","0.445596","0.44345504","0.44195205","0.44178945","0.44139856","0.44080818","0.4377532","0.4353478","0.43497998","0.43241233","0.4319483","0.4318673","0.43096623","0.42973256","0.42612612","0.42586645","0.42569834","0.4255403","0.42285556","0.42285556","0.42285556","0.42285556","0.4226552","0.42237476","0.4191453","0.419092","0.41668385","0.41599143","0.41452268","0.41408226","0.41219363","0.40927705","0.40818524","0.40616468","0.40600422","0.40599367","0.40582088","0.40535718","0.40534085","0.40534085","0.40534085","0.40489474","0.40222353","0.40030396","0.4001778","0.39990863","0.399247","0.3992375","0.39877763","0.3982326","0.39769134","0.39654213","0.39571244","0.3957038","0.39556602","0.39531678","0.39513907","0.39381146","0.39308843","0.39305586","0.3929666","0.3928891","0.39150962","0.39099082"],"string":"[\n \"0.62555885\",\n \"0.5955372\",\n \"0.59179115\",\n \"0.58235437\",\n \"0.5750309\",\n \"0.5729708\",\n \"0.5658097\",\n \"0.5573649\",\n \"0.55022633\",\n \"0.5491252\",\n \"0.5472508\",\n \"0.54424894\",\n \"0.5424224\",\n \"0.5221963\",\n \"0.5099995\",\n \"0.50891393\",\n \"0.5028969\",\n \"0.49343708\",\n \"0.48285758\",\n \"0.47922873\",\n \"0.47917458\",\n \"0.47826916\",\n \"0.47747797\",\n \"0.47706518\",\n \"0.47669125\",\n \"0.47379306\",\n \"0.4710506\",\n \"0.47085384\",\n \"0.4668222\",\n \"0.4664772\",\n \"0.46549657\",\n \"0.46532995\",\n \"0.45682552\",\n \"0.45119137\",\n \"0.45072418\",\n \"0.4464518\",\n \"0.445596\",\n \"0.44345504\",\n \"0.44195205\",\n \"0.44178945\",\n \"0.44139856\",\n \"0.44080818\",\n \"0.4377532\",\n \"0.4353478\",\n \"0.43497998\",\n \"0.43241233\",\n \"0.4319483\",\n \"0.4318673\",\n \"0.43096623\",\n \"0.42973256\",\n \"0.42612612\",\n \"0.42586645\",\n \"0.42569834\",\n \"0.4255403\",\n \"0.42285556\",\n \"0.42285556\",\n \"0.42285556\",\n \"0.42285556\",\n \"0.4226552\",\n \"0.42237476\",\n \"0.4191453\",\n \"0.419092\",\n \"0.41668385\",\n \"0.41599143\",\n \"0.41452268\",\n \"0.41408226\",\n \"0.41219363\",\n \"0.40927705\",\n \"0.40818524\",\n \"0.40616468\",\n \"0.40600422\",\n \"0.40599367\",\n \"0.40582088\",\n \"0.40535718\",\n \"0.40534085\",\n \"0.40534085\",\n \"0.40534085\",\n \"0.40489474\",\n \"0.40222353\",\n \"0.40030396\",\n \"0.4001778\",\n \"0.39990863\",\n \"0.399247\",\n \"0.3992375\",\n \"0.39877763\",\n \"0.3982326\",\n \"0.39769134\",\n \"0.39654213\",\n \"0.39571244\",\n \"0.3957038\",\n \"0.39556602\",\n \"0.39531678\",\n \"0.39513907\",\n \"0.39381146\",\n \"0.39308843\",\n \"0.39305586\",\n \"0.3929666\",\n \"0.3928891\",\n \"0.39150962\",\n \"0.39099082\"\n]"},"document_score":{"kind":"string","value":"0.75923693"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":105063,"cells":{"query":{"kind":"string","value":"FromPlain returns the charset of a plain text. It relies on BOM presence and it falls back on checking each byte in content."},"document":{"kind":"string","value":"func FromPlain(content []byte) string {\n\tif len(content) == 0 {\n\t\treturn \"\"\n\t}\n\tif cset := FromBOM(content); cset != \"\" {\n\t\treturn cset\n\t}\n\torigContent := content\n\t// Try to detect UTF-8.\n\t// First eliminate any partial rune at the end.\n\tfor i := len(content) - 1; i >= 0 && i > len(content)-4; i-- {\n\t\tb := content[i]\n\t\tif b < 0x80 {\n\t\t\tbreak\n\t\t}\n\t\tif utf8.RuneStart(b) {\n\t\t\tcontent = content[:i]\n\t\t\tbreak\n\t\t}\n\t}\n\thasHighBit := false\n\tfor _, c := range content {\n\t\tif c >= 0x80 {\n\t\t\thasHighBit = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif hasHighBit && utf8.Valid(content) {\n\t\treturn \"utf-8\"\n\t}\n\n\t// ASCII is a subset of UTF8. Follow W3C recommendation and replace with UTF8.\n\tif ascii(origContent) {\n\t\treturn \"utf-8\"\n\t}\n\n\treturn latin(origContent)\n}"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["func ReadPlainBytes(b []byte) ByteReadScanner {\n\treturn bytes.NewReader(b)\n}","func FromHTML(content []byte) string {\n\tif cset := FromBOM(content); cset != \"\" {\n\t\treturn cset\n\t}\n\tif cset := fromHTML(content); cset != \"\" {\n\t\treturn cset\n\t}\n\treturn FromPlain(content)\n}","func CreatePlainMessage(t string) Message {\n\treturn Message{\n\t\tPayload: string(t),\n\t\tType: 0,\n\t}\n}","func (cs *CsvStructure) checkForConvertToUtf8(textBytes []byte) (outBytes []byte) {\n\tvar strByte []byte\n\tvar err error\n\toutBytes = make([]byte, len(textBytes))\n\tcopy(outBytes, textBytes)\n\t_, cs.Charset, _ = charset.DetermineEncoding(textBytes, \"\")\n\t// fmt.Println(cs.Charset)\n\tif cs.Charset != \"utf-8\" { // convert to UTF-8\n\t\tif reader, err := charset.NewReader(strings.NewReader(string(textBytes)), cs.Charset); err == nil {\n\t\t\tif strByte, err = ioutil.ReadAll(reader); err == nil {\n\t\t\t\toutBytes = make([]byte, len(strByte))\n\t\t\t\tcopy(outBytes, strByte)\n\t\t\t}\n\t\t}\n\t}\n\tif err != nil {\n\t\tfmt.Println(\"Error while trying to convert %s to utf-8: \", cs.Charset)\n\t}\n\treturn outBytes\n}","func AcceptPlain(pw string) (EncodedPasswd, error) {\n\treturn &plainPassword{pw}, nil\n}","func (text *Text) Plain(content string) *Text {\n\ttext.Spans = append(text.Spans, Span{\n\t\tContent: content,\n\t})\n\treturn text\n}","func Text(raw []byte, limit uint32) bool {\n\t// First look for BOM.\n\tif cset := charset.FromBOM(raw); cset != \"\" {\n\t\treturn true\n\t}\n\t// Binary data bytes as defined here: https://mimesniff.spec.whatwg.org/#binary-data-byte\n\tfor _, b := range raw {\n\t\tif b <= 0x08 ||\n\t\t\tb == 0x0B ||\n\t\t\t0x0E <= b && b <= 0x1A ||\n\t\t\t0x1C <= b && b <= 0x1F {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}","func correctEncodingToUtf8(text []byte) []byte {\n\tr, err := charset.NewReader(bytes.NewBuffer(text), \"application/xml\")\n\tif err != nil {\n\t\tfmt.Println(\"Error converting encoding:\", err)\n\t\treturn nil\n\t}\n\ttext, _ = ioutil.ReadAll(r)\n\treturn text\n}","func (be *ContentEnc) PlainBS() uint64 {\n\treturn be.plainBS\n}","func (in *ActionMailTemplateTranslationUpdateInput) SetTextPlain(value string) *ActionMailTemplateTranslationUpdateInput {\n\tin.TextPlain = value\n\n\tif in._selectedParameters == nil {\n\t\tin._selectedParameters = make(map[string]interface{})\n\t}\n\n\tin._selectedParameters[\"TextPlain\"] = nil\n\treturn in\n}","func (w *Wallet) GetPlain() (psw, content string, err error) {\n\tbase64Decoded, err := base64.StdEncoding.DecodeString(w.CipherContent)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tcontentBytes, err := crypto.AESDecrypt(base64Decoded, passWd)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tcontent = util.String(contentBytes)\n\n\tbase64Decoded, err = base64.StdEncoding.DecodeString(w.CipherPSW)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tpswBytes, err := crypto.AESDecrypt(base64Decoded, passWd)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tpsw = util.String(pswBytes)\n\treturn\n}","func New(cc *cryptocore.CryptoCore, plainBS uint64, forceDecode bool) *ContentEnc {\n\tcipherBS := plainBS + uint64(cc.IVLen) + cryptocore.AuthTagLen\n\n\treturn &ContentEnc{\n\t\tcryptoCore: cc,\n\t\tplainBS: plainBS,\n\t\tcipherBS: cipherBS,\n\t\tallZeroBlock: make([]byte, cipherBS),\n\t\tallZeroNonce: make([]byte, cc.IVLen),\n\t\tforceDecode: forceDecode,\n\t}\n}","func NewDataFrameFromTextMessage(msg string, mask bool) (*DataFrame, error) {\n\tdf := &DataFrame{\n\t\tpayload: []byte(msg),\n\t\tmask: mask,\n\t\tfin: true,\n\t\tOpCode: OpCodeText,\n\t\tpayloadLen: len(msg),\n\t}\n\treturn df, nil\n}","func PlainText(s string) Response {\n\treturn stringResponse{s}\n}","func TestText(t *testing.T) {\n\tinput := \"Hello world!\"\n\tresult := Text(input)\n\n\tif !strings.EqualFold(input, result) {\n\t\tt.Errorf(\"Should have same content except capitalisation: \\\"%s\\\" - \\\"%s\\\"\", input, result)\n\t}\n}","func fromTextPb(_ *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {\n\tvar ctor starlark.Value\n\tvar text starlark.String\n\tif err := starlark.UnpackArgs(\"from_textpb\", args, kwargs, \"ctor\", &ctor, \"text\", &text); err != nil {\n\t\treturn nil, err\n\t}\n\n\tc, ok := ctor.(*messageCtor)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"from_textpb: got %s, expecting a proto message constructor\", ctor.Type())\n\t}\n\ttyp := c.typ\n\n\tprotoMsg := typ.NewProtoMessage().Interface().(proto.Message)\n\tif err := proto.UnmarshalText(text.GoString(), protoMsg); err != nil {\n\t\treturn nil, fmt.Errorf(\"from_textpb: %s\", err)\n\t}\n\n\tmsg := NewMessage(typ)\n\tif err := msg.FromProto(protoMsg); err != nil {\n\t\treturn nil, fmt.Errorf(\"from_textpb: %s\", err)\n\t}\n\treturn msg, nil\n}","func NewTextMail(msg *mail.Message) (*TextMailMessage, error) {\n\t_, params, err := mime.ParseMediaType(msg.Header.Get(\"Content-Type\"))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdata, err := DecodeText(msg.Body, params[\"charset\"])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tt := &TextMailMessage{\n\t\tbody: msg.Body,\n\t\theader: msg.Header,\n\t\ttext: data,\n\t}\n\treturn t, nil\n}","func (ckms *CKMS) DecryptRaw(cipherText []byte) ([]byte, error) {\n\n\tresult, err := ckms.svc.Decrypt(&kms.DecryptInput{CiphertextBlob: cipherText})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn result.Plaintext, nil\n}","func FromBOM(content []byte) string {\n\tfor _, b := range boms {\n\t\tif bytes.HasPrefix(content, b.bom) {\n\t\t\treturn b.enc\n\t\t}\n\t}\n\treturn \"\"\n}","func GetUTF8Body(body []byte, contentType string,\n\tignoreInvalidUTF8Chars bool) (string, error) {\n\t// Detect charset.\n\tcs, err := DetectCharset(body, contentType)\n\tif err != nil {\n\t\tif !ignoreInvalidUTF8Chars {\n\t\t\treturn \"\", err\n\t\t}\n\t\tcs = \"utf-8\"\n\t}\n\n\t// Remove utf8.RuneError if ignoreInvalidUTF8Chars is true.\n\tbs := string(body)\n\tif ignoreInvalidUTF8Chars {\n\t\tif !utf8.ValidString(bs) {\n\t\t\tv := make([]rune, 0, len(bs))\n\t\t\tfor i, r := range bs {\n\t\t\t\tif r == utf8.RuneError {\n\t\t\t\t\t_, size := utf8.DecodeRuneInString(bs[i:])\n\t\t\t\t\tif size == 1 {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tv = append(v, r)\n\t\t\t}\n\t\t\tbs = string(v)\n\t\t}\n\t}\n\n\t// Convert body.\n\tconverted, err := iconv.ConvertString(bs, cs, \"utf-8\")\n\tif err != nil && !strings.Contains(converted, \"\") {\n\t\treturn \"\", err\n\t}\n\n\treturn converted, nil\n}","func (sc *serverConn) authPlain() error {\n\tm := &msg{\n\t\theader: header{\n\t\t\tOp: opAuthStart,\n\t\t},\n\n\t\tkey: \"PLAIN\",\n\t\tval: fmt.Sprintf(\"\\x00%s\\x00%s\", sc.username, sc.password),\n\t}\n\n\treturn sc.sendRecv(m)\n}","func TestLoadedSimpleFontEncoding(t *testing.T) {\n\trawpdf := `\n59 0 obj\n<>\nendobj\n60 0 obj\n<>\nendobj\n`\n\n\tobjects, err := testutils.ParseIndirectObjects(rawpdf)\n\tif err != nil {\n\t\tt.Fatalf(\"Error: %v\", err)\n\t}\n\n\tfont, err := model.NewPdfFontFromPdfObject(objects[59])\n\tif err != nil {\n\t\tt.Fatalf(\"Error: %v\", err)\n\t}\n\n\t// The expected encoding is StandardEncoding with the applied differences.\n\tbaseEncoding := newStandandTextEncoder(t)\n\n\tdifferencesMap := map[textencoding.CharCode]rune{\n\t\t24: '˘',\n\t\t25: 'ˇ',\n\t\t26: 'ˆ',\n\t\t27: '˙',\n\t\t28: '˝',\n\t\t29: '˛',\n\t\t30: '˚',\n\t\t31: '˜',\n\t\t39: '\\'',\n\t\t96: '`',\n\t\t128: '•',\n\t\t129: '†',\n\t\t130: '‡',\n\t\t131: '…',\n\t\t132: '—',\n\t\t133: '–',\n\t\t134: 'ƒ',\n\t\t135: '⁄',\n\t\t136: '‹',\n\t\t137: '›',\n\t\t138: '−',\n\t\t139: '‰',\n\t\t140: '„',\n\t\t141: '“',\n\t\t142: '”',\n\t\t143: '‘',\n\t\t144: '’',\n\t\t145: '‚',\n\t\t146: '™',\n\t\t147: 'fi',\n\t\t148: 'fl',\n\t\t149: 'Ł',\n\t\t150: 'Œ',\n\t\t151: 'Š',\n\t\t152: 'Ÿ',\n\t\t153: 'Ž',\n\t\t154: 'ı',\n\t\t155: 'ł',\n\t\t156: 'œ',\n\t\t157: 'š',\n\t\t158: 'ž',\n\t\t160: '€',\n\t\t164: '¤',\n\t\t166: '¦',\n\t\t168: '¨',\n\t\t169: '©',\n\t\t170: 'ª',\n\t\t172: '¬',\n\t\t173: '�',\n\t\t174: '®',\n\t\t175: '¯',\n\t\t176: '°',\n\t\t177: '±',\n\t\t178: '²',\n\t\t179: '³',\n\t\t180: '´',\n\t\t181: 'µ',\n\t\t183: '·',\n\t\t184: '¸',\n\t\t185: '¹',\n\t\t186: 'º',\n\t\t188: '¼',\n\t\t189: '½',\n\t\t190: '¾',\n\t\t192: 'À',\n\t\t193: 'Á',\n\t\t194: 'Â',\n\t\t195: 'Ã',\n\t\t196: 'Ä',\n\t\t197: 'Å',\n\t\t198: 'Æ',\n\t\t199: 'Ç',\n\t\t200: 'È',\n\t\t201: 'É',\n\t\t202: 'Ê',\n\t\t203: 'Ë',\n\t\t204: 'Ì',\n\t\t205: 'Í',\n\t\t206: 'Î',\n\t\t207: 'Ï',\n\t\t208: 'Ð',\n\t\t209: 'Ñ',\n\t\t210: 'Ò',\n\t\t211: 'Ó',\n\t\t212: 'Ô',\n\t\t213: 'Õ',\n\t\t214: 'Ö',\n\t\t215: '×',\n\t\t216: 'Ø',\n\t\t217: 'Ù',\n\t\t218: 'Ú',\n\t\t219: 'Û',\n\t\t220: 'Ü',\n\t\t221: 'Ý',\n\t\t222: 'Þ',\n\t\t223: 'ß',\n\t\t224: 'à',\n\t\t225: 'á',\n\t\t226: 'â',\n\t\t227: 'ã',\n\t\t228: 'ä',\n\t\t229: 'å',\n\t\t230: 'æ',\n\t\t231: 'ç',\n\t\t232: 'è',\n\t\t233: 'é',\n\t\t234: 'ê',\n\t\t235: 'ë',\n\t\t236: 'ì',\n\t\t237: 'í',\n\t\t238: 'î',\n\t\t239: 'ï',\n\t\t240: 'ð',\n\t\t241: 'ñ',\n\t\t242: 'ò',\n\t\t243: 'ó',\n\t\t244: 'ô',\n\t\t245: 'õ',\n\t\t246: 'ö',\n\t\t247: '÷',\n\t\t248: 'ø',\n\t\t249: 'ù',\n\t\t250: 'ú',\n\t\t251: 'û',\n\t\t252: 'ü',\n\t\t253: 'ý',\n\t\t254: 'þ',\n\t\t255: 'ÿ',\n\t}\n\n\tenc := font.Encoder()\n\tfor code := textencoding.CharCode(32); code < 255; code++ {\n\t\tfontrune, has := enc.CharcodeToRune(code)\n\t\tif !has {\n\t\t\tbaserune, bad := baseEncoding.CharcodeToRune(code)\n\t\t\tif bad {\n\t\t\t\tt.Fatalf(\"font not having glyph for char code %d - whereas base encoding had %q\", code, baserune)\n\t\t\t}\n\t\t}\n\n\t\t// Check if in differencesmap first.\n\t\trune, has := differencesMap[code]\n\t\tif has {\n\t\t\tif rune != fontrune {\n\t\t\t\tt.Fatalf(\"Mismatch for char code %d, font has: %q and expected is: %q (differences)\", code, fontrune, rune)\n\t\t\t}\n\n\t\t\tcontinue\n\t\t}\n\n\t\t// If not in differences, should be according to StandardEncoding (base).\n\t\trune, has = baseEncoding.CharcodeToRune(code)\n\t\tif has && rune != fontrune {\n\t\t\tt.Fatalf(\"Mismatch for char code %d (%X), font has: %q and expected is: %q (StandardEncoding)\", code, code, fontrune, rune)\n\t\t}\n\t}\n}","func plainText(h http.HandlerFunc) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Add(\"Content-Type\", \"text/plain; charset=utf-8\")\n\t\th(w, r)\n\t}\n}","func (c *Cell) PlainText(b *bytes.Buffer) string {\n\tn := len(c.P)\n\tif n == 1 {\n\t\treturn c.P[0].PlainText(b)\n\t}\n\n\tb.Reset()\n\tfor i := range c.P {\n\t\tif i != n-1 {\n\t\t\tc.P[i].writePlainText(b)\n\t\t\tb.WriteByte('\\n')\n\t\t} else {\n\t\t\tc.P[i].writePlainText(b)\n\t\t}\n\t}\n\treturn b.String()\n}","func DetectCharset(body []byte, contentType string) (string, error) {\n\t// 1. Use charset.DetermineEncoding\n\t_, name, certain := charset.DetermineEncoding(body, contentType)\n\tif certain {\n\t\treturn name, nil\n\t}\n\n\t// Handle uncertain cases\n\t// 2. Use chardet.Detector.DetectBest\n\tr, err := chardet.NewHtmlDetector().DetectBest(body)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif r.Confidence == 100 {\n\t\treturn strings.ToLower(r.Charset), nil\n\t}\n\n\t// 3. Parse meta tag for Content-Type\n\troot, err := html.Parse(bytes.NewReader(body))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdoc := goquery.NewDocumentFromNode(root)\n\tvar csFromMeta string\n\tdoc.Find(\"meta\").EachWithBreak(func(i int, s *goquery.Selection) bool {\n\t\t// \n\t\tif c, exists := s.Attr(\"content\"); exists && strings.Contains(c, \"charset\") {\n\t\t\tif _, params, err := mime.ParseMediaType(c); err == nil {\n\t\t\t\tif cs, ok := params[\"charset\"]; ok {\n\t\t\t\t\tcsFromMeta = strings.ToLower(cs)\n\t\t\t\t\t// Handle Korean charsets.\n\t\t\t\t\tif csFromMeta == \"ms949\" || csFromMeta == \"cp949\" {\n\t\t\t\t\t\tcsFromMeta = \"euc-kr\"\n\t\t\t\t\t}\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\n\t\t// \n\t\tif c, exists := s.Attr(\"charset\"); exists {\n\t\t\tcsFromMeta = c\n\t\t\treturn false\n\t\t}\n\n\t\treturn true\n\t})\n\n\tif csFromMeta == \"\" {\n\t\treturn \"\", fmt.Errorf(\"failed to detect charset\")\n\t}\n\n\treturn csFromMeta, nil\n}","func NewDummyCipher(b []byte, k int) (Cipher, error) {\n\treturn &DummyCipher{}, nil\n}","func (w *Wallet) SetPlain(psw, content string) (err error) {\n\n\taesBytes, err := crypto.AESEncrypt(util.Slice(content), passWd)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tw.CipherContent = base64.StdEncoding.EncodeToString(aesBytes)\n\n\taesBytes, err = crypto.AESEncrypt(util.Slice(psw), passWd)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tw.CipherPSW = base64.StdEncoding.EncodeToString(aesBytes)\n\treturn\n}","func Body(body, contentType, transferEncoding string, opt Options) (string, error) {\n\t// attempt to do some base64-decoding anyway\n\tif decoded, err := base64.URLEncoding.DecodeString(body); err == nil {\n\t\tbody = string(decoded)\n\t}\n\tif decoded, err := base64.StdEncoding.DecodeString(body); err == nil {\n\t\tbody = string(decoded)\n\t}\n\n\tif strings.ToLower(transferEncoding) == \"quoted-printable\" {\n\t\tb, err := ioutil.ReadAll(quotedprintable.NewReader(strings.NewReader(body)))\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tbody = string(b)\n\t}\n\n\tct := strings.ToLower(contentType)\n\tif strings.Contains(ct, \"multipart/\") {\n\t\treturn parseMultipart(body, contentType, opt)\n\t}\n\n\tif !opt.SkipHTML && strings.Contains(ct, \"text/html\") {\n\t\tbody = stripHTML(body, opt)\n\t}\n\n\tbody = stripEmbedded(body, opt)\n\tif opt.LineLimit > 0 || opt.ColLimit > 0 {\n\t\tlines := strings.Split(body, \"\\n\")\n\t\tif len(lines) > opt.LineLimit {\n\t\t\tlines = lines[:opt.LineLimit]\n\t\t}\n\t\tfor kk, l := range lines {\n\t\t\tif len(l) > opt.ColLimit {\n\t\t\t\tlines[kk] = l[:opt.ColLimit]\n\t\t\t}\n\t\t}\n\t\tbody = strings.Join(lines, \"\\n\")\n\t}\n\treturn body, nil\n}","func PlainText(h http.Handler) http.Handler {\n\tfn := func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\t\th.ServeHTTP(w, r)\n\t}\n\treturn http.HandlerFunc(fn)\n}","func FromMultipart(body []byte, boundary string) Mimes {\n\tmi := make(Mimes, 0, 10)\n\tsr := bytes.NewReader(body)\n\tmr := multipart.NewReader(sr, boundary)\n\tfor {\n\t\tp, err := mr.NextPart()\n\t\tif err == io.EOF {\n\t\t\treturn mi\n\t\t}\n\t\tif err != nil {\n\t\t\tlog.Printf(\"mimedata.IsMultipart: malformed multipart MIME: %v\\n\", err)\n\t\t\treturn mi\n\t\t}\n\t\tb, err := ioutil.ReadAll(p)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"mimedata.IsMultipart: bad ReadAll of multipart MIME: %v\\n\", err)\n\t\t\treturn mi\n\t\t}\n\t\td := Data{}\n\t\td.Type = p.Header.Get(ContentType)\n\t\tcte := p.Header.Get(ContentTransferEncoding)\n\t\tif cte != \"\" {\n\t\t\tswitch cte {\n\t\t\tcase \"base64\":\n\t\t\t\teb := make([]byte, base64.StdEncoding.DecodedLen(len(b)))\n\t\t\t\tbase64.StdEncoding.Decode(eb, b)\n\t\t\t\tb = eb\n\t\t\t}\n\t\t}\n\t\td.Data = b\n\t\tmi = append(mi, &d)\n\t}\n\treturn mi\n}","func NewPlain(section string, operation *MetricOperation, success, uniDecode bool) *Plain {\n\toperationSanitized := make([]string, cap(operation.operations))\n\tfor k, v := range operation.operations {\n\t\toperationSanitized[k] = SanitizeMetricName(v, uniDecode)\n\t}\n\treturn &Plain{SanitizeMetricName(section, uniDecode), strings.Join(operationSanitized, \".\"), success}\n}","func New(in []byte) (*SecurityTxt, error) {\n\tmsg, err := NewSignedMessage(in)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttxt := &SecurityTxt{\n\t\tsigned: msg.Signed(),\n\t}\n\n\t// Note: try and collect as many fields as possible and as many errors as possible\n\t// Output should be human-readable error report.\n\n\terr = Parse(msg.Message(), txt)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Caller should deal with parsing errors\n\treturn txt, nil\n}","func (b *Builder) AddTextPlain(text []byte) {\n\tb.AddTextPart(text)\n}","func PlainParser(r io.Reader, set func(name, value string) error) error {\n\ts := bufio.NewScanner(r)\n\tfor s.Scan() {\n\t\tline := strings.TrimSpace(s.Text())\n\t\tif line == \"\" {\n\t\t\tcontinue // skip empties\n\t\t}\n\n\t\tif line[0] == '#' {\n\t\t\tcontinue // skip comments\n\t\t}\n\n\t\tvar (\n\t\t\tname string\n\t\t\tvalue string\n\t\t\tindex = strings.IndexRune(line, ' ')\n\t\t)\n\t\tif index < 0 {\n\t\t\tname, value = line, \"true\" // boolean option\n\t\t} else {\n\t\t\tname, value = line[:index], strings.TrimSpace(line[index:])\n\t\t}\n\n\t\tif i := strings.Index(value, \" #\"); i >= 0 {\n\t\t\tvalue = strings.TrimSpace(value[:i])\n\t\t}\n\n\t\tif err := set(name, value); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}","func PlainParser(r io.Reader, set func(name, value string) error) error {\n\ts := bufio.NewScanner(r)\n\tfor s.Scan() {\n\t\tline := strings.TrimSpace(s.Text())\n\t\tif line == \"\" {\n\t\t\tcontinue // skip empties\n\t\t}\n\n\t\tif line[0] == '#' {\n\t\t\tcontinue // skip comments\n\t\t}\n\n\t\tvar (\n\t\t\tname string\n\t\t\tvalue string\n\t\t\tindex = strings.IndexRune(line, ' ')\n\t\t)\n\t\tif index < 0 {\n\t\t\tname, value = line, \"true\" // boolean option\n\t\t} else {\n\t\t\tname, value = line[:index], strings.TrimSpace(line[index:])\n\t\t}\n\n\t\tif i := strings.Index(value, \" #\"); i >= 0 {\n\t\t\tvalue = strings.TrimSpace(value[:i])\n\t\t}\n\n\t\tif err := set(name, value); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn s.Err()\n}","func NewCorrupter(w io.Writer) *Corrupter {\n\treturn &Corrupter{w: w, b: make([]byte, utf8.MaxRune)}\n}","func (p *Plain) Parse(data []byte) (T, error) {\n\tt := newPlainT(p.archetypes)\n\n\t//convert to string and remove spaces according to unicode\n\tstr := strings.TrimRightFunc(string(data), unicode.IsSpace)\n\n\t//creat element\n\te := NewElement(str)\n\n\t//set it as single table value\n\tt.Set(\".0\", e)\n\n\treturn t, nil\n}","func From(s string) *Buffer {\n\treturn &Buffer{b: []byte(s)}\n}","func FromXML(content []byte) string {\n\tif cset := fromXML(content); cset != \"\" {\n\t\treturn cset\n\t}\n\treturn FromPlain(content)\n}","func FromBytes(content []byte, pkg string, w io.Writer) error {\n\tbundle := i18n.NewBundle(language.English)\n\tbundle.RegisterUnmarshalFunc(\"json\", json.Unmarshal)\n\n\t// Load source language\n\tmessageFile, err := bundle.ParseMessageFileBytes(content, \"en.json\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn generate(messageFile, pkg, w)\n}","func StringFromCharset(length int, charset string) (string, error) {\n\tresult := make([]byte, length) // Random string to return\n\tcharsetlen := big.NewInt(int64(len(charset)))\n\n\tfor i := 0; i < length; i++ {\n\t\tb, err := rand.Int(rand.Reader, charsetlen)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tr := int(b.Int64())\n\t\tresult[i] = charset[r]\n\t}\n\n\treturn string(result), nil\n}","func (p Piece) GetPlain() Piece {\n\treturn p & 0xf\n}","func RejectPlain(pw string) (EncodedPasswd, error) {\n\treturn nil, fmt.Errorf(\"plain password rejected: %s\", pw)\n}","func (b *Builder) Plain(s string) *Builder {\n\tb.message.WriteString(s)\n\treturn b\n}","func NewBuffer(data string) Buffer {\n\tif len(data) == 0 {\n\t\treturn nilBuffer\n\t}\n\tvar (\n\t\tidx = 0\n\t\tbuf8 = make([]byte, 0, len(data))\n\t\tbuf16 []uint16\n\t\tbuf32 []rune\n\t)\n\tfor idx < len(data) {\n\t\tr, s := utf8.DecodeRuneInString(data[idx:])\n\t\tidx += s\n\t\tif r < utf8.RuneSelf {\n\t\t\tbuf8 = append(buf8, byte(r))\n\t\t\tcontinue\n\t\t}\n\t\tif r <= 0xffff {\n\t\t\tbuf16 = make([]uint16, len(buf8), len(data))\n\t\t\tfor i, v := range buf8 {\n\t\t\t\tbuf16[i] = uint16(v)\n\t\t\t}\n\t\t\tbuf8 = nil\n\t\t\tbuf16 = append(buf16, uint16(r))\n\t\t\tgoto copy16\n\t\t}\n\t\tbuf32 = make([]rune, len(buf8), len(data))\n\t\tfor i, v := range buf8 {\n\t\t\tbuf32[i] = rune(uint32(v))\n\t\t}\n\t\tbuf8 = nil\n\t\tbuf32 = append(buf32, r)\n\t\tgoto copy32\n\t}\n\treturn &asciiBuffer{\n\t\tarr: buf8,\n\t}\ncopy16:\n\tfor idx < len(data) {\n\t\tr, s := utf8.DecodeRuneInString(data[idx:])\n\t\tidx += s\n\t\tif r <= 0xffff {\n\t\t\tbuf16 = append(buf16, uint16(r))\n\t\t\tcontinue\n\t\t}\n\t\tbuf32 = make([]rune, len(buf16), len(data))\n\t\tfor i, v := range buf16 {\n\t\t\tbuf32[i] = rune(uint32(v))\n\t\t}\n\t\tbuf16 = nil\n\t\tbuf32 = append(buf32, r)\n\t\tgoto copy32\n\t}\n\treturn &basicBuffer{\n\t\tarr: buf16,\n\t}\ncopy32:\n\tfor idx < len(data) {\n\t\tr, s := utf8.DecodeRuneInString(data[idx:])\n\t\tidx += s\n\t\tbuf32 = append(buf32, r)\n\t}\n\treturn &supplementalBuffer{\n\t\tarr: buf32,\n\t}\n}","func NewTextData(text string) *Data {\n\treturn &Data{TextPlain, []byte(text)}\n}","func (m MAC) PlainString() string {\n\tconst hexDigit = \"0123456789abcdef\"\n\tbuf := make([]byte, 0, len(m)*2)\n\tfor _, b := range m {\n\t\tbuf = append(buf, hexDigit[b>>4])\n\t\tbuf = append(buf, hexDigit[b&0xF])\n\t}\n\treturn string(buf)\n}","func TestLoadStandardFontEncodings(t *testing.T) {\n\traw := `\n\t1 0 obj\n\t<< /Type /Font\n\t\t/BaseFont /Courier\n\t\t/Subtype /Type1\n\t>>\n\tendobj\n\t`\n\n\tr := model.NewReaderForText(raw)\n\n\terr := r.ParseIndObjSeries()\n\tif err != nil {\n\t\tt.Fatalf(\"Failed loading indirect object series: %v\", err)\n\t}\n\n\t// Load the field from object number 1.\n\tobj, err := r.GetIndirectObjectByNumber(1)\n\tif err != nil {\n\t\tt.Fatalf(\"Failed to parse indirect obj (%s)\", err)\n\t}\n\n\tfont, err := model.NewPdfFontFromPdfObject(obj)\n\tif err != nil {\n\t\tt.Fatalf(\"Error: %v\", err)\n\t}\n\n\tstr := \"Aabcdefg0123456790*\"\n\tfor _, r := range str {\n\t\t_, has := font.GetRuneMetrics(r)\n\t\tif !has {\n\t\t\tt.Fatalf(\"Loaded simple font not having glyph char metrics for %v\", r)\n\t\t}\n\t}\n}","func PlainText(s string) ([]store.Measurement, error) {\n\tnow := time.Now()\n\tret := []store.Measurement{}\n\tlines := strings.Split(s, \"\\n\")\n\tfor _, l := range lines {\n\t\tparts := strings.Split(l, \" \")\n\t\tif len(parts) != 2 {\n\t\t\treturn nil, fmt.Errorf(\"Invalid input line format: %q\", l)\n\t\t}\n\t\tkey := parts[0]\n\t\tvalue, err := strconv.ParseInt(parts[1], 10, 64)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Invalid value format: %q\", l)\n\t\t}\n\t\tret = append(ret, store.Measurement{\n\t\t\tKey: key,\n\t\t\tPoint: ts.Point{\n\t\t\t\tTimestamp: now.Unix(),\n\t\t\t\tValue: value,\n\t\t\t},\n\t\t})\n\t}\n\treturn ret, nil\n}","func PlainText(content string) TextLit {\n\treturn TextLit{Suffix: content}\n}","func NewText(text string) Mimes {\n\tmd := NewTextData(text)\n\tmi := make(Mimes, 1)\n\tmi[0] = md\n\treturn mi\n}","func NewReaderFromText(name string, text string) *Reader {\n\tnoExternalNewlines := strings.Trim(text, \"\\n\")\n\treturn &Reader{\n\t\tname: &name,\n\t\tlines: strings.Split(noExternalNewlines, \"\\n\"),\n\t\tlock: &sync.Mutex{},\n\t}\n}","func (downloader *HTTPDownloader) changeCharsetEncodingAuto(contentTypeStr string, sor io.ReadCloser) string {\r\n\tvar err error\r\n\tdestReader, err := charset.NewReader(sor, contentTypeStr)\r\n\r\n\tif err != nil {\r\n\t\tmlog.LogInst().LogError(err.Error())\r\n\t\tdestReader = sor\r\n\t}\r\n\r\n\tvar sorbody []byte\r\n\tif sorbody, err = ioutil.ReadAll(destReader); err != nil {\r\n\t\tmlog.LogInst().LogError(err.Error())\r\n\t\t// For gb2312, an error will be returned.\r\n\t\t// Error like: simplifiedchinese: invalid GBK encoding\r\n\t\t// return \"\"\r\n\t}\r\n\t//e,name,certain := charset.DetermineEncoding(sorbody,contentTypeStr)\r\n\tbodystr := string(sorbody)\r\n\r\n\treturn bodystr\r\n}","func Test_fromNetASCII(t *testing.T) {\n\tvar tests = []struct {\n\t\tin []byte\n\t\tout []byte\n\t}{\n\t\t{\n\t\t\tin: nil,\n\t\t\tout: nil,\n\t\t},\n\t\t{\n\t\t\tin: []byte{'a', 'b', 'c'},\n\t\t\tout: []byte{'a', 'b', 'c'},\n\t\t},\n\t\t{\n\t\t\tin: []byte{'a', '\\r', '\\n', 'b', '\\r', '\\n', 'c'},\n\t\t\tout: []byte{'a', '\\n', 'b', '\\n', 'c'},\n\t\t},\n\t\t{\n\t\t\tin: []byte{'a', '\\r', 0, 'b', '\\r', 0, 'c'},\n\t\t\tout: []byte{'a', '\\r', 'b', '\\r', 'c'},\n\t\t},\n\t\t{\n\t\t\tin: []byte{'a', '\\r', 0, 'b', '\\r', '\\n', 'c'},\n\t\t\tout: []byte{'a', '\\r', 'b', '\\n', 'c'},\n\t\t},\n\t\t// TODO(mdlayher): determine if it possible for a carriage return to\n\t\t// be the last character in a buffer. For the time being, we perform\n\t\t// no conversion if this is the case.\n\t\t{\n\t\t\tin: []byte{'a', '\\r'},\n\t\t\tout: []byte{'a', '\\r'},\n\t\t},\n\t}\n\n\tfor i, tt := range tests {\n\t\tif want, got := tt.out, fromNetASCII(tt.in); !bytes.Equal(want, got) {\n\t\t\tt.Fatalf(\"[%02d] unexpected fromNetASCII conversion:\\n- want: %v\\n- got: %v\",\n\t\t\t\ti, want, got)\n\t\t}\n\t}\n}","func NewReader(r io.Reader, cpn ...string) (io.Reader, error) {\n\tif r == nil {\n\t\treturn r, errInputIsNil\n\t}\n\ttmpReader := bufio.NewReader(r)\n\tvar err error\n\tcp := ASCII\n\tif len(cpn) > 0 {\n\t\tcp = codepageByName(cpn[0])\n\t}\n\tif cp == ASCII {\n\t\tcp, err = CodepageDetect(tmpReader)\n\t}\n\t//TODO внимательно нужно посмотреть что может вернуть CodepageDetect()\n\t//эти случаи обработать, например через func unsupportedCodepageToDecode(cp)\n\tswitch {\n\tcase (cp == UTF32) || (cp == UTF32BE) || (cp == UTF32LE):\n\t\treturn r, errUnsupportedCodepage\n\tcase cp == ASCII: // кодировку определить не удалось, неизвестную кодировку возвращаем как есть\n\t\treturn r, errUnknown\n\tcase err != nil: // и если ошибка при чтении, то возвращаем как есть\n\t\treturn r, err\n\t}\n\n\tif checkBomExist(tmpReader) {\n\t\t//ошибку не обрабатываем, если мы здесь, то эти байты мы уже читали\n\t\ttmpReader.Read(make([]byte, cp.BomLen())) // считываем в никуда количество байт занимаемых BOM этой кодировки\n\t}\n\tif cp == UTF8 {\n\t\treturn tmpReader, nil // когда удалили BOM тогда можно вернуть UTF-8, ведь его конвертировать не нужно\n\t}\n\t//ошибку не обрабатываем, htmlindex.Get() возвращает ошибку только если не найдена кодировка, здесь это уже невозможно\n\t//здесь cp может содержать только кодировки имеющиеся в htmlindex\n\te, _ := htmlindex.Get(cp.String())\n\tr = transform.NewReader(tmpReader, e.NewDecoder())\n\treturn r, nil\n}","func Plain() Spiff {\n\treturn &spiff{\n\t\tkey: \"\",\n\t\tmode: MODE_DEFAULT,\n\t\tfeatures: features.FeatureFlags{},\n\t\tregistry: dynaml.DefaultRegistry(),\n\t}\n}","func parseText(strBytes []byte) (string, error) {\n\tif len(strBytes) == 0 {\n\t\treturn \"\", errors.New(\"empty id3 frame\")\n\t}\n\tif len(strBytes) < 2 {\n\t\t// Not an error according to the spec (because at least 1 byte big)\n\t\treturn \"\", nil\n\t}\n\tencoding, strBytes := strBytes[0], strBytes[1:]\n\n\tswitch encoding {\n\tcase 0: // ISO-8859-1 text.\n\t\treturn parseIso8859(strBytes), nil\n\n\tcase 1: // UTF-16 with BOM.\n\t\treturn parseUtf16WithBOM(strBytes)\n\n\tcase 2: // UTF-16BE without BOM.\n\t\treturn parseUtf16(strBytes, binary.BigEndian)\n\n\tcase 3: // UTF-8 text.\n\t\treturn parseUtf8(strBytes)\n\n\tdefault:\n\t\treturn \"\", id3v24Err(\"invalid encoding byte %x\", encoding)\n\t}\n}","func UnmarshalText(text []byte) (f *Filter, err error) {\n\tr := bytes.NewBuffer(text)\n\tk, n, m, err := unmarshalTextHeader(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tkeys, err := newKeysBlank(k)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = unmarshalTextKeys(r, keys)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbits, err := newBits(m)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = unmarshalTextBits(r, bits)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tf, err = newWithKeysAndBits(m, keys, bits, n)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = unmarshalAndCheckTextHash(r, f)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn f, nil\n}","func DefaultCharsetForType(tp byte) (defaultCharset string, defaultCollation string) {\n\tswitch tp {\n\tcase mysql.TypeVarString, mysql.TypeString, mysql.TypeVarchar:\n\t\t// Default charset for string types is utf8mb4.\n\t\treturn mysql.DefaultCharset, mysql.DefaultCollationName\n\t}\n\treturn charset.CharsetBin, charset.CollationBin\n}","func fromgb(in []byte) string {\n\tout := make([]byte, len(in)*4)\n\n\t_, _, err := iconv.Convert(in, out, \"gb2312\", \"utf-8\")\n\tcheck(err)\n\treturn strings.Trim(string(out), \" \\n\\r\\x00\")\n}","func NewTextMessageFromString(payload string) Message {\n\treturn NewTextMessage([]byte(payload))\n}","func testTxtData(t *testing.T) {\n\ttxtData = discovery.TxtData{\n\t\tID: clientCluster.clusterId.GetClusterID(),\n\t\tNamespace: \"default\",\n\t\tApiUrl: \"https://\" + serverCluster.cfg.Host,\n\t\tAllowUntrustedCA: true,\n\t}\n\ttxt, err := txtData.Encode()\n\tassert.NilError(t, err, \"Error encoding txtData to DNS format\")\n\n\ttxtData2, err := discovery.Decode(\"127.0.0.1\", strings.Split(serverCluster.cfg.Host, \":\")[1], txt)\n\tassert.NilError(t, err, \"Error decoding txtData from DNS format\")\n\tassert.Equal(t, txtData, *txtData2, \"TxtData before and after encoding doesn't match\")\n}","func NewSimpleTextEncoder(baseName string, differences map[CharCode]GlyphName) (SimpleEncoder, error) {\n\tfnc, ok := simple[baseName]\n\tif !ok {\n\t\tcommon.Log.Debug(\"ERROR: NewSimpleTextEncoder. Unknown encoding %q\", baseName)\n\t\treturn nil, errors.New(\"unsupported font encoding\")\n\t}\n\tenc := fnc()\n\tif len(differences) != 0 {\n\t\tenc = ApplyDifferences(enc, differences)\n\t}\n\treturn enc, nil\n}","func New(beginToken, endToken, separator string, metaTemplates []string) (TemplateEngine, error) {\n\tif len(beginToken) == 0 || len(endToken) == 0 || len(separator) == 0 || len(metaTemplates) == 0 {\n\t\treturn DummyTemplate{}, fmt.Errorf(\"invalid input, beingToken %s, endToken %s, separator = %s , metaTempaltes %v\",\n\t\t\tbeginToken, endToken, separator, metaTemplates)\n\t}\n\tt := &TextTemplate{\n\t\tbeginToken: beginToken,\n\t\tendToken: endToken,\n\t\tseparator: separator,\n\t\tmetaTemplates: metaTemplates,\n\t\tdict: map[string]interface{}{},\n\t}\n\n\tif err := t.buildTemplateTree(); err != nil {\n\t\treturn DummyTemplate{}, err\n\t}\n\n\treturn t, nil\n}","func NewText(pathname string, name dns.Name) *Text {\n\treturn &Text{\n\t\tMemory: NewMemory(),\n\t\tname: name,\n\t\tpathname: pathname,\n\t}\n}","func detectCharEncode(body []byte) CharEncode {\n\tdet := chardet.NewTextDetector()\n\tres, err := det.DetectBest(body)\n\tif err != nil {\n\t\treturn CharUnknown\n\t}\n\treturn typeOfCharEncode(res.Charset)\n}","func Parse(src []byte) (*Font, error) {\n\tface, err := truetype.Parse(bytes.NewReader(src))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed parsing truetype font: %w\", err)\n\t}\n\treturn &Font{\n\t\tfont: face,\n\t}, nil\n}","func CreatePlainCrypt() *PlainCrypt {\n\treturn &PlainCrypt{}\n}","func TestEncodeAndDecode(t *testing.T) {\n\tt.Parallel()\n\n\tcases := []struct {\n\t\tname string\n\t\tin string\n\t\tencoding Scheme\n\t\tout string\n\t}{\n\t\t{\n\t\t\tname: \"F1F2F3 v1\",\n\t\t\tin: \"\\xF1\\xF2\\xF3\",\n\t\t\tencoding: V1,\n\t\t\tout: \"wUAn\",\n\t\t},\n\t\t{\n\t\t\tname: \"F1F2F3 v2\",\n\t\t\tin: \"\\xF1\\xF2\\xF3\",\n\t\t\tencoding: V2,\n\t\t\tout: \"wUAn\",\n\t\t},\n\t\t{\n\t\t\tname: \"empty string v1\",\n\t\t\tin: \"\",\n\t\t\tencoding: V1,\n\t\t\tout: \"\",\n\t\t},\n\t\t{\n\t\t\tname: \"empty string v2\",\n\t\t\tin: \"\",\n\t\t\tencoding: V1,\n\t\t\tout: \"\",\n\t\t},\n\t\t{\n\t\t\tname: \"single char v1\",\n\t\t\tin: \"\\x00\",\n\t\t\tencoding: V1,\n\t\t\tout: \"00\",\n\t\t},\n\t\t{\n\t\t\tname: \"single char v2\",\n\t\t\tin: \"\\x00\",\n\t\t\tencoding: V2,\n\t\t\tout: \"..\",\n\t\t},\n\t\t{\n\t\t\tname: \"random string v1\",\n\t\t\tin: \"\\x67\\x9a\\x5c\\x48\\xbe\\x97\\x27\\x75\\xdf\\x6a\",\n\t\t\tencoding: V1,\n\t\t\tout: \"OtdRHAuM9rMUPV\",\n\t\t},\n\t\t{\n\t\t\tname: \"random string v2\",\n\t\t\tin: \"\\x67\\x9a\\x5c\\x48\\xbe\\x97\\x27\\x75\\xdf\\x6a\",\n\t\t\tencoding: V2,\n\t\t\tout: \"OtdRHAuM8rMUPV\",\n\t\t},\n\t}\n\n\tfor _, tt := range cases {\n\t\ttt := tt\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tt.Parallel()\n\n\t\t\tencoding := encodings[tt.encoding]\n\n\t\t\tin := []byte(tt.in)\n\t\t\tactual, err := Encode(encoding, in)\n\t\t\tif err != nil {\n\t\t\t\tt.Errorf(\"unexpected error for subtest %q: %s\", tt.name, err)\n\t\t\t}\n\t\t\texpected := tt.out\n\n\t\t\tif diff := cmp.Diff(expected, actual); diff != \"\" {\n\t\t\t\tt.Errorf(\"unexpected diff during encoding for subtest %q (-want +got): %s\", tt.name, diff)\n\t\t\t}\n\t\t})\n\t}\n}","func NewFzText() *FzText {\n\treturn (*FzText)(allocFzTextMemory(1))\n}","func NewTextDataBytes(text []byte) *Data {\n\treturn &Data{TextPlain, text}\n}","func FromStringUnsafe(s string) []byte {\n\tvar b []byte\n\tpb := (*reflect.SliceHeader)(unsafe.Pointer(&b))\n\tps := (*reflect.StringHeader)(unsafe.Pointer(&s))\n\tpb.Data = ps.Data\n\tpb.Len = ps.Len\n\tpb.Cap = ps.Len\n\treturn b\n}","func (be *CryptFS) PlainBS() uint64 {\n\treturn be.plainBS\n}","func (iv *InitialValueMode) UnmarshalText(in []byte) error {\n\tswitch mode := InitialValueMode(in); mode {\n\tcase InitialValueModeAuto,\n\t\tInitialValueModeDrop,\n\t\tInitialValueModeKeep:\n\t\t*iv = mode\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid initial value mode %q\", mode)\n\t}\n}","func FromLocal(fn string) ([]byte, error) {\n\tlog.Print(\"Reading from file\")\n\n\tf, err := os.Open(fn)\n\tif err != nil {\n\t\tlog.Printf(\"Unable to open file: %s\\n\", err.Error())\n\t\treturn nil, err\n\t}\n\n\tdefer cleanup(f)\n\tr := bufio.NewScanner(f)\n\n\treturn r.Bytes(), nil\n}","func (t *TopicType) UnmarshalText(input []byte) error {\n\treturn hexutil.UnmarshalFixedText(\"Topic\", input, t[:])\n}","func TestParseText(t *testing.T) {\n\ttests := []struct {\n\t\tname string\n\t\ttext string\n\t\texpected *Digest\n\t\texpectedErr error\n\t}{\n\t\t// Strings.\n\n\t\t{\n\t\t\tname: \"short and long strings\",\n\t\t\ttext: \"\\\"short string\\\"\\n'''long'''\\n'''string'''\",\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tString{text: []byte(\"short string\")},\n\t\t\t\tString{text: []byte(\"longstring\")},\n\t\t\t}},\n\t\t},\n\t\t{\n\t\t\tname: \"escaped strings\",\n\t\t\ttext: `\"H\\x48\\u0048\\U00000048\" '''h\\x68\\u0068\\U00000068'''`,\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tString{text: []byte(\"HHHH\")},\n\t\t\t\tString{text: []byte(\"hhhh\")},\n\t\t\t}},\n\t\t},\n\n\t\t// Symbols\n\n\t\t{\n\t\t\tname: \"symbol\",\n\t\t\ttext: \"'short symbol'\",\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tSymbol{text: []byte(\"short symbol\")},\n\t\t\t}},\n\t\t},\n\t\t{\n\t\t\tname: \"escaped symbols\",\n\t\t\ttext: `'H\\x48\\u0048\\U00000048'`,\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tSymbol{text: []byte(\"HHHH\")},\n\t\t\t}},\n\t\t},\n\n\t\t// Numeric\n\n\t\t{\n\t\t\tname: \"infinity\",\n\t\t\ttext: \"inf +inf -inf\",\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\t// \"inf\" must have a plus or minus on it to be considered a number.\n\t\t\t\tSymbol{text: []byte(\"inf\")},\n\t\t\t\tFloat{isSet: true, text: []byte(\"+inf\")},\n\t\t\t\tFloat{isSet: true, text: []byte(\"-inf\")},\n\t\t\t}},\n\t\t},\n\t\t{\n\t\t\tname: \"integers\",\n\t\t\ttext: \"0 -1 1_2_3 0xFf -0xFf 0Xe_d 0b10 -0b10 0B1_0\",\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tInt{isSet: true, text: []byte(\"0\")},\n\t\t\t\tInt{isSet: true, isNegative: true, text: []byte(\"-1\")},\n\t\t\t\tInt{isSet: true, text: []byte(\"1_2_3\")},\n\t\t\t\tInt{isSet: true, base: intBase16, text: []byte(\"0xFf\")},\n\t\t\t\tInt{isSet: true, isNegative: true, base: intBase16, text: []byte(\"-0xFf\")},\n\t\t\t\tInt{isSet: true, base: intBase16, text: []byte(\"0Xe_d\")},\n\t\t\t\tInt{isSet: true, base: intBase2, text: []byte(\"0b10\")},\n\t\t\t\tInt{isSet: true, isNegative: true, base: intBase2, text: []byte(\"-0b10\")},\n\t\t\t\tInt{isSet: true, base: intBase2, text: []byte(\"0B1_0\")},\n\t\t\t}},\n\t\t},\n\t\t{\n\t\t\tname: \"decimals\",\n\t\t\ttext: \"0. 0.123 -0.12d4 0D-0 0d+0 12_34.56_78\",\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tDecimal{isSet: true, text: []byte(\"0.\")},\n\t\t\t\tDecimal{isSet: true, text: []byte(\"0.123\")},\n\t\t\t\tDecimal{isSet: true, text: []byte(\"-0.12d4\")},\n\t\t\t\tDecimal{isSet: true, text: []byte(\"0D-0\")},\n\t\t\t\tDecimal{isSet: true, text: []byte(\"0d+0\")},\n\t\t\t\tDecimal{isSet: true, text: []byte(\"12_34.56_78\")},\n\t\t\t}},\n\t\t},\n\t\t{\n\t\t\tname: \"floats\",\n\t\t\ttext: \"0E0 0.12e-4 -0e+0\",\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tFloat{isSet: true, text: []byte(\"0E0\")},\n\t\t\t\tFloat{isSet: true, text: []byte(\"0.12e-4\")},\n\t\t\t\tFloat{isSet: true, text: []byte(\"-0e+0\")},\n\t\t\t}},\n\t\t},\n\n\t\t{\n\t\t\tname: \"dates\",\n\t\t\ttext: \"2019T 2019-10T 2019-10-30 2019-10-30T\",\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tTimestamp{precision: TimestampPrecisionYear, text: []byte(\"2019T\")},\n\t\t\t\tTimestamp{precision: TimestampPrecisionMonth, text: []byte(\"2019-10T\")},\n\t\t\t\tTimestamp{precision: TimestampPrecisionDay, text: []byte(\"2019-10-30\")},\n\t\t\t\tTimestamp{precision: TimestampPrecisionDay, text: []byte(\"2019-10-30T\")},\n\t\t\t}},\n\t\t},\n\t\t{\n\t\t\tname: \"times\",\n\t\t\ttext: \"2019-10-30T22:30Z 2019-10-30T12:30:59+02:30 2019-10-30T12:30:59.999-02:30\",\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tTimestamp{precision: TimestampPrecisionMinute, text: []byte(\"2019-10-30T22:30Z\")},\n\t\t\t\tTimestamp{precision: TimestampPrecisionSecond, text: []byte(\"2019-10-30T12:30:59+02:30\")},\n\t\t\t\tTimestamp{precision: TimestampPrecisionMillisecond3, text: []byte(\"2019-10-30T12:30:59.999-02:30\")},\n\t\t\t}},\n\t\t},\n\n\t\t// Binary.\n\n\t\t{\n\t\t\tname: \"short blob\",\n\t\t\ttext: \"{{+AB/}}\",\n\t\t\texpected: &Digest{values: []Value{Blob{text: []byte(\"+AB/\")}}},\n\t\t},\n\t\t{\n\t\t\tname: \"padded blob with whitespace\",\n\t\t\ttext: \"{{ + A\\nB\\t/abc= }}\",\n\t\t\texpected: &Digest{values: []Value{Blob{text: []byte(\"+AB/abc=\")}}},\n\t\t},\n\t\t{\n\t\t\tname: \"short clob\",\n\t\t\ttext: `{{ \"A\\n\" }}`,\n\t\t\texpected: &Digest{values: []Value{Clob{text: []byte(\"A\\n\")}}},\n\t\t},\n\t\t{\n\t\t\tname: \"long clob\",\n\t\t\ttext: \"{{ '''+AB/''' }}\",\n\t\t\texpected: &Digest{values: []Value{Clob{text: []byte(\"+AB/\")}}},\n\t\t},\n\t\t{\n\t\t\tname: \"multiple long clobs\",\n\t\t\ttext: \"{{ '''A\\\\nB'''\\n'''foo''' }}\",\n\t\t\texpected: &Digest{values: []Value{Clob{text: []byte(\"A\\nBfoo\")}}},\n\t\t},\n\t\t{\n\t\t\tname: \"escaped clobs\",\n\t\t\ttext: `{{\"H\\x48\\x48H\"}} {{'''h\\x68\\x68h'''}}`,\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tClob{text: []byte(\"HHHH\")},\n\t\t\t\tClob{text: []byte(\"hhhh\")},\n\t\t\t}},\n\t\t},\n\n\t\t// Containers\n\n\t\t{\n\t\t\tname: \"struct with symbol to symbol\",\n\t\t\ttext: `{symbol1: 'symbol', 'symbol2': symbol}`,\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tStruct{fields: []StructField{\n\t\t\t\t\t{Symbol: Symbol{text: []byte(\"symbol1\")}, Value: Symbol{quoted: true, text: []byte(\"symbol\")}},\n\t\t\t\t\t{Symbol: Symbol{quoted: true, text: []byte(\"symbol2\")}, Value: Symbol{text: []byte(\"symbol\")}},\n\t\t\t\t}},\n\t\t\t}},\n\t\t},\n\t\t{\n\t\t\tname: \"struct with annotated field\",\n\t\t\ttext: `{symbol1: ann::'symbol'}`,\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tStruct{fields: []StructField{\n\t\t\t\t\t{Symbol: Symbol{text: []byte(\"symbol1\")}, Value: Symbol{annotations: []Symbol{{text: []byte(\"ann\")}}, quoted: true, text: []byte(\"symbol\")}},\n\t\t\t\t}},\n\t\t\t}},\n\t\t},\n\t\t{\n\t\t\tname: \"struct with doubly-annotated field\",\n\t\t\ttext: `{symbol1: ann1::ann2::'symbol'}`,\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tStruct{fields: []StructField{\n\t\t\t\t\t{Symbol: Symbol{text: []byte(\"symbol1\")}, Value: Symbol{annotations: []Symbol{{text: []byte(\"ann1\")}, {text: []byte(\"ann2\")}}, quoted: true, text: []byte(\"symbol\")}},\n\t\t\t\t}},\n\t\t\t}},\n\t\t},\n\t\t{\n\t\t\tname: \"struct with comments between symbol and value\",\n\t\t\ttext: \"{abc : // Line\\n/* Block */ {{ \\\"A\\\\n\\\" }}}\",\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tStruct{fields: []StructField{\n\t\t\t\t\t{Symbol: Symbol{text: []byte(\"abc\")}, Value: Clob{text: []byte(\"A\\n\")}},\n\t\t\t\t}},\n\t\t\t}},\n\t\t},\n\n\t\t{\n\t\t\tname: \"struct with empty list, struct, and sexp\",\n\t\t\ttext: \"{a:[], b:{}, c:()}\",\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tStruct{fields: []StructField{\n\t\t\t\t\t{Symbol: Symbol{text: []byte(\"a\")}, Value: List{}},\n\t\t\t\t\t{Symbol: Symbol{text: []byte(\"b\")}, Value: Struct{}},\n\t\t\t\t\t{Symbol: Symbol{text: []byte(\"c\")}, Value: SExp{}},\n\t\t\t\t}},\n\t\t\t}},\n\t\t},\n\t\t{\n\t\t\tname: \"list with empty list, struct, and sexp\",\n\t\t\ttext: \"[[], {}, ()]\",\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tList{values: []Value{List{}, Struct{}, SExp{}}},\n\t\t\t}},\n\t\t},\n\t\t{\n\t\t\tname: \"list of things\",\n\t\t\ttext: \"[a, 1, ' ', {}, () /* comment */ ]\",\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tList{values: []Value{\n\t\t\t\t\tSymbol{text: []byte(\"a\")},\n\t\t\t\t\tInt{isSet: true, text: []byte(\"1\")},\n\t\t\t\t\tSymbol{text: []byte(\" \")},\n\t\t\t\t\tStruct{},\n\t\t\t\t\tSExp{},\n\t\t\t\t}},\n\t\t\t}},\n\t\t},\n\t\t{\n\t\t\tname: \"struct of things\",\n\t\t\ttext: \"{'a' : 1 , s:'', 'st': {}, \\n/* comment */lst:[],\\\"sexp\\\":()}\",\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tStruct{fields: []StructField{\n\t\t\t\t\t{Symbol: Symbol{text: []byte(\"a\")}, Value: Int{isSet: true, text: []byte(\"1\")}},\n\t\t\t\t\t{Symbol: Symbol{text: []byte(\"s\")}, Value: Symbol{text: []byte(\"\")}},\n\t\t\t\t\t{Symbol: Symbol{text: []byte(\"st\")}, Value: Struct{}},\n\t\t\t\t\t{Symbol: Symbol{text: []byte(\"lst\")}, Value: List{}},\n\t\t\t\t\t{Symbol: Symbol{text: []byte(\"sexp\")}, Value: SExp{}},\n\t\t\t\t}},\n\t\t\t}},\n\t\t},\n\t\t{\n\t\t\tname: \"s-expression of things\",\n\t\t\ttext: \"(a+b/c<( j * k))\",\n\t\t\texpected: &Digest{values: []Value{\n\t\t\t\tSExp{values: []Value{\n\t\t\t\t\tSymbol{text: []byte(\"a\")},\n\t\t\t\t\tSymbol{text: []byte(\"+\")},\n\t\t\t\t\tSymbol{text: []byte(\"b\")},\n\t\t\t\t\tSymbol{text: []byte(\"/\")},\n\t\t\t\t\tSymbol{text: []byte(\"c\")},\n\t\t\t\t\tSymbol{text: []byte(\"<\")},\n\t\t\t\t\tSExp{values: []Value{\n\t\t\t\t\t\tSymbol{text: []byte(\"j\")},\n\t\t\t\t\t\tSymbol{text: []byte(\"*\")},\n\t\t\t\t\t\tSymbol{text: []byte(\"k\")},\n\t\t\t\t\t}},\n\t\t\t\t}},\n\t\t\t}},\n\t\t},\n\n\t\t// Error cases\n\n\t\t{\n\t\t\tname: \"list starts with comma\",\n\t\t\ttext: \"[, [], {}, ()]\",\n\t\t\texpectedErr: errors.New(\"parsing line 1 - list may not start with a comma\"),\n\t\t},\n\t\t{\n\t\t\tname: \"struct starts with comma\",\n\t\t\ttext: \"{, a:1}\",\n\t\t\texpectedErr: errors.New(\"parsing line 1 - struct may not start with a comma\"),\n\t\t},\n\t\t{\n\t\t\tname: \"list without commas\",\n\t\t\ttext: \"[[] {} ()]\",\n\t\t\texpectedErr: errors.New(\"parsing line 1 - list items must be separated by commas\"),\n\t\t},\n\t\t{\n\t\t\tname: \"struct without commas\",\n\t\t\ttext: \"{a:1 b:2}\",\n\t\t\texpectedErr: errors.New(\"parsing line 1 - struct fields must be separated by commas\"),\n\t\t},\n\t}\n\tfor _, tst := range tests {\n\t\ttest := tst\n\t\tt.Run(test.name, func(t *testing.T) {\n\t\t\tdigest, err := ParseText(strings.NewReader(test.text))\n\t\t\tif diff := cmpDigests(test.expected, digest); diff != \"\" {\n\t\t\t\tt.Logf(\"expected: %#v\", test.expected)\n\t\t\t\tt.Logf(\"found: %#v\", digest)\n\t\t\t\tt.Error(\"(-expected, +found)\", diff)\n\t\t\t}\n\t\t\tif diff := cmpErrs(test.expectedErr, err); diff != \"\" {\n\t\t\t\tt.Error(\"err: (-expected, +found)\", diff)\n\t\t\t}\n\t\t})\n\t}\n}","func New() *Text {\n\treturn &Text{}\n}","func textEncoderDummy(w io.Writer, props properties, text []byte) (textEncoder, error) {\n\t_, err := w.Write(text)\n\treturn textEncoderDummy, err\n}","func NewColouredTextTypeChunk(text string, face font.Face, colour uint32) TypeChunk {\n\trunes := []rune{}\n\tfor _, r := range text {\n\t\trunes = append(runes, r)\n\t}\n\treturn fyTextTypeChunk{\n\t\trunes,\n\t\tface,\n\t\tcolour,\n\t}\n}","func ISO8859_1toUTF8(in string) (out string, err error) {\n\t// create a Reader using the input string as Reader and ISO8859 decoder\n\tdecoded := transform.NewReader(strings.NewReader(in), charmap.ISO8859_1.NewDecoder())\n\tdecodedBytes, err := ioutil.ReadAll(decoded)\n\tif err != nil {\n\t\treturn\n\t}\n\tout = string(decodedBytes)\n\treturn\n}","func PlainText(w http.ResponseWriter, r *http.Request, v string) {\n\trender.PlainText(w, r, v)\n}","func NewFromCSV(headers, columns []string) types.Document {\n\tfb := NewFieldBuffer()\n\tfor i, h := range headers {\n\t\tif i >= len(columns) {\n\t\t\tbreak\n\t\t}\n\n\t\tfb.Add(h, types.NewTextValue(columns[i]))\n\t}\n\n\treturn fb\n}","func (c *Plain) Safe() bool {\n\treturn true\n}","func isText(s []byte) bool {\n\tconst max = 1024 // at least utf8.UTFMax\n\tif len(s) > max {\n\t\ts = s[0:max]\n\t}\n\tfor i, c := range string(s) {\n\t\tif i+utf8.UTFMax > len(s) {\n\t\t\t// last char may be incomplete - ignore\n\t\t\tbreak\n\t\t}\n\t\tif c == 0xFFFD || c < ' ' && c != '\\n' && c != '\\t' && c != '\\f' {\n\t\t\t// decoding error or control character - not a text file\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}","func convertCP(in string) (out string) {\n\tbuf := new(bytes.Buffer)\n\tw, err := charset.NewWriter(\"windows-1252\", buf)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Fprintf(w, in)\n\tw.Close()\n\n\tout = fmt.Sprintf(\"%s\", buf)\n\treturn out\n}","func (self *CommitMessagePanelDriver) InitialText(expected *TextMatcher) *CommitMessagePanelDriver {\n\treturn self.Content(expected)\n}","func (sm *CumulativeMonotonicSumMode) UnmarshalText(in []byte) error {\n\tswitch mode := CumulativeMonotonicSumMode(in); mode {\n\tcase CumulativeMonotonicSumModeToDelta,\n\t\tCumulativeMonotonicSumModeRawValue:\n\t\t*sm = mode\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid cumulative monotonic sum mode %q\", mode)\n\t}\n}","func (text *Text) Plainf(format string, a ...interface{}) *Text {\n\treturn text.Plain(fmt.Sprintf(format, a...))\n}","func FormatBytes(src []byte, invalid []byte, invalidWidth int, isJSON, isRaw bool, sep, quote rune) *Value {\n\tres := &Value{\n\t\tTabs: make([][][2]int, 1),\n\t}\n\tvar tmp [4]byte\n\tvar r rune\n\tvar l, w int\n\tfor ; len(src) > 0; src = src[w:] {\n\t\tr, w = rune(src[0]), 1\n\t\t// lazy decode\n\t\tif r >= utf8.RuneSelf {\n\t\t\tr, w = utf8.DecodeRune(src)\n\t\t}\n\t\t// invalid rune decoded\n\t\tif w == 1 && r == utf8.RuneError {\n\t\t\t// replace with invalid (if set), otherwise hex encode\n\t\t\tif invalid != nil {\n\t\t\t\tres.Buf = append(res.Buf, invalid...)\n\t\t\t\tres.Width += invalidWidth\n\t\t\t\tres.Quoted = true\n\t\t\t} else {\n\t\t\t\tres.Buf = append(res.Buf, '\\\\', 'x', lowerhex[src[0]>>4], lowerhex[src[0]&0xf])\n\t\t\t\tres.Width += 4\n\t\t\t\tres.Quoted = true\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\t// handle json encoding\n\t\tif isJSON {\n\t\t\tswitch r {\n\t\t\tcase '\\t':\n\t\t\t\tres.Buf = append(res.Buf, '\\\\', 't')\n\t\t\t\tres.Width += 2\n\t\t\t\tcontinue\n\t\t\tcase '\\n':\n\t\t\t\tres.Buf = append(res.Buf, '\\\\', 'n')\n\t\t\t\tres.Width += 2\n\t\t\t\tcontinue\n\t\t\tcase '\\\\':\n\t\t\t\tres.Buf = append(res.Buf, '\\\\', '\\\\')\n\t\t\t\tres.Width += 2\n\t\t\t\tcontinue\n\t\t\tcase '\"':\n\t\t\t\tres.Buf = append(res.Buf, '\\\\', '\"')\n\t\t\t\tres.Width += 2\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\t// handle raw encoding\n\t\tif isRaw {\n\t\t\tn := utf8.EncodeRune(tmp[:], r)\n\t\t\tres.Buf = append(res.Buf, tmp[:n]...)\n\t\t\tres.Width += runewidth.RuneWidth(r)\n\t\t\tswitch {\n\t\t\tcase r == sep:\n\t\t\t\tres.Quoted = true\n\t\t\tcase r == quote && quote != 0:\n\t\t\t\tres.Buf = append(res.Buf, tmp[:n]...)\n\t\t\t\tres.Width += runewidth.RuneWidth(r)\n\t\t\t\tres.Quoted = true\n\t\t\tdefault:\n\t\t\t\tres.Quoted = res.Quoted || unicode.IsSpace(r)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\t// printable character\n\t\tif strconv.IsGraphic(r) {\n\t\t\tn := utf8.EncodeRune(tmp[:], r)\n\t\t\tres.Buf = append(res.Buf, tmp[:n]...)\n\t\t\tres.Width += runewidth.RuneWidth(r)\n\t\t\tcontinue\n\t\t}\n\t\tswitch r {\n\t\t// escape \\a \\b \\f \\r \\v (Go special characters)\n\t\tcase '\\a':\n\t\t\tres.Buf = append(res.Buf, '\\\\', 'a')\n\t\t\tres.Width += 2\n\t\tcase '\\b':\n\t\t\tres.Buf = append(res.Buf, '\\\\', 'b')\n\t\t\tres.Width += 2\n\t\tcase '\\f':\n\t\t\tres.Buf = append(res.Buf, '\\\\', 'f')\n\t\t\tres.Width += 2\n\t\tcase '\\r':\n\t\t\tres.Buf = append(res.Buf, '\\\\', 'r')\n\t\t\tres.Width += 2\n\t\tcase '\\v':\n\t\t\tres.Buf = append(res.Buf, '\\\\', 'v')\n\t\t\tres.Width += 2\n\t\tcase '\\t':\n\t\t\t// save position\n\t\t\tres.Tabs[l] = append(res.Tabs[l], [2]int{len(res.Buf), res.Width})\n\t\t\tres.Buf = append(res.Buf, '\\t')\n\t\t\tres.Width = 0\n\t\tcase '\\n':\n\t\t\t// save position\n\t\t\tres.Newlines = append(res.Newlines, [2]int{len(res.Buf), res.Width})\n\t\t\tres.Buf = append(res.Buf, '\\n')\n\t\t\tres.Width = 0\n\t\t\t// increase line count\n\t\t\tres.Tabs = append(res.Tabs, nil)\n\t\t\tl++\n\t\tdefault:\n\t\t\tswitch {\n\t\t\t// escape as \\x00\n\t\t\tcase r < ' ':\n\t\t\t\tres.Buf = append(res.Buf, '\\\\', 'x', lowerhex[byte(r)>>4], lowerhex[byte(r)&0xf])\n\t\t\t\tres.Width += 4\n\t\t\t// escape as \\u0000\n\t\t\tcase r > utf8.MaxRune:\n\t\t\t\tr = 0xfffd\n\t\t\t\tfallthrough\n\t\t\tcase r < 0x10000:\n\t\t\t\tres.Buf = append(res.Buf, '\\\\', 'u')\n\t\t\t\tfor s := 12; s >= 0; s -= 4 {\n\t\t\t\t\tres.Buf = append(res.Buf, lowerhex[r>>uint(s)&0xf])\n\t\t\t\t}\n\t\t\t\tres.Width += 6\n\t\t\t// escape as \\U00000000\n\t\t\tdefault:\n\t\t\t\tres.Buf = append(res.Buf, '\\\\', 'U')\n\t\t\t\tfor s := 28; s >= 0; s -= 4 {\n\t\t\t\t\tres.Buf = append(res.Buf, lowerhex[r>>uint(s)&0xf])\n\t\t\t\t}\n\t\t\t\tres.Width += 10\n\t\t\t}\n\t\t}\n\t}\n\treturn res\n}","func (p *TOMLParser) FromBytes(byteData []byte) (interface{}, error) {\n\tvar data interface{}\n\tif err := toml.Unmarshal(byteData, &data); err != nil {\n\t\treturn data, fmt.Errorf(\"could not unmarshal data: %w\", err)\n\t}\n\treturn &BasicSingleDocument{\n\t\tValue: data,\n\t}, nil\n}","func sanitizeText(str string) string {\n\t// count bytes in output & check whether modification is required\n\tnlen := 0\n\tmustmod := false\n\tfor _, r := range []rune(str) {\n\t\toutrune := cleanRune(r)\n\t\tif outrune != '\\000' {\n\t\t\tnlen++\n\t\t}\n\t\tif outrune != r {\n\t\t\tmustmod = true\n\t\t}\n\t}\n\n\t// if no modification is required, use the original string\n\tif !mustmod {\n\t\treturn str\n\t}\n\n\t// build new string\n\tnstr := make([]byte, nlen)\n\ti := 0\n\tfor _, r := range []rune(str) {\n\t\toutrune := cleanRune(r)\n\t\tif outrune != '\\000' {\n\t\t\tnstr[i] = byte(outrune)\n\t\t\ti++\n\t\t}\n\t}\n\n\t// unsafe convert byte slice to string\n\treturn *(*string)(unsafe.Pointer(&reflect.StringHeader{\n\t\tData: uintptr(unsafe.Pointer(&nstr[0])),\n\t\tLen: len(nstr),\n\t}))\n}","func (m Message) EncodedText() (*field.EncodedTextField, quickfix.MessageRejectError) {\n\tf := &field.EncodedTextField{}\n\terr := m.Body.Get(f)\n\treturn f, err\n}","func (m Message) EncodedText() (*field.EncodedTextField, quickfix.MessageRejectError) {\n\tf := &field.EncodedTextField{}\n\terr := m.Body.Get(f)\n\treturn f, err\n}","func (m Message) EncodedText() (*field.EncodedTextField, quickfix.MessageRejectError) {\n\tf := &field.EncodedTextField{}\n\terr := m.Body.Get(f)\n\treturn f, err\n}","func (m Message) EncodedText() (*field.EncodedTextField, quickfix.MessageRejectError) {\n\tf := &field.EncodedTextField{}\n\terr := m.Body.Get(f)\n\treturn f, err\n}","func (m Message) EncodedText() (*field.EncodedTextField, quickfix.MessageRejectError) {\n\tf := &field.EncodedTextField{}\n\terr := m.Body.Get(f)\n\treturn f, err\n}","func (m Message) EncodedText() (*field.EncodedTextField, quickfix.MessageRejectError) {\n\tf := &field.EncodedTextField{}\n\terr := m.Body.Get(f)\n\treturn f, err\n}","func NewFzTextRef(ref unsafe.Pointer) *FzText {\n\treturn (*FzText)(ref)\n}","func DefaultStrConv() (ret *StrConv) {\n\tvar (\n\t\tb []byte\n\t\tr []rune\n\t)\n\n\treturn &StrConv{\n\t\tByType: map[reflect.Type]ConvFunc{\n\t\t\treflect.TypeOf(b): StringConverter,\n\t\t\treflect.TypeOf(r): StringConverter,\n\t\t},\n\t\tByKind: map[reflect.Kind]ConvFunc{\n\t\t\treflect.Bool: BoolConverter,\n\t\t\treflect.Int: IntDecConverter,\n\t\t\treflect.Int8: IntDecConverter,\n\t\t\treflect.Int16: IntDecConverter,\n\t\t\treflect.Int32: IntDecConverter,\n\t\t\treflect.Int64: IntDecConverter,\n\t\t\treflect.Uint: UintDecConverter,\n\t\t\treflect.Uint8: UintDecConverter,\n\t\t\treflect.Uint16: UintDecConverter,\n\t\t\treflect.Uint32: UintDecConverter,\n\t\t\treflect.Uint64: UintDecConverter,\n\t\t\treflect.Float32: FloatConverter,\n\t\t\treflect.Float64: FloatConverter,\n\t\t\treflect.String: StringConverter,\n\t\t},\n\t}\n}"],"string":"[\n \"func ReadPlainBytes(b []byte) ByteReadScanner {\\n\\treturn bytes.NewReader(b)\\n}\",\n \"func FromHTML(content []byte) string {\\n\\tif cset := FromBOM(content); cset != \\\"\\\" {\\n\\t\\treturn cset\\n\\t}\\n\\tif cset := fromHTML(content); cset != \\\"\\\" {\\n\\t\\treturn cset\\n\\t}\\n\\treturn FromPlain(content)\\n}\",\n \"func CreatePlainMessage(t string) Message {\\n\\treturn Message{\\n\\t\\tPayload: string(t),\\n\\t\\tType: 0,\\n\\t}\\n}\",\n \"func (cs *CsvStructure) checkForConvertToUtf8(textBytes []byte) (outBytes []byte) {\\n\\tvar strByte []byte\\n\\tvar err error\\n\\toutBytes = make([]byte, len(textBytes))\\n\\tcopy(outBytes, textBytes)\\n\\t_, cs.Charset, _ = charset.DetermineEncoding(textBytes, \\\"\\\")\\n\\t// fmt.Println(cs.Charset)\\n\\tif cs.Charset != \\\"utf-8\\\" { // convert to UTF-8\\n\\t\\tif reader, err := charset.NewReader(strings.NewReader(string(textBytes)), cs.Charset); err == nil {\\n\\t\\t\\tif strByte, err = ioutil.ReadAll(reader); err == nil {\\n\\t\\t\\t\\toutBytes = make([]byte, len(strByte))\\n\\t\\t\\t\\tcopy(outBytes, strByte)\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\tif err != nil {\\n\\t\\tfmt.Println(\\\"Error while trying to convert %s to utf-8: \\\", cs.Charset)\\n\\t}\\n\\treturn outBytes\\n}\",\n \"func AcceptPlain(pw string) (EncodedPasswd, error) {\\n\\treturn &plainPassword{pw}, nil\\n}\",\n \"func (text *Text) Plain(content string) *Text {\\n\\ttext.Spans = append(text.Spans, Span{\\n\\t\\tContent: content,\\n\\t})\\n\\treturn text\\n}\",\n \"func Text(raw []byte, limit uint32) bool {\\n\\t// First look for BOM.\\n\\tif cset := charset.FromBOM(raw); cset != \\\"\\\" {\\n\\t\\treturn true\\n\\t}\\n\\t// Binary data bytes as defined here: https://mimesniff.spec.whatwg.org/#binary-data-byte\\n\\tfor _, b := range raw {\\n\\t\\tif b <= 0x08 ||\\n\\t\\t\\tb == 0x0B ||\\n\\t\\t\\t0x0E <= b && b <= 0x1A ||\\n\\t\\t\\t0x1C <= b && b <= 0x1F {\\n\\t\\t\\treturn false\\n\\t\\t}\\n\\t}\\n\\treturn true\\n}\",\n \"func correctEncodingToUtf8(text []byte) []byte {\\n\\tr, err := charset.NewReader(bytes.NewBuffer(text), \\\"application/xml\\\")\\n\\tif err != nil {\\n\\t\\tfmt.Println(\\\"Error converting encoding:\\\", err)\\n\\t\\treturn nil\\n\\t}\\n\\ttext, _ = ioutil.ReadAll(r)\\n\\treturn text\\n}\",\n \"func (be *ContentEnc) PlainBS() uint64 {\\n\\treturn be.plainBS\\n}\",\n \"func (in *ActionMailTemplateTranslationUpdateInput) SetTextPlain(value string) *ActionMailTemplateTranslationUpdateInput {\\n\\tin.TextPlain = value\\n\\n\\tif in._selectedParameters == nil {\\n\\t\\tin._selectedParameters = make(map[string]interface{})\\n\\t}\\n\\n\\tin._selectedParameters[\\\"TextPlain\\\"] = nil\\n\\treturn in\\n}\",\n \"func (w *Wallet) GetPlain() (psw, content string, err error) {\\n\\tbase64Decoded, err := base64.StdEncoding.DecodeString(w.CipherContent)\\n\\tif err != nil {\\n\\t\\treturn\\n\\t}\\n\\n\\tcontentBytes, err := crypto.AESDecrypt(base64Decoded, passWd)\\n\\tif err != nil {\\n\\t\\treturn\\n\\t}\\n\\n\\tcontent = util.String(contentBytes)\\n\\n\\tbase64Decoded, err = base64.StdEncoding.DecodeString(w.CipherPSW)\\n\\tif err != nil {\\n\\t\\treturn\\n\\t}\\n\\n\\tpswBytes, err := crypto.AESDecrypt(base64Decoded, passWd)\\n\\tif err != nil {\\n\\t\\treturn\\n\\t}\\n\\n\\tpsw = util.String(pswBytes)\\n\\treturn\\n}\",\n \"func New(cc *cryptocore.CryptoCore, plainBS uint64, forceDecode bool) *ContentEnc {\\n\\tcipherBS := plainBS + uint64(cc.IVLen) + cryptocore.AuthTagLen\\n\\n\\treturn &ContentEnc{\\n\\t\\tcryptoCore: cc,\\n\\t\\tplainBS: plainBS,\\n\\t\\tcipherBS: cipherBS,\\n\\t\\tallZeroBlock: make([]byte, cipherBS),\\n\\t\\tallZeroNonce: make([]byte, cc.IVLen),\\n\\t\\tforceDecode: forceDecode,\\n\\t}\\n}\",\n \"func NewDataFrameFromTextMessage(msg string, mask bool) (*DataFrame, error) {\\n\\tdf := &DataFrame{\\n\\t\\tpayload: []byte(msg),\\n\\t\\tmask: mask,\\n\\t\\tfin: true,\\n\\t\\tOpCode: OpCodeText,\\n\\t\\tpayloadLen: len(msg),\\n\\t}\\n\\treturn df, nil\\n}\",\n \"func PlainText(s string) Response {\\n\\treturn stringResponse{s}\\n}\",\n \"func TestText(t *testing.T) {\\n\\tinput := \\\"Hello world!\\\"\\n\\tresult := Text(input)\\n\\n\\tif !strings.EqualFold(input, result) {\\n\\t\\tt.Errorf(\\\"Should have same content except capitalisation: \\\\\\\"%s\\\\\\\" - \\\\\\\"%s\\\\\\\"\\\", input, result)\\n\\t}\\n}\",\n \"func fromTextPb(_ *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {\\n\\tvar ctor starlark.Value\\n\\tvar text starlark.String\\n\\tif err := starlark.UnpackArgs(\\\"from_textpb\\\", args, kwargs, \\\"ctor\\\", &ctor, \\\"text\\\", &text); err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tc, ok := ctor.(*messageCtor)\\n\\tif !ok {\\n\\t\\treturn nil, fmt.Errorf(\\\"from_textpb: got %s, expecting a proto message constructor\\\", ctor.Type())\\n\\t}\\n\\ttyp := c.typ\\n\\n\\tprotoMsg := typ.NewProtoMessage().Interface().(proto.Message)\\n\\tif err := proto.UnmarshalText(text.GoString(), protoMsg); err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"from_textpb: %s\\\", err)\\n\\t}\\n\\n\\tmsg := NewMessage(typ)\\n\\tif err := msg.FromProto(protoMsg); err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"from_textpb: %s\\\", err)\\n\\t}\\n\\treturn msg, nil\\n}\",\n \"func NewTextMail(msg *mail.Message) (*TextMailMessage, error) {\\n\\t_, params, err := mime.ParseMediaType(msg.Header.Get(\\\"Content-Type\\\"))\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tdata, err := DecodeText(msg.Body, params[\\\"charset\\\"])\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\tt := &TextMailMessage{\\n\\t\\tbody: msg.Body,\\n\\t\\theader: msg.Header,\\n\\t\\ttext: data,\\n\\t}\\n\\treturn t, nil\\n}\",\n \"func (ckms *CKMS) DecryptRaw(cipherText []byte) ([]byte, error) {\\n\\n\\tresult, err := ckms.svc.Decrypt(&kms.DecryptInput{CiphertextBlob: cipherText})\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\treturn result.Plaintext, nil\\n}\",\n \"func FromBOM(content []byte) string {\\n\\tfor _, b := range boms {\\n\\t\\tif bytes.HasPrefix(content, b.bom) {\\n\\t\\t\\treturn b.enc\\n\\t\\t}\\n\\t}\\n\\treturn \\\"\\\"\\n}\",\n \"func GetUTF8Body(body []byte, contentType string,\\n\\tignoreInvalidUTF8Chars bool) (string, error) {\\n\\t// Detect charset.\\n\\tcs, err := DetectCharset(body, contentType)\\n\\tif err != nil {\\n\\t\\tif !ignoreInvalidUTF8Chars {\\n\\t\\t\\treturn \\\"\\\", err\\n\\t\\t}\\n\\t\\tcs = \\\"utf-8\\\"\\n\\t}\\n\\n\\t// Remove utf8.RuneError if ignoreInvalidUTF8Chars is true.\\n\\tbs := string(body)\\n\\tif ignoreInvalidUTF8Chars {\\n\\t\\tif !utf8.ValidString(bs) {\\n\\t\\t\\tv := make([]rune, 0, len(bs))\\n\\t\\t\\tfor i, r := range bs {\\n\\t\\t\\t\\tif r == utf8.RuneError {\\n\\t\\t\\t\\t\\t_, size := utf8.DecodeRuneInString(bs[i:])\\n\\t\\t\\t\\t\\tif size == 1 {\\n\\t\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tv = append(v, r)\\n\\t\\t\\t}\\n\\t\\t\\tbs = string(v)\\n\\t\\t}\\n\\t}\\n\\n\\t// Convert body.\\n\\tconverted, err := iconv.ConvertString(bs, cs, \\\"utf-8\\\")\\n\\tif err != nil && !strings.Contains(converted, \\\"\\\") {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\n\\treturn converted, nil\\n}\",\n \"func (sc *serverConn) authPlain() error {\\n\\tm := &msg{\\n\\t\\theader: header{\\n\\t\\t\\tOp: opAuthStart,\\n\\t\\t},\\n\\n\\t\\tkey: \\\"PLAIN\\\",\\n\\t\\tval: fmt.Sprintf(\\\"\\\\x00%s\\\\x00%s\\\", sc.username, sc.password),\\n\\t}\\n\\n\\treturn sc.sendRecv(m)\\n}\",\n \"func TestLoadedSimpleFontEncoding(t *testing.T) {\\n\\trawpdf := `\\n59 0 obj\\n<>\\nendobj\\n60 0 obj\\n<>\\nendobj\\n`\\n\\n\\tobjects, err := testutils.ParseIndirectObjects(rawpdf)\\n\\tif err != nil {\\n\\t\\tt.Fatalf(\\\"Error: %v\\\", err)\\n\\t}\\n\\n\\tfont, err := model.NewPdfFontFromPdfObject(objects[59])\\n\\tif err != nil {\\n\\t\\tt.Fatalf(\\\"Error: %v\\\", err)\\n\\t}\\n\\n\\t// The expected encoding is StandardEncoding with the applied differences.\\n\\tbaseEncoding := newStandandTextEncoder(t)\\n\\n\\tdifferencesMap := map[textencoding.CharCode]rune{\\n\\t\\t24: '˘',\\n\\t\\t25: 'ˇ',\\n\\t\\t26: 'ˆ',\\n\\t\\t27: '˙',\\n\\t\\t28: '˝',\\n\\t\\t29: '˛',\\n\\t\\t30: '˚',\\n\\t\\t31: '˜',\\n\\t\\t39: '\\\\'',\\n\\t\\t96: '`',\\n\\t\\t128: '•',\\n\\t\\t129: '†',\\n\\t\\t130: '‡',\\n\\t\\t131: '…',\\n\\t\\t132: '—',\\n\\t\\t133: '–',\\n\\t\\t134: 'ƒ',\\n\\t\\t135: '⁄',\\n\\t\\t136: '‹',\\n\\t\\t137: '›',\\n\\t\\t138: '−',\\n\\t\\t139: '‰',\\n\\t\\t140: '„',\\n\\t\\t141: '“',\\n\\t\\t142: '”',\\n\\t\\t143: '‘',\\n\\t\\t144: '’',\\n\\t\\t145: '‚',\\n\\t\\t146: '™',\\n\\t\\t147: 'fi',\\n\\t\\t148: 'fl',\\n\\t\\t149: 'Ł',\\n\\t\\t150: 'Œ',\\n\\t\\t151: 'Š',\\n\\t\\t152: 'Ÿ',\\n\\t\\t153: 'Ž',\\n\\t\\t154: 'ı',\\n\\t\\t155: 'ł',\\n\\t\\t156: 'œ',\\n\\t\\t157: 'š',\\n\\t\\t158: 'ž',\\n\\t\\t160: '€',\\n\\t\\t164: '¤',\\n\\t\\t166: '¦',\\n\\t\\t168: '¨',\\n\\t\\t169: '©',\\n\\t\\t170: 'ª',\\n\\t\\t172: '¬',\\n\\t\\t173: '�',\\n\\t\\t174: '®',\\n\\t\\t175: '¯',\\n\\t\\t176: '°',\\n\\t\\t177: '±',\\n\\t\\t178: '²',\\n\\t\\t179: '³',\\n\\t\\t180: '´',\\n\\t\\t181: 'µ',\\n\\t\\t183: '·',\\n\\t\\t184: '¸',\\n\\t\\t185: '¹',\\n\\t\\t186: 'º',\\n\\t\\t188: '¼',\\n\\t\\t189: '½',\\n\\t\\t190: '¾',\\n\\t\\t192: 'À',\\n\\t\\t193: 'Á',\\n\\t\\t194: 'Â',\\n\\t\\t195: 'Ã',\\n\\t\\t196: 'Ä',\\n\\t\\t197: 'Å',\\n\\t\\t198: 'Æ',\\n\\t\\t199: 'Ç',\\n\\t\\t200: 'È',\\n\\t\\t201: 'É',\\n\\t\\t202: 'Ê',\\n\\t\\t203: 'Ë',\\n\\t\\t204: 'Ì',\\n\\t\\t205: 'Í',\\n\\t\\t206: 'Î',\\n\\t\\t207: 'Ï',\\n\\t\\t208: 'Ð',\\n\\t\\t209: 'Ñ',\\n\\t\\t210: 'Ò',\\n\\t\\t211: 'Ó',\\n\\t\\t212: 'Ô',\\n\\t\\t213: 'Õ',\\n\\t\\t214: 'Ö',\\n\\t\\t215: '×',\\n\\t\\t216: 'Ø',\\n\\t\\t217: 'Ù',\\n\\t\\t218: 'Ú',\\n\\t\\t219: 'Û',\\n\\t\\t220: 'Ü',\\n\\t\\t221: 'Ý',\\n\\t\\t222: 'Þ',\\n\\t\\t223: 'ß',\\n\\t\\t224: 'à',\\n\\t\\t225: 'á',\\n\\t\\t226: 'â',\\n\\t\\t227: 'ã',\\n\\t\\t228: 'ä',\\n\\t\\t229: 'å',\\n\\t\\t230: 'æ',\\n\\t\\t231: 'ç',\\n\\t\\t232: 'è',\\n\\t\\t233: 'é',\\n\\t\\t234: 'ê',\\n\\t\\t235: 'ë',\\n\\t\\t236: 'ì',\\n\\t\\t237: 'í',\\n\\t\\t238: 'î',\\n\\t\\t239: 'ï',\\n\\t\\t240: 'ð',\\n\\t\\t241: 'ñ',\\n\\t\\t242: 'ò',\\n\\t\\t243: 'ó',\\n\\t\\t244: 'ô',\\n\\t\\t245: 'õ',\\n\\t\\t246: 'ö',\\n\\t\\t247: '÷',\\n\\t\\t248: 'ø',\\n\\t\\t249: 'ù',\\n\\t\\t250: 'ú',\\n\\t\\t251: 'û',\\n\\t\\t252: 'ü',\\n\\t\\t253: 'ý',\\n\\t\\t254: 'þ',\\n\\t\\t255: 'ÿ',\\n\\t}\\n\\n\\tenc := font.Encoder()\\n\\tfor code := textencoding.CharCode(32); code < 255; code++ {\\n\\t\\tfontrune, has := enc.CharcodeToRune(code)\\n\\t\\tif !has {\\n\\t\\t\\tbaserune, bad := baseEncoding.CharcodeToRune(code)\\n\\t\\t\\tif bad {\\n\\t\\t\\t\\tt.Fatalf(\\\"font not having glyph for char code %d - whereas base encoding had %q\\\", code, baserune)\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\t// Check if in differencesmap first.\\n\\t\\trune, has := differencesMap[code]\\n\\t\\tif has {\\n\\t\\t\\tif rune != fontrune {\\n\\t\\t\\t\\tt.Fatalf(\\\"Mismatch for char code %d, font has: %q and expected is: %q (differences)\\\", code, fontrune, rune)\\n\\t\\t\\t}\\n\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\n\\t\\t// If not in differences, should be according to StandardEncoding (base).\\n\\t\\trune, has = baseEncoding.CharcodeToRune(code)\\n\\t\\tif has && rune != fontrune {\\n\\t\\t\\tt.Fatalf(\\\"Mismatch for char code %d (%X), font has: %q and expected is: %q (StandardEncoding)\\\", code, code, fontrune, rune)\\n\\t\\t}\\n\\t}\\n}\",\n \"func plainText(h http.HandlerFunc) http.HandlerFunc {\\n\\treturn func(w http.ResponseWriter, r *http.Request) {\\n\\t\\tw.Header().Add(\\\"Content-Type\\\", \\\"text/plain; charset=utf-8\\\")\\n\\t\\th(w, r)\\n\\t}\\n}\",\n \"func (c *Cell) PlainText(b *bytes.Buffer) string {\\n\\tn := len(c.P)\\n\\tif n == 1 {\\n\\t\\treturn c.P[0].PlainText(b)\\n\\t}\\n\\n\\tb.Reset()\\n\\tfor i := range c.P {\\n\\t\\tif i != n-1 {\\n\\t\\t\\tc.P[i].writePlainText(b)\\n\\t\\t\\tb.WriteByte('\\\\n')\\n\\t\\t} else {\\n\\t\\t\\tc.P[i].writePlainText(b)\\n\\t\\t}\\n\\t}\\n\\treturn b.String()\\n}\",\n \"func DetectCharset(body []byte, contentType string) (string, error) {\\n\\t// 1. Use charset.DetermineEncoding\\n\\t_, name, certain := charset.DetermineEncoding(body, contentType)\\n\\tif certain {\\n\\t\\treturn name, nil\\n\\t}\\n\\n\\t// Handle uncertain cases\\n\\t// 2. Use chardet.Detector.DetectBest\\n\\tr, err := chardet.NewHtmlDetector().DetectBest(body)\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\tif r.Confidence == 100 {\\n\\t\\treturn strings.ToLower(r.Charset), nil\\n\\t}\\n\\n\\t// 3. Parse meta tag for Content-Type\\n\\troot, err := html.Parse(bytes.NewReader(body))\\n\\tif err != nil {\\n\\t\\treturn \\\"\\\", err\\n\\t}\\n\\tdoc := goquery.NewDocumentFromNode(root)\\n\\tvar csFromMeta string\\n\\tdoc.Find(\\\"meta\\\").EachWithBreak(func(i int, s *goquery.Selection) bool {\\n\\t\\t// \\n\\t\\tif c, exists := s.Attr(\\\"content\\\"); exists && strings.Contains(c, \\\"charset\\\") {\\n\\t\\t\\tif _, params, err := mime.ParseMediaType(c); err == nil {\\n\\t\\t\\t\\tif cs, ok := params[\\\"charset\\\"]; ok {\\n\\t\\t\\t\\t\\tcsFromMeta = strings.ToLower(cs)\\n\\t\\t\\t\\t\\t// Handle Korean charsets.\\n\\t\\t\\t\\t\\tif csFromMeta == \\\"ms949\\\" || csFromMeta == \\\"cp949\\\" {\\n\\t\\t\\t\\t\\t\\tcsFromMeta = \\\"euc-kr\\\"\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\treturn false\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\treturn true\\n\\t\\t}\\n\\n\\t\\t// \\n\\t\\tif c, exists := s.Attr(\\\"charset\\\"); exists {\\n\\t\\t\\tcsFromMeta = c\\n\\t\\t\\treturn false\\n\\t\\t}\\n\\n\\t\\treturn true\\n\\t})\\n\\n\\tif csFromMeta == \\\"\\\" {\\n\\t\\treturn \\\"\\\", fmt.Errorf(\\\"failed to detect charset\\\")\\n\\t}\\n\\n\\treturn csFromMeta, nil\\n}\",\n \"func NewDummyCipher(b []byte, k int) (Cipher, error) {\\n\\treturn &DummyCipher{}, nil\\n}\",\n \"func (w *Wallet) SetPlain(psw, content string) (err error) {\\n\\n\\taesBytes, err := crypto.AESEncrypt(util.Slice(content), passWd)\\n\\tif err != nil {\\n\\t\\treturn\\n\\t}\\n\\n\\tw.CipherContent = base64.StdEncoding.EncodeToString(aesBytes)\\n\\n\\taesBytes, err = crypto.AESEncrypt(util.Slice(psw), passWd)\\n\\tif err != nil {\\n\\t\\treturn\\n\\t}\\n\\n\\tw.CipherPSW = base64.StdEncoding.EncodeToString(aesBytes)\\n\\treturn\\n}\",\n \"func Body(body, contentType, transferEncoding string, opt Options) (string, error) {\\n\\t// attempt to do some base64-decoding anyway\\n\\tif decoded, err := base64.URLEncoding.DecodeString(body); err == nil {\\n\\t\\tbody = string(decoded)\\n\\t}\\n\\tif decoded, err := base64.StdEncoding.DecodeString(body); err == nil {\\n\\t\\tbody = string(decoded)\\n\\t}\\n\\n\\tif strings.ToLower(transferEncoding) == \\\"quoted-printable\\\" {\\n\\t\\tb, err := ioutil.ReadAll(quotedprintable.NewReader(strings.NewReader(body)))\\n\\t\\tif err != nil {\\n\\t\\t\\treturn \\\"\\\", err\\n\\t\\t}\\n\\t\\tbody = string(b)\\n\\t}\\n\\n\\tct := strings.ToLower(contentType)\\n\\tif strings.Contains(ct, \\\"multipart/\\\") {\\n\\t\\treturn parseMultipart(body, contentType, opt)\\n\\t}\\n\\n\\tif !opt.SkipHTML && strings.Contains(ct, \\\"text/html\\\") {\\n\\t\\tbody = stripHTML(body, opt)\\n\\t}\\n\\n\\tbody = stripEmbedded(body, opt)\\n\\tif opt.LineLimit > 0 || opt.ColLimit > 0 {\\n\\t\\tlines := strings.Split(body, \\\"\\\\n\\\")\\n\\t\\tif len(lines) > opt.LineLimit {\\n\\t\\t\\tlines = lines[:opt.LineLimit]\\n\\t\\t}\\n\\t\\tfor kk, l := range lines {\\n\\t\\t\\tif len(l) > opt.ColLimit {\\n\\t\\t\\t\\tlines[kk] = l[:opt.ColLimit]\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\tbody = strings.Join(lines, \\\"\\\\n\\\")\\n\\t}\\n\\treturn body, nil\\n}\",\n \"func PlainText(h http.Handler) http.Handler {\\n\\tfn := func(w http.ResponseWriter, r *http.Request) {\\n\\t\\tw.Header().Set(\\\"Content-Type\\\", \\\"text/plain\\\")\\n\\t\\th.ServeHTTP(w, r)\\n\\t}\\n\\treturn http.HandlerFunc(fn)\\n}\",\n \"func FromMultipart(body []byte, boundary string) Mimes {\\n\\tmi := make(Mimes, 0, 10)\\n\\tsr := bytes.NewReader(body)\\n\\tmr := multipart.NewReader(sr, boundary)\\n\\tfor {\\n\\t\\tp, err := mr.NextPart()\\n\\t\\tif err == io.EOF {\\n\\t\\t\\treturn mi\\n\\t\\t}\\n\\t\\tif err != nil {\\n\\t\\t\\tlog.Printf(\\\"mimedata.IsMultipart: malformed multipart MIME: %v\\\\n\\\", err)\\n\\t\\t\\treturn mi\\n\\t\\t}\\n\\t\\tb, err := ioutil.ReadAll(p)\\n\\t\\tif err != nil {\\n\\t\\t\\tlog.Printf(\\\"mimedata.IsMultipart: bad ReadAll of multipart MIME: %v\\\\n\\\", err)\\n\\t\\t\\treturn mi\\n\\t\\t}\\n\\t\\td := Data{}\\n\\t\\td.Type = p.Header.Get(ContentType)\\n\\t\\tcte := p.Header.Get(ContentTransferEncoding)\\n\\t\\tif cte != \\\"\\\" {\\n\\t\\t\\tswitch cte {\\n\\t\\t\\tcase \\\"base64\\\":\\n\\t\\t\\t\\teb := make([]byte, base64.StdEncoding.DecodedLen(len(b)))\\n\\t\\t\\t\\tbase64.StdEncoding.Decode(eb, b)\\n\\t\\t\\t\\tb = eb\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\td.Data = b\\n\\t\\tmi = append(mi, &d)\\n\\t}\\n\\treturn mi\\n}\",\n \"func NewPlain(section string, operation *MetricOperation, success, uniDecode bool) *Plain {\\n\\toperationSanitized := make([]string, cap(operation.operations))\\n\\tfor k, v := range operation.operations {\\n\\t\\toperationSanitized[k] = SanitizeMetricName(v, uniDecode)\\n\\t}\\n\\treturn &Plain{SanitizeMetricName(section, uniDecode), strings.Join(operationSanitized, \\\".\\\"), success}\\n}\",\n \"func New(in []byte) (*SecurityTxt, error) {\\n\\tmsg, err := NewSignedMessage(in)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\ttxt := &SecurityTxt{\\n\\t\\tsigned: msg.Signed(),\\n\\t}\\n\\n\\t// Note: try and collect as many fields as possible and as many errors as possible\\n\\t// Output should be human-readable error report.\\n\\n\\terr = Parse(msg.Message(), txt)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\t// Caller should deal with parsing errors\\n\\treturn txt, nil\\n}\",\n \"func (b *Builder) AddTextPlain(text []byte) {\\n\\tb.AddTextPart(text)\\n}\",\n \"func PlainParser(r io.Reader, set func(name, value string) error) error {\\n\\ts := bufio.NewScanner(r)\\n\\tfor s.Scan() {\\n\\t\\tline := strings.TrimSpace(s.Text())\\n\\t\\tif line == \\\"\\\" {\\n\\t\\t\\tcontinue // skip empties\\n\\t\\t}\\n\\n\\t\\tif line[0] == '#' {\\n\\t\\t\\tcontinue // skip comments\\n\\t\\t}\\n\\n\\t\\tvar (\\n\\t\\t\\tname string\\n\\t\\t\\tvalue string\\n\\t\\t\\tindex = strings.IndexRune(line, ' ')\\n\\t\\t)\\n\\t\\tif index < 0 {\\n\\t\\t\\tname, value = line, \\\"true\\\" // boolean option\\n\\t\\t} else {\\n\\t\\t\\tname, value = line[:index], strings.TrimSpace(line[index:])\\n\\t\\t}\\n\\n\\t\\tif i := strings.Index(value, \\\" #\\\"); i >= 0 {\\n\\t\\t\\tvalue = strings.TrimSpace(value[:i])\\n\\t\\t}\\n\\n\\t\\tif err := set(name, value); err != nil {\\n\\t\\t\\treturn err\\n\\t\\t}\\n\\t}\\n\\treturn nil\\n}\",\n \"func PlainParser(r io.Reader, set func(name, value string) error) error {\\n\\ts := bufio.NewScanner(r)\\n\\tfor s.Scan() {\\n\\t\\tline := strings.TrimSpace(s.Text())\\n\\t\\tif line == \\\"\\\" {\\n\\t\\t\\tcontinue // skip empties\\n\\t\\t}\\n\\n\\t\\tif line[0] == '#' {\\n\\t\\t\\tcontinue // skip comments\\n\\t\\t}\\n\\n\\t\\tvar (\\n\\t\\t\\tname string\\n\\t\\t\\tvalue string\\n\\t\\t\\tindex = strings.IndexRune(line, ' ')\\n\\t\\t)\\n\\t\\tif index < 0 {\\n\\t\\t\\tname, value = line, \\\"true\\\" // boolean option\\n\\t\\t} else {\\n\\t\\t\\tname, value = line[:index], strings.TrimSpace(line[index:])\\n\\t\\t}\\n\\n\\t\\tif i := strings.Index(value, \\\" #\\\"); i >= 0 {\\n\\t\\t\\tvalue = strings.TrimSpace(value[:i])\\n\\t\\t}\\n\\n\\t\\tif err := set(name, value); err != nil {\\n\\t\\t\\treturn err\\n\\t\\t}\\n\\t}\\n\\treturn s.Err()\\n}\",\n \"func NewCorrupter(w io.Writer) *Corrupter {\\n\\treturn &Corrupter{w: w, b: make([]byte, utf8.MaxRune)}\\n}\",\n \"func (p *Plain) Parse(data []byte) (T, error) {\\n\\tt := newPlainT(p.archetypes)\\n\\n\\t//convert to string and remove spaces according to unicode\\n\\tstr := strings.TrimRightFunc(string(data), unicode.IsSpace)\\n\\n\\t//creat element\\n\\te := NewElement(str)\\n\\n\\t//set it as single table value\\n\\tt.Set(\\\".0\\\", e)\\n\\n\\treturn t, nil\\n}\",\n \"func From(s string) *Buffer {\\n\\treturn &Buffer{b: []byte(s)}\\n}\",\n \"func FromXML(content []byte) string {\\n\\tif cset := fromXML(content); cset != \\\"\\\" {\\n\\t\\treturn cset\\n\\t}\\n\\treturn FromPlain(content)\\n}\",\n \"func FromBytes(content []byte, pkg string, w io.Writer) error {\\n\\tbundle := i18n.NewBundle(language.English)\\n\\tbundle.RegisterUnmarshalFunc(\\\"json\\\", json.Unmarshal)\\n\\n\\t// Load source language\\n\\tmessageFile, err := bundle.ParseMessageFileBytes(content, \\\"en.json\\\")\\n\\tif err != nil {\\n\\t\\treturn err\\n\\t}\\n\\n\\treturn generate(messageFile, pkg, w)\\n}\",\n \"func StringFromCharset(length int, charset string) (string, error) {\\n\\tresult := make([]byte, length) // Random string to return\\n\\tcharsetlen := big.NewInt(int64(len(charset)))\\n\\n\\tfor i := 0; i < length; i++ {\\n\\t\\tb, err := rand.Int(rand.Reader, charsetlen)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn \\\"\\\", err\\n\\t\\t}\\n\\t\\tr := int(b.Int64())\\n\\t\\tresult[i] = charset[r]\\n\\t}\\n\\n\\treturn string(result), nil\\n}\",\n \"func (p Piece) GetPlain() Piece {\\n\\treturn p & 0xf\\n}\",\n \"func RejectPlain(pw string) (EncodedPasswd, error) {\\n\\treturn nil, fmt.Errorf(\\\"plain password rejected: %s\\\", pw)\\n}\",\n \"func (b *Builder) Plain(s string) *Builder {\\n\\tb.message.WriteString(s)\\n\\treturn b\\n}\",\n \"func NewBuffer(data string) Buffer {\\n\\tif len(data) == 0 {\\n\\t\\treturn nilBuffer\\n\\t}\\n\\tvar (\\n\\t\\tidx = 0\\n\\t\\tbuf8 = make([]byte, 0, len(data))\\n\\t\\tbuf16 []uint16\\n\\t\\tbuf32 []rune\\n\\t)\\n\\tfor idx < len(data) {\\n\\t\\tr, s := utf8.DecodeRuneInString(data[idx:])\\n\\t\\tidx += s\\n\\t\\tif r < utf8.RuneSelf {\\n\\t\\t\\tbuf8 = append(buf8, byte(r))\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\t\\tif r <= 0xffff {\\n\\t\\t\\tbuf16 = make([]uint16, len(buf8), len(data))\\n\\t\\t\\tfor i, v := range buf8 {\\n\\t\\t\\t\\tbuf16[i] = uint16(v)\\n\\t\\t\\t}\\n\\t\\t\\tbuf8 = nil\\n\\t\\t\\tbuf16 = append(buf16, uint16(r))\\n\\t\\t\\tgoto copy16\\n\\t\\t}\\n\\t\\tbuf32 = make([]rune, len(buf8), len(data))\\n\\t\\tfor i, v := range buf8 {\\n\\t\\t\\tbuf32[i] = rune(uint32(v))\\n\\t\\t}\\n\\t\\tbuf8 = nil\\n\\t\\tbuf32 = append(buf32, r)\\n\\t\\tgoto copy32\\n\\t}\\n\\treturn &asciiBuffer{\\n\\t\\tarr: buf8,\\n\\t}\\ncopy16:\\n\\tfor idx < len(data) {\\n\\t\\tr, s := utf8.DecodeRuneInString(data[idx:])\\n\\t\\tidx += s\\n\\t\\tif r <= 0xffff {\\n\\t\\t\\tbuf16 = append(buf16, uint16(r))\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\t\\tbuf32 = make([]rune, len(buf16), len(data))\\n\\t\\tfor i, v := range buf16 {\\n\\t\\t\\tbuf32[i] = rune(uint32(v))\\n\\t\\t}\\n\\t\\tbuf16 = nil\\n\\t\\tbuf32 = append(buf32, r)\\n\\t\\tgoto copy32\\n\\t}\\n\\treturn &basicBuffer{\\n\\t\\tarr: buf16,\\n\\t}\\ncopy32:\\n\\tfor idx < len(data) {\\n\\t\\tr, s := utf8.DecodeRuneInString(data[idx:])\\n\\t\\tidx += s\\n\\t\\tbuf32 = append(buf32, r)\\n\\t}\\n\\treturn &supplementalBuffer{\\n\\t\\tarr: buf32,\\n\\t}\\n}\",\n \"func NewTextData(text string) *Data {\\n\\treturn &Data{TextPlain, []byte(text)}\\n}\",\n \"func (m MAC) PlainString() string {\\n\\tconst hexDigit = \\\"0123456789abcdef\\\"\\n\\tbuf := make([]byte, 0, len(m)*2)\\n\\tfor _, b := range m {\\n\\t\\tbuf = append(buf, hexDigit[b>>4])\\n\\t\\tbuf = append(buf, hexDigit[b&0xF])\\n\\t}\\n\\treturn string(buf)\\n}\",\n \"func TestLoadStandardFontEncodings(t *testing.T) {\\n\\traw := `\\n\\t1 0 obj\\n\\t<< /Type /Font\\n\\t\\t/BaseFont /Courier\\n\\t\\t/Subtype /Type1\\n\\t>>\\n\\tendobj\\n\\t`\\n\\n\\tr := model.NewReaderForText(raw)\\n\\n\\terr := r.ParseIndObjSeries()\\n\\tif err != nil {\\n\\t\\tt.Fatalf(\\\"Failed loading indirect object series: %v\\\", err)\\n\\t}\\n\\n\\t// Load the field from object number 1.\\n\\tobj, err := r.GetIndirectObjectByNumber(1)\\n\\tif err != nil {\\n\\t\\tt.Fatalf(\\\"Failed to parse indirect obj (%s)\\\", err)\\n\\t}\\n\\n\\tfont, err := model.NewPdfFontFromPdfObject(obj)\\n\\tif err != nil {\\n\\t\\tt.Fatalf(\\\"Error: %v\\\", err)\\n\\t}\\n\\n\\tstr := \\\"Aabcdefg0123456790*\\\"\\n\\tfor _, r := range str {\\n\\t\\t_, has := font.GetRuneMetrics(r)\\n\\t\\tif !has {\\n\\t\\t\\tt.Fatalf(\\\"Loaded simple font not having glyph char metrics for %v\\\", r)\\n\\t\\t}\\n\\t}\\n}\",\n \"func PlainText(s string) ([]store.Measurement, error) {\\n\\tnow := time.Now()\\n\\tret := []store.Measurement{}\\n\\tlines := strings.Split(s, \\\"\\\\n\\\")\\n\\tfor _, l := range lines {\\n\\t\\tparts := strings.Split(l, \\\" \\\")\\n\\t\\tif len(parts) != 2 {\\n\\t\\t\\treturn nil, fmt.Errorf(\\\"Invalid input line format: %q\\\", l)\\n\\t\\t}\\n\\t\\tkey := parts[0]\\n\\t\\tvalue, err := strconv.ParseInt(parts[1], 10, 64)\\n\\t\\tif err != nil {\\n\\t\\t\\treturn nil, fmt.Errorf(\\\"Invalid value format: %q\\\", l)\\n\\t\\t}\\n\\t\\tret = append(ret, store.Measurement{\\n\\t\\t\\tKey: key,\\n\\t\\t\\tPoint: ts.Point{\\n\\t\\t\\t\\tTimestamp: now.Unix(),\\n\\t\\t\\t\\tValue: value,\\n\\t\\t\\t},\\n\\t\\t})\\n\\t}\\n\\treturn ret, nil\\n}\",\n \"func PlainText(content string) TextLit {\\n\\treturn TextLit{Suffix: content}\\n}\",\n \"func NewText(text string) Mimes {\\n\\tmd := NewTextData(text)\\n\\tmi := make(Mimes, 1)\\n\\tmi[0] = md\\n\\treturn mi\\n}\",\n \"func NewReaderFromText(name string, text string) *Reader {\\n\\tnoExternalNewlines := strings.Trim(text, \\\"\\\\n\\\")\\n\\treturn &Reader{\\n\\t\\tname: &name,\\n\\t\\tlines: strings.Split(noExternalNewlines, \\\"\\\\n\\\"),\\n\\t\\tlock: &sync.Mutex{},\\n\\t}\\n}\",\n \"func (downloader *HTTPDownloader) changeCharsetEncodingAuto(contentTypeStr string, sor io.ReadCloser) string {\\r\\n\\tvar err error\\r\\n\\tdestReader, err := charset.NewReader(sor, contentTypeStr)\\r\\n\\r\\n\\tif err != nil {\\r\\n\\t\\tmlog.LogInst().LogError(err.Error())\\r\\n\\t\\tdestReader = sor\\r\\n\\t}\\r\\n\\r\\n\\tvar sorbody []byte\\r\\n\\tif sorbody, err = ioutil.ReadAll(destReader); err != nil {\\r\\n\\t\\tmlog.LogInst().LogError(err.Error())\\r\\n\\t\\t// For gb2312, an error will be returned.\\r\\n\\t\\t// Error like: simplifiedchinese: invalid GBK encoding\\r\\n\\t\\t// return \\\"\\\"\\r\\n\\t}\\r\\n\\t//e,name,certain := charset.DetermineEncoding(sorbody,contentTypeStr)\\r\\n\\tbodystr := string(sorbody)\\r\\n\\r\\n\\treturn bodystr\\r\\n}\",\n \"func Test_fromNetASCII(t *testing.T) {\\n\\tvar tests = []struct {\\n\\t\\tin []byte\\n\\t\\tout []byte\\n\\t}{\\n\\t\\t{\\n\\t\\t\\tin: nil,\\n\\t\\t\\tout: nil,\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tin: []byte{'a', 'b', 'c'},\\n\\t\\t\\tout: []byte{'a', 'b', 'c'},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tin: []byte{'a', '\\\\r', '\\\\n', 'b', '\\\\r', '\\\\n', 'c'},\\n\\t\\t\\tout: []byte{'a', '\\\\n', 'b', '\\\\n', 'c'},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tin: []byte{'a', '\\\\r', 0, 'b', '\\\\r', 0, 'c'},\\n\\t\\t\\tout: []byte{'a', '\\\\r', 'b', '\\\\r', 'c'},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tin: []byte{'a', '\\\\r', 0, 'b', '\\\\r', '\\\\n', 'c'},\\n\\t\\t\\tout: []byte{'a', '\\\\r', 'b', '\\\\n', 'c'},\\n\\t\\t},\\n\\t\\t// TODO(mdlayher): determine if it possible for a carriage return to\\n\\t\\t// be the last character in a buffer. For the time being, we perform\\n\\t\\t// no conversion if this is the case.\\n\\t\\t{\\n\\t\\t\\tin: []byte{'a', '\\\\r'},\\n\\t\\t\\tout: []byte{'a', '\\\\r'},\\n\\t\\t},\\n\\t}\\n\\n\\tfor i, tt := range tests {\\n\\t\\tif want, got := tt.out, fromNetASCII(tt.in); !bytes.Equal(want, got) {\\n\\t\\t\\tt.Fatalf(\\\"[%02d] unexpected fromNetASCII conversion:\\\\n- want: %v\\\\n- got: %v\\\",\\n\\t\\t\\t\\ti, want, got)\\n\\t\\t}\\n\\t}\\n}\",\n \"func NewReader(r io.Reader, cpn ...string) (io.Reader, error) {\\n\\tif r == nil {\\n\\t\\treturn r, errInputIsNil\\n\\t}\\n\\ttmpReader := bufio.NewReader(r)\\n\\tvar err error\\n\\tcp := ASCII\\n\\tif len(cpn) > 0 {\\n\\t\\tcp = codepageByName(cpn[0])\\n\\t}\\n\\tif cp == ASCII {\\n\\t\\tcp, err = CodepageDetect(tmpReader)\\n\\t}\\n\\t//TODO внимательно нужно посмотреть что может вернуть CodepageDetect()\\n\\t//эти случаи обработать, например через func unsupportedCodepageToDecode(cp)\\n\\tswitch {\\n\\tcase (cp == UTF32) || (cp == UTF32BE) || (cp == UTF32LE):\\n\\t\\treturn r, errUnsupportedCodepage\\n\\tcase cp == ASCII: // кодировку определить не удалось, неизвестную кодировку возвращаем как есть\\n\\t\\treturn r, errUnknown\\n\\tcase err != nil: // и если ошибка при чтении, то возвращаем как есть\\n\\t\\treturn r, err\\n\\t}\\n\\n\\tif checkBomExist(tmpReader) {\\n\\t\\t//ошибку не обрабатываем, если мы здесь, то эти байты мы уже читали\\n\\t\\ttmpReader.Read(make([]byte, cp.BomLen())) // считываем в никуда количество байт занимаемых BOM этой кодировки\\n\\t}\\n\\tif cp == UTF8 {\\n\\t\\treturn tmpReader, nil // когда удалили BOM тогда можно вернуть UTF-8, ведь его конвертировать не нужно\\n\\t}\\n\\t//ошибку не обрабатываем, htmlindex.Get() возвращает ошибку только если не найдена кодировка, здесь это уже невозможно\\n\\t//здесь cp может содержать только кодировки имеющиеся в htmlindex\\n\\te, _ := htmlindex.Get(cp.String())\\n\\tr = transform.NewReader(tmpReader, e.NewDecoder())\\n\\treturn r, nil\\n}\",\n \"func Plain() Spiff {\\n\\treturn &spiff{\\n\\t\\tkey: \\\"\\\",\\n\\t\\tmode: MODE_DEFAULT,\\n\\t\\tfeatures: features.FeatureFlags{},\\n\\t\\tregistry: dynaml.DefaultRegistry(),\\n\\t}\\n}\",\n \"func parseText(strBytes []byte) (string, error) {\\n\\tif len(strBytes) == 0 {\\n\\t\\treturn \\\"\\\", errors.New(\\\"empty id3 frame\\\")\\n\\t}\\n\\tif len(strBytes) < 2 {\\n\\t\\t// Not an error according to the spec (because at least 1 byte big)\\n\\t\\treturn \\\"\\\", nil\\n\\t}\\n\\tencoding, strBytes := strBytes[0], strBytes[1:]\\n\\n\\tswitch encoding {\\n\\tcase 0: // ISO-8859-1 text.\\n\\t\\treturn parseIso8859(strBytes), nil\\n\\n\\tcase 1: // UTF-16 with BOM.\\n\\t\\treturn parseUtf16WithBOM(strBytes)\\n\\n\\tcase 2: // UTF-16BE without BOM.\\n\\t\\treturn parseUtf16(strBytes, binary.BigEndian)\\n\\n\\tcase 3: // UTF-8 text.\\n\\t\\treturn parseUtf8(strBytes)\\n\\n\\tdefault:\\n\\t\\treturn \\\"\\\", id3v24Err(\\\"invalid encoding byte %x\\\", encoding)\\n\\t}\\n}\",\n \"func UnmarshalText(text []byte) (f *Filter, err error) {\\n\\tr := bytes.NewBuffer(text)\\n\\tk, n, m, err := unmarshalTextHeader(r)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tkeys, err := newKeysBlank(k)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\terr = unmarshalTextKeys(r, keys)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tbits, err := newBits(m)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\terr = unmarshalTextBits(r, bits)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tf, err = newWithKeysAndBits(m, keys, bits, n)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\terr = unmarshalAndCheckTextHash(r, f)\\n\\tif err != nil {\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\treturn f, nil\\n}\",\n \"func DefaultCharsetForType(tp byte) (defaultCharset string, defaultCollation string) {\\n\\tswitch tp {\\n\\tcase mysql.TypeVarString, mysql.TypeString, mysql.TypeVarchar:\\n\\t\\t// Default charset for string types is utf8mb4.\\n\\t\\treturn mysql.DefaultCharset, mysql.DefaultCollationName\\n\\t}\\n\\treturn charset.CharsetBin, charset.CollationBin\\n}\",\n \"func fromgb(in []byte) string {\\n\\tout := make([]byte, len(in)*4)\\n\\n\\t_, _, err := iconv.Convert(in, out, \\\"gb2312\\\", \\\"utf-8\\\")\\n\\tcheck(err)\\n\\treturn strings.Trim(string(out), \\\" \\\\n\\\\r\\\\x00\\\")\\n}\",\n \"func NewTextMessageFromString(payload string) Message {\\n\\treturn NewTextMessage([]byte(payload))\\n}\",\n \"func testTxtData(t *testing.T) {\\n\\ttxtData = discovery.TxtData{\\n\\t\\tID: clientCluster.clusterId.GetClusterID(),\\n\\t\\tNamespace: \\\"default\\\",\\n\\t\\tApiUrl: \\\"https://\\\" + serverCluster.cfg.Host,\\n\\t\\tAllowUntrustedCA: true,\\n\\t}\\n\\ttxt, err := txtData.Encode()\\n\\tassert.NilError(t, err, \\\"Error encoding txtData to DNS format\\\")\\n\\n\\ttxtData2, err := discovery.Decode(\\\"127.0.0.1\\\", strings.Split(serverCluster.cfg.Host, \\\":\\\")[1], txt)\\n\\tassert.NilError(t, err, \\\"Error decoding txtData from DNS format\\\")\\n\\tassert.Equal(t, txtData, *txtData2, \\\"TxtData before and after encoding doesn't match\\\")\\n}\",\n \"func NewSimpleTextEncoder(baseName string, differences map[CharCode]GlyphName) (SimpleEncoder, error) {\\n\\tfnc, ok := simple[baseName]\\n\\tif !ok {\\n\\t\\tcommon.Log.Debug(\\\"ERROR: NewSimpleTextEncoder. Unknown encoding %q\\\", baseName)\\n\\t\\treturn nil, errors.New(\\\"unsupported font encoding\\\")\\n\\t}\\n\\tenc := fnc()\\n\\tif len(differences) != 0 {\\n\\t\\tenc = ApplyDifferences(enc, differences)\\n\\t}\\n\\treturn enc, nil\\n}\",\n \"func New(beginToken, endToken, separator string, metaTemplates []string) (TemplateEngine, error) {\\n\\tif len(beginToken) == 0 || len(endToken) == 0 || len(separator) == 0 || len(metaTemplates) == 0 {\\n\\t\\treturn DummyTemplate{}, fmt.Errorf(\\\"invalid input, beingToken %s, endToken %s, separator = %s , metaTempaltes %v\\\",\\n\\t\\t\\tbeginToken, endToken, separator, metaTemplates)\\n\\t}\\n\\tt := &TextTemplate{\\n\\t\\tbeginToken: beginToken,\\n\\t\\tendToken: endToken,\\n\\t\\tseparator: separator,\\n\\t\\tmetaTemplates: metaTemplates,\\n\\t\\tdict: map[string]interface{}{},\\n\\t}\\n\\n\\tif err := t.buildTemplateTree(); err != nil {\\n\\t\\treturn DummyTemplate{}, err\\n\\t}\\n\\n\\treturn t, nil\\n}\",\n \"func NewText(pathname string, name dns.Name) *Text {\\n\\treturn &Text{\\n\\t\\tMemory: NewMemory(),\\n\\t\\tname: name,\\n\\t\\tpathname: pathname,\\n\\t}\\n}\",\n \"func detectCharEncode(body []byte) CharEncode {\\n\\tdet := chardet.NewTextDetector()\\n\\tres, err := det.DetectBest(body)\\n\\tif err != nil {\\n\\t\\treturn CharUnknown\\n\\t}\\n\\treturn typeOfCharEncode(res.Charset)\\n}\",\n \"func Parse(src []byte) (*Font, error) {\\n\\tface, err := truetype.Parse(bytes.NewReader(src))\\n\\tif err != nil {\\n\\t\\treturn nil, fmt.Errorf(\\\"failed parsing truetype font: %w\\\", err)\\n\\t}\\n\\treturn &Font{\\n\\t\\tfont: face,\\n\\t}, nil\\n}\",\n \"func CreatePlainCrypt() *PlainCrypt {\\n\\treturn &PlainCrypt{}\\n}\",\n \"func TestEncodeAndDecode(t *testing.T) {\\n\\tt.Parallel()\\n\\n\\tcases := []struct {\\n\\t\\tname string\\n\\t\\tin string\\n\\t\\tencoding Scheme\\n\\t\\tout string\\n\\t}{\\n\\t\\t{\\n\\t\\t\\tname: \\\"F1F2F3 v1\\\",\\n\\t\\t\\tin: \\\"\\\\xF1\\\\xF2\\\\xF3\\\",\\n\\t\\t\\tencoding: V1,\\n\\t\\t\\tout: \\\"wUAn\\\",\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"F1F2F3 v2\\\",\\n\\t\\t\\tin: \\\"\\\\xF1\\\\xF2\\\\xF3\\\",\\n\\t\\t\\tencoding: V2,\\n\\t\\t\\tout: \\\"wUAn\\\",\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"empty string v1\\\",\\n\\t\\t\\tin: \\\"\\\",\\n\\t\\t\\tencoding: V1,\\n\\t\\t\\tout: \\\"\\\",\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"empty string v2\\\",\\n\\t\\t\\tin: \\\"\\\",\\n\\t\\t\\tencoding: V1,\\n\\t\\t\\tout: \\\"\\\",\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"single char v1\\\",\\n\\t\\t\\tin: \\\"\\\\x00\\\",\\n\\t\\t\\tencoding: V1,\\n\\t\\t\\tout: \\\"00\\\",\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"single char v2\\\",\\n\\t\\t\\tin: \\\"\\\\x00\\\",\\n\\t\\t\\tencoding: V2,\\n\\t\\t\\tout: \\\"..\\\",\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"random string v1\\\",\\n\\t\\t\\tin: \\\"\\\\x67\\\\x9a\\\\x5c\\\\x48\\\\xbe\\\\x97\\\\x27\\\\x75\\\\xdf\\\\x6a\\\",\\n\\t\\t\\tencoding: V1,\\n\\t\\t\\tout: \\\"OtdRHAuM9rMUPV\\\",\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"random string v2\\\",\\n\\t\\t\\tin: \\\"\\\\x67\\\\x9a\\\\x5c\\\\x48\\\\xbe\\\\x97\\\\x27\\\\x75\\\\xdf\\\\x6a\\\",\\n\\t\\t\\tencoding: V2,\\n\\t\\t\\tout: \\\"OtdRHAuM8rMUPV\\\",\\n\\t\\t},\\n\\t}\\n\\n\\tfor _, tt := range cases {\\n\\t\\ttt := tt\\n\\t\\tt.Run(tt.name, func(t *testing.T) {\\n\\t\\t\\tt.Parallel()\\n\\n\\t\\t\\tencoding := encodings[tt.encoding]\\n\\n\\t\\t\\tin := []byte(tt.in)\\n\\t\\t\\tactual, err := Encode(encoding, in)\\n\\t\\t\\tif err != nil {\\n\\t\\t\\t\\tt.Errorf(\\\"unexpected error for subtest %q: %s\\\", tt.name, err)\\n\\t\\t\\t}\\n\\t\\t\\texpected := tt.out\\n\\n\\t\\t\\tif diff := cmp.Diff(expected, actual); diff != \\\"\\\" {\\n\\t\\t\\t\\tt.Errorf(\\\"unexpected diff during encoding for subtest %q (-want +got): %s\\\", tt.name, diff)\\n\\t\\t\\t}\\n\\t\\t})\\n\\t}\\n}\",\n \"func NewFzText() *FzText {\\n\\treturn (*FzText)(allocFzTextMemory(1))\\n}\",\n \"func NewTextDataBytes(text []byte) *Data {\\n\\treturn &Data{TextPlain, text}\\n}\",\n \"func FromStringUnsafe(s string) []byte {\\n\\tvar b []byte\\n\\tpb := (*reflect.SliceHeader)(unsafe.Pointer(&b))\\n\\tps := (*reflect.StringHeader)(unsafe.Pointer(&s))\\n\\tpb.Data = ps.Data\\n\\tpb.Len = ps.Len\\n\\tpb.Cap = ps.Len\\n\\treturn b\\n}\",\n \"func (be *CryptFS) PlainBS() uint64 {\\n\\treturn be.plainBS\\n}\",\n \"func (iv *InitialValueMode) UnmarshalText(in []byte) error {\\n\\tswitch mode := InitialValueMode(in); mode {\\n\\tcase InitialValueModeAuto,\\n\\t\\tInitialValueModeDrop,\\n\\t\\tInitialValueModeKeep:\\n\\t\\t*iv = mode\\n\\t\\treturn nil\\n\\tdefault:\\n\\t\\treturn fmt.Errorf(\\\"invalid initial value mode %q\\\", mode)\\n\\t}\\n}\",\n \"func FromLocal(fn string) ([]byte, error) {\\n\\tlog.Print(\\\"Reading from file\\\")\\n\\n\\tf, err := os.Open(fn)\\n\\tif err != nil {\\n\\t\\tlog.Printf(\\\"Unable to open file: %s\\\\n\\\", err.Error())\\n\\t\\treturn nil, err\\n\\t}\\n\\n\\tdefer cleanup(f)\\n\\tr := bufio.NewScanner(f)\\n\\n\\treturn r.Bytes(), nil\\n}\",\n \"func (t *TopicType) UnmarshalText(input []byte) error {\\n\\treturn hexutil.UnmarshalFixedText(\\\"Topic\\\", input, t[:])\\n}\",\n \"func TestParseText(t *testing.T) {\\n\\ttests := []struct {\\n\\t\\tname string\\n\\t\\ttext string\\n\\t\\texpected *Digest\\n\\t\\texpectedErr error\\n\\t}{\\n\\t\\t// Strings.\\n\\n\\t\\t{\\n\\t\\t\\tname: \\\"short and long strings\\\",\\n\\t\\t\\ttext: \\\"\\\\\\\"short string\\\\\\\"\\\\n'''long'''\\\\n'''string'''\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tString{text: []byte(\\\"short string\\\")},\\n\\t\\t\\t\\tString{text: []byte(\\\"longstring\\\")},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"escaped strings\\\",\\n\\t\\t\\ttext: `\\\"H\\\\x48\\\\u0048\\\\U00000048\\\" '''h\\\\x68\\\\u0068\\\\U00000068'''`,\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tString{text: []byte(\\\"HHHH\\\")},\\n\\t\\t\\t\\tString{text: []byte(\\\"hhhh\\\")},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\n\\t\\t// Symbols\\n\\n\\t\\t{\\n\\t\\t\\tname: \\\"symbol\\\",\\n\\t\\t\\ttext: \\\"'short symbol'\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tSymbol{text: []byte(\\\"short symbol\\\")},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"escaped symbols\\\",\\n\\t\\t\\ttext: `'H\\\\x48\\\\u0048\\\\U00000048'`,\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tSymbol{text: []byte(\\\"HHHH\\\")},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\n\\t\\t// Numeric\\n\\n\\t\\t{\\n\\t\\t\\tname: \\\"infinity\\\",\\n\\t\\t\\ttext: \\\"inf +inf -inf\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\t// \\\"inf\\\" must have a plus or minus on it to be considered a number.\\n\\t\\t\\t\\tSymbol{text: []byte(\\\"inf\\\")},\\n\\t\\t\\t\\tFloat{isSet: true, text: []byte(\\\"+inf\\\")},\\n\\t\\t\\t\\tFloat{isSet: true, text: []byte(\\\"-inf\\\")},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"integers\\\",\\n\\t\\t\\ttext: \\\"0 -1 1_2_3 0xFf -0xFf 0Xe_d 0b10 -0b10 0B1_0\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tInt{isSet: true, text: []byte(\\\"0\\\")},\\n\\t\\t\\t\\tInt{isSet: true, isNegative: true, text: []byte(\\\"-1\\\")},\\n\\t\\t\\t\\tInt{isSet: true, text: []byte(\\\"1_2_3\\\")},\\n\\t\\t\\t\\tInt{isSet: true, base: intBase16, text: []byte(\\\"0xFf\\\")},\\n\\t\\t\\t\\tInt{isSet: true, isNegative: true, base: intBase16, text: []byte(\\\"-0xFf\\\")},\\n\\t\\t\\t\\tInt{isSet: true, base: intBase16, text: []byte(\\\"0Xe_d\\\")},\\n\\t\\t\\t\\tInt{isSet: true, base: intBase2, text: []byte(\\\"0b10\\\")},\\n\\t\\t\\t\\tInt{isSet: true, isNegative: true, base: intBase2, text: []byte(\\\"-0b10\\\")},\\n\\t\\t\\t\\tInt{isSet: true, base: intBase2, text: []byte(\\\"0B1_0\\\")},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"decimals\\\",\\n\\t\\t\\ttext: \\\"0. 0.123 -0.12d4 0D-0 0d+0 12_34.56_78\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tDecimal{isSet: true, text: []byte(\\\"0.\\\")},\\n\\t\\t\\t\\tDecimal{isSet: true, text: []byte(\\\"0.123\\\")},\\n\\t\\t\\t\\tDecimal{isSet: true, text: []byte(\\\"-0.12d4\\\")},\\n\\t\\t\\t\\tDecimal{isSet: true, text: []byte(\\\"0D-0\\\")},\\n\\t\\t\\t\\tDecimal{isSet: true, text: []byte(\\\"0d+0\\\")},\\n\\t\\t\\t\\tDecimal{isSet: true, text: []byte(\\\"12_34.56_78\\\")},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"floats\\\",\\n\\t\\t\\ttext: \\\"0E0 0.12e-4 -0e+0\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tFloat{isSet: true, text: []byte(\\\"0E0\\\")},\\n\\t\\t\\t\\tFloat{isSet: true, text: []byte(\\\"0.12e-4\\\")},\\n\\t\\t\\t\\tFloat{isSet: true, text: []byte(\\\"-0e+0\\\")},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\n\\t\\t{\\n\\t\\t\\tname: \\\"dates\\\",\\n\\t\\t\\ttext: \\\"2019T 2019-10T 2019-10-30 2019-10-30T\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tTimestamp{precision: TimestampPrecisionYear, text: []byte(\\\"2019T\\\")},\\n\\t\\t\\t\\tTimestamp{precision: TimestampPrecisionMonth, text: []byte(\\\"2019-10T\\\")},\\n\\t\\t\\t\\tTimestamp{precision: TimestampPrecisionDay, text: []byte(\\\"2019-10-30\\\")},\\n\\t\\t\\t\\tTimestamp{precision: TimestampPrecisionDay, text: []byte(\\\"2019-10-30T\\\")},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"times\\\",\\n\\t\\t\\ttext: \\\"2019-10-30T22:30Z 2019-10-30T12:30:59+02:30 2019-10-30T12:30:59.999-02:30\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tTimestamp{precision: TimestampPrecisionMinute, text: []byte(\\\"2019-10-30T22:30Z\\\")},\\n\\t\\t\\t\\tTimestamp{precision: TimestampPrecisionSecond, text: []byte(\\\"2019-10-30T12:30:59+02:30\\\")},\\n\\t\\t\\t\\tTimestamp{precision: TimestampPrecisionMillisecond3, text: []byte(\\\"2019-10-30T12:30:59.999-02:30\\\")},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\n\\t\\t// Binary.\\n\\n\\t\\t{\\n\\t\\t\\tname: \\\"short blob\\\",\\n\\t\\t\\ttext: \\\"{{+AB/}}\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{Blob{text: []byte(\\\"+AB/\\\")}}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"padded blob with whitespace\\\",\\n\\t\\t\\ttext: \\\"{{ + A\\\\nB\\\\t/abc= }}\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{Blob{text: []byte(\\\"+AB/abc=\\\")}}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"short clob\\\",\\n\\t\\t\\ttext: `{{ \\\"A\\\\n\\\" }}`,\\n\\t\\t\\texpected: &Digest{values: []Value{Clob{text: []byte(\\\"A\\\\n\\\")}}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"long clob\\\",\\n\\t\\t\\ttext: \\\"{{ '''+AB/''' }}\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{Clob{text: []byte(\\\"+AB/\\\")}}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"multiple long clobs\\\",\\n\\t\\t\\ttext: \\\"{{ '''A\\\\\\\\nB'''\\\\n'''foo''' }}\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{Clob{text: []byte(\\\"A\\\\nBfoo\\\")}}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"escaped clobs\\\",\\n\\t\\t\\ttext: `{{\\\"H\\\\x48\\\\x48H\\\"}} {{'''h\\\\x68\\\\x68h'''}}`,\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tClob{text: []byte(\\\"HHHH\\\")},\\n\\t\\t\\t\\tClob{text: []byte(\\\"hhhh\\\")},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\n\\t\\t// Containers\\n\\n\\t\\t{\\n\\t\\t\\tname: \\\"struct with symbol to symbol\\\",\\n\\t\\t\\ttext: `{symbol1: 'symbol', 'symbol2': symbol}`,\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tStruct{fields: []StructField{\\n\\t\\t\\t\\t\\t{Symbol: Symbol{text: []byte(\\\"symbol1\\\")}, Value: Symbol{quoted: true, text: []byte(\\\"symbol\\\")}},\\n\\t\\t\\t\\t\\t{Symbol: Symbol{quoted: true, text: []byte(\\\"symbol2\\\")}, Value: Symbol{text: []byte(\\\"symbol\\\")}},\\n\\t\\t\\t\\t}},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"struct with annotated field\\\",\\n\\t\\t\\ttext: `{symbol1: ann::'symbol'}`,\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tStruct{fields: []StructField{\\n\\t\\t\\t\\t\\t{Symbol: Symbol{text: []byte(\\\"symbol1\\\")}, Value: Symbol{annotations: []Symbol{{text: []byte(\\\"ann\\\")}}, quoted: true, text: []byte(\\\"symbol\\\")}},\\n\\t\\t\\t\\t}},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"struct with doubly-annotated field\\\",\\n\\t\\t\\ttext: `{symbol1: ann1::ann2::'symbol'}`,\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tStruct{fields: []StructField{\\n\\t\\t\\t\\t\\t{Symbol: Symbol{text: []byte(\\\"symbol1\\\")}, Value: Symbol{annotations: []Symbol{{text: []byte(\\\"ann1\\\")}, {text: []byte(\\\"ann2\\\")}}, quoted: true, text: []byte(\\\"symbol\\\")}},\\n\\t\\t\\t\\t}},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"struct with comments between symbol and value\\\",\\n\\t\\t\\ttext: \\\"{abc : // Line\\\\n/* Block */ {{ \\\\\\\"A\\\\\\\\n\\\\\\\" }}}\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tStruct{fields: []StructField{\\n\\t\\t\\t\\t\\t{Symbol: Symbol{text: []byte(\\\"abc\\\")}, Value: Clob{text: []byte(\\\"A\\\\n\\\")}},\\n\\t\\t\\t\\t}},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\n\\t\\t{\\n\\t\\t\\tname: \\\"struct with empty list, struct, and sexp\\\",\\n\\t\\t\\ttext: \\\"{a:[], b:{}, c:()}\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tStruct{fields: []StructField{\\n\\t\\t\\t\\t\\t{Symbol: Symbol{text: []byte(\\\"a\\\")}, Value: List{}},\\n\\t\\t\\t\\t\\t{Symbol: Symbol{text: []byte(\\\"b\\\")}, Value: Struct{}},\\n\\t\\t\\t\\t\\t{Symbol: Symbol{text: []byte(\\\"c\\\")}, Value: SExp{}},\\n\\t\\t\\t\\t}},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"list with empty list, struct, and sexp\\\",\\n\\t\\t\\ttext: \\\"[[], {}, ()]\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tList{values: []Value{List{}, Struct{}, SExp{}}},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"list of things\\\",\\n\\t\\t\\ttext: \\\"[a, 1, ' ', {}, () /* comment */ ]\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tList{values: []Value{\\n\\t\\t\\t\\t\\tSymbol{text: []byte(\\\"a\\\")},\\n\\t\\t\\t\\t\\tInt{isSet: true, text: []byte(\\\"1\\\")},\\n\\t\\t\\t\\t\\tSymbol{text: []byte(\\\" \\\")},\\n\\t\\t\\t\\t\\tStruct{},\\n\\t\\t\\t\\t\\tSExp{},\\n\\t\\t\\t\\t}},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"struct of things\\\",\\n\\t\\t\\ttext: \\\"{'a' : 1 , s:'', 'st': {}, \\\\n/* comment */lst:[],\\\\\\\"sexp\\\\\\\":()}\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tStruct{fields: []StructField{\\n\\t\\t\\t\\t\\t{Symbol: Symbol{text: []byte(\\\"a\\\")}, Value: Int{isSet: true, text: []byte(\\\"1\\\")}},\\n\\t\\t\\t\\t\\t{Symbol: Symbol{text: []byte(\\\"s\\\")}, Value: Symbol{text: []byte(\\\"\\\")}},\\n\\t\\t\\t\\t\\t{Symbol: Symbol{text: []byte(\\\"st\\\")}, Value: Struct{}},\\n\\t\\t\\t\\t\\t{Symbol: Symbol{text: []byte(\\\"lst\\\")}, Value: List{}},\\n\\t\\t\\t\\t\\t{Symbol: Symbol{text: []byte(\\\"sexp\\\")}, Value: SExp{}},\\n\\t\\t\\t\\t}},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"s-expression of things\\\",\\n\\t\\t\\ttext: \\\"(a+b/c<( j * k))\\\",\\n\\t\\t\\texpected: &Digest{values: []Value{\\n\\t\\t\\t\\tSExp{values: []Value{\\n\\t\\t\\t\\t\\tSymbol{text: []byte(\\\"a\\\")},\\n\\t\\t\\t\\t\\tSymbol{text: []byte(\\\"+\\\")},\\n\\t\\t\\t\\t\\tSymbol{text: []byte(\\\"b\\\")},\\n\\t\\t\\t\\t\\tSymbol{text: []byte(\\\"/\\\")},\\n\\t\\t\\t\\t\\tSymbol{text: []byte(\\\"c\\\")},\\n\\t\\t\\t\\t\\tSymbol{text: []byte(\\\"<\\\")},\\n\\t\\t\\t\\t\\tSExp{values: []Value{\\n\\t\\t\\t\\t\\t\\tSymbol{text: []byte(\\\"j\\\")},\\n\\t\\t\\t\\t\\t\\tSymbol{text: []byte(\\\"*\\\")},\\n\\t\\t\\t\\t\\t\\tSymbol{text: []byte(\\\"k\\\")},\\n\\t\\t\\t\\t\\t}},\\n\\t\\t\\t\\t}},\\n\\t\\t\\t}},\\n\\t\\t},\\n\\n\\t\\t// Error cases\\n\\n\\t\\t{\\n\\t\\t\\tname: \\\"list starts with comma\\\",\\n\\t\\t\\ttext: \\\"[, [], {}, ()]\\\",\\n\\t\\t\\texpectedErr: errors.New(\\\"parsing line 1 - list may not start with a comma\\\"),\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"struct starts with comma\\\",\\n\\t\\t\\ttext: \\\"{, a:1}\\\",\\n\\t\\t\\texpectedErr: errors.New(\\\"parsing line 1 - struct may not start with a comma\\\"),\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"list without commas\\\",\\n\\t\\t\\ttext: \\\"[[] {} ()]\\\",\\n\\t\\t\\texpectedErr: errors.New(\\\"parsing line 1 - list items must be separated by commas\\\"),\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\tname: \\\"struct without commas\\\",\\n\\t\\t\\ttext: \\\"{a:1 b:2}\\\",\\n\\t\\t\\texpectedErr: errors.New(\\\"parsing line 1 - struct fields must be separated by commas\\\"),\\n\\t\\t},\\n\\t}\\n\\tfor _, tst := range tests {\\n\\t\\ttest := tst\\n\\t\\tt.Run(test.name, func(t *testing.T) {\\n\\t\\t\\tdigest, err := ParseText(strings.NewReader(test.text))\\n\\t\\t\\tif diff := cmpDigests(test.expected, digest); diff != \\\"\\\" {\\n\\t\\t\\t\\tt.Logf(\\\"expected: %#v\\\", test.expected)\\n\\t\\t\\t\\tt.Logf(\\\"found: %#v\\\", digest)\\n\\t\\t\\t\\tt.Error(\\\"(-expected, +found)\\\", diff)\\n\\t\\t\\t}\\n\\t\\t\\tif diff := cmpErrs(test.expectedErr, err); diff != \\\"\\\" {\\n\\t\\t\\t\\tt.Error(\\\"err: (-expected, +found)\\\", diff)\\n\\t\\t\\t}\\n\\t\\t})\\n\\t}\\n}\",\n \"func New() *Text {\\n\\treturn &Text{}\\n}\",\n \"func textEncoderDummy(w io.Writer, props properties, text []byte) (textEncoder, error) {\\n\\t_, err := w.Write(text)\\n\\treturn textEncoderDummy, err\\n}\",\n \"func NewColouredTextTypeChunk(text string, face font.Face, colour uint32) TypeChunk {\\n\\trunes := []rune{}\\n\\tfor _, r := range text {\\n\\t\\trunes = append(runes, r)\\n\\t}\\n\\treturn fyTextTypeChunk{\\n\\t\\trunes,\\n\\t\\tface,\\n\\t\\tcolour,\\n\\t}\\n}\",\n \"func ISO8859_1toUTF8(in string) (out string, err error) {\\n\\t// create a Reader using the input string as Reader and ISO8859 decoder\\n\\tdecoded := transform.NewReader(strings.NewReader(in), charmap.ISO8859_1.NewDecoder())\\n\\tdecodedBytes, err := ioutil.ReadAll(decoded)\\n\\tif err != nil {\\n\\t\\treturn\\n\\t}\\n\\tout = string(decodedBytes)\\n\\treturn\\n}\",\n \"func PlainText(w http.ResponseWriter, r *http.Request, v string) {\\n\\trender.PlainText(w, r, v)\\n}\",\n \"func NewFromCSV(headers, columns []string) types.Document {\\n\\tfb := NewFieldBuffer()\\n\\tfor i, h := range headers {\\n\\t\\tif i >= len(columns) {\\n\\t\\t\\tbreak\\n\\t\\t}\\n\\n\\t\\tfb.Add(h, types.NewTextValue(columns[i]))\\n\\t}\\n\\n\\treturn fb\\n}\",\n \"func (c *Plain) Safe() bool {\\n\\treturn true\\n}\",\n \"func isText(s []byte) bool {\\n\\tconst max = 1024 // at least utf8.UTFMax\\n\\tif len(s) > max {\\n\\t\\ts = s[0:max]\\n\\t}\\n\\tfor i, c := range string(s) {\\n\\t\\tif i+utf8.UTFMax > len(s) {\\n\\t\\t\\t// last char may be incomplete - ignore\\n\\t\\t\\tbreak\\n\\t\\t}\\n\\t\\tif c == 0xFFFD || c < ' ' && c != '\\\\n' && c != '\\\\t' && c != '\\\\f' {\\n\\t\\t\\t// decoding error or control character - not a text file\\n\\t\\t\\treturn false\\n\\t\\t}\\n\\t}\\n\\treturn true\\n}\",\n \"func convertCP(in string) (out string) {\\n\\tbuf := new(bytes.Buffer)\\n\\tw, err := charset.NewWriter(\\\"windows-1252\\\", buf)\\n\\tif err != nil {\\n\\t\\tlog.Fatal(err)\\n\\t}\\n\\tfmt.Fprintf(w, in)\\n\\tw.Close()\\n\\n\\tout = fmt.Sprintf(\\\"%s\\\", buf)\\n\\treturn out\\n}\",\n \"func (self *CommitMessagePanelDriver) InitialText(expected *TextMatcher) *CommitMessagePanelDriver {\\n\\treturn self.Content(expected)\\n}\",\n \"func (sm *CumulativeMonotonicSumMode) UnmarshalText(in []byte) error {\\n\\tswitch mode := CumulativeMonotonicSumMode(in); mode {\\n\\tcase CumulativeMonotonicSumModeToDelta,\\n\\t\\tCumulativeMonotonicSumModeRawValue:\\n\\t\\t*sm = mode\\n\\t\\treturn nil\\n\\tdefault:\\n\\t\\treturn fmt.Errorf(\\\"invalid cumulative monotonic sum mode %q\\\", mode)\\n\\t}\\n}\",\n \"func (text *Text) Plainf(format string, a ...interface{}) *Text {\\n\\treturn text.Plain(fmt.Sprintf(format, a...))\\n}\",\n \"func FormatBytes(src []byte, invalid []byte, invalidWidth int, isJSON, isRaw bool, sep, quote rune) *Value {\\n\\tres := &Value{\\n\\t\\tTabs: make([][][2]int, 1),\\n\\t}\\n\\tvar tmp [4]byte\\n\\tvar r rune\\n\\tvar l, w int\\n\\tfor ; len(src) > 0; src = src[w:] {\\n\\t\\tr, w = rune(src[0]), 1\\n\\t\\t// lazy decode\\n\\t\\tif r >= utf8.RuneSelf {\\n\\t\\t\\tr, w = utf8.DecodeRune(src)\\n\\t\\t}\\n\\t\\t// invalid rune decoded\\n\\t\\tif w == 1 && r == utf8.RuneError {\\n\\t\\t\\t// replace with invalid (if set), otherwise hex encode\\n\\t\\t\\tif invalid != nil {\\n\\t\\t\\t\\tres.Buf = append(res.Buf, invalid...)\\n\\t\\t\\t\\tres.Width += invalidWidth\\n\\t\\t\\t\\tres.Quoted = true\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tres.Buf = append(res.Buf, '\\\\\\\\', 'x', lowerhex[src[0]>>4], lowerhex[src[0]&0xf])\\n\\t\\t\\t\\tres.Width += 4\\n\\t\\t\\t\\tres.Quoted = true\\n\\t\\t\\t}\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\t\\t// handle json encoding\\n\\t\\tif isJSON {\\n\\t\\t\\tswitch r {\\n\\t\\t\\tcase '\\\\t':\\n\\t\\t\\t\\tres.Buf = append(res.Buf, '\\\\\\\\', 't')\\n\\t\\t\\t\\tres.Width += 2\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tcase '\\\\n':\\n\\t\\t\\t\\tres.Buf = append(res.Buf, '\\\\\\\\', 'n')\\n\\t\\t\\t\\tres.Width += 2\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tcase '\\\\\\\\':\\n\\t\\t\\t\\tres.Buf = append(res.Buf, '\\\\\\\\', '\\\\\\\\')\\n\\t\\t\\t\\tres.Width += 2\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tcase '\\\"':\\n\\t\\t\\t\\tres.Buf = append(res.Buf, '\\\\\\\\', '\\\"')\\n\\t\\t\\t\\tres.Width += 2\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t// handle raw encoding\\n\\t\\tif isRaw {\\n\\t\\t\\tn := utf8.EncodeRune(tmp[:], r)\\n\\t\\t\\tres.Buf = append(res.Buf, tmp[:n]...)\\n\\t\\t\\tres.Width += runewidth.RuneWidth(r)\\n\\t\\t\\tswitch {\\n\\t\\t\\tcase r == sep:\\n\\t\\t\\t\\tres.Quoted = true\\n\\t\\t\\tcase r == quote && quote != 0:\\n\\t\\t\\t\\tres.Buf = append(res.Buf, tmp[:n]...)\\n\\t\\t\\t\\tres.Width += runewidth.RuneWidth(r)\\n\\t\\t\\t\\tres.Quoted = true\\n\\t\\t\\tdefault:\\n\\t\\t\\t\\tres.Quoted = res.Quoted || unicode.IsSpace(r)\\n\\t\\t\\t}\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\t\\t// printable character\\n\\t\\tif strconv.IsGraphic(r) {\\n\\t\\t\\tn := utf8.EncodeRune(tmp[:], r)\\n\\t\\t\\tres.Buf = append(res.Buf, tmp[:n]...)\\n\\t\\t\\tres.Width += runewidth.RuneWidth(r)\\n\\t\\t\\tcontinue\\n\\t\\t}\\n\\t\\tswitch r {\\n\\t\\t// escape \\\\a \\\\b \\\\f \\\\r \\\\v (Go special characters)\\n\\t\\tcase '\\\\a':\\n\\t\\t\\tres.Buf = append(res.Buf, '\\\\\\\\', 'a')\\n\\t\\t\\tres.Width += 2\\n\\t\\tcase '\\\\b':\\n\\t\\t\\tres.Buf = append(res.Buf, '\\\\\\\\', 'b')\\n\\t\\t\\tres.Width += 2\\n\\t\\tcase '\\\\f':\\n\\t\\t\\tres.Buf = append(res.Buf, '\\\\\\\\', 'f')\\n\\t\\t\\tres.Width += 2\\n\\t\\tcase '\\\\r':\\n\\t\\t\\tres.Buf = append(res.Buf, '\\\\\\\\', 'r')\\n\\t\\t\\tres.Width += 2\\n\\t\\tcase '\\\\v':\\n\\t\\t\\tres.Buf = append(res.Buf, '\\\\\\\\', 'v')\\n\\t\\t\\tres.Width += 2\\n\\t\\tcase '\\\\t':\\n\\t\\t\\t// save position\\n\\t\\t\\tres.Tabs[l] = append(res.Tabs[l], [2]int{len(res.Buf), res.Width})\\n\\t\\t\\tres.Buf = append(res.Buf, '\\\\t')\\n\\t\\t\\tres.Width = 0\\n\\t\\tcase '\\\\n':\\n\\t\\t\\t// save position\\n\\t\\t\\tres.Newlines = append(res.Newlines, [2]int{len(res.Buf), res.Width})\\n\\t\\t\\tres.Buf = append(res.Buf, '\\\\n')\\n\\t\\t\\tres.Width = 0\\n\\t\\t\\t// increase line count\\n\\t\\t\\tres.Tabs = append(res.Tabs, nil)\\n\\t\\t\\tl++\\n\\t\\tdefault:\\n\\t\\t\\tswitch {\\n\\t\\t\\t// escape as \\\\x00\\n\\t\\t\\tcase r < ' ':\\n\\t\\t\\t\\tres.Buf = append(res.Buf, '\\\\\\\\', 'x', lowerhex[byte(r)>>4], lowerhex[byte(r)&0xf])\\n\\t\\t\\t\\tres.Width += 4\\n\\t\\t\\t// escape as \\\\u0000\\n\\t\\t\\tcase r > utf8.MaxRune:\\n\\t\\t\\t\\tr = 0xfffd\\n\\t\\t\\t\\tfallthrough\\n\\t\\t\\tcase r < 0x10000:\\n\\t\\t\\t\\tres.Buf = append(res.Buf, '\\\\\\\\', 'u')\\n\\t\\t\\t\\tfor s := 12; s >= 0; s -= 4 {\\n\\t\\t\\t\\t\\tres.Buf = append(res.Buf, lowerhex[r>>uint(s)&0xf])\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tres.Width += 6\\n\\t\\t\\t// escape as \\\\U00000000\\n\\t\\t\\tdefault:\\n\\t\\t\\t\\tres.Buf = append(res.Buf, '\\\\\\\\', 'U')\\n\\t\\t\\t\\tfor s := 28; s >= 0; s -= 4 {\\n\\t\\t\\t\\t\\tres.Buf = append(res.Buf, lowerhex[r>>uint(s)&0xf])\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tres.Width += 10\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\treturn res\\n}\",\n \"func (p *TOMLParser) FromBytes(byteData []byte) (interface{}, error) {\\n\\tvar data interface{}\\n\\tif err := toml.Unmarshal(byteData, &data); err != nil {\\n\\t\\treturn data, fmt.Errorf(\\\"could not unmarshal data: %w\\\", err)\\n\\t}\\n\\treturn &BasicSingleDocument{\\n\\t\\tValue: data,\\n\\t}, nil\\n}\",\n \"func sanitizeText(str string) string {\\n\\t// count bytes in output & check whether modification is required\\n\\tnlen := 0\\n\\tmustmod := false\\n\\tfor _, r := range []rune(str) {\\n\\t\\toutrune := cleanRune(r)\\n\\t\\tif outrune != '\\\\000' {\\n\\t\\t\\tnlen++\\n\\t\\t}\\n\\t\\tif outrune != r {\\n\\t\\t\\tmustmod = true\\n\\t\\t}\\n\\t}\\n\\n\\t// if no modification is required, use the original string\\n\\tif !mustmod {\\n\\t\\treturn str\\n\\t}\\n\\n\\t// build new string\\n\\tnstr := make([]byte, nlen)\\n\\ti := 0\\n\\tfor _, r := range []rune(str) {\\n\\t\\toutrune := cleanRune(r)\\n\\t\\tif outrune != '\\\\000' {\\n\\t\\t\\tnstr[i] = byte(outrune)\\n\\t\\t\\ti++\\n\\t\\t}\\n\\t}\\n\\n\\t// unsafe convert byte slice to string\\n\\treturn *(*string)(unsafe.Pointer(&reflect.StringHeader{\\n\\t\\tData: uintptr(unsafe.Pointer(&nstr[0])),\\n\\t\\tLen: len(nstr),\\n\\t}))\\n}\",\n \"func (m Message) EncodedText() (*field.EncodedTextField, quickfix.MessageRejectError) {\\n\\tf := &field.EncodedTextField{}\\n\\terr := m.Body.Get(f)\\n\\treturn f, err\\n}\",\n \"func (m Message) EncodedText() (*field.EncodedTextField, quickfix.MessageRejectError) {\\n\\tf := &field.EncodedTextField{}\\n\\terr := m.Body.Get(f)\\n\\treturn f, err\\n}\",\n \"func (m Message) EncodedText() (*field.EncodedTextField, quickfix.MessageRejectError) {\\n\\tf := &field.EncodedTextField{}\\n\\terr := m.Body.Get(f)\\n\\treturn f, err\\n}\",\n \"func (m Message) EncodedText() (*field.EncodedTextField, quickfix.MessageRejectError) {\\n\\tf := &field.EncodedTextField{}\\n\\terr := m.Body.Get(f)\\n\\treturn f, err\\n}\",\n \"func (m Message) EncodedText() (*field.EncodedTextField, quickfix.MessageRejectError) {\\n\\tf := &field.EncodedTextField{}\\n\\terr := m.Body.Get(f)\\n\\treturn f, err\\n}\",\n \"func (m Message) EncodedText() (*field.EncodedTextField, quickfix.MessageRejectError) {\\n\\tf := &field.EncodedTextField{}\\n\\terr := m.Body.Get(f)\\n\\treturn f, err\\n}\",\n \"func NewFzTextRef(ref unsafe.Pointer) *FzText {\\n\\treturn (*FzText)(ref)\\n}\",\n \"func DefaultStrConv() (ret *StrConv) {\\n\\tvar (\\n\\t\\tb []byte\\n\\t\\tr []rune\\n\\t)\\n\\n\\treturn &StrConv{\\n\\t\\tByType: map[reflect.Type]ConvFunc{\\n\\t\\t\\treflect.TypeOf(b): StringConverter,\\n\\t\\t\\treflect.TypeOf(r): StringConverter,\\n\\t\\t},\\n\\t\\tByKind: map[reflect.Kind]ConvFunc{\\n\\t\\t\\treflect.Bool: BoolConverter,\\n\\t\\t\\treflect.Int: IntDecConverter,\\n\\t\\t\\treflect.Int8: IntDecConverter,\\n\\t\\t\\treflect.Int16: IntDecConverter,\\n\\t\\t\\treflect.Int32: IntDecConverter,\\n\\t\\t\\treflect.Int64: IntDecConverter,\\n\\t\\t\\treflect.Uint: UintDecConverter,\\n\\t\\t\\treflect.Uint8: UintDecConverter,\\n\\t\\t\\treflect.Uint16: UintDecConverter,\\n\\t\\t\\treflect.Uint32: UintDecConverter,\\n\\t\\t\\treflect.Uint64: UintDecConverter,\\n\\t\\t\\treflect.Float32: FloatConverter,\\n\\t\\t\\treflect.Float64: FloatConverter,\\n\\t\\t\\treflect.String: StringConverter,\\n\\t\\t},\\n\\t}\\n}\"\n]"},"negative_scores":{"kind":"list like","value":["0.49815226","0.4444452","0.43660194","0.42840382","0.4256527","0.4245073","0.42352146","0.4208308","0.4181139","0.4091659","0.40825537","0.40743327","0.40652514","0.40333664","0.402485","0.40085512","0.40047","0.4001616","0.39838123","0.397401","0.39643714","0.39590704","0.3948951","0.3943882","0.39404306","0.39037493","0.3861112","0.38376728","0.3834697","0.38189304","0.38154003","0.3801105","0.37847874","0.37708223","0.37605503","0.37559214","0.37442333","0.3740616","0.3737156","0.37318963","0.37235552","0.3708758","0.3706139","0.36910698","0.36827815","0.36712673","0.36699018","0.3660626","0.3608667","0.36083558","0.36041987","0.359827","0.3585674","0.35673976","0.3559286","0.35560548","0.3552995","0.35494402","0.35467237","0.3540503","0.35388517","0.35372156","0.35287634","0.3521024","0.3519376","0.35130724","0.3504963","0.35017723","0.35008246","0.34936494","0.3491794","0.34874058","0.34821793","0.34810925","0.34794986","0.34772497","0.3475225","0.34636915","0.34587243","0.34557298","0.3455063","0.34495175","0.3447693","0.3442875","0.34428236","0.34412608","0.3437017","0.34240735","0.34232157","0.34207687","0.34203565","0.3415874","0.34152782","0.34152782","0.34152782","0.34152782","0.34152782","0.34152782","0.3413884","0.34113973"],"string":"[\n \"0.49815226\",\n \"0.4444452\",\n \"0.43660194\",\n \"0.42840382\",\n \"0.4256527\",\n \"0.4245073\",\n \"0.42352146\",\n \"0.4208308\",\n \"0.4181139\",\n \"0.4091659\",\n \"0.40825537\",\n \"0.40743327\",\n \"0.40652514\",\n \"0.40333664\",\n \"0.402485\",\n \"0.40085512\",\n \"0.40047\",\n \"0.4001616\",\n \"0.39838123\",\n \"0.397401\",\n \"0.39643714\",\n \"0.39590704\",\n \"0.3948951\",\n \"0.3943882\",\n \"0.39404306\",\n \"0.39037493\",\n \"0.3861112\",\n \"0.38376728\",\n \"0.3834697\",\n \"0.38189304\",\n \"0.38154003\",\n \"0.3801105\",\n \"0.37847874\",\n \"0.37708223\",\n \"0.37605503\",\n \"0.37559214\",\n \"0.37442333\",\n \"0.3740616\",\n \"0.3737156\",\n \"0.37318963\",\n \"0.37235552\",\n \"0.3708758\",\n \"0.3706139\",\n \"0.36910698\",\n \"0.36827815\",\n \"0.36712673\",\n \"0.36699018\",\n \"0.3660626\",\n \"0.3608667\",\n \"0.36083558\",\n \"0.36041987\",\n \"0.359827\",\n \"0.3585674\",\n \"0.35673976\",\n \"0.3559286\",\n \"0.35560548\",\n \"0.3552995\",\n \"0.35494402\",\n \"0.35467237\",\n \"0.3540503\",\n \"0.35388517\",\n \"0.35372156\",\n \"0.35287634\",\n \"0.3521024\",\n \"0.3519376\",\n \"0.35130724\",\n \"0.3504963\",\n \"0.35017723\",\n \"0.35008246\",\n \"0.34936494\",\n \"0.3491794\",\n \"0.34874058\",\n \"0.34821793\",\n \"0.34810925\",\n \"0.34794986\",\n \"0.34772497\",\n \"0.3475225\",\n \"0.34636915\",\n \"0.34587243\",\n \"0.34557298\",\n \"0.3455063\",\n \"0.34495175\",\n \"0.3447693\",\n \"0.3442875\",\n \"0.34428236\",\n \"0.34412608\",\n \"0.3437017\",\n \"0.34240735\",\n \"0.34232157\",\n \"0.34207687\",\n \"0.34203565\",\n \"0.3415874\",\n \"0.34152782\",\n \"0.34152782\",\n \"0.34152782\",\n \"0.34152782\",\n \"0.34152782\",\n \"0.34152782\",\n \"0.3413884\",\n \"0.34113973\"\n]"},"document_score":{"kind":"string","value":"0.78827673"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":105064,"cells":{"query":{"kind":"string","value":"FromXML returns the charset of an XML document. It relies on the XML header and falls back on the plain text content."},"document":{"kind":"string","value":"func FromXML(content []byte) string {\n\tif cset := fromXML(content); cset != \"\" {\n\t\treturn cset\n\t}\n\treturn FromPlain(content)\n}"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["func (c *Charset) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {\n\tvar v string\n\td.DecodeElement(&v, &start)\n\tswitch v {\n\tdefault:\n\t\treturn fmt.Errorf(\"undefined code for Charset has been passed, got [%s]\", v)\n\t}\n}","func (*XMLDocument) Charset() (charset string) {\n\tmacro.Rewrite(\"$_.charset\")\n\treturn charset\n}","func (conn *IRODSConnection) PreprocessXML(in []byte) (out []byte, err error) {\n\tbuf := in\n\n\tfor len(buf) > 0 {\n\t\tswitch {\n\t\t// turn &#34; into &quot;\n\t\tcase bytes.HasPrefix(buf, escQuot):\n\t\t\tout = append(out, irodsEscQuot...)\n\t\t\tbuf = buf[len(escQuot):]\n\n\t\t// turn &#39 into &apos; or '\n\t\tcase bytes.HasPrefix(buf, escApos):\n\t\t\tif conn.talksCorrectXML() {\n\t\t\t\tout = append(out, irodsEscApos...)\n\t\t\t} else {\n\t\t\t\tout = append(out, '\\'')\n\t\t\t}\n\t\t\tbuf = buf[len(escApos):]\n\n\t\t// irods does not decode encoded tabs\n\t\tcase bytes.HasPrefix(buf, escTab):\n\t\t\tout = append(out, '\\t')\n\t\t\tbuf = buf[len(escTab):]\n\n\t\t// irods does not decode encoded carriage returns\n\t\tcase bytes.HasPrefix(buf, escCR):\n\t\t\tout = append(out, '\\r')\n\t\t\tbuf = buf[len(escCR):]\n\n\t\t// irods does not decode encoded newlines\n\t\tcase bytes.HasPrefix(buf, escNL):\n\t\t\tout = append(out, '\\n')\n\t\t\tbuf = buf[len(escNL):]\n\n\t\t// turn ` into &apos;\n\t\tcase buf[0] == '`' && !conn.talksCorrectXML():\n\t\t\tout = append(out, irodsEscApos...)\n\t\t\tbuf = buf[1:]\n\n\t\t// pass utf8 characters\n\t\tdefault:\n\t\t\tr, size := utf8.DecodeRune(buf)\n\n\t\t\tif r == utf8.RuneError && size == 1 {\n\t\t\t\terr = ErrInvalidUTF8\n\t\t\t\tout = in\n\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tout = append(out, buf[:size]...)\n\t\t\tbuf = buf[size:]\n\t\t}\n\t}\n\n\treturn\n}","func correctXml(text []byte) []byte {\n\ttext = correctEncodingToUtf8(text)\n\ttext = correctGibberish(text)\n\ttext = correctUnquotedAttrs(text)\n\ttext = correctEncodingField(text)\n\ttext = correctAmpersands(text)\n\n\treturn text\n}","func (c *CopyrightType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {\n\tvar v string\n\td.DecodeElement(&v, &start)\n\tfor _, attr := range start.Attr {\n\t\tif attr.Name.Local == \"datestamp\" {\n\t\t\tc.Datestamp = DtDotDateOrDateTime(attr.Value)\n\t\t}\n\t\tif attr.Name.Local == \"sourcetype\" {\n\t\t\tc.Sourcetype = SourceTypeCode(attr.Value)\n\t\t}\n\t\tif attr.Name.Local == \"sourcename\" {\n\t\t\tc.Sourcename = DtDotNonEmptyString(attr.Value)\n\t\t}\n\t}\n\tswitch v {\n\n // Text or image copyright (normally indicated by the © symbol). The default if no is specified\n case \"C\":\n\t\tc.Body = `Copyright`\n\n // Phonogram copyright or neighbouring right (normally indicated by the ℗ symbol)\n case \"P\":\n\t\tc.Body = `Phonogram right`\n\n // Sui generis database right\n case \"D\":\n\t\tc.Body = `Database right`\n\tdefault:\n\t\treturn fmt.Errorf(\"undefined code for CopyrightType has been passed, got [%s]\", v)\n\t}\n\treturn nil\n}","func (c *DefaultLanguageOfText) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {\n\tvar v string\n\td.DecodeElement(&v, &start)\n\tfor _, attr := range start.Attr {\n\t\tif attr.Name.Local == \"datestamp\" {\n\t\t\tc.Datestamp = DtDotDateOrDateTime(attr.Value)\n\t\t}\n\t\tif attr.Name.Local == \"sourcetype\" {\n\t\t\tc.Sourcetype = SourceTypeCode(attr.Value)\n\t\t}\n\t\tif attr.Name.Local == \"sourcename\" {\n\t\t\tc.Sourcename = DtDotNonEmptyString(attr.Value)\n\t\t}\n\t}\n\tswitch v {\n\n // Afar\n case \"aar\":\n\t\tc.Body = `Afar`\n\n // Abkhaz\n case \"abk\":\n\t\tc.Body = `Abkhaz`\n\n // Achinese\n case \"ace\":\n\t\tc.Body = `Achinese`\n\n // Acoli\n case \"ach\":\n\t\tc.Body = `Acoli`\n\n // Adangme\n case \"ada\":\n\t\tc.Body = `Adangme`\n\n // Adygei\n case \"ady\":\n\t\tc.Body = `Adygei`\n\n // Collective name\n case \"afa\":\n\t\tc.Body = `Afro-Asiatic languages`\n\n // Artificial language\n case \"afh\":\n\t\tc.Body = `Afrihili`\n\n // Afrikaans\n case \"afr\":\n\t\tc.Body = `Afrikaans`\n\n // Ainu\n case \"ain\":\n\t\tc.Body = `Ainu`\n\n // Macrolanguage\n case \"aka\":\n\t\tc.Body = `Akan`\n\n // Akkadian\n case \"akk\":\n\t\tc.Body = `Akkadian`\n\n // Macrolanguage\n case \"alb\":\n\t\tc.Body = `Albanian`\n\n // Aleut\n case \"ale\":\n\t\tc.Body = `Aleut`\n\n // Collective name\n case \"alg\":\n\t\tc.Body = `Algonquian languages`\n\n // Southern Altai\n case \"alt\":\n\t\tc.Body = `Southern Altai`\n\n // Amharic\n case \"amh\":\n\t\tc.Body = `Amharic`\n\n // English, Old (ca. 450-1100)\n case \"ang\":\n\t\tc.Body = `English, Old (ca. 450-1100)`\n\n // Angika\n case \"anp\":\n\t\tc.Body = `Angika`\n\n // Collective name\n case \"apa\":\n\t\tc.Body = `Apache languages`\n\n // Macrolanguage\n case \"ara\":\n\t\tc.Body = `Arabic`\n\n // Official Aramaic; Imperial Aramaic (700-300 BCE)\n case \"arc\":\n\t\tc.Body = `Official Aramaic; Imperial Aramaic (700-300 BCE)`\n\n // Aragonese\n case \"arg\":\n\t\tc.Body = `Aragonese`\n\n // Armenian\n case \"arm\":\n\t\tc.Body = `Armenian`\n\n // Mapudungun; Mapuche\n case \"arn\":\n\t\tc.Body = `Mapudungun; Mapuche`\n\n // Arapaho\n case \"arp\":\n\t\tc.Body = `Arapaho`\n\n // Collective name\n case \"art\":\n\t\tc.Body = `Artificial languages`\n\n // Arawak\n case \"arw\":\n\t\tc.Body = `Arawak`\n\n // Assamese\n case \"asm\":\n\t\tc.Body = `Assamese`\n\n // Asturian; Bable; Leonese; Asturleonese\n case \"ast\":\n\t\tc.Body = `Asturian; Bable; Leonese; Asturleonese`\n\n // Collective name\n case \"ath\":\n\t\tc.Body = `Athapascan languages`\n\n // Collective name\n case \"aus\":\n\t\tc.Body = `Australian languages`\n\n // Avaric\n case \"ava\":\n\t\tc.Body = `Avaric`\n\n // Avestan\n case \"ave\":\n\t\tc.Body = `Avestan`\n\n // Awadhi\n case \"awa\":\n\t\tc.Body = `Awadhi`\n\n // Macrolanguage\n case \"aym\":\n\t\tc.Body = `Aymara`\n\n // Macrolanguage\n case \"aze\":\n\t\tc.Body = `Azerbaijani`\n\n // Collective name\n case \"bad\":\n\t\tc.Body = `Banda languages`\n\n // Collective name\n case \"bai\":\n\t\tc.Body = `Bamileke languages`\n\n // Bashkir\n case \"bak\":\n\t\tc.Body = `Bashkir`\n\n // Macrolanguage\n case \"bal\":\n\t\tc.Body = `Baluchi`\n\n // Bambara\n case \"bam\":\n\t\tc.Body = `Bambara`\n\n // Balinese\n case \"ban\":\n\t\tc.Body = `Balinese`\n\n // Basque\n case \"baq\":\n\t\tc.Body = `Basque`\n\n // Basa\n case \"bas\":\n\t\tc.Body = `Basa`\n\n // Collective name\n case \"bat\":\n\t\tc.Body = `Baltic languages`\n\n // Beja; Bedawiyet\n case \"bej\":\n\t\tc.Body = `Beja; Bedawiyet`\n\n // Belarusian\n case \"bel\":\n\t\tc.Body = `Belarusian`\n\n // Bemba\n case \"bem\":\n\t\tc.Body = `Bemba`\n\n // Bengali\n case \"ben\":\n\t\tc.Body = `Bengali`\n\n // Collective name\n case \"ber\":\n\t\tc.Body = `Berber languages`\n\n // Bhojpuri\n case \"bho\":\n\t\tc.Body = `Bhojpuri`\n\n // Collective name\n case \"bih\":\n\t\tc.Body = `Bihari languages`\n\n // Macrolanguage\n case \"bik\":\n\t\tc.Body = `Bikol`\n\n // Bini; Edo\n case \"bin\":\n\t\tc.Body = `Bini; Edo`\n\n // Bislama\n case \"bis\":\n\t\tc.Body = `Bislama`\n\n // Siksika\n case \"bla\":\n\t\tc.Body = `Siksika`\n\n // Collective name\n case \"bnt\":\n\t\tc.Body = `Bantu languages`\n\n // Bosnian\n case \"bos\":\n\t\tc.Body = `Bosnian`\n\n // Braj\n case \"bra\":\n\t\tc.Body = `Braj`\n\n // Breton\n case \"bre\":\n\t\tc.Body = `Breton`\n\n // Collective name\n case \"btk\":\n\t\tc.Body = `Batak languages`\n\n // Macrolanguage\n case \"bua\":\n\t\tc.Body = `Buriat`\n\n // Buginese\n case \"bug\":\n\t\tc.Body = `Buginese`\n\n // Bulgarian\n case \"bul\":\n\t\tc.Body = `Bulgarian`\n\n // Burmese\n case \"bur\":\n\t\tc.Body = `Burmese`\n\n // Blin; Bilin\n case \"byn\":\n\t\tc.Body = `Blin; Bilin`\n\n // Caddo\n case \"cad\":\n\t\tc.Body = `Caddo`\n\n // Collective name\n case \"cai\":\n\t\tc.Body = `Central American Indian languages`\n\n // Galibi Carib\n case \"car\":\n\t\tc.Body = `Galibi Carib`\n\n // Catalan\n case \"cat\":\n\t\tc.Body = `Catalan`\n\n // Collective name\n case \"cau\":\n\t\tc.Body = `Caucasian languages`\n\n // Cebuano\n case \"ceb\":\n\t\tc.Body = `Cebuano`\n\n // Collective name\n case \"cel\":\n\t\tc.Body = `Celtic languages`\n\n // Chamorro\n case \"cha\":\n\t\tc.Body = `Chamorro`\n\n // Chibcha\n case \"chb\":\n\t\tc.Body = `Chibcha`\n\n // Chechen\n case \"che\":\n\t\tc.Body = `Chechen`\n\n // Chagatai\n case \"chg\":\n\t\tc.Body = `Chagatai`\n\n // Macrolanguage\n case \"chi\":\n\t\tc.Body = `Chinese`\n\n // Chuukese (Truk)\n case \"chk\":\n\t\tc.Body = `Chuukese (Truk)`\n\n // Macrolanguage\n case \"chm\":\n\t\tc.Body = `Mari`\n\n // Chinook jargon\n case \"chn\":\n\t\tc.Body = `Chinook jargon`\n\n // Choctaw\n case \"cho\":\n\t\tc.Body = `Choctaw`\n\n // Chipewyan; Dene Suline\n case \"chp\":\n\t\tc.Body = `Chipewyan; Dene Suline`\n\n // Cherokee\n case \"chr\":\n\t\tc.Body = `Cherokee`\n\n // Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic\n case \"chu\":\n\t\tc.Body = `Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic`\n\n // Chuvash\n case \"chv\":\n\t\tc.Body = `Chuvash`\n\n // Cheyenne\n case \"chy\":\n\t\tc.Body = `Cheyenne`\n\n // ONIX local code, equivalent to ckb in ISO 639-3. For use in ONIX 3.0 only\n case \"ckb\":\n\t\tc.Body = `Central Kurdish (Sorani)`\n\n // Collective name\n case \"cmc\":\n\t\tc.Body = `Chamic languages`\n\n // ONIX local code, equivalent to cmn in ISO 639-3\n case \"cmn\":\n\t\tc.Body = `Mandarin`\n\n // For use in ONIX 3.0 only\n case \"cnr\":\n\t\tc.Body = `Montenegrin`\n\n // Coptic\n case \"cop\":\n\t\tc.Body = `Coptic`\n\n // Cornish\n case \"cor\":\n\t\tc.Body = `Cornish`\n\n // Corsican\n case \"cos\":\n\t\tc.Body = `Corsican`\n\n // Collective name\n case \"cpe\":\n\t\tc.Body = `Creoles and pidgins, English-based`\n\n // Collective name\n case \"cpf\":\n\t\tc.Body = `Creoles and pidgins, French-based`\n\n // Collective name\n case \"cpp\":\n\t\tc.Body = `Creoles and pidgins, Portuguese-based`\n\n // Macrolanguage\n case \"cre\":\n\t\tc.Body = `Cree`\n\n // Crimean Turkish; Crimean Tatar\n case \"crh\":\n\t\tc.Body = `Crimean Turkish; Crimean Tatar`\n\n // Collective name\n case \"crp\":\n\t\tc.Body = `Creoles and pidgins`\n\n // Kashubian\n case \"csb\":\n\t\tc.Body = `Kashubian`\n\n // Collective name\n case \"cus\":\n\t\tc.Body = `Cushitic languages`\n\n // Czech\n case \"cze\":\n\t\tc.Body = `Czech`\n\n // Dakota\n case \"dak\":\n\t\tc.Body = `Dakota`\n\n // Danish\n case \"dan\":\n\t\tc.Body = `Danish`\n\n // Dargwa\n case \"dar\":\n\t\tc.Body = `Dargwa`\n\n // Collective name\n case \"day\":\n\t\tc.Body = `Land Dayak languages`\n\n // Macrolanguage\n case \"del\":\n\t\tc.Body = `Delaware`\n\n // Macrolanguage\n case \"den\":\n\t\tc.Body = `Slave (Athapascan)`\n\n // Dogrib\n case \"dgr\":\n\t\tc.Body = `Dogrib`\n\n // Macrolanguage\n case \"din\":\n\t\tc.Body = `Dinka`\n\n // Divehi; Dhivehi; Maldivian\n case \"div\":\n\t\tc.Body = `Divehi; Dhivehi; Maldivian`\n\n // Macrolanguage\n case \"doi\":\n\t\tc.Body = `Dogri`\n\n // Collective name\n case \"dra\":\n\t\tc.Body = `Dravidian languages`\n\n // Lower Sorbian\n case \"dsb\":\n\t\tc.Body = `Lower Sorbian`\n\n // Duala\n case \"dua\":\n\t\tc.Body = `Duala`\n\n // Dutch, Middle (ca. 1050-1350)\n case \"dum\":\n\t\tc.Body = `Dutch, Middle (ca. 1050-1350)`\n\n // Dutch; Flemish\n case \"dut\":\n\t\tc.Body = `Dutch; Flemish`\n\n // Dyula\n case \"dyu\":\n\t\tc.Body = `Dyula`\n\n // Dzongkha\n case \"dzo\":\n\t\tc.Body = `Dzongkha`\n\n // Efik\n case \"efi\":\n\t\tc.Body = `Efik`\n\n // ONIX local code for Italian dialect, equivalent to egl in ISO 639-3. For use in ONIX 3.0 only\n case \"egl\":\n\t\tc.Body = `Emilian`\n\n // Egyptian (Ancient)\n case \"egy\":\n\t\tc.Body = `Egyptian (Ancient)`\n\n // Ekajuk\n case \"eka\":\n\t\tc.Body = `Ekajuk`\n\n // Elamite\n case \"elx\":\n\t\tc.Body = `Elamite`\n\n // English\n case \"eng\":\n\t\tc.Body = `English`\n\n // English, Middle (1100-1500)\n case \"enm\":\n\t\tc.Body = `English, Middle (1100-1500)`\n\n // Artificial language\n case \"epo\":\n\t\tc.Body = `Esperanto`\n\n // Macrolanguage\n case \"est\":\n\t\tc.Body = `Estonian`\n\n // Ewe\n case \"ewe\":\n\t\tc.Body = `Ewe`\n\n // Ewondo\n case \"ewo\":\n\t\tc.Body = `Ewondo`\n\n // Fang\n case \"fan\":\n\t\tc.Body = `Fang`\n\n // Faroese\n case \"fao\":\n\t\tc.Body = `Faroese`\n\n // Fanti\n case \"fat\":\n\t\tc.Body = `Fanti`\n\n // Fijian\n case \"fij\":\n\t\tc.Body = `Fijian`\n\n // Filipino; Pilipino\n case \"fil\":\n\t\tc.Body = `Filipino; Pilipino`\n\n // Finnish\n case \"fin\":\n\t\tc.Body = `Finnish`\n\n // ONIX local code, equivalent to fit in ISO 639-3\n case \"fit\":\n\t\tc.Body = `Meänkieli / Tornedalen Finnish`\n\n // Collective name\n case \"fiu\":\n\t\tc.Body = `Finno-Ugrian languages`\n\n // ONIX local code, equivalent to fkv in ISO 639-3\n case \"fkv\":\n\t\tc.Body = `Kvensk`\n\n // Fon\n case \"fon\":\n\t\tc.Body = `Fon`\n\n // French\n case \"fre\":\n\t\tc.Body = `French`\n\n // French, Middle (ca. 1400-1600)\n case \"frm\":\n\t\tc.Body = `French, Middle (ca. 1400-1600)`\n\n // French, Old (ca. 842-1400)\n case \"fro\":\n\t\tc.Body = `French, Old (ca. 842-1400)`\n\n // Northern Frisian\n case \"frr\":\n\t\tc.Body = `Northern Frisian`\n\n // Eastern Frisian\n case \"frs\":\n\t\tc.Body = `Eastern Frisian`\n\n // Western Frisian\n case \"fry\":\n\t\tc.Body = `Western Frisian`\n\n // Fulah\n case \"ful\":\n\t\tc.Body = `Fulah`\n\n // Friulian\n case \"fur\":\n\t\tc.Body = `Friulian`\n\n // Gã\n case \"gaa\":\n\t\tc.Body = `Gã`\n\n // Gayo\n case \"gay\":\n\t\tc.Body = `Gayo`\n\n // Macrolanguage\n case \"gba\":\n\t\tc.Body = `Gbaya`\n\n // Collective name\n case \"gem\":\n\t\tc.Body = `Germanic languages`\n\n // Georgian\n case \"geo\":\n\t\tc.Body = `Georgian`\n\n // German\n case \"ger\":\n\t\tc.Body = `German`\n\n // Ethiopic (Ge’ez)\n case \"gez\":\n\t\tc.Body = `Ethiopic (Ge’ez)`\n\n // Gilbertese\n case \"gil\":\n\t\tc.Body = `Gilbertese`\n\n // Scottish Gaelic\n case \"gla\":\n\t\tc.Body = `Scottish Gaelic`\n\n // Irish\n case \"gle\":\n\t\tc.Body = `Irish`\n\n // Galician\n case \"glg\":\n\t\tc.Body = `Galician`\n\n // Manx\n case \"glv\":\n\t\tc.Body = `Manx`\n\n // German, Middle High (ca. 1050-1500)\n case \"gmh\":\n\t\tc.Body = `German, Middle High (ca. 1050-1500)`\n\n // German, Old High (ca. 750-1050)\n case \"goh\":\n\t\tc.Body = `German, Old High (ca. 750-1050)`\n\n // Macrolanguage\n case \"gon\":\n\t\tc.Body = `Gondi`\n\n // Gorontalo\n case \"gor\":\n\t\tc.Body = `Gorontalo`\n\n // Gothic\n case \"got\":\n\t\tc.Body = `Gothic`\n\n // Macrolanguage\n case \"grb\":\n\t\tc.Body = `Grebo`\n\n // Greek, Ancient (to 1453)\n case \"grc\":\n\t\tc.Body = `Greek, Ancient (to 1453)`\n\n // Greek, Modern (1453-)\n case \"gre\":\n\t\tc.Body = `Greek, Modern (1453-)`\n\n // Macrolanguage\n case \"grn\":\n\t\tc.Body = `Guarani`\n\n // ONIX local code, equivalent to grt in ISO 639-3\n case \"grt\":\n\t\tc.Body = `Garo`\n\n // Swiss German; Alemannic\n case \"gsw\":\n\t\tc.Body = `Swiss German; Alemannic`\n\n // Gujarati\n case \"guj\":\n\t\tc.Body = `Gujarati`\n\n // Gwich’in\n case \"gwi\":\n\t\tc.Body = `Gwich’in`\n\n // Macrolanguage\n case \"hai\":\n\t\tc.Body = `Haida`\n\n // Haitian French Creole\n case \"hat\":\n\t\tc.Body = `Haitian French Creole`\n\n // Hausa\n case \"hau\":\n\t\tc.Body = `Hausa`\n\n // Hawaiian\n case \"haw\":\n\t\tc.Body = `Hawaiian`\n\n // Hebrew\n case \"heb\":\n\t\tc.Body = `Hebrew`\n\n // Herero\n case \"her\":\n\t\tc.Body = `Herero`\n\n // Hiligaynon\n case \"hil\":\n\t\tc.Body = `Hiligaynon`\n\n // Collective name\n case \"him\":\n\t\tc.Body = `Himachali languages; Western Pahari languages`\n\n // Hindi\n case \"hin\":\n\t\tc.Body = `Hindi`\n\n // Hittite\n case \"hit\":\n\t\tc.Body = `Hittite`\n\n // Macrolanguage\n case \"hmn\":\n\t\tc.Body = `Hmong; Mong`\n\n // Hiri Motu\n case \"hmo\":\n\t\tc.Body = `Hiri Motu`\n\n // Croatian\n case \"hrv\":\n\t\tc.Body = `Croatian`\n\n // Upper Sorbian\n case \"hsb\":\n\t\tc.Body = `Upper Sorbian`\n\n // Hungarian\n case \"hun\":\n\t\tc.Body = `Hungarian`\n\n // Hupa\n case \"hup\":\n\t\tc.Body = `Hupa`\n\n // Iban\n case \"iba\":\n\t\tc.Body = `Iban`\n\n // Igbo\n case \"ibo\":\n\t\tc.Body = `Igbo`\n\n // Icelandic\n case \"ice\":\n\t\tc.Body = `Icelandic`\n\n // Artificial language\n case \"ido\":\n\t\tc.Body = `Ido`\n\n // Sichuan Yi; Nuosu\n case \"iii\":\n\t\tc.Body = `Sichuan Yi; Nuosu`\n\n // Collective name\n case \"ijo\":\n\t\tc.Body = `Ijo languages`\n\n // Macrolanguage\n case \"iku\":\n\t\tc.Body = `Inuktitut`\n\n // Artificial language\n case \"ile\":\n\t\tc.Body = `Interlingue; Occidental`\n\n // Iloko\n case \"ilo\":\n\t\tc.Body = `Iloko`\n\n // Artificial language\n case \"ina\":\n\t\tc.Body = `Interlingua (International Auxiliary Language Association)`\n\n // Collective name\n case \"inc\":\n\t\tc.Body = `Indic languages`\n\n // Indonesian\n case \"ind\":\n\t\tc.Body = `Indonesian`\n\n // Collective name\n case \"ine\":\n\t\tc.Body = `Indo-European languages`\n\n // Ingush\n case \"inh\":\n\t\tc.Body = `Ingush`\n\n // Macrolanguage\n case \"ipk\":\n\t\tc.Body = `Inupiaq`\n\n // Collective name\n case \"ira\":\n\t\tc.Body = `Iranian languages`\n\n // Collective name\n case \"iro\":\n\t\tc.Body = `Iroquoian languages`\n\n // Italian\n case \"ita\":\n\t\tc.Body = `Italian`\n\n // Javanese\n case \"jav\":\n\t\tc.Body = `Javanese`\n\n // Lojban\n case \"jbo\":\n\t\tc.Body = `Lojban`\n\n // Japanese\n case \"jpn\":\n\t\tc.Body = `Japanese`\n\n // Judeo-Persian\n case \"jpr\":\n\t\tc.Body = `Judeo-Persian`\n\n // Macrolanguage\n case \"jrb\":\n\t\tc.Body = `Judeo-Arabic`\n\n // Kara-Kalpak\n case \"kaa\":\n\t\tc.Body = `Kara-Kalpak`\n\n // Kabyle\n case \"kab\":\n\t\tc.Body = `Kabyle`\n\n // Kachin; Jingpho\n case \"kac\":\n\t\tc.Body = `Kachin; Jingpho`\n\n // Kalâtdlisut; Greenlandic\n case \"kal\":\n\t\tc.Body = `Kalâtdlisut; Greenlandic`\n\n // Kamba\n case \"kam\":\n\t\tc.Body = `Kamba`\n\n // Kannada\n case \"kan\":\n\t\tc.Body = `Kannada`\n\n // Collective name\n case \"kar\":\n\t\tc.Body = `Karen languages`\n\n // Kashmiri\n case \"kas\":\n\t\tc.Body = `Kashmiri`\n\n // Macrolanguage\n case \"kau\":\n\t\tc.Body = `Kanuri`\n\n // Kawi\n case \"kaw\":\n\t\tc.Body = `Kawi`\n\n // Kazakh\n case \"kaz\":\n\t\tc.Body = `Kazakh`\n\n // Kabardian (Circassian)\n case \"kbd\":\n\t\tc.Body = `Kabardian (Circassian)`\n\n // ONIX local code, equivalent to kdr in ISO 639-3\n case \"kdr\":\n\t\tc.Body = `Karaim`\n\n // Khasi\n case \"kha\":\n\t\tc.Body = `Khasi`\n\n // Collective name\n case \"khi\":\n\t\tc.Body = `Khoisan languages`\n\n // Central Khmer\n case \"khm\":\n\t\tc.Body = `Central Khmer`\n\n // Khotanese; Sakan\n case \"kho\":\n\t\tc.Body = `Khotanese; Sakan`\n\n // Kikuyu; Gikuyu\n case \"kik\":\n\t\tc.Body = `Kikuyu; Gikuyu`\n\n // Kinyarwanda\n case \"kin\":\n\t\tc.Body = `Kinyarwanda`\n\n // Kirghiz; Kyrgyz\n case \"kir\":\n\t\tc.Body = `Kirghiz; Kyrgyz`\n\n // Kimbundu\n case \"kmb\":\n\t\tc.Body = `Kimbundu`\n\n // Macrolanguage\n case \"kok\":\n\t\tc.Body = `Konkani`\n\n // Macrolanguage\n case \"kom\":\n\t\tc.Body = `Komi`\n\n // Macrolanguage\n case \"kon\":\n\t\tc.Body = `Kongo`\n\n // Korean\n case \"kor\":\n\t\tc.Body = `Korean`\n\n // Kusaiean (Caroline Islands)\n case \"kos\":\n\t\tc.Body = `Kusaiean (Caroline Islands)`\n\n // Macrolanguage\n case \"kpe\":\n\t\tc.Body = `Kpelle`\n\n // Karachay-Balkar\n case \"krc\":\n\t\tc.Body = `Karachay-Balkar`\n\n // Karelian\n case \"krl\":\n\t\tc.Body = `Karelian`\n\n // Collective name\n case \"kro\":\n\t\tc.Body = `Kru languages`\n\n // Kurukh\n case \"kru\":\n\t\tc.Body = `Kurukh`\n\n // Kuanyama\n case \"kua\":\n\t\tc.Body = `Kuanyama`\n\n // Kumyk\n case \"kum\":\n\t\tc.Body = `Kumyk`\n\n // Macrolanguage\n case \"kur\":\n\t\tc.Body = `Kurdish`\n\n // Kutenai\n case \"kut\":\n\t\tc.Body = `Kutenai`\n\n // Ladino\n case \"lad\":\n\t\tc.Body = `Ladino`\n\n // Macrolanguage\n case \"lah\":\n\t\tc.Body = `Lahnda`\n\n // Lamba\n case \"lam\":\n\t\tc.Body = `Lamba`\n\n // Lao\n case \"lao\":\n\t\tc.Body = `Lao`\n\n // Latin\n case \"lat\":\n\t\tc.Body = `Latin`\n\n // Macrolanguage\n case \"lav\":\n\t\tc.Body = `Latvian`\n\n // Lezgian\n case \"lez\":\n\t\tc.Body = `Lezgian`\n\n // ONIX local code for Italian dialect, equivalent to lij in ISO 639-3. For use in ONIX 3.0 only\n case \"lij\":\n\t\tc.Body = `Ligurian`\n\n // Limburgish\n case \"lim\":\n\t\tc.Body = `Limburgish`\n\n // Lingala\n case \"lin\":\n\t\tc.Body = `Lingala`\n\n // Lithuanian\n case \"lit\":\n\t\tc.Body = `Lithuanian`\n\n // ONIX local code for Italian dialect, equivalent to lmo in ISO 639-3. For use in ONIX 3.0 only\n case \"lmo\":\n\t\tc.Body = `Lombard`\n\n // Mongo-Nkundu\n case \"lol\":\n\t\tc.Body = `Mongo-Nkundu`\n\n // Lozi\n case \"loz\":\n\t\tc.Body = `Lozi`\n\n // Luxembourgish; Letzeburgesch\n case \"ltz\":\n\t\tc.Body = `Luxembourgish; Letzeburgesch`\n\n // Luba-Lulua\n case \"lua\":\n\t\tc.Body = `Luba-Lulua`\n\n // Luba-Katanga\n case \"lub\":\n\t\tc.Body = `Luba-Katanga`\n\n // Ganda\n case \"lug\":\n\t\tc.Body = `Ganda`\n\n // Luiseño\n case \"lui\":\n\t\tc.Body = `Luiseño`\n\n // Lunda\n case \"lun\":\n\t\tc.Body = `Lunda`\n\n // Luo (Kenya and Tanzania)\n case \"luo\":\n\t\tc.Body = `Luo (Kenya and Tanzania)`\n\n // Lushai\n case \"lus\":\n\t\tc.Body = `Lushai`\n\n // Macedonian\n case \"mac\":\n\t\tc.Body = `Macedonian`\n\n // Madurese\n case \"mad\":\n\t\tc.Body = `Madurese`\n\n // Magahi\n case \"mag\":\n\t\tc.Body = `Magahi`\n\n // Marshallese\n case \"mah\":\n\t\tc.Body = `Marshallese`\n\n // Maithili\n case \"mai\":\n\t\tc.Body = `Maithili`\n\n // Makasar\n case \"mak\":\n\t\tc.Body = `Makasar`\n\n // Malayalam\n case \"mal\":\n\t\tc.Body = `Malayalam`\n\n // Macrolanguage\n case \"man\":\n\t\tc.Body = `Mandingo`\n\n // Maori\n case \"mao\":\n\t\tc.Body = `Maori`\n\n // Collective name\n case \"map\":\n\t\tc.Body = `Austronesian languages`\n\n // Marathi\n case \"mar\":\n\t\tc.Body = `Marathi`\n\n // Masai\n case \"mas\":\n\t\tc.Body = `Masai`\n\n // Macrolanguage\n case \"may\":\n\t\tc.Body = `Malay`\n\n // Moksha\n case \"mdf\":\n\t\tc.Body = `Moksha`\n\n // Mandar\n case \"mdr\":\n\t\tc.Body = `Mandar`\n\n // Mende\n case \"men\":\n\t\tc.Body = `Mende`\n\n // Irish, Middle (ca. 1100-1550)\n case \"mga\":\n\t\tc.Body = `Irish, Middle (ca. 1100-1550)`\n\n // Mi’kmaq; Micmac\n case \"mic\":\n\t\tc.Body = `Mi’kmaq; Micmac`\n\n // Minangkabau\n case \"min\":\n\t\tc.Body = `Minangkabau`\n\n // Use where no suitable code is available\n case \"mis\":\n\t\tc.Body = `Uncoded languages`\n\n // Collective name\n case \"mkh\":\n\t\tc.Body = `Mon-Khmer languages`\n\n // Macrolanguage\n case \"mlg\":\n\t\tc.Body = `Malagasy`\n\n // Maltese\n case \"mlt\":\n\t\tc.Body = `Maltese`\n\n // Manchu\n case \"mnc\":\n\t\tc.Body = `Manchu`\n\n // Manipuri\n case \"mni\":\n\t\tc.Body = `Manipuri`\n\n // Collective name\n case \"mno\":\n\t\tc.Body = `Manobo languages`\n\n // Mohawk\n case \"moh\":\n\t\tc.Body = `Mohawk`\n\n // DEPRECATED – use rum\n case \"mol\":\n\t\tc.Body = `Moldavian; Moldovan`\n\n // Macrolanguage\n case \"mon\":\n\t\tc.Body = `Mongolian`\n\n // Mooré; Mossi\n case \"mos\":\n\t\tc.Body = `Mooré; Mossi`\n\n // Multiple languages\n case \"mul\":\n\t\tc.Body = `Multiple languages`\n\n // Collective name\n case \"mun\":\n\t\tc.Body = `Munda languages`\n\n // Creek\n case \"mus\":\n\t\tc.Body = `Creek`\n\n // ONIX local code, equivalent to mwf in ISO 639-3. For use in ONIX 3.0 only\n case \"mwf\":\n\t\tc.Body = `Murrinh-Patha`\n\n // Mirandese\n case \"mwl\":\n\t\tc.Body = `Mirandese`\n\n // Macrolanguage\n case \"mwr\":\n\t\tc.Body = `Marwari`\n\n // Collective name\n case \"myn\":\n\t\tc.Body = `Mayan languages`\n\n // Erzya\n case \"myv\":\n\t\tc.Body = `Erzya`\n\n // Collective name\n case \"nah\":\n\t\tc.Body = `Nahuatl languages`\n\n // Collective name\n case \"nai\":\n\t\tc.Body = `North American Indian languages`\n\n // Neapolitan\n case \"nap\":\n\t\tc.Body = `Neapolitan`\n\n // Nauruan\n case \"nau\":\n\t\tc.Body = `Nauruan`\n\n // Navajo\n case \"nav\":\n\t\tc.Body = `Navajo`\n\n // Ndebele, South\n case \"nbl\":\n\t\tc.Body = `Ndebele, South`\n\n // Ndebele, North\n case \"nde\":\n\t\tc.Body = `Ndebele, North`\n\n // Ndonga\n case \"ndo\":\n\t\tc.Body = `Ndonga`\n\n // Low German; Low Saxon\n case \"nds\":\n\t\tc.Body = `Low German; Low Saxon`\n\n // Macrolanguage\n case \"nep\":\n\t\tc.Body = `Nepali`\n\n // Newari; Nepal Bhasa\n case \"new\":\n\t\tc.Body = `Newari; Nepal Bhasa`\n\n // Nias\n case \"nia\":\n\t\tc.Body = `Nias`\n\n // Collective name\n case \"nic\":\n\t\tc.Body = `Niger-Kordofanian languages`\n\n // Niuean\n case \"niu\":\n\t\tc.Body = `Niuean`\n\n // Norwegian Nynorsk\n case \"nno\":\n\t\tc.Body = `Norwegian Nynorsk`\n\n // Norwegian Bokmål\n case \"nob\":\n\t\tc.Body = `Norwegian Bokmål`\n\n // Nogai\n case \"nog\":\n\t\tc.Body = `Nogai`\n\n // Old Norse\n case \"non\":\n\t\tc.Body = `Old Norse`\n\n // Macrolanguage\n case \"nor\":\n\t\tc.Body = `Norwegian`\n\n // N’Ko\n case \"nqo\":\n\t\tc.Body = `N’Ko`\n\n // ONIX local code, equivalent to nrf in ISO 639-3. For use in ONIX 3.0 only\n case \"nrf\":\n\t\tc.Body = `Guernésiais, Jèrriais`\n\n // Pedi; Sepedi; Northern Sotho\n case \"nso\":\n\t\tc.Body = `Pedi; Sepedi; Northern Sotho`\n\n // Collective name\n case \"nub\":\n\t\tc.Body = `Nubian languages`\n\n // Classical Newari; Old Newari; Classical Nepal Bhasa\n case \"nwc\":\n\t\tc.Body = `Classical Newari; Old Newari; Classical Nepal Bhasa`\n\n // Chichewa; Chewa; Nyanja\n case \"nya\":\n\t\tc.Body = `Chichewa; Chewa; Nyanja`\n\n // Nyamwezi\n case \"nym\":\n\t\tc.Body = `Nyamwezi`\n\n // Nyankole\n case \"nyn\":\n\t\tc.Body = `Nyankole`\n\n // Nyoro\n case \"nyo\":\n\t\tc.Body = `Nyoro`\n\n // Nzima\n case \"nzi\":\n\t\tc.Body = `Nzima`\n\n // Occitan (post 1500)\n case \"oci\":\n\t\tc.Body = `Occitan (post 1500)`\n\n // ONIX local code, equivalent to odt in ISO 639-3\n case \"odt\":\n\t\tc.Body = `Old Dutch / Old Low Franconian (ca. 400–1050)`\n\n // Macrolanguage\n case \"oji\":\n\t\tc.Body = `Ojibwa`\n\n // ONIX local code, equivalent to omq in ISO 639-5. Collective name\n case \"omq\":\n\t\tc.Body = `Oto-Manguean languages`\n\n // Macrolanguage\n case \"ori\":\n\t\tc.Body = `Oriya`\n\n // Macrolanguage\n case \"orm\":\n\t\tc.Body = `Oromo`\n\n // Osage\n case \"osa\":\n\t\tc.Body = `Osage`\n\n // Ossetian; Ossetic\n case \"oss\":\n\t\tc.Body = `Ossetian; Ossetic`\n\n // Turkish, Ottoman\n case \"ota\":\n\t\tc.Body = `Turkish, Ottoman`\n\n // Collective name\n case \"oto\":\n\t\tc.Body = `Otomian languages`\n\n // Collective name\n case \"paa\":\n\t\tc.Body = `Papuan languages`\n\n // Pangasinan\n case \"pag\":\n\t\tc.Body = `Pangasinan`\n\n // Pahlavi\n case \"pal\":\n\t\tc.Body = `Pahlavi`\n\n // Pampanga; Kapampangan\n case \"pam\":\n\t\tc.Body = `Pampanga; Kapampangan`\n\n // Panjabi\n case \"pan\":\n\t\tc.Body = `Panjabi`\n\n // Papiamento\n case \"pap\":\n\t\tc.Body = `Papiamento`\n\n // Palauan\n case \"pau\":\n\t\tc.Body = `Palauan`\n\n // Old Persian (ca. 600-400 B.C.)\n case \"peo\":\n\t\tc.Body = `Old Persian (ca. 600-400 B.C.)`\n\n // Macrolanguage\n case \"per\":\n\t\tc.Body = `Persian; Farsi`\n\n // ONIX local code, equivalent to pes in ISO 639-3. For use in ONIX 3.0 only\n case \"pes\":\n\t\tc.Body = `Iranian Persian; Parsi`\n\n // Collective name\n case \"phi\":\n\t\tc.Body = `Philippine languages`\n\n // Phoenician\n case \"phn\":\n\t\tc.Body = `Phoenician`\n\n // Pali\n case \"pli\":\n\t\tc.Body = `Pali`\n\n // ONIX local code for Italian dialect, equivalent to pms in ISO 639-3. For use in ONIX 3.0 only\n case \"pms\":\n\t\tc.Body = `Piedmontese`\n\n // Polish\n case \"pol\":\n\t\tc.Body = `Polish`\n\n // Ponapeian\n case \"pon\":\n\t\tc.Body = `Ponapeian`\n\n // Portuguese\n case \"por\":\n\t\tc.Body = `Portuguese`\n\n // Collective name\n case \"pra\":\n\t\tc.Body = `Prakrit languages`\n\n // Provençal, Old (to 1500); Occitan, Old (to 1500)\n case \"pro\":\n\t\tc.Body = `Provençal, Old (to 1500); Occitan, Old (to 1500)`\n\n // ONIX local code, equivalent to prs in ISO 639-3. For use in ONIX 3.0 only\n case \"prs\":\n\t\tc.Body = `Dari; Afghan Persian`\n\n // Macrolanguage\n case \"pus\":\n\t\tc.Body = `Pushto; Pashto`\n\n // ONIX local code, distinct dialect of Occitan (not distinguished from oci by ISO 639-3)\n case \"qar\":\n\t\tc.Body = `Aranés`\n\n // ONIX local code, distinct dialect of Catalan (not distinguished from cat by ISO 639-3)\n case \"qav\":\n\t\tc.Body = `Valencian`\n\n // ONIX local code, distinct variant of langue d’oïl (old northern French) (not distinguished from fro, or from frm, fre, nrf by ISO 639-3). For use in ONIX 3.0 only\n case \"qgl\":\n\t\tc.Body = `Gallo`\n\n // ONIX local code, distinct dialect of of Rusyn (not distinguished from rue by ISO 639-3). For use in ONIX 3.0 only\n case \"qlk\":\n\t\tc.Body = `Lemko`\n\n // ONIX local code, distinct and exclusively spoken variation of Spanish, not distinguished from spa (Spanish, Castilian) by ISO 639-3. Neutral Latin American Spanish should be considered a ‘shorthand’ for spa plus a ‘country code’ for Latin America – but prefer spa plus the relevant country code for specifically Mexican Spanish, Argentine (Rioplatense) Spanish, Puerto Rican Spanish etc. Neutral Latin American Spanish must only be used with audio material (including the audio tracks of TV, video and film) to indicate use of accent, vocabulary and construction suitable for broad use across Latin America. For use in ONIX 3.0 only\n case \"qls\":\n\t\tc.Body = `Neutral Latin American Spanish`\n\n // Macrolanguage\n case \"que\":\n\t\tc.Body = `Quechua`\n\n // Macrolanguage\n case \"raj\":\n\t\tc.Body = `Rajasthani`\n\n // Rapanui\n case \"rap\":\n\t\tc.Body = `Rapanui`\n\n // Rarotongan; Cook Islands Maori\n case \"rar\":\n\t\tc.Body = `Rarotongan; Cook Islands Maori`\n\n // ONIX local code, equivalent to rcf in ISO 639-3. For use in ONIX 3.0 only\n case \"rcf\":\n\t\tc.Body = `Réunion Creole French`\n\n // ONIX local code for Italian dialect, equivalent to rgl in ISO 639-3. For use in ONIX 3.0 only\n case \"rgn\":\n\t\tc.Body = `Romagnol`\n\n // Collective name\n case \"roa\":\n\t\tc.Body = `Romance languages`\n\n // Romansh\n case \"roh\":\n\t\tc.Body = `Romansh`\n\n // Macrolanguage\n case \"rom\":\n\t\tc.Body = `Romany`\n\n // Romanian\n case \"rum\":\n\t\tc.Body = `Romanian`\n\n // Rundi\n case \"run\":\n\t\tc.Body = `Rundi`\n\n // Aromanian; Arumanian; Macedo-Romanian\n case \"rup\":\n\t\tc.Body = `Aromanian; Arumanian; Macedo-Romanian`\n\n // Russian\n case \"rus\":\n\t\tc.Body = `Russian`\n\n // Sandawe\n case \"sad\":\n\t\tc.Body = `Sandawe`\n\n // Sango\n case \"sag\":\n\t\tc.Body = `Sango`\n\n // Yakut\n case \"sah\":\n\t\tc.Body = `Yakut`\n\n // Collective name\n case \"sai\":\n\t\tc.Body = `South American Indian languages`\n\n // Collective name\n case \"sal\":\n\t\tc.Body = `Salishan languages`\n\n // Samaritan Aramaic\n case \"sam\":\n\t\tc.Body = `Samaritan Aramaic`\n\n // Sanskrit\n case \"san\":\n\t\tc.Body = `Sanskrit`\n\n // Sasak\n case \"sas\":\n\t\tc.Body = `Sasak`\n\n // Santali\n case \"sat\":\n\t\tc.Body = `Santali`\n\n // DEPRECATED – use srp\n case \"scc\":\n\t\tc.Body = `Serbian`\n\n // Sicilian\n case \"scn\":\n\t\tc.Body = `Sicilian`\n\n // Scots\n case \"sco\":\n\t\tc.Body = `Scots`\n\n // DEPRECATED – use hrv\n case \"scr\":\n\t\tc.Body = `Croatian`\n\n // ONIX local code for Sardinian dialect, equivalent to sdc in ISO 639-3. For use in ONIX 3.0 only\n case \"sdc\":\n\t\tc.Body = `Sassarese`\n\n // ONIX local code for Sardinian dialect, equivalent to sdn in ISO 639-3. For use in ONIX 3.0 only\n case \"sdn\":\n\t\tc.Body = `Gallurese`\n\n // Selkup\n case \"sel\":\n\t\tc.Body = `Selkup`\n\n // Collective name\n case \"sem\":\n\t\tc.Body = `Semitic languages`\n\n // Irish, Old (to 1100)\n case \"sga\":\n\t\tc.Body = `Irish, Old (to 1100)`\n\n // Collective name\n case \"sgn\":\n\t\tc.Body = `Sign languages`\n\n // Shan\n case \"shn\":\n\t\tc.Body = `Shan`\n\n // Sidamo\n case \"sid\":\n\t\tc.Body = `Sidamo`\n\n // Sinhala; Sinhalese\n case \"sin\":\n\t\tc.Body = `Sinhala; Sinhalese`\n\n // Collective name\n case \"sio\":\n\t\tc.Body = `Siouan languages`\n\n // Collective name\n case \"sit\":\n\t\tc.Body = `Sino-Tibetan languages`\n\n // Collective name\n case \"sla\":\n\t\tc.Body = `Slavic languages`\n\n // Slovak\n case \"slo\":\n\t\tc.Body = `Slovak`\n\n // Slovenian\n case \"slv\":\n\t\tc.Body = `Slovenian`\n\n // Southern Sami\n case \"sma\":\n\t\tc.Body = `Southern Sami`\n\n // Northern Sami\n case \"sme\":\n\t\tc.Body = `Northern Sami`\n\n // Collective name\n case \"smi\":\n\t\tc.Body = `Sami languages`\n\n // Lule Sami\n case \"smj\":\n\t\tc.Body = `Lule Sami`\n\n // Inari Sami\n case \"smn\":\n\t\tc.Body = `Inari Sami`\n\n // Samoan\n case \"smo\":\n\t\tc.Body = `Samoan`\n\n // Skolt Sami\n case \"sms\":\n\t\tc.Body = `Skolt Sami`\n\n // Shona\n case \"sna\":\n\t\tc.Body = `Shona`\n\n // Sindhi\n case \"snd\":\n\t\tc.Body = `Sindhi`\n\n // Soninke\n case \"snk\":\n\t\tc.Body = `Soninke`\n\n // Sogdian\n case \"sog\":\n\t\tc.Body = `Sogdian`\n\n // Somali\n case \"som\":\n\t\tc.Body = `Somali`\n\n // Collective name\n case \"son\":\n\t\tc.Body = `Songhai languages`\n\n // Sotho; Sesotho\n case \"sot\":\n\t\tc.Body = `Sotho; Sesotho`\n\n // Spanish\n case \"spa\":\n\t\tc.Body = `Spanish`\n\n // Macrolanguage\n case \"srd\":\n\t\tc.Body = `Sardinian`\n\n // Sranan Tongo\n case \"srn\":\n\t\tc.Body = `Sranan Tongo`\n\n // ONIX local code for Sardinian dialect, equivalent to sro in ISO 639-3. For use in ONIX 3.0 only\n case \"sro\":\n\t\tc.Body = `Campidanese`\n\n // Serbian\n case \"srp\":\n\t\tc.Body = `Serbian`\n\n // Serer\n case \"srr\":\n\t\tc.Body = `Serer`\n\n // Collective name\n case \"ssa\":\n\t\tc.Body = `Nilo-Saharan languages`\n\n // Swazi; Swati\n case \"ssw\":\n\t\tc.Body = `Swazi; Swati`\n\n // Sukuma\n case \"suk\":\n\t\tc.Body = `Sukuma`\n\n // Sundanese\n case \"sun\":\n\t\tc.Body = `Sundanese`\n\n // Susu\n case \"sus\":\n\t\tc.Body = `Susu`\n\n // Sumerian\n case \"sux\":\n\t\tc.Body = `Sumerian`\n\n // Macrolanguage\n case \"swa\":\n\t\tc.Body = `Swahili`\n\n // Swedish\n case \"swe\":\n\t\tc.Body = `Swedish`\n\n // Classical Syriac\n case \"syc\":\n\t\tc.Body = `Classical Syriac`\n\n // Macrolanguage\n case \"syr\":\n\t\tc.Body = `Syriac`\n\n // Tahitian\n case \"tah\":\n\t\tc.Body = `Tahitian`\n\n // Collective name\n case \"tai\":\n\t\tc.Body = `Tai languages`\n\n // Tamil\n case \"tam\":\n\t\tc.Body = `Tamil`\n\n // Tatar\n case \"tat\":\n\t\tc.Body = `Tatar`\n\n // Telugu\n case \"tel\":\n\t\tc.Body = `Telugu`\n\n // Temne; Time\n case \"tem\":\n\t\tc.Body = `Temne; Time`\n\n // Terena\n case \"ter\":\n\t\tc.Body = `Terena`\n\n // Tetum\n case \"tet\":\n\t\tc.Body = `Tetum`\n\n // Tajik; Tajiki Persian\n case \"tgk\":\n\t\tc.Body = `Tajik; Tajiki Persian`\n\n // Tagalog\n case \"tgl\":\n\t\tc.Body = `Tagalog`\n\n // Thai\n case \"tha\":\n\t\tc.Body = `Thai`\n\n // Tibetan\n case \"tib\":\n\t\tc.Body = `Tibetan`\n\n // Tigré\n case \"tig\":\n\t\tc.Body = `Tigré`\n\n // Tigrinya\n case \"tir\":\n\t\tc.Body = `Tigrinya`\n\n // Tiv\n case \"tiv\":\n\t\tc.Body = `Tiv`\n\n // Tokelauan\n case \"tkl\":\n\t\tc.Body = `Tokelauan`\n\n // Artificial language\n case \"tlh\":\n\t\tc.Body = `Klingon; tlhIngan-Hol`\n\n // Tlingit\n case \"tli\":\n\t\tc.Body = `Tlingit`\n\n // Macrolanguage\n case \"tmh\":\n\t\tc.Body = `Tamashek`\n\n // Tonga (Nyasa)\n case \"tog\":\n\t\tc.Body = `Tonga (Nyasa)`\n\n // Tongan\n case \"ton\":\n\t\tc.Body = `Tongan`\n\n // Tok Pisin\n case \"tpi\":\n\t\tc.Body = `Tok Pisin`\n\n // Tsimshian\n case \"tsi\":\n\t\tc.Body = `Tsimshian`\n\n // AKA Setswana\n case \"tsn\":\n\t\tc.Body = `Tswana`\n\n // Tsonga\n case \"tso\":\n\t\tc.Body = `Tsonga`\n\n // Turkmen\n case \"tuk\":\n\t\tc.Body = `Turkmen`\n\n // Tumbuka\n case \"tum\":\n\t\tc.Body = `Tumbuka`\n\n // Collective name\n case \"tup\":\n\t\tc.Body = `Tupi languages`\n\n // Turkish\n case \"tur\":\n\t\tc.Body = `Turkish`\n\n // Altaic languages\n case \"tut\":\n\t\tc.Body = `Altaic languages`\n\n // Tuvaluan\n case \"tvl\":\n\t\tc.Body = `Tuvaluan`\n\n // Twi\n case \"twi\":\n\t\tc.Body = `Twi`\n\n // Tuvinian\n case \"tyv\":\n\t\tc.Body = `Tuvinian`\n\n // ONIX local code, equivalent to tzo in ISO 639-3\n case \"tzo\":\n\t\tc.Body = `Tzotzil`\n\n // Udmurt\n case \"udm\":\n\t\tc.Body = `Udmurt`\n\n // Ugaritic\n case \"uga\":\n\t\tc.Body = `Ugaritic`\n\n // Uighur; Uyghur\n case \"uig\":\n\t\tc.Body = `Uighur; Uyghur`\n\n // Ukrainian\n case \"ukr\":\n\t\tc.Body = `Ukrainian`\n\n // Umbundu\n case \"umb\":\n\t\tc.Body = `Umbundu`\n\n // Undetermined language\n case \"und\":\n\t\tc.Body = `Undetermined language`\n\n // Urdu\n case \"urd\":\n\t\tc.Body = `Urdu`\n\n // Macrolanguage\n case \"uzb\":\n\t\tc.Body = `Uzbek`\n\n // Vai\n case \"vai\":\n\t\tc.Body = `Vai`\n\n // ONIX local code for Italian dialect, equivalent to vec in ISO 639-3. For use in ONIX 3.0 only\n case \"vec\":\n\t\tc.Body = `Venetian/Venetan`\n\n // Venda\n case \"ven\":\n\t\tc.Body = `Venda`\n\n // Vietnamese\n case \"vie\":\n\t\tc.Body = `Vietnamese`\n\n // Artificial language\n case \"vol\":\n\t\tc.Body = `Volapük`\n\n // Votic\n case \"vot\":\n\t\tc.Body = `Votic`\n\n // Collective name\n case \"wak\":\n\t\tc.Body = `Wakashan languages`\n\n // Wolaitta; Wolaytta\n case \"wal\":\n\t\tc.Body = `Wolaitta; Wolaytta`\n\n // Waray\n case \"war\":\n\t\tc.Body = `Waray`\n\n // Washo\n case \"was\":\n\t\tc.Body = `Washo`\n\n // Welsh\n case \"wel\":\n\t\tc.Body = `Welsh`\n\n // Collective name\n case \"wen\":\n\t\tc.Body = `Sorbian languages`\n\n // Walloon\n case \"wln\":\n\t\tc.Body = `Walloon`\n\n // Wolof\n case \"wol\":\n\t\tc.Body = `Wolof`\n\n // Kalmyk\n case \"xal\":\n\t\tc.Body = `Kalmyk`\n\n // Xhosa\n case \"xho\":\n\t\tc.Body = `Xhosa`\n\n // ONIX local code, equivalent to xuu in ISO 639-3. For use in ONIX 3.0 only\n case \"xuu\":\n\t\tc.Body = `Khwedam, Kxoe`\n\n // Yao\n case \"yao\":\n\t\tc.Body = `Yao`\n\n // Yapese\n case \"yap\":\n\t\tc.Body = `Yapese`\n\n // Macrolanguage\n case \"yid\":\n\t\tc.Body = `Yiddish`\n\n // Yoruba\n case \"yor\":\n\t\tc.Body = `Yoruba`\n\n // Collective name\n case \"ypk\":\n\t\tc.Body = `Yupik languages`\n\n // ONIX local code, equivalent to yue in ISO 639-3\n case \"yue\":\n\t\tc.Body = `Cantonese`\n\n // Macrolanguage\n case \"zap\":\n\t\tc.Body = `Zapotec`\n\n // Artificial language\n case \"zbl\":\n\t\tc.Body = `Blissymbols; Blissymbolics; Bliss`\n\n // Zenaga\n case \"zen\":\n\t\tc.Body = `Zenaga`\n\n // Standard Moroccan Tamazight\n case \"zgh\":\n\t\tc.Body = `Standard Moroccan Tamazight`\n\n // Macrolanguage\n case \"zha\":\n\t\tc.Body = `Zhuang; Chuang`\n\n // Collective name\n case \"znd\":\n\t\tc.Body = `Zande languages`\n\n // Zulu\n case \"zul\":\n\t\tc.Body = `Zulu`\n\n // Zuni\n case \"zun\":\n\t\tc.Body = `Zuni`\n\n // No linguistic content\n case \"zxx\":\n\t\tc.Body = `No linguistic content`\n\n // Macrolanguage\n case \"zza\":\n\t\tc.Body = `Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki`\n\tdefault:\n\t\treturn fmt.Errorf(\"undefined code for DefaultLanguageOfText has been passed, got [%s]\", v)\n\t}\n\treturn nil\n}","func correctEncodingToUtf8(text []byte) []byte {\n\tr, err := charset.NewReader(bytes.NewBuffer(text), \"application/xml\")\n\tif err != nil {\n\t\tfmt.Println(\"Error converting encoding:\", err)\n\t\treturn nil\n\t}\n\ttext, _ = ioutil.ReadAll(r)\n\treturn text\n}","func (c *TextCaseCode) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {\n\tvar v string\n\td.DecodeElement(&v, &start)\n\tswitch v {\n\tdefault:\n\t\treturn fmt.Errorf(\"undefined code for TextCaseCode has been passed, got [%s]\", v)\n\t}\n}","func FromPlain(content []byte) string {\n\tif len(content) == 0 {\n\t\treturn \"\"\n\t}\n\tif cset := FromBOM(content); cset != \"\" {\n\t\treturn cset\n\t}\n\torigContent := content\n\t// Try to detect UTF-8.\n\t// First eliminate any partial rune at the end.\n\tfor i := len(content) - 1; i >= 0 && i > len(content)-4; i-- {\n\t\tb := content[i]\n\t\tif b < 0x80 {\n\t\t\tbreak\n\t\t}\n\t\tif utf8.RuneStart(b) {\n\t\t\tcontent = content[:i]\n\t\t\tbreak\n\t\t}\n\t}\n\thasHighBit := false\n\tfor _, c := range content {\n\t\tif c >= 0x80 {\n\t\t\thasHighBit = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif hasHighBit && utf8.Valid(content) {\n\t\treturn \"utf-8\"\n\t}\n\n\t// ASCII is a subset of UTF8. Follow W3C recommendation and replace with UTF8.\n\tif ascii(origContent) {\n\t\treturn \"utf-8\"\n\t}\n\n\treturn latin(origContent)\n}","func (c *Character) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {\n\tvar v string\n\td.DecodeElement(&v, &start)\n\tswitch v {\n\tdefault:\n\t\treturn fmt.Errorf(\"undefined code for Character has been passed, got [%s]\", v)\n\t}\n}","func (c *TextType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {\n\tvar v string\n\td.DecodeElement(&v, &start)\n\tfor _, attr := range start.Attr {\n\t\tif attr.Name.Local == \"datestamp\" {\n\t\t\tc.Datestamp = DtDotDateOrDateTime(attr.Value)\n\t\t}\n\t\tif attr.Name.Local == \"sourcetype\" {\n\t\t\tc.Sourcetype = SourceTypeCode(attr.Value)\n\t\t}\n\t\tif attr.Name.Local == \"sourcename\" {\n\t\t\tc.Sourcename = DtDotNonEmptyString(attr.Value)\n\t\t}\n\t}\n\tswitch v {\n\n // To be used only in circumstances where the parties to an exchange have agreed to include text which (a) is not for general distribution, and (b) cannot be coded elsewhere. If more than one type of text is sent, it must be identified by tagging within the text itself\n case \"01\":\n\t\tc.Body = `Sender-defined text`\n\n // Limited to a maximum of 350 characters\n case \"02\":\n\t\tc.Body = `Short description/annotation`\n\n // Length unrestricted\n case \"03\":\n\t\tc.Body = `Description`\n\n // Used for a table of contents sent as a single text field, which may or may not carry structure expressed using XHTML\n case \"04\":\n\t\tc.Body = `Table of contents`\n\n // Primary descriptive blurb usually taken from the back cover or jacket, or occasionally from the cover/jacket flaps. See also code 27\n case \"05\":\n\t\tc.Body = `Primary cover copy`\n\n // A quote taken from a review of the product or of the work in question where there is no need to take account of different editions\n case \"06\":\n\t\tc.Body = `Review quote`\n\n // A quote taken from a review of a previous edition of the work\n case \"07\":\n\t\tc.Body = `Review quote: previous edition`\n\n // A quote taken from a review of a previous work by the same author(s) or in the same series\n case \"08\":\n\t\tc.Body = `Review quote: previous work`\n\n // A quote usually provided by a celebrity or another author to promote a new book, not from a review\n case \"09\":\n\t\tc.Body = `Endorsement`\n\n // A promotional phrase which is intended to headline a description of the product\n case \"10\":\n\t\tc.Body = `Promotional headline`\n\n // Text describing a feature of a product to which the publisher wishes to draw attention for promotional purposes. Each separate feature should be described by a separate repeat, so that formatting can be applied at the discretion of the receiver of the ONIX record, or multiple features can be described using appropriate XHTML markup\n case \"11\":\n\t\tc.Body = `Feature`\n\n // A note referring to all contributors to a product – NOT linked to a single contributor\n case \"12\":\n\t\tc.Body = `Biographical note`\n\n // A statement included by a publisher in fulfillment of contractual obligations, such as a disclaimer, sponsor statement, or legal notice of any sort. Note that the inclusion of such a notice cannot and does not imply that a user of the ONIX record is obliged to reproduce it\n case \"13\":\n\t\tc.Body = `Publisher’s notice`\n\n // A short excerpt from the main text of the work\n case \"14\":\n\t\tc.Body = `Excerpt`\n\n // Used for an index sent as a single text field, which may be structured using XHTML\n case \"15\":\n\t\tc.Body = `Index`\n\n // (of which the product is a part.) Limited to a maximum of 350 characters\n case \"16\":\n\t\tc.Body = `Short description/annotation for collection`\n\n // (of which the product is a part.) Length unrestricted\n case \"17\":\n\t\tc.Body = `Description for collection`\n\n // As code 11 but used for a new feature of this edition or version\n case \"18\":\n\t\tc.Body = `New feature`\n\n // Version history\n case \"19\":\n\t\tc.Body = `Version history`\n\n // Short summary statement of open access status and any related conditions (eg ‘Open access – no commercial use’), primarily for marketing purposes. Should always be accompanied by a link to the complete license (see or code 99 in List 158)\n case \"20\":\n\t\tc.Body = `Open access statement`\n\n // Short summary statement that the product is available only in digital formats (eg ‘Digital exclusive’). If a non-digital version is planned, should be used to specify the date when exclusivity will end (use content date role code 15). If a non-digital version is available, the statement should not be included\n case \"21\":\n\t\tc.Body = `Digital exclusivity statement`\n\n // For example a recommendation or approval provided by a ministry of education or other official body. Use to provide details and ideally use to name the approver\n case \"22\":\n\t\tc.Body = `Official recommendation`\n\n // Short description in format specified by Japanese Book Publishers Association\n case \"23\":\n\t\tc.Body = `JBPA description`\n\n // JSON-LD snippet suitable for use within an HTML